| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |
| 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ | 6 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "content/public/common/resource_type.h" | 11 #include "content/public/common/resource_type.h" |
| 12 | 12 |
| 13 namespace net { | 13 namespace net { |
| 14 class URLRequest; | 14 class URLRequest; |
| 15 } // namespace net | 15 } // namespace net |
| 16 | 16 |
| 17 namespace extensions { | 17 namespace extensions { |
| 18 | 18 |
| 19 // Enumerates all resource/request types that WebRequest API cares about. | 19 // Enumerates all resource/request types that WebRequest API cares about. |
| 20 enum class WebRequestResourceType : uint8_t { | 20 enum class WebRequestResourceType : uint8_t { |
| 21 MAIN_FRAME, | 21 MAIN_FRAME, |
| 22 SUB_FRAME, | 22 SUB_FRAME, |
| 23 STYLESHEET, | 23 STYLESHEET, |
| 24 SCRIPT, | 24 SCRIPT, |
| 25 IMAGE, | 25 IMAGE, |
| 26 FONT, | 26 FONT, |
| 27 OBJECT, | 27 OBJECT, |
| 28 XHR, | 28 XHR, |
| 29 PING, | 29 PING, |
| 30 CSP_REPORT, |
| 30 MEDIA, | 31 MEDIA, |
| 31 WEB_SOCKET, | 32 WEB_SOCKET, |
| 32 | 33 |
| 33 OTHER, // The type is unknown, or differs from all the above. | 34 OTHER, // The type is unknown, or differs from all the above. |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 // Multiple content::ResourceTypes may map to the same WebRequestResourceType, | 37 // Multiple content::ResourceTypes may map to the same WebRequestResourceType, |
| 37 // but the converse is not possible. | 38 // but the converse is not possible. |
| 38 WebRequestResourceType ToWebRequestResourceType(content::ResourceType type); | 39 WebRequestResourceType ToWebRequestResourceType(content::ResourceType type); |
| 39 | 40 |
| 40 // Returns a type for a non-empty URLRequest. | 41 // Returns a type for a non-empty URLRequest. |
| 41 WebRequestResourceType GetWebRequestResourceType(const net::URLRequest*); | 42 WebRequestResourceType GetWebRequestResourceType(const net::URLRequest*); |
| 42 | 43 |
| 43 // Returns a string representation of |type|. | 44 // Returns a string representation of |type|. |
| 44 const char* WebRequestResourceTypeToString(WebRequestResourceType type); | 45 const char* WebRequestResourceTypeToString(WebRequestResourceType type); |
| 45 | 46 |
| 46 // Finds a |type| such that its string representation equals to |text|. Returns | 47 // Finds a |type| such that its string representation equals to |text|. Returns |
| 47 // true iff the type is found. | 48 // true iff the type is found. |
| 48 bool ParseWebRequestResourceType(base::StringPiece text, | 49 bool ParseWebRequestResourceType(base::StringPiece text, |
| 49 WebRequestResourceType* type); | 50 WebRequestResourceType* type); |
| 50 | 51 |
| 51 } // namespace extensions | 52 } // namespace extensions |
| 52 | 53 |
| 53 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ | 54 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_RESOURCE_TYPE_H_ |
| OLD | NEW |