| Index: chrome/common/extensions/docs/server2/templates/private/declarativeWebRequest_intro.html
|
| diff --git a/chrome/common/extensions/docs/server2/templates/private/declarativeWebRequest_intro.html b/chrome/common/extensions/docs/server2/templates/private/declarativeWebRequest_intro.html
|
| deleted file mode 100644
|
| index 2ba2f9b0a07e07e03388154b86ea76b0bfe2ae47..0000000000000000000000000000000000000000
|
| --- a/chrome/common/extensions/docs/server2/templates/private/declarativeWebRequest_intro.html
|
| +++ /dev/null
|
| @@ -1,107 +0,0 @@
|
| -<!-- BEGIN AUTHORED CONTENT -->
|
| -<h2 id="notes">Notes</h2>
|
| -<p>
|
| -Use the <code>chrome.declarativeWebRequest</code> module to intercept, block, or
|
| -modify requests in-flight. It is significantly faster than the <a
|
| - href="webRequest.html"><code>chrome.webRequest</code> API</a> because you can
|
| -register rules that are evaluated in the browser rather than the
|
| -JavaScript engine which reduces roundtrip latencies and allows for very high
|
| -efficiency.
|
| -</p>
|
| -<h2 id="manifest">Manifest</h2>
|
| -<p>
|
| -You must declare the "declarative" and the "declarativeWebRequest" permission in
|
| -the <a href="manifest.html">extension manifest</a> to use this API,
|
| -along with <a href="manifest.html#permissions">host permissions</a> for any
|
| -hosts whose network requests you want to access.
|
| -</p>
|
| -<pre>{
|
| - "name": "My extension",
|
| - ...
|
| -<b> "permissions": [
|
| - "declarative",
|
| - "declarativeWebRequest",
|
| - "*://*.google.com"
|
| - ]</b>,
|
| - ...
|
| -}</pre>
|
| -<h2 id="rules">Rules</h2>
|
| -<p>
|
| -The Declarative Web Request API follows the concepts of the <a
|
| - href="events.html#declarative">Declarative API</a>. You can register rules to
|
| -the <code>chrome.declarativeWebRequest.onRequest</code> event object.
|
| -</p>
|
| -<p>
|
| -The Declarative Web Request API supports a single type of match criteria, the
|
| -<code>RequestMatcher</code>. The <code>RequestMatcher</code> matches network
|
| -requests if and only if all listed criteria are met. The following
|
| -<code>RequestMatcher</code> would match a network request when the user enters
|
| -"http://www.example.com" in the URL bar:
|
| -</p>
|
| -<pre>
|
| -var matcher = new chrome.declarativeWebRequest.RequestMatcher({
|
| - url: { hostSuffix: 'example.com', schemes: ['http'] },
|
| - resourceType: 'main_frame'
|
| - });
|
| -</pre>
|
| -<p>
|
| -Requests to "https://www.example.com" would be rejected by the
|
| -<code>RequestMatcher</code> due to the scheme. Also all requests for an embedded
|
| -iframe would be rejected due to the <code>resourceType</code>.
|
| -</p>
|
| -<p class="note">
|
| -<strong>Note:</strong> All conditions and actions are created via a constructor
|
| -as shown in the example above.
|
| -<p>
|
| -<p>
|
| -In order to cancel all requests to "example.com", you can define a rule as
|
| -follows:
|
| -</p>
|
| -<pre>
|
| -var rule = {
|
| - conditions: [
|
| - new chrome.declarativeWebRequest.RequestMatcher({
|
| - url: { hostSuffix: 'example.com' } })
|
| - ],
|
| - actions: [
|
| - new chrome.declarativeWebRequest.CancelRequest()
|
| - ]};
|
| -</pre>
|
| -<p>
|
| -In order to cancel all requests to "example.com" and "foobar.com", you can add a
|
| -second condition, as each condition is sufficient to trigger all specified
|
| -actions:
|
| -</p>
|
| -<pre>
|
| -var rule2 = {
|
| - conditions: [
|
| - new chrome.declarativeWebRequest.RequestMatcher({
|
| - url: { hostSuffix: 'example.com' } }),
|
| - new chrome.declarativeWebRequest.RequestMatcher({
|
| - url: { hostSuffix: 'foobar.com' } })
|
| - ],
|
| - actions: [
|
| - new chrome.declarativeWebRequest.CancelRequest()
|
| - ]};
|
| -</pre>
|
| -<p>
|
| -Register rules as follows:
|
| -</p>
|
| -<pre>
|
| -chrome.declarativeWebRequest.onRequest.addRules([rule2]);
|
| -</pre>
|
| -<p class="note">
|
| -<strong>Note:</strong> You should always register or unregister rules in bulk rather than
|
| -individually because each of these operations recreates internal data
|
| -structures. This re-creation is computationally expensive but facilitates a
|
| -very fast URL matching algorithm for hundreds of thousands of URLs.
|
| -</p>
|
| -<h2 id="TODO">Todo</h2>
|
| -<ul>
|
| - <li>Explain precedences, once we can ignore rules based on their priority
|
| - (e.g. how can I cancel all requests except for a specific whitelist?)
|
| - <li>Explain when conditions can be evaluated, when actions can be executed,
|
| - and when rules can be executed (e.g. you cannot cancel a request when you
|
| - have received the response already)
|
| -</ul>
|
| -<!-- END AUTHORED CONTENT -->
|
|
|