OLD | NEW |
---|---|
1 <h2 id="manifest">Manifest</h2> | 1 <h2 id="manifest">Manifest</h2> |
2 | 2 |
3 <p> | 3 <p> |
4 You must declare the "declarativeWebRequest" permission in the | 4 You must declare the "declarativeWebRequest" permission in the |
5 <a href="manifest.html">extension manifest</a> to use this API, | 5 <a href="manifest.html">extension manifest</a> to use this API, |
6 along with <a href="declare_permissions.html">host permissions</a>. | 6 along with <a href="declare_permissions.html">host permissions</a>. |
7 </p> | 7 </p> |
8 | 8 |
9 <pre data-filename="manifest.json"> | 9 <pre data-filename="manifest.json"> |
10 { | 10 { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 <th>onHeadersReceived | 173 <th>onHeadersReceived |
174 <th>onAuthRequired | 174 <th>onAuthRequired |
175 </tr> | 175 </tr> |
176 <tr><td>AddRequestCookie<td><td>✓<td><td> | 176 <tr><td>AddRequestCookie<td><td>✓<td><td> |
177 <tr><td>AddResponseCookie<td><td><td>✓<td> | 177 <tr><td>AddResponseCookie<td><td><td>✓<td> |
178 <tr><td>AddResponseHeader<td><td><td>✓<td> | 178 <tr><td>AddResponseHeader<td><td><td>✓<td> |
179 <tr><td>CancelRequest<td>✓<td>✓<td>✓<td>✓ | 179 <tr><td>CancelRequest<td>✓<td>✓<td>✓<td>✓ |
180 <tr><td>EditRequestCookie<td><td>✓<td><td> | 180 <tr><td>EditRequestCookie<td><td>✓<td><td> |
181 <tr><td>EditResponseCookie<td><td><td>✓<td> | 181 <tr><td>EditResponseCookie<td><td><td>✓<td> |
182 <tr><td>IgnoreRules<td>✓<td>✓<td>✓<td>✓ | 182 <tr><td>IgnoreRules<td>✓<td>✓<td>✓<td>✓ |
183 <tr><td>RedirectByRegEx<td>✓<td><td><td> | 183 <tr><td>RedirectByRegEx<td>✓<td><td>✓<td> |
184 <tr><td>RedirectRequest<td>✓<td><td><td> | 184 <tr><td>RedirectRequest<td>✓<td><td>✓<td> |
185 <tr><td>RedirectToEmptyDocument<td>✓<td><td><td> | 185 <tr><td>RedirectToEmptyDocument<td>✓<td><td>✓<td> |
186 <tr><td>RedirectToTransparentImage<td>✓<td><td><td> | 186 <tr><td>RedirectToTransparentImage<td>✓<td><td>✓<td> |
187 <tr><td>RemoveRequestCookie<td><td>✓<td><td> | 187 <tr><td>RemoveRequestCookie<td><td>✓<td><td> |
188 <tr><td>RemoveRequestHeader<td><td>✓<td><td> | 188 <tr><td>RemoveRequestHeader<td><td>✓<td><td> |
189 <tr><td>RemoveResponseCookie<td><td><td>✓<td> | 189 <tr><td>RemoveResponseCookie<td><td><td>✓<td> |
190 <tr><td>RemoveResponseHeader<td><td><td>✓<td> | 190 <tr><td>RemoveResponseHeader<td><td><td>✓<td> |
191 <tr><td>SendMessageToExtension<td>✓<td>✓<td>✓<td>✓ | 191 <tr><td>SendMessageToExtension<td>✓<td>✓<td>✓<td>✓ |
192 <tr><td>SetRequestHeader<td><td>✓<td><td> | 192 <tr><td>SetRequestHeader<td><td>✓<td><td> |
193 </table> | 193 </table> |
194 </p> | 194 </p> |
195 | 195 |
196 <p> | 196 <p> |
197 <strong>Note:</strong> Applicable stages can be further constrained by using the | 197 <strong>Note:</strong> Applicable stages can be further constrained by using the |
198 "stages" attribute. | 198 "stages" attribute. |
199 </p> | 199 </p> |
200 <p> | 200 <p> |
201 <strong>Note:</strong> If a redirect action is declared at the onHeadersReceived | |
202 stage, then POST requests will be redirected using the GET method. In other case s | |
battre
2014/03/25 00:47:30
nit: 80 characters
robwu
2014/03/25 10:08:14
Done.
| |
203 the HTTP method is preserved. | |
battre
2014/03/25 00:47:30
Why is this?
robwu
2014/03/25 10:08:14
onBeforeRequest = 307 redirect, which doesn't chan
| |
204 </p> | |
205 <p> | |
201 <strong>Example:</strong> It is possible to combine a | 206 <strong>Example:</strong> It is possible to combine a |
202 <code>new chrome.declarativeWebRequest.RequestMatcher({contentType: ["image/jpeg "]})</code> | 207 <code>new chrome.declarativeWebRequest.RequestMatcher({contentType: ["image/jpeg "]})</code> |
203 condition with a <code>new chrome.declarativeWebRequest.CancelRequest()</code> | 208 condition with a <code>new chrome.declarativeWebRequest.CancelRequest()</code> |
204 action because both of them can be evaluated in the onHeadersReceived stage. | 209 action because both of them can be evaluated in the onHeadersReceived stage. |
205 It is, however, impossible to combine the request matcher with a | 210 It is, however, impossible to combine the request matcher with a |
206 <code>new chrome.declarativeWebRequest.RedirectToTransparentImage()</code> | 211 <code>new chrome.declarativeWebRequest.SetRequestHeader()</code> |
207 because redirects cannot be executed any more by the time the content | 212 because request headers cannot be set any more by the time the content type has been terminated. |
208 type has been determined. | |
209 </p> | 213 </p> |
210 | 214 |
211 <h2 id="precedences">Using priorities to override rules</h2> | 215 <h2 id="precedences">Using priorities to override rules</h2> |
212 | 216 |
213 <p> | 217 <p> |
214 Rules can be associated with priorities as described in the | 218 Rules can be associated with priorities as described in the |
215 <a href="events.html#declarative">Events API</a>. This mechanism can be used | 219 <a href="events.html#declarative">Events API</a>. This mechanism can be used |
216 to express exceptions. The following example will block all requests to | 220 to express exceptions. The following example will block all requests to |
217 images named "evil.jpg" except on the server "myserver.com". | 221 images named "evil.jpg" except on the server "myserver.com". |
218 </p> | 222 </p> |
(...skipping 23 matching lines...) Expand all Loading... | |
242 chrome.declarativeWebRequest.onRequest.addRules([rule1, rule2]); | 246 chrome.declarativeWebRequest.onRequest.addRules([rule1, rule2]); |
243 </pre> | 247 </pre> |
244 | 248 |
245 <p> | 249 <p> |
246 It is important to recognize that the <code>IgnoreRules</code> action is not | 250 It is important to recognize that the <code>IgnoreRules</code> action is not |
247 persisted across <a href="#evaluation">request stages</a>. All conditions of | 251 persisted across <a href="#evaluation">request stages</a>. All conditions of |
248 all rules are evaluated at each stage of a web request. If an | 252 all rules are evaluated at each stage of a web request. If an |
249 <code>IgnoreRules</code> action is executed, it applies only to other actions | 253 <code>IgnoreRules</code> action is executed, it applies only to other actions |
250 that are executed for the same web request in the same stage. | 254 that are executed for the same web request in the same stage. |
251 </p> | 255 </p> |
OLD | NEW |