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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_
6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_
7
8 #include "content/public/common/resource_type.h"
9
10 namespace extensions {
11
12 // Enumerates all resource/request types that WebRequest API cares about.
13 enum class WebRequestResourceType {
14 // Below are content::ResourceType values. Note: Each content::RESOURCE_TYPE_*
15 // is typed explicitly in order to catch if some of those values get deleted.
16 MAIN_FRAME = content::RESOURCE_TYPE_MAIN_FRAME,
17 SUB_FRAME = content::RESOURCE_TYPE_SUB_FRAME,
18 STYLESHEET = content::RESOURCE_TYPE_STYLESHEET,
19 SCRIPT = content::RESOURCE_TYPE_SCRIPT,
20 IMAGE = content::RESOURCE_TYPE_IMAGE,
21 FONT_RESOURCE = content::RESOURCE_TYPE_FONT_RESOURCE,
22 SUB_RESOURCE = content::RESOURCE_TYPE_SUB_RESOURCE,
23 OBJECT = content::RESOURCE_TYPE_OBJECT,
24 MEDIA = content::RESOURCE_TYPE_MEDIA,
25 WORKER = content::RESOURCE_TYPE_WORKER,
26 SHARED_WORKER = content::RESOURCE_TYPE_SHARED_WORKER,
27 PREFETCH = content::RESOURCE_TYPE_PREFETCH,
28 FAVICON = content::RESOURCE_TYPE_FAVICON,
29 XHR = content::RESOURCE_TYPE_XHR,
30 PING = content::RESOURCE_TYPE_PING,
31 SERVICE_WORKER = content::RESOURCE_TYPE_SERVICE_WORKER,
32 CSP_REPORT = content::RESOURCE_TYPE_CSP_REPORT,
33 PLUGIN_RESOURCE = content::RESOURCE_TYPE_PLUGIN_RESOURCE,
34
35 // Types of requests not in content::ResourceType.
36 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.
37
38 LAST_TYPE,
39 };
40
41 static_assert(content::RESOURCE_TYPE_LAST_TYPE ==
42 content::RESOURCE_TYPE_PLUGIN_RESOURCE + 1,
43 "content::ResourceType has been modified.");
44
45 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
46 content::ResourceType type) {
47 return type == content::RESOURCE_TYPE_LAST_TYPE
48 ? WebRequestResourceType::LAST_TYPE
49 : static_cast<WebRequestResourceType>(type);
50 }
51
52 } // namespace extensions
53
54 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698