OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Helper classes and functions used for the WebRequest API. | 5 // Helper classes and functions used for the WebRequest API. |
6 | 6 |
7 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 7 #ifndef EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
8 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 8 #define EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "content/public/common/resource_type.h" |
18 #include "extensions/browser/warning_set.h" | 19 #include "extensions/browser/warning_set.h" |
19 #include "net/base/auth.h" | 20 #include "net/base/auth.h" |
20 #include "net/http/http_request_headers.h" | 21 #include "net/http/http_request_headers.h" |
21 #include "net/http/http_response_headers.h" | 22 #include "net/http/http_response_headers.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class ListValue; | 26 class ListValue; |
26 class Value; | 27 class Value; |
27 } | 28 } |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 class RenderProcessHost; | 31 class RenderProcessHost; |
31 } | 32 } |
32 | 33 |
33 namespace extensions { | 34 namespace extensions { |
34 class Extension; | 35 class Extension; |
35 } | 36 } |
36 | 37 |
37 namespace net { | 38 namespace net { |
38 class BoundNetLog; | 39 class BoundNetLog; |
39 class URLRequest; | 40 class URLRequest; |
40 } | 41 } |
41 | 42 |
42 namespace extension_web_request_api_helpers { | 43 namespace extension_web_request_api_helpers { |
43 | 44 |
44 | |
45 typedef std::pair<std::string, std::string> ResponseHeader; | 45 typedef std::pair<std::string, std::string> ResponseHeader; |
46 typedef std::vector<ResponseHeader> ResponseHeaders; | 46 typedef std::vector<ResponseHeader> ResponseHeaders; |
47 | 47 |
48 // Data container for RequestCookies as defined in the declarative WebRequest | 48 // Data container for RequestCookies as defined in the declarative WebRequest |
49 // API definition. | 49 // API definition. |
50 struct RequestCookie { | 50 struct RequestCookie { |
51 RequestCookie(); | 51 RequestCookie(); |
52 ~RequestCookie(); | 52 ~RequestCookie(); |
53 scoped_ptr<std::string> name; | 53 scoped_ptr<std::string> name; |
54 scoped_ptr<std::string> value; | 54 scoped_ptr<std::string> value; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 | 319 |
320 // Send updates to |host| with information about what webRequest-related | 320 // Send updates to |host| with information about what webRequest-related |
321 // extensions are installed. | 321 // extensions are installed. |
322 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); | 322 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); |
323 | 323 |
324 // Converts the |name|, |value| pair of a http header to a HttpHeaders | 324 // Converts the |name|, |value| pair of a http header to a HttpHeaders |
325 // dictionary. Ownership is passed to the caller. | 325 // dictionary. Ownership is passed to the caller. |
326 base::DictionaryValue* CreateHeaderDictionary( | 326 base::DictionaryValue* CreateHeaderDictionary( |
327 const std::string& name, const std::string& value); | 327 const std::string& name, const std::string& value); |
328 | 328 |
| 329 // Returns whether |type| is a ResourceType that is handled by the web request |
| 330 // API. |
| 331 bool IsRelevantResourceType(content::ResourceType type); |
| 332 |
| 333 // Returns a string representation of |type| or |other| if |type| is not handled |
| 334 // by the web request API. |
| 335 const char* ResourceTypeToString(content::ResourceType type); |
| 336 |
| 337 // Stores a |content::ResourceType| representation in |type| if |type_str| is |
| 338 // a resource type handled by the web request API. Returns true in case of |
| 339 // success. |
| 340 bool ParseResourceType(const std::string& type_str, |
| 341 content::ResourceType* type); |
| 342 |
329 } // namespace extension_web_request_api_helpers | 343 } // namespace extension_web_request_api_helpers |
330 | 344 |
331 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ | 345 #endif // EXTENSIONS_BROWSER_API_WEB_REQUEST_WEB_REQUEST_API_HELPERS_H_ |
OLD | NEW |