summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorrob <rob@robwu.nl>2015-12-22 11:46:51 -0800
committerCommit bot <commit-bot@chromium.org>2015-12-22 19:47:40 +0000
commit6a32a203bbae04ef29a42f3f364ec00a0adf9179 (patch)
treebd050d81bf3272834e71766e7aa1b55fda9507b9 /extensions
parent6abb1cd695aeb366d9a9a4e4e6dbbe3e94902ab1 (diff)
downloadchromium_src-6a32a203bbae04ef29a42f3f364ec00a0adf9179.zip
chromium_src-6a32a203bbae04ef29a42f3f364ec00a0adf9179.tar.gz
chromium_src-6a32a203bbae04ef29a42f3f364ec00a0adf9179.tar.bz2
WebRequest API: add more resource types
Added new resource types "font" and "ping" to identify fonts, <a ping> and navigator.sendBeacon requests. Existing types are also extended: Workers (web workers, shared workers, service workers) are mapped to "script" and favicons are mapped to "image". Plugin requests are also labeled as "object". (all of these mentioned requests were previously labeled as "other"). Added two resource types: - RESOURCE_TYPE_CSP_REPORT; Previously RequestContextCSPReport mapped to RESOURCE_TYPE_PING. ping and beacons are commonly used for tracking, whereas CSP reports aid the security of website owners. By not including CSP reports in the ping type, extensions that disable ping will not inadvertently block security features of a website. - RESOURCE_TYPE_PLUGIN_RESOURCE; plugin requests should be tagged as "object" instead of "other". But we cannot use RESOURCE_TYPE_OBJECT because this is used by MimeTypeResourceHandler::SelectNextHandler to determine whether to intercept the resource and display the result in a plugin. BUG=80230,410382,512406 TEST=ExtensionWebRequestApiTest.* Review URL: https://codereview.chromium.org/1515703005 Cr-Commit-Position: refs/heads/master@{#366632}
Diffstat (limited to 'extensions')
-rw-r--r--extensions/browser/api/web_request/web_request_api_helpers.cc23
-rw-r--r--extensions/common/api/declarative_web_request.json2
-rw-r--r--extensions/common/api/web_request.json2
3 files changed, 16 insertions, 11 deletions
diff --git a/extensions/browser/api/web_request/web_request_api_helpers.cc b/extensions/browser/api/web_request/web_request_api_helpers.cc
index bc5038e..b2e71e3 100644
--- a/extensions/browser/api/web_request/web_request_api_helpers.cc
+++ b/extensions/browser/api/web_request/web_request_api_helpers.cc
@@ -52,9 +52,15 @@ static const char* kResourceTypeStrings[] = {
"stylesheet",
"script",
"image",
+ "font",
"object",
+ "script",
+ "script",
+ "image",
"xmlhttprequest",
- "other",
+ "ping",
+ "script",
+ "object",
"other",
};
@@ -66,15 +72,16 @@ static ResourceType kResourceTypeValues[] = {
content::RESOURCE_TYPE_STYLESHEET,
content::RESOURCE_TYPE_SCRIPT,
content::RESOURCE_TYPE_IMAGE,
+ content::RESOURCE_TYPE_FONT_RESOURCE,
content::RESOURCE_TYPE_OBJECT,
+ content::RESOURCE_TYPE_WORKER,
+ content::RESOURCE_TYPE_SHARED_WORKER,
+ content::RESOURCE_TYPE_FAVICON,
content::RESOURCE_TYPE_XHR,
+ content::RESOURCE_TYPE_PING,
+ content::RESOURCE_TYPE_SERVICE_WORKER,
+ content::RESOURCE_TYPE_PLUGIN_RESOURCE,
content::RESOURCE_TYPE_LAST_TYPE, // represents "other"
- // TODO(jochen): We duplicate the last entry, so the array's size is not a
- // power of two. If it is, this triggers a bug in gcc 4.4 in Release builds
- // (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949). Once we use a version
- // of gcc with this bug fixed, or the array is changed so this duplicate
- // entry is no longer required, this should be removed.
- content::RESOURCE_TYPE_LAST_TYPE,
};
const size_t kResourceTypeValuesLength = arraysize(kResourceTypeValues);
@@ -1251,8 +1258,6 @@ base::DictionaryValue* CreateHeaderDictionary(
return header;
}
-#define ARRAYEND(array) (array + arraysize(array))
-
bool IsRelevantResourceType(ResourceType type) {
ResourceType* iter =
std::find(kResourceTypeValues,
diff --git a/extensions/common/api/declarative_web_request.json b/extensions/common/api/declarative_web_request.json
index e9ea8a2..bfb7082 100644
--- a/extensions/common/api/declarative_web_request.json
+++ b/extensions/common/api/declarative_web_request.json
@@ -79,7 +79,7 @@
"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", "object", "xmlhttprequest", "other"] }
+ "items": { "type": "string", "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "other"] }
},
"contentType": {
"type": "array",
diff --git a/extensions/common/api/web_request.json b/extensions/common/api/web_request.json
index f76e941..4e314eb 100644
--- a/extensions/common/api/web_request.json
+++ b/extensions/common/api/web_request.json
@@ -16,7 +16,7 @@
{
"id": "ResourceType",
"type": "string",
- "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "object", "xmlhttprequest", "other"]
+ "enum": ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "other"]
},
{
"id": "OnBeforeRequestOptions",