Declarative Web Request API
Note: The [declarative web request
API](https://developer.chrome.com/extensions/declarativeWebRequest)…
Declarative Web Request API
Note: The [declarative web request
API](https://developer.chrome.com/extensions/declarativeWebRequest) is
available only on the [beta
channel](https://www.google.com/landing/chrome/beta/) and [dev
channel](http://www.chromium.org/getting-involved/dev-channel). This sample
will not work on stable channel
builds.
This sample shows how to use the declarative web request API with a
webview. The app implements a simple content blocker for URLs that match a
RE2 regular expression. The
default pattern blocks hosts that contain blogspot. (such as blogspot.com
blogs) or gstatic. (such as thumbnails in Google image search). Top frame
and sub-frame navigation redirects the whole webview to a "page blocked" page
(see screenshot left). Image loads are redirected to a dummy image that
contains a shortened version of the image URL as text (see screenshot
right). The user can modify the URL matching pattern using a form on the
top-right. Content blocking actions are logged beneath the form on the
top-right.
See the source code at https://github.com/GoogleChrome/chrome-app-samples/tree/master/webview-samples/declarative-web-request
This version was built from git commit 8dfb9ab https://github.com/GoogleChrome/chrome-app-samples/tree/8dfb9ab/webview-samples/declarative-web-request