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

Side by Side Diff: extensions/browser/api/web_request/web_request_resource_type.h

Issue 2700553002: Introduce WebRequestResourceType. (Closed)
Patch Set: Make compiler happy; make type<->string mapping self-checking. 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 <stdint.h>
9
10 #include "base/strings/string_piece.h"
11 #include "content/public/common/resource_type.h"
12
13 namespace net {
14 class URLRequest;
15 } // namespace net
16
17 namespace extensions {
18
19 // Enumerates all resource/request types that WebRequest API cares about.
20 enum class WebRequestResourceType : uint8_t {
21 MAIN_FRAME,
22 SUB_FRAME,
23 STYLESHEET,
24 SCRIPT,
25 IMAGE,
26 FONT,
27 OBJECT,
28 XHR,
29 PING,
30 MEDIA,
31 WEB_SOCKET,
32
33 OTHER, // The type is unknown, or differs from all the above.
34 };
35
36 // Multiple content::ResourceTypes may map to the same WebRequestResourceType,
37 // but the converse is not possible.
38 WebRequestResourceType ToWebRequestResourceType(content::ResourceType type);
39
40 // Returns a type for a non-empty URLRequest.
41 WebRequestResourceType GetWebRequestResourceType(const net::URLRequest*);
42
43 // Returns a string representation of |type|.
44 const char* WebRequestResourceTypeToString(WebRequestResourceType type);
45
46 // Finds a |type| such that its string representation equals to |text|. Returns
47 // true iff the type is found.
48 bool ParseWebRequestResourceType(base::StringPiece text,
49 WebRequestResourceType* type);
50
51 } // namespace extensions
52
53 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698