Chromium Code Reviews| Index: extensions/browser/api/web_request/web_request_resource_type.h |
| diff --git a/extensions/browser/api/web_request/web_request_resource_type.h b/extensions/browser/api/web_request/web_request_resource_type.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8a55a90b38e5f27e83809e29d03fbcb05bb5ec2e |
| --- /dev/null |
| +++ b/extensions/browser/api/web_request/web_request_resource_type.h |
| @@ -0,0 +1,60 @@ |
| +// Copyright 2017 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. |
| + |
| +#ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |
| +#define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |
| + |
| +#include "content/public/common/resource_type.h" |
| + |
| +namespace net { |
| +class URLRequest; |
| +} // namespace net |
| + |
| +namespace extensions { |
| + |
| +// Enumerates all resource/request types that WebRequest API cares about. |
| +enum class WebRequestResourceType { |
| + // Below are content::ResourceType values. Note: Each content::RESOURCE_TYPE_* |
| + // is typed explicitly in order to catch if some of those values get deleted. |
| + MAIN_FRAME = content::RESOURCE_TYPE_MAIN_FRAME, |
| + SUB_FRAME = content::RESOURCE_TYPE_SUB_FRAME, |
| + STYLESHEET = content::RESOURCE_TYPE_STYLESHEET, |
| + SCRIPT = content::RESOURCE_TYPE_SCRIPT, |
| + IMAGE = content::RESOURCE_TYPE_IMAGE, |
| + FONT_RESOURCE = content::RESOURCE_TYPE_FONT_RESOURCE, |
| + SUB_RESOURCE = content::RESOURCE_TYPE_SUB_RESOURCE, |
| + OBJECT = content::RESOURCE_TYPE_OBJECT, |
| + MEDIA = content::RESOURCE_TYPE_MEDIA, |
| + WORKER = content::RESOURCE_TYPE_WORKER, |
| + SHARED_WORKER = content::RESOURCE_TYPE_SHARED_WORKER, |
| + PREFETCH = content::RESOURCE_TYPE_PREFETCH, |
| + FAVICON = content::RESOURCE_TYPE_FAVICON, |
| + XHR = content::RESOURCE_TYPE_XHR, |
| + PING = content::RESOURCE_TYPE_PING, |
| + SERVICE_WORKER = content::RESOURCE_TYPE_SERVICE_WORKER, |
| + CSP_REPORT = content::RESOURCE_TYPE_CSP_REPORT, |
| + PLUGIN_RESOURCE = content::RESOURCE_TYPE_PLUGIN_RESOURCE, |
| + |
| + // Types of requests not in content::ResourceType. |
| + WEB_SOCKET, |
| + |
| + OTHER, |
|
Devlin
2017/02/16 16:08:26
(see other comment, but I wonder if we should put
tyoshino (SeeGerritForStatus)
2017/02/16 17:07:37
Oh. Using OTHER here would make kResourceTypeValue
pkalinnikov
2017/02/16 19:27:33
I addressed the inconsistency. Please see the glob
|
| +}; |
| + |
| +static_assert(content::RESOURCE_TYPE_LAST_TYPE == |
| + content::RESOURCE_TYPE_PLUGIN_RESOURCE + 1, |
| + "content::ResourceType has been modified."); |
| + |
| +inline WebRequestResourceType ToWebRequestResourceType( |
| + content::ResourceType type) { |
| + return type == content::RESOURCE_TYPE_LAST_TYPE |
| + ? WebRequestResourceType::OTHER |
| + : static_cast<WebRequestResourceType>(type); |
| +} |
| + |
| +WebRequestResourceType ToWebRequestResourceType(const net::URLRequest* request); |
|
pkalinnikov
2017/02/16 15:55:38
Actually, GetWebRequestResourceType fits this func
Devlin
2017/02/16 16:08:26
I was going to suggest something like WebRequestRe
|
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |