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..77553caf4219de6dfad94bad734a8ab6aeb171f9 |
| --- /dev/null |
| +++ b/extensions/browser/api/web_request/web_request_resource_type.h |
| @@ -0,0 +1,54 @@ |
| +// 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 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. |
| + WEBSOCKET, |
| + |
| + LAST_TYPE, |
| +}; |
| + |
| +static_assert(content::RESOURCE_TYPE_LAST_TYPE == |
| + content::RESOURCE_TYPE_PLUGIN_RESOURCE + 1, |
| + "content::ResourceType has been modified."); |
|
tyoshino (SeeGerritForStatus)
2017/02/16 16:13:58
The comment for ResourceType is saying:
// Used i
pkalinnikov
2017/02/16 19:27:30
Ack. This is approximately what I thought here as
|
| + |
| +inline WebRequestResourceType ToWebRequestResourceType( |
| + content::ResourceType type) { |
| + return type == content::RESOURCE_TYPE_LAST_TYPE |
| + ? WebRequestResourceType::LAST_TYPE |
| + : static_cast<WebRequestResourceType>(type); |
| +} |
| + |
| +} // namespace extensions |
| + |
| +#endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |