blob: bfb7082e8f39a9e9a88f5fb1904e7ed6ecaab767 [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
[
{
"namespace": "declarativeWebRequest",
"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.",
"types": [
{
"id": "HeaderFilter",
"type": "object",
"description": "Filters request headers for various criteria. Multiple criteria are evaluated as a conjunction.",
"properties": {
"namePrefix": {
"description" : "Matches if the header name starts with the specified string.",
"type": "string",
"optional": true
},
"nameSuffix": {
"type": "string",
"optional": true,
"description" : "Matches if the header name ends with the specified string."
},
"nameContains": {
"choices": [
{"type": "array", "items": {"type": "string"}},
{"type": "string"}
],
"optional": true,
"description" : "Matches if the header name contains all of the specified strings."
},
"nameEquals": {
"type": "string",
"optional": true,
"description" : "Matches if the header name is equal to the specified string."
},
"valuePrefix": {
"type": "string",
"optional": true,
"description" : "Matches if the header value starts with the specified string."
},
"valueSuffix": {
"type": "string",
"optional": true,
"description" : "Matches if the header value ends with the specified string."
},
"valueContains": {
"choices": [
{"type": "array", "items": {"type": "string"}},
{"type": "string"}
],
"optional": true,
"description" : "Matches if the header value contains all of the specified strings."
},
"valueEquals": {
"type": "string",
"optional": true,
"description" : "Matches if the header value is equal to the specified string."
}
}
},
{
"id": "RequestMatcher",
"type": "object",
"description": "Matches network events by various criteria.",
"properties": {
"url": {
"$ref": "events.UrlFilter",
"description": "Matches if the conditions of the UrlFilter are fulfilled for the URL of the request.",
"optional": true
},
"firstPartyForCookiesUrl": {
"$ref": "events.UrlFilter",
"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.",
"optional": true
},
"resourceType": {
"type": "array",
"optional": true,
"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.",
"items": { "type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "other"] }
},
"contentType": {
"type": "array",
"optional": true,
"description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is contained in the list.",
"items": { "type": "string" }
},
"excludeContentType": {
"type": "array",
"optional": true,
"description": "Matches if the MIME media type of a response (from the HTTP Content-Type header) is <em>not</em> contained in the list.",
"items": { "type": "string" }
},
"requestHeaders": {
"type": "array",
"optional": true,
"description": "Matches if some of the request headers is matched by one of the HeaderFilters.",
"items": { "$ref": "HeaderFilter" }
},
"excludeRequestHeaders": {
"type": "array",
"optional": true,
"description": "Matches if none of the request headers is matched by any of the HeaderFilters.",
"items": { "$ref": "HeaderFilter" }
},
"responseHeaders": {
"type": "array",
"optional": true,
"description": "Matches if some of the response headers is matched by one of the HeaderFilters.",
"items": { "$ref": "HeaderFilter" }
},
"excludeResponseHeaders": {
"type": "array",
"optional": true,
"description": "Matches if none of the response headers is matched by any of the HeaderFilters.",
"items": { "$ref": "HeaderFilter" }
},
"thirdPartyForCookies": {
"type": "boolean",
"optional": true,
"description": "If set to true, matches requests that are subject to third-party cookie policies. If set to false, matches all other requests."
},
"stages": {
"type": "array",
"items": {
"type": "string",
"enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"]
},
"optional": true,
"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."
},
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RequestMatcher"],
"nodoc": true
}
}
},
{
"id": "CancelRequest",
"description": "Declarative event action that cancels a network request.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.CancelRequest"],
"nodoc": true
}
}
},
{
"id": "RedirectRequest",
"description": "Declarative event action that redirects a network request.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RedirectRequest"],
"nodoc": true
},
"redirectUrl": { "type": "string", "description": "Destination to where the request is redirected."}
}
},
{
"id": "declarativeWebRequest.RedirectToTransparentImage",
"description": "Declarative event action that redirects a network request to a transparent image.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RedirectToTransparentImage"],
"nodoc": true
}
}
},
{
"id": "declarativeWebRequest.RedirectToEmptyDocument",
"description": "Declarative event action that redirects a network request to an empty document.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RedirectToEmptyDocument"],
"nodoc": true
}
}
},
{
"id": "declarativeWebRequest.RedirectByRegEx",
"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>.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RedirectByRegEx"],
"nodoc": true
},
"from": {
"type": "string",
"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."
},
"to": {
"type": "string",
"description": "Destination pattern."
}
}
},
{
"id": "declarativeWebRequest.SetRequestHeader",
"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.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.SetRequestHeader"],
"nodoc": true
},
"name": {
"type": "string",
"description": "HTTP request header name."
},
"value": {
"type": "string",
"description": "HTTP request header value."
}
}
},
{
"id": "declarativeWebRequest.RemoveRequestHeader",
"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.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RemoveRequestHeader"],
"nodoc": true
},
"name": {
"type": "string",
"description": "HTTP request header name (case-insensitive)."
}
}
},
{
"id": "declarativeWebRequest.AddResponseHeader",
"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.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.AddResponseHeader"],
"nodoc": true
},
"name": {
"type": "string",
"description": "HTTP response header name."
},
"value": {
"type": "string",
"description": "HTTP response header value."
}
}
},
{
"id": "declarativeWebRequest.RemoveResponseHeader",
"description": "Removes all response headers of the specified names and values.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RemoveResponseHeader"],
"nodoc": true
},
"name": {
"type": "string",
"description": "HTTP request header name (case-insensitive)."
},
"value": {
"type": "string",
"description": "HTTP request header value (case-insensitive).",
"optional": true
}
}
},
{
"id": "declarativeWebRequest.IgnoreRules",
"description": "Masks all rules that match the specified criteria.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.IgnoreRules"],
"nodoc": true
},
"lowerPriorityThan": {
"type": "integer",
"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.",
"optional": true
},
"hasTag": {
"type": "string",
"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.",
"optional": true
}
}
},
{
"id": "declarativeWebRequest.SendMessageToExtension",
"description": "Triggers the $(ref:declarativeWebRequest.onMessage) event.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.SendMessageToExtension"],
"nodoc": true
},
"message": {
"type": "string",
"description": "The value that will be passed in the <code>message</code> attribute of the dictionary that is passed to the event handler."
}
}
},
{
"id": "declarativeWebRequest.RequestCookie",
"description": "A filter or specification of a cookie in HTTP Requests.",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of a cookie.",
"optional": true
},
"value": {
"type": "string",
"description": "Value of a cookie, may be padded in double-quotes.",
"optional": true
}
}
},
{
"id": "declarativeWebRequest.ResponseCookie",
"description": "A specification of a cookie in HTTP Responses.",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of a cookie.",
"optional": true
},
"value": {
"type": "string",
"description": "Value of a cookie, may be padded in double-quotes.",
"optional": true
},
"expires": {
"type": "string",
"description": "Value of the Expires cookie attribute.",
"optional": true
},
"maxAge": {
"type": "number",
"description": "Value of the Max-Age cookie attribute",
"optional": true
},
"domain": {
"type": "string",
"description": "Value of the Domain cookie attribute.",
"optional": true
},
"path": {
"type": "string",
"description": "Value of the Path cookie attribute.",
"optional": true
},
"secure": {
"type": "string",
"description": "Existence of the Secure cookie attribute.",
"optional": true
},
"httpOnly": {
"type": "string",
"description": "Existence of the HttpOnly cookie attribute.",
"optional": true
}
}
},
{
"id": "declarativeWebRequest.FilterResponseCookie",
"description": "A filter of a cookie in HTTP Responses.",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of a cookie.",
"optional": true
},
"value": {
"type": "string",
"description": "Value of a cookie, may be padded in double-quotes.",
"optional": true
},
"expires": {
"type": "string",
"description": "Value of the Expires cookie attribute.",
"optional": true
},
"maxAge": {
"type": "number",
"description": "Value of the Max-Age cookie attribute",
"optional": true
},
"domain": {
"type": "string",
"description": "Value of the Domain cookie attribute.",
"optional": true
},
"path": {
"type": "string",
"description": "Value of the Path cookie attribute.",
"optional": true
},
"secure": {
"type": "string",
"description": "Existence of the Secure cookie attribute.",
"optional": true
},
"httpOnly": {
"type": "string",
"description": "Existence of the HttpOnly cookie attribute.",
"optional": true
},
"ageUpperBound": {
"type": "integer",
"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.",
"minimum": 0,
"optional": true
},
"ageLowerBound": {
"type": "integer",
"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.",
"minimum": 0,
"optional": true
},
"sessionCookie": {
"type": "boolean",
"description": "Filters session cookies. Session cookies have no lifetime specified in any of 'max-age' or 'expires' attributes.",
"optional": true
}
}
},
{
"id": "declarativeWebRequest.AddRequestCookie",
"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.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.AddRequestCookie"],
"nodoc": true
},
"cookie": {
"$ref": "declarativeWebRequest.RequestCookie",
"description": "Cookie to be added to the request. No field may be undefined."
}
}
},
{
"id": "declarativeWebRequest.AddResponseCookie",
"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.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.AddResponseCookie"],
"nodoc": true
},
"cookie": {
"$ref": "declarativeWebRequest.ResponseCookie",
"description": "Cookie to be added to the response. The name and value need to be specified."
}
}
},
{
"id": "declarativeWebRequest.EditRequestCookie",
"description": "Edits one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.EditRequestCookie"],
"nodoc": true
},
"filter": {
"$ref": "declarativeWebRequest.RequestCookie",
"description": "Filter for cookies that will be modified. All empty entries are ignored."
},
"modification": {
"$ref": "declarativeWebRequest.RequestCookie",
"description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
}
}
},
{
"id": "declarativeWebRequest.EditResponseCookie",
"description": "Edits one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.EditResponseCookie"],
"nodoc": true
},
"filter": {
"$ref": "declarativeWebRequest.FilterResponseCookie",
"description": "Filter for cookies that will be modified. All empty entries are ignored."
},
"modification": {
"$ref": "declarativeWebRequest.ResponseCookie",
"description": "Attributes that shall be overridden in cookies that machted the filter. Attributes that are set to an empty string are removed."
}
}
},
{
"id": "declarativeWebRequest.RemoveRequestCookie",
"description": "Removes one or more cookies of request. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RemoveRequestCookie"],
"nodoc": true
},
"filter": {
"$ref": "declarativeWebRequest.RequestCookie",
"description": "Filter for cookies that will be removed. All empty entries are ignored."
}
}
},
{
"id": "declarativeWebRequest.RemoveResponseCookie",
"description": "Removes one or more cookies of response. Note that it is preferred to use the Cookies API because this is computationally less expensive.",
"type": "object",
"properties": {
"instanceType": {
"type": "string", "enum": ["declarativeWebRequest.RemoveResponseCookie"],
"nodoc": true
},
"filter": {
"$ref": "declarativeWebRequest.FilterResponseCookie",
"description": "Filter for cookies that will be removed. All empty entries are ignored."
}
}
}
],
"functions": [
],
"events": [
{
"name": "onRequest",
"options": {
"supportsListeners": false,
"supportsRules": true,
"conditions": ["declarativeWebRequest.RequestMatcher"],
"actions": [
"declarativeWebRequest.AddRequestCookie",
"declarativeWebRequest.AddResponseCookie",
"declarativeWebRequest.AddResponseHeader",
"declarativeWebRequest.CancelRequest",
"declarativeWebRequest.EditRequestCookie",
"declarativeWebRequest.EditResponseCookie",
"declarativeWebRequest.RedirectRequest",
"declarativeWebRequest.RedirectToTransparentImage",
"declarativeWebRequest.RedirectToEmptyDocument",
"declarativeWebRequest.RedirectByRegEx",
"declarativeWebRequest.RemoveRequestCookie",
"declarativeWebRequest.RemoveResponseCookie",
"declarativeWebRequest.RemoveRequestHeader",
"declarativeWebRequest.RemoveResponseHeader",
"declarativeWebRequest.SetRequestHeader",
"declarativeWebRequest.SendMessageToExtension",
"declarativeWebRequest.IgnoreRules"
]
}
},
{
"name": "onMessage",
"type": "function",
"description": "Fired when a message is sent via $(ref:declarativeWebRequest.SendMessageToExtension) from an action of the declarative web request API.",
"parameters": [
{
"type": "object",
"name": "details",
"properties": {
"message": {"type": "string", "description": "The message sent by the calling script."},
"stage": {"type": "string",
"enum": ["onBeforeRequest", "onBeforeSendHeaders", "onHeadersReceived", "onAuthRequired"],
"description": "The stage of the network request during which the event was triggered."},
"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."},
"url": {"type": "string"},
"method": {"type": "string", "description": "Standard HTTP method."},
"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."},
"parentFrameId": {"type": "integer", "description": "ID of frame that wraps the frame which sent the request. Set to -1 if no parent frame exists."},
"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."},
"type": {"type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"], "description": "How the requested resource will be used."},
"timeStamp": {"type": "number", "description": "The time when this signal is triggered, in milliseconds since the epoch."}
}
}
]
}
]
}
]