OLD | NEW |
---|---|
(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 net { | |
11 class URLRequest; | |
12 } // namespace net | |
13 | |
14 namespace extensions { | |
15 | |
16 // Enumerates all resource/request types that WebRequest API cares about. | |
17 enum class WebRequestResourceType { | |
18 // Below are content::ResourceType values. Note: Each content::RESOURCE_TYPE_* | |
19 // is typed explicitly in order to catch if some of those values get deleted. | |
20 MAIN_FRAME = content::RESOURCE_TYPE_MAIN_FRAME, | |
21 SUB_FRAME = content::RESOURCE_TYPE_SUB_FRAME, | |
22 STYLESHEET = content::RESOURCE_TYPE_STYLESHEET, | |
23 SCRIPT = content::RESOURCE_TYPE_SCRIPT, | |
24 IMAGE = content::RESOURCE_TYPE_IMAGE, | |
25 FONT_RESOURCE = content::RESOURCE_TYPE_FONT_RESOURCE, | |
26 SUB_RESOURCE = content::RESOURCE_TYPE_SUB_RESOURCE, | |
27 OBJECT = content::RESOURCE_TYPE_OBJECT, | |
28 MEDIA = content::RESOURCE_TYPE_MEDIA, | |
29 WORKER = content::RESOURCE_TYPE_WORKER, | |
30 SHARED_WORKER = content::RESOURCE_TYPE_SHARED_WORKER, | |
31 PREFETCH = content::RESOURCE_TYPE_PREFETCH, | |
32 FAVICON = content::RESOURCE_TYPE_FAVICON, | |
33 XHR = content::RESOURCE_TYPE_XHR, | |
34 PING = content::RESOURCE_TYPE_PING, | |
35 SERVICE_WORKER = content::RESOURCE_TYPE_SERVICE_WORKER, | |
36 CSP_REPORT = content::RESOURCE_TYPE_CSP_REPORT, | |
37 PLUGIN_RESOURCE = content::RESOURCE_TYPE_PLUGIN_RESOURCE, | |
38 | |
39 // Types of requests not in content::ResourceType. | |
40 WEB_SOCKET, | |
41 | |
42 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
| |
43 }; | |
44 | |
45 static_assert(content::RESOURCE_TYPE_LAST_TYPE == | |
46 content::RESOURCE_TYPE_PLUGIN_RESOURCE + 1, | |
47 "content::ResourceType has been modified."); | |
48 | |
49 inline WebRequestResourceType ToWebRequestResourceType( | |
50 content::ResourceType type) { | |
51 return type == content::RESOURCE_TYPE_LAST_TYPE | |
52 ? WebRequestResourceType::OTHER | |
53 : static_cast<WebRequestResourceType>(type); | |
54 } | |
55 | |
56 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
| |
57 | |
58 } // namespace extensions | |
59 | |
60 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ | |
OLD | NEW |