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

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

Issue 2700553002: Introduce WebRequestResourceType. (Closed)
Patch Set: Address comments; add 'media'; make type mapping consistent. 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, // A valid resource/request type, but none of the above.
34 UNDEFINED, // The type is invalid or unknown.
35 };
36
37 // Multiple content::ResourceTypes may map to the same WebRequestResourceType,
38 // but the converse is not possible.
39 WebRequestResourceType ToWebRequestResourceType(content::ResourceType type);
40
41 // Returns a type for a non-empty URLRequest.
42 WebRequestResourceType GetWebRequestResourceType(const net::URLRequest*);
43
44 // Returns a string representation of |type|, which shouldn't be UNDEFINED.
45 const char* WebRequestResourceTypeToString(WebRequestResourceType type);
46
47 // Returns a type such that its string representation equals to |text|. If such
48 // a type doesn't exist, returns UNDEFINED.
49 WebRequestResourceType ParseWebRequestResourceType(base::StringPiece text);
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