1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 "namespace": "declarativeWebRequest",
8 "description": "<em><strong>Note:</strong> this API is currently on hold, without concrete plans to move to stable.</em> Use the <code>chrome.declarativeWebRequest</code> API to intercept, block, or modify requests in-flight. It is significantly faster than the <a href='webRequest'><code>chrome.webRequest</code> API</a> because you can register rules that are evaluated in the browser rather than the JavaScript engine with reduces roundtrip latencies and allows higher efficiency.",
13 "description": "Filters request headers for various criteria. Multiple criteria are evaluated as a conjunction.",
16 "description" : "Matches if the header name starts with the specified string.",
23 "description" : "Matches if the header name ends with the specified string."
27 {"type": "array", "items": {"type": "string"}},
31 "description" : "Matches if the header name contains all of the specified strings."
36 "description" : "Matches if the header name is equal to the specified string."
41 "description" : "Matches if the header value starts with the specified string."
46 "description" : "Matches if the header value ends with the specified string."
50 {"type": "array", "items": {"type": "string"}},
54 "description" : "Matches if the header value contains all of the specified strings."
59 "description" : "Matches if the header value is equal to the specified string."
64 "id": "RequestMatcher",
66 "description": "Matches network events by various criteria.",
69 "$ref": "events.UrlFilter",
70 "description": "Matches if the conditions of the UrlFilter are fulfilled for the URL of the request.",
73 "firstPartyForCookiesUrl": {
74 "$ref": "events.UrlFilter",
75 "description": "Matches if the conditions of the UrlFilter are fulfilled for the 'first party' URL of the request. The 'first party' URL of a request, when present, can be different from the request's target URL, and describes what is considered 'first party' for the sake of third-party checks for cookies.",
81 "description": "Matches if the request type of a request is contained in the list. Requests that cannot match any of the types will be filtered out.",
82 "items": { "type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"] }
87 "description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is contained in the list.",
88 "items": { "type": "string" }
90 "excludeContentType": {
93 "description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is <em>not</em> contained in the list.",
94 "items": { "type": "string" }
99 "description": "Matches if some of the request headers is matched by one of the HeaderFilters.",
100 "items": { "$ref": "HeaderFilter" }
102 "excludeRequestHeaders": {
105 "description": "Matches if none of the request headers is matched by any of the HeaderFilters.",
106 "items": { "$ref": "HeaderFilter" }
111 "description": "Matches if some of the response headers is matched by one of the HeaderFilters.",
112 "items": { "$ref": "HeaderFilter" }
114 "excludeResponseHeaders": {
117 "description": "Matches if none of the response headers is matched by any of the HeaderFilters.",
118 "items": { "$ref": "HeaderFilter" }
120 "thirdPartyForCookies": {
123 "description": "If set to true, matches requests that are subject to third-party cookie policies. If set to false, matches all other requests."
129 "enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"]
132 "description": "Contains a list of strings describing stages. Allowed values are 'onBeforeRequest', 'onBeforeSendHeaders', 'onHeadersReceived', 'onAuthRequired'. If this attribute is present, then it limits the applicable stages to those listed. Note that the whole condition is only applicable in stages compatible with all attributes."
135 "type": "string", "enum": ["declarativeWebRequest.RequestMatcher"],
141 "id": "CancelRequest",
142 "description": "Declarative event action that cancels a network request.",
146 "type": "string", "enum": ["declarativeWebRequest.CancelRequest"],
152 "id": "RedirectRequest",
153 "description": "Declarative event action that redirects a network request.",
157 "type": "string", "enum": ["declarativeWebRequest.RedirectRequest"],
160 "redirectUrl": { "type": "string", "description": "Destination to where the request is redirected."}
164 "id": "declarativeWebRequest.RedirectToTransparentImage",
165 "description": "Declarative event action that redirects a network request to a transparent image.",
169 "type": "string", "enum": ["declarativeWebRequest.RedirectToTransparentImage"],
175 "id": "declarativeWebRequest.RedirectToEmptyDocument",
176 "description": "Declarative event action that redirects a network request to an empty document.",
180 "type": "string", "enum": ["declarativeWebRequest.RedirectToEmptyDocument"],
186 "id": "declarativeWebRequest.RedirectByRegEx",
187 "description": "Redirects a request by applying a regular expression on the URL. The regular expressions use the <a href=\"http://code.google.com/p/re2/wiki/Syntax\">RE2 syntax</a>.",
191 "type": "string", "enum": ["declarativeWebRequest.RedirectByRegEx"],
196 "description": "A match pattern that may contain capture groups. Capture groups are referenced in the Perl syntax ($1, $2, ...) instead of the RE2 syntax (\\1, \\2, ...) in order to be closer to JavaScript Regular Expressions."
200 "description": "Destination pattern."
205 "id": "declarativeWebRequest.SetRequestHeader",
206 "description": "Sets the request header of the specified name to the specified value. If a header with the specified name did not exist before, a new one is created. Header name comparison is always case-insensitive. Each request header name occurs only once in each request.",
210 "type": "string", "enum": ["declarativeWebRequest.SetRequestHeader"],
215 "description": "HTTP request header name."
219 "description": "HTTP request header value."
224 "id": "declarativeWebRequest.RemoveRequestHeader",
225 "description": "Removes the request header of the specified name. Do not use SetRequestHeader and RemoveRequestHeader with the same header name on the same request. Each request header name occurs only once in each request.",
229 "type": "string", "enum": ["declarativeWebRequest.RemoveRequestHeader"],
234 "description": "HTTP request header name (case-insensitive)."
239 "id": "declarativeWebRequest.AddResponseHeader",
240 "description": "Adds the response header to the response of this web request. As multiple response headers may share the same name, you need to first remove and then add a new response header in order to replace one.",
244 "type": "string", "enum": ["declarativeWebRequest.AddResponseHeader"],
249 "description": "HTTP response header name."
253 "description": "HTTP response header value."
258 "id": "declarativeWebRequest.RemoveResponseHeader",
259 "description": "Removes all response headers of the specified names and values.",
263 "type": "string", "enum": ["declarativeWebRequest.RemoveResponseHeader"],
268 "description": "HTTP request header name (case-insensitive)."
272 "description": "HTTP request header value (case-insensitive).",
278 "id": "declarativeWebRequest.IgnoreRules",
279 "description": "Masks all rules that match the specified criteria.",
283 "type": "string", "enum": ["declarativeWebRequest.IgnoreRules"],
286 "lowerPriorityThan": {
288 "description": "If set, rules with a lower priority than the specified value are ignored. This boundary is not persisted, it affects only rules and their actions of the same network request stage.",
293 "description": "If set, rules with the specified tag are ignored. This ignoring is not persisted, it affects only rules and their actions of the same network request stage. Note that rules are executed in descending order of their priorities. This action affects rules of lower priority than the current rule. Rules with the same priority may or may not be ignored.",
299 "id": "declarativeWebRequest.SendMessageToExtension",
300 "description": "Triggers the $(ref:declarativeWebRequest.onMessage) event.",
304 "type": "string", "enum": ["declarativeWebRequest.SendMessageToExtension"],
309 "description": "The value that will be passed in the <code>message</code> attribute of the dictionary that is passed to the event handler."
314 "id": "declarativeWebRequest.RequestCookie",
315 "description": "A filter or specification of a cookie in HTTP Requests.",
320 "description": "Name of a cookie.",
325 "description": "Value of a cookie, may be padded in double-quotes.",
331 "id": "declarativeWebRequest.ResponseCookie",
332 "description": "A specification of a cookie in HTTP Responses.",
337 "description": "Name of a cookie.",
342 "description": "Value of a cookie, may be padded in double-quotes.",
347 "description": "Value of the Expires cookie attribute.",
352 "description": "Value of the Max-Age cookie attribute",
357 "description": "Value of the Domain cookie attribute.",
362 "description": "Value of the Path cookie attribute.",
367 "description": "Existence of the Secure cookie attribute.",
372 "description": "Existence of the HttpOnly cookie attribute.",
378 "id": "declarativeWebRequest.FilterResponseCookie",
379 "description": "A filter of a cookie in HTTP Responses.",
384 "description": "Name of a cookie.",
389 "description": "Value of a cookie, may be padded in double-quotes.",
394 "description": "Value of the Expires cookie attribute.",
399 "description": "Value of the Max-Age cookie attribute",
404 "description": "Value of the Domain cookie attribute.",
409 "description": "Value of the Path cookie attribute.",
414 "description": "Existence of the Secure cookie attribute.",
419 "description": "Existence of the HttpOnly cookie attribute.",
424 "description": "Inclusive upper bound on the cookie lifetime (specified in seconds after current time). Only cookies whose expiration date-time is in the interval [now, now + ageUpperBound] fulfill this criterion. Session cookies and cookies whose expiration date-time is in the past do not meet the criterion of this filter. The cookie lifetime is calculated from either 'max-age' or 'expires' cookie attributes. If both are specified, 'max-age' is used to calculate the cookie lifetime.",
430 "description": "Inclusive lower bound on the cookie lifetime (specified in seconds after current time). Only cookies whose expiration date-time is set to 'now + ageLowerBound' or later fulfill this criterion. Session cookies do not meet the criterion of this filter. The cookie lifetime is calculated from either 'max-age' or 'expires' cookie attributes. If both are specified, 'max-age' is used to calculate the cookie lifetime.",
436 "description": "Filters session cookies. Session cookies have no lifetime specified in any of 'max-age' or 'expires' attributes.",
442 "id": "declarativeWebRequest.AddRequestCookie",
443 "description": "Adds a cookie to the request or overrides a cookie, in case another cookie of the same name exists already. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
447 "type": "string", "enum": ["declarativeWebRequest.AddRequestCookie"],
451 "$ref": "declarativeWebRequest.RequestCookie",
452 "description": "Cookie to be added to the request. No field may be undefined."
457 "id": "declarativeWebRequest.AddResponseCookie",
458 "description": "Adds a cookie to the response or overrides a cookie, in case another cookie of the same name exists already. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
462 "type": "string", "enum": ["declarativeWebRequest.AddResponseCookie"],
466 "$ref": "declarativeWebRequest.ResponseCookie",
467 "description": "Cookie to be added to the response. The name and value need to be specified."
472 "id": "declarativeWebRequest.EditRequestCookie",
473 "description": "Edits one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
477 "type": "string", "enum": ["declarativeWebRequest.EditRequestCookie"],
481 "$ref": "declarativeWebRequest.RequestCookie",
482 "description": "Filter for cookies that will be modified. All empty entries are ignored."
485 "$ref": "declarativeWebRequest.RequestCookie",
486 "description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
491 "id": "declarativeWebRequest.EditResponseCookie",
492 "description": "Edits one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
496 "type": "string", "enum": ["declarativeWebRequest.EditResponseCookie"],
500 "$ref": "declarativeWebRequest.FilterResponseCookie",
501 "description": "Filter for cookies that will be modified. All empty entries are ignored."
504 "$ref": "declarativeWebRequest.ResponseCookie",
505 "description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
510 "id": "declarativeWebRequest.RemoveRequestCookie",
511 "description": "Removes one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
515 "type": "string", "enum": ["declarativeWebRequest.RemoveRequestCookie"],
519 "$ref": "declarativeWebRequest.RequestCookie",
520 "description": "Filter for cookies that will be removed. All empty entries are ignored."
525 "id": "declarativeWebRequest.RemoveResponseCookie",
526 "description": "Removes one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
530 "type": "string", "enum": ["declarativeWebRequest.RemoveResponseCookie"],
534 "$ref": "declarativeWebRequest.FilterResponseCookie",
535 "description": "Filter for cookies that will be removed. All empty entries are ignored."
546 "supportsListeners": false,
547 "supportsRules": true,
548 "conditions": ["declarativeWebRequest.RequestMatcher"],
550 "declarativeWebRequest.AddRequestCookie",
551 "declarativeWebRequest.AddResponseCookie",
552 "declarativeWebRequest.AddResponseHeader",
553 "declarativeWebRequest.CancelRequest",
554 "declarativeWebRequest.EditRequestCookie",
555 "declarativeWebRequest.EditResponseCookie",
556 "declarativeWebRequest.RedirectRequest",
557 "declarativeWebRequest.RedirectToTransparentImage",
558 "declarativeWebRequest.RedirectToEmptyDocument",
559 "declarativeWebRequest.RedirectByRegEx",
560 "declarativeWebRequest.RemoveRequestCookie",
561 "declarativeWebRequest.RemoveResponseCookie",
562 "declarativeWebRequest.RemoveRequestHeader",
563 "declarativeWebRequest.RemoveResponseHeader",
564 "declarativeWebRequest.SetRequestHeader",
565 "declarativeWebRequest.SendMessageToExtension",
566 "declarativeWebRequest.IgnoreRules"
573 "description": "Fired when a message is sent via $(ref:declarativeWebRequest.SendMessageToExtension) from an action of the declarative web request API.",
579 "message": {"type": "string", "description": "The message sent by the calling script."},
580 "stage": {"type": "string",
581 "enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"],
582 "description": "The stage of the network request during which the event was triggered."},
583 "requestId": {"type": "string", "description": "The ID of the request. Request IDs are unique within a browser session. As a result, they could be used to relate different events of the same request."},
584 "url": {"type": "string"},
585 "method": {"type": "string", "description": "Standard HTTP method."},
586 "frameId": {"type": "integer", "description": "The value 0 indicates that the request happens in the main frame; a positive value indicates the ID of a subframe in which the request happens. If the document of a (sub-)frame is loaded (<code>type</code> is <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code> indicates the ID of this frame, not the ID of the outer frame. Frame IDs are unique within a tab."},
587 "parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
588 "tabId": {"type": "integer", "description": "The ID of the tab in which the request takes place. Set to -1 if the request isn't related to a tab."},
589 "type": {"type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"], "description": "How the requested resource will be used."},
590 "timeStamp": {"type": "number", "description": "The time when this signal is triggered, in milliseconds since the epoch."}