OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "chrome/browser/extensions/extension_function.h" | 16 #include "chrome/browser/extensions/extension_function.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/extensions/url_pattern_set.h" | 18 #include "chrome/common/extensions/url_pattern_set.h" |
19 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
20 #include "net/base/completion_callback.h" | 20 #include "net/base/completion_callback.h" |
21 #include "webkit/glue/resource_type.h" | 21 #include "webkit/glue/resource_type.h" |
22 | 22 |
23 class DictionaryValue; | |
24 class ExtensionInfoMap; | 23 class ExtensionInfoMap; |
25 class GURL; | 24 class GURL; |
| 25 |
| 26 namespace base { |
| 27 class DictionaryValue; |
26 class ListValue; | 28 class ListValue; |
27 class StringValue; | 29 class StringValue; |
| 30 } |
28 | 31 |
29 namespace net { | 32 namespace net { |
30 class HostPortPair; | 33 class HostPortPair; |
31 class HttpRequestHeaders; | 34 class HttpRequestHeaders; |
32 class HttpResponseHeaders; | 35 class HttpResponseHeaders; |
33 class URLRequest; | 36 class URLRequest; |
34 } | 37 } |
35 | 38 |
36 // This class observes network events and routes them to the appropriate | 39 // This class observes network events and routes them to the appropriate |
37 // extensions listening to those events. All methods must be called on the IO | 40 // extensions listening to those events. All methods must be called on the IO |
(...skipping 18 matching lines...) Expand all Loading... |
56 std::vector<ResourceType::Type> types; | 59 std::vector<ResourceType::Type> types; |
57 int tab_id; | 60 int tab_id; |
58 int window_id; | 61 int window_id; |
59 | 62 |
60 RequestFilter(); | 63 RequestFilter(); |
61 ~RequestFilter(); | 64 ~RequestFilter(); |
62 | 65 |
63 // Returns false if there was an error initializing. If it is a user error, | 66 // Returns false if there was an error initializing. If it is a user error, |
64 // an error message is provided, otherwise the error is internal (and | 67 // an error message is provided, otherwise the error is internal (and |
65 // unexpected). | 68 // unexpected). |
66 bool InitFromValue(const DictionaryValue& value, std::string* error); | 69 bool InitFromValue(const base::DictionaryValue& value, std::string* error); |
67 }; | 70 }; |
68 | 71 |
69 // Internal representation of the extraInfoSpec parameter on webRequest | 72 // Internal representation of the extraInfoSpec parameter on webRequest |
70 // events, used to specify extra information to be included with network | 73 // events, used to specify extra information to be included with network |
71 // events. | 74 // events. |
72 struct ExtraInfoSpec { | 75 struct ExtraInfoSpec { |
73 enum Flags { | 76 enum Flags { |
74 REQUEST_LINE = 1<<0, | 77 REQUEST_LINE = 1<<0, |
75 REQUEST_HEADERS = 1<<1, | 78 REQUEST_HEADERS = 1<<1, |
76 STATUS_LINE = 1<<2, | 79 STATUS_LINE = 1<<2, |
77 RESPONSE_HEADERS = 1<<3, | 80 RESPONSE_HEADERS = 1<<3, |
78 BLOCKING = 1<<4, | 81 BLOCKING = 1<<4, |
79 }; | 82 }; |
80 | 83 |
81 static bool InitFromValue(const ListValue& value, int* extra_info_spec); | 84 static bool InitFromValue(const base::ListValue& value, |
| 85 int* extra_info_spec); |
82 }; | 86 }; |
83 | 87 |
84 // Contains an extension's response to a blocking event. | 88 // Contains an extension's response to a blocking event. |
85 struct EventResponse { | 89 struct EventResponse { |
86 // ID of the extension that sent this response. | 90 // ID of the extension that sent this response. |
87 std::string extension_id; | 91 std::string extension_id; |
88 | 92 |
89 // The time that the extension was installed. Used for deciding order of | 93 // The time that the extension was installed. Used for deciding order of |
90 // precedence in case multiple extensions respond with conflicting | 94 // precedence in case multiple extensions respond with conflicting |
91 // decisions. | 95 // decisions. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 typedef std::map<uint64, int> SignaledRequestMap; | 212 typedef std::map<uint64, int> SignaledRequestMap; |
209 typedef std::map<ProfileId, ProfileId> CrossProfileMap; | 213 typedef std::map<ProfileId, ProfileId> CrossProfileMap; |
210 | 214 |
211 ExtensionWebRequestEventRouter(); | 215 ExtensionWebRequestEventRouter(); |
212 ~ExtensionWebRequestEventRouter(); | 216 ~ExtensionWebRequestEventRouter(); |
213 | 217 |
214 bool DispatchEvent( | 218 bool DispatchEvent( |
215 ProfileId profile_id, | 219 ProfileId profile_id, |
216 net::URLRequest* request, | 220 net::URLRequest* request, |
217 const std::vector<const EventListener*>& listeners, | 221 const std::vector<const EventListener*>& listeners, |
218 const ListValue& args); | 222 const base::ListValue& args); |
219 | 223 |
220 // Returns a list of event listeners that care about the given event, based | 224 // Returns a list of event listeners that care about the given event, based |
221 // on their filter parameters. |extra_info_spec| will contain the combined | 225 // on their filter parameters. |extra_info_spec| will contain the combined |
222 // set of extra_info_spec flags that every matching listener asked for. | 226 // set of extra_info_spec flags that every matching listener asked for. |
223 std::vector<const EventListener*> GetMatchingListeners( | 227 std::vector<const EventListener*> GetMatchingListeners( |
224 ProfileId profile_id, | 228 ProfileId profile_id, |
225 ExtensionInfoMap* extension_info_map, | 229 ExtensionInfoMap* extension_info_map, |
226 const std::string& event_name, | 230 const std::string& event_name, |
227 const GURL& url, | 231 const GURL& url, |
228 int tab_id, | 232 int tab_id, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.addEventListener"); | 301 DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.addEventListener"); |
298 }; | 302 }; |
299 | 303 |
300 class WebRequestEventHandled : public SyncIOThreadExtensionFunction { | 304 class WebRequestEventHandled : public SyncIOThreadExtensionFunction { |
301 public: | 305 public: |
302 virtual bool RunImpl(); | 306 virtual bool RunImpl(); |
303 DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.eventHandled"); | 307 DECLARE_EXTENSION_FUNCTION_NAME("experimental.webRequest.eventHandled"); |
304 }; | 308 }; |
305 | 309 |
306 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ | 310 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEBREQUEST_API_H_ |
OLD | NEW |