Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <h2 id="manifest">Manifest</h2> | 1 <h2 id="manifest">Manifest</h2> |
| 2 <p>You must declare the "webRequest" permission in the <a | 2 <p>You must declare the "webRequest" permission in the <a |
| 3 href="manifest">extension manifest</a> to use the web request | 3 href="manifest">extension manifest</a> to use the web request |
| 4 API, along with <a href="declare_permissions">host permissions</a> | 4 API, along with <a href="declare_permissions">host permissions</a> |
| 5 for any hosts whose network requests you want to access. If you want to | 5 for any hosts whose network requests you want to access. If you want to |
| 6 use the web request API in a blocking fashion, you need to request | 6 use the web request API in a blocking fashion, you need to request |
| 7 the "webRequestBlocking" permission in addition. | 7 the "webRequestBlocking" permission in addition. |
| 8 For example:</p> | 8 For example:</p> |
| 9 <pre data-filename="manifest.json"> | 9 <pre data-filename="manifest.json"> |
| 10 { | 10 { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 203 <code>'blocking'</code> (only allowed for specific events), the callback | 203 <code>'blocking'</code> (only allowed for specific events), the callback |
| 204 function is handled synchronously. That means that the request is blocked until | 204 function is handled synchronously. That means that the request is blocked until |
| 205 the callback function returns. In this case, the callback can return a | 205 the callback function returns. In this case, the callback can return a |
| 206 $(ref:webRequest.BlockingResponse) that determines the further | 206 $(ref:webRequest.BlockingResponse) that determines the further |
| 207 life cycle of the request. Depending on the context, this response allows | 207 life cycle of the request. Depending on the context, this response allows |
| 208 cancelling or redirecting a request (<code>onBeforeRequest</code>), cancelling a | 208 cancelling or redirecting a request (<code>onBeforeRequest</code>), cancelling a |
| 209 request or modifying headers (<code>onBeforeSendHeaders</code>, | 209 request or modifying headers (<code>onBeforeSendHeaders</code>, |
| 210 <code>onHeadersReceived</code>), or providing authentication credentials | 210 <code>onHeadersReceived</code>), or providing authentication credentials |
| 211 (<code>onAuthRequired</code>).</p> | 211 (<code>onAuthRequired</code>).</p> |
| 212 | 212 |
| 213 <p>If the optional <code>opt_extraInfoSpec</code> array contains the string | |
| 214 <code>'asyncBlocking'</code> instead (only allowed for | |
| 215 <code>onAuthRequired</code>), the extension can generate the | |
|
lazyboy
2017/02/24 00:17:22
<code>onAuthRequired</code> event), ...
nit: chang
karandeepb
2017/02/24 01:04:39
Done.
| |
| 216 $(ref:webRequest.BlockingResponse) object asynchronously, unlike the | |
| 217 <code>'blocking'</code> mode where the callback has to synchronously return the | |
| 218 $(ref:webRequest.BlockingResponse).</p> | |
| 219 | |
| 213 <p>The $(ref:webRequest.RequestFilter) | 220 <p>The $(ref:webRequest.RequestFilter) |
| 214 <code>filter</code> allows limiting the requests for which events are | 221 <code>filter</code> allows limiting the requests for which events are |
| 215 triggered in various dimensions: | 222 triggered in various dimensions: |
| 216 <dl> | 223 <dl> |
| 217 <dt>URLs</dt> | 224 <dt>URLs</dt> |
| 218 <dd><a href="match_patterns">URL patterns</a> such as | 225 <dd><a href="match_patterns">URL patterns</a> such as |
| 219 <code>*://www.google.com/foo*bar</code>.</dd> | 226 <code>*://www.google.com/foo*bar</code>.</dd> |
| 220 <dt>Types</dt> | 227 <dt>Types</dt> |
| 221 <dd>Request types such as <code>main_frame</code> (a document that is loaded | 228 <dd>Request types such as <code>main_frame</code> (a document that is loaded |
| 222 for a top-level frame), <code>sub_frame</code> (a document that is loaded for | 229 for a top-level frame), <code>sub_frame</code> (a document that is loaded for |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 } | 326 } |
| 320 } | 327 } |
| 321 return {requestHeaders: details.requestHeaders}; | 328 return {requestHeaders: details.requestHeaders}; |
| 322 }, | 329 }, |
| 323 {urls: ["<all_urls>"]}, | 330 {urls: ["<all_urls>"]}, |
| 324 ["blocking", "requestHeaders"]); | 331 ["blocking", "requestHeaders"]); |
| 325 </pre> | 332 </pre> |
| 326 | 333 |
| 327 <p> For more example code, see the <a href="samples#search:webrequest">web reque st | 334 <p> For more example code, see the <a href="samples#search:webrequest">web reque st |
| 328 samples</a>.</p> | 335 samples</a>.</p> |
| OLD | NEW |