Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: extensions/browser/api/web_request/web_request_resource_type.h

Issue 2700553002: Introduce WebRequestResourceType. (Closed)
Patch Set: Fix fix win build. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,
Devlin 2017/02/16 15:13:05 nit: Why WEBSOCKET instead of WEB_SOCKET? (If thi
pkalinnikov 2017/02/16 15:52:45 Changed to WEB_SOCKET.
+
+ LAST_TYPE,
+};
+
+static_assert(content::RESOURCE_TYPE_LAST_TYPE ==
+ content::RESOURCE_TYPE_PLUGIN_RESOURCE + 1,
+ "content::ResourceType has been modified.");
+
+inline WebRequestResourceType ToWebRequestResourceType(
Devlin 2017/02/16 15:13:05 When we begin intercepting WebSocket requests, thi
pkalinnikov 2017/02/16 15:52:45 I had been thinking about this as well, but I had
+ 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_

Powered by Google App Engine
This is Rietveld 408576698