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

Side by Side Diff: chrome/browser/extensions/api/web_request/web_request_api.h

Issue 63933003: Moved ExtensionInfoMap and ExtensionsQuotaService to extensions/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment fix Created 7 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
7 7
8 #include <list> 8 #include <list>
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/memory/weak_ptr.h" 15 #include "base/memory/weak_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" 17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h"
18 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 18 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
19 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" 19 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h"
20 #include "chrome/browser/extensions/extension_function.h" 20 #include "chrome/browser/extensions/extension_function.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_version_info.h" 22 #include "chrome/common/chrome_version_info.h"
23 #include "extensions/common/url_pattern_set.h" 23 #include "extensions/common/url_pattern_set.h"
24 #include "ipc/ipc_sender.h" 24 #include "ipc/ipc_sender.h"
25 #include "net/base/completion_callback.h" 25 #include "net/base/completion_callback.h"
26 #include "net/base/network_delegate.h" 26 #include "net/base/network_delegate.h"
27 #include "net/http/http_request_headers.h" 27 #include "net/http/http_request_headers.h"
28 #include "webkit/common/resource_type.h" 28 #include "webkit/common/resource_type.h"
29 29
30 class ExtensionInfoMap;
31 class ExtensionWebRequestTimeTracker; 30 class ExtensionWebRequestTimeTracker;
32 class GURL; 31 class GURL;
33 32
34 namespace base { 33 namespace base {
35 class DictionaryValue; 34 class DictionaryValue;
36 class ListValue; 35 class ListValue;
37 class StringValue; 36 class StringValue;
38 } 37 }
39 38
40 namespace content { 39 namespace content {
41 class RenderProcessHost; 40 class RenderProcessHost;
42 } 41 }
43 42
44 namespace extensions { 43 namespace extensions {
44 class InfoMap;
45 class WebRequestRulesRegistry; 45 class WebRequestRulesRegistry;
46 } 46 }
47 47
48 namespace net { 48 namespace net {
49 class AuthCredentials; 49 class AuthCredentials;
50 class AuthChallengeInfo; 50 class AuthChallengeInfo;
51 class HttpRequestHeaders; 51 class HttpRequestHeaders;
52 class HttpResponseHeaders; 52 class HttpResponseHeaders;
53 class URLRequest; 53 class URLRequest;
54 } 54 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Registers a rule registry. Pass null for |rules_registry| to unregister 138 // Registers a rule registry. Pass null for |rules_registry| to unregister
139 // the rule registry for |profile|. 139 // the rule registry for |profile|.
140 void RegisterRulesRegistry( 140 void RegisterRulesRegistry(
141 void* profile, 141 void* profile,
142 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); 142 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry);
143 143
144 // Dispatches the OnBeforeRequest event to any extensions whose filters match 144 // Dispatches the OnBeforeRequest event to any extensions whose filters match
145 // the given request. Returns net::ERR_IO_PENDING if an extension is 145 // the given request. Returns net::ERR_IO_PENDING if an extension is
146 // intercepting the request, OK otherwise. 146 // intercepting the request, OK otherwise.
147 int OnBeforeRequest(void* profile, 147 int OnBeforeRequest(void* profile,
148 ExtensionInfoMap* extension_info_map, 148 extensions::InfoMap* extension_info_map,
149 net::URLRequest* request, 149 net::URLRequest* request,
150 const net::CompletionCallback& callback, 150 const net::CompletionCallback& callback,
151 GURL* new_url); 151 GURL* new_url);
152 152
153 // Dispatches the onBeforeSendHeaders event. This is fired for HTTP(s) 153 // Dispatches the onBeforeSendHeaders event. This is fired for HTTP(s)
154 // requests only, and allows modification of the outgoing request headers. 154 // requests only, and allows modification of the outgoing request headers.
155 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK 155 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, OK
156 // otherwise. 156 // otherwise.
157 int OnBeforeSendHeaders(void* profile, 157 int OnBeforeSendHeaders(void* profile,
158 ExtensionInfoMap* extension_info_map, 158 extensions::InfoMap* extension_info_map,
159 net::URLRequest* request, 159 net::URLRequest* request,
160 const net::CompletionCallback& callback, 160 const net::CompletionCallback& callback,
161 net::HttpRequestHeaders* headers); 161 net::HttpRequestHeaders* headers);
162 162
163 // Dispatches the onSendHeaders event. This is fired for HTTP(s) requests 163 // Dispatches the onSendHeaders event. This is fired for HTTP(s) requests
164 // only. 164 // only.
165 void OnSendHeaders(void* profile, 165 void OnSendHeaders(void* profile,
166 ExtensionInfoMap* extension_info_map, 166 extensions::InfoMap* extension_info_map,
167 net::URLRequest* request, 167 net::URLRequest* request,
168 const net::HttpRequestHeaders& headers); 168 const net::HttpRequestHeaders& headers);
169 169
170 // Dispatches the onHeadersReceived event. This is fired for HTTP(s) 170 // Dispatches the onHeadersReceived event. This is fired for HTTP(s)
171 // requests only, and allows modification of incoming response headers. 171 // requests only, and allows modification of incoming response headers.
172 // Returns net::ERR_IO_PENDING if an extension is intercepting the request, 172 // Returns net::ERR_IO_PENDING if an extension is intercepting the request,
173 // OK otherwise. |original_response_headers| is reference counted. |callback| 173 // OK otherwise. |original_response_headers| is reference counted. |callback|
174 // and |override_response_headers| are owned by a URLRequestJob. They are 174 // and |override_response_headers| are owned by a URLRequestJob. They are
175 // guaranteed to be valid until |callback| is called or OnURLRequestDestroyed 175 // guaranteed to be valid until |callback| is called or OnURLRequestDestroyed
176 // is called (whatever comes first). 176 // is called (whatever comes first).
177 // Do not modify |original_response_headers| directly but write new ones 177 // Do not modify |original_response_headers| directly but write new ones
178 // into |override_response_headers|. 178 // into |override_response_headers|.
179 int OnHeadersReceived( 179 int OnHeadersReceived(
180 void* profile, 180 void* profile,
181 ExtensionInfoMap* extension_info_map, 181 extensions::InfoMap* extension_info_map,
182 net::URLRequest* request, 182 net::URLRequest* request,
183 const net::CompletionCallback& callback, 183 const net::CompletionCallback& callback,
184 const net::HttpResponseHeaders* original_response_headers, 184 const net::HttpResponseHeaders* original_response_headers,
185 scoped_refptr<net::HttpResponseHeaders>* override_response_headers); 185 scoped_refptr<net::HttpResponseHeaders>* override_response_headers);
186 186
187 // Dispatches the OnAuthRequired event to any extensions whose filters match 187 // Dispatches the OnAuthRequired event to any extensions whose filters match
188 // the given request. If the listener is not registered as "blocking", then 188 // the given request. If the listener is not registered as "blocking", then
189 // AUTH_REQUIRED_RESPONSE_OK is returned. Otherwise, 189 // AUTH_REQUIRED_RESPONSE_OK is returned. Otherwise,
190 // AUTH_REQUIRED_RESPONSE_IO_PENDING is returned and |callback| will be 190 // AUTH_REQUIRED_RESPONSE_IO_PENDING is returned and |callback| will be
191 // invoked later. 191 // invoked later.
192 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired( 192 net::NetworkDelegate::AuthRequiredResponse OnAuthRequired(
193 void* profile, 193 void* profile,
194 ExtensionInfoMap* extension_info_map, 194 extensions::InfoMap* extension_info_map,
195 net::URLRequest* request, 195 net::URLRequest* request,
196 const net::AuthChallengeInfo& auth_info, 196 const net::AuthChallengeInfo& auth_info,
197 const net::NetworkDelegate::AuthCallback& callback, 197 const net::NetworkDelegate::AuthCallback& callback,
198 net::AuthCredentials* credentials); 198 net::AuthCredentials* credentials);
199 199
200 // Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests 200 // Dispatches the onBeforeRedirect event. This is fired for HTTP(s) requests
201 // only. 201 // only.
202 void OnBeforeRedirect(void* profile, 202 void OnBeforeRedirect(void* profile,
203 ExtensionInfoMap* extension_info_map, 203 extensions::InfoMap* extension_info_map,
204 net::URLRequest* request, 204 net::URLRequest* request,
205 const GURL& new_location); 205 const GURL& new_location);
206 206
207 // Dispatches the onResponseStarted event indicating that the first bytes of 207 // Dispatches the onResponseStarted event indicating that the first bytes of
208 // the response have arrived. 208 // the response have arrived.
209 void OnResponseStarted(void* profile, 209 void OnResponseStarted(void* profile,
210 ExtensionInfoMap* extension_info_map, 210 extensions::InfoMap* extension_info_map,
211 net::URLRequest* request); 211 net::URLRequest* request);
212 212
213 // Dispatches the onComplete event. 213 // Dispatches the onComplete event.
214 void OnCompleted(void* profile, 214 void OnCompleted(void* profile,
215 ExtensionInfoMap* extension_info_map, 215 extensions::InfoMap* extension_info_map,
216 net::URLRequest* request); 216 net::URLRequest* request);
217 217
218 // Dispatches an onErrorOccurred event. 218 // Dispatches an onErrorOccurred event.
219 void OnErrorOccurred(void* profile, 219 void OnErrorOccurred(void* profile,
220 ExtensionInfoMap* extension_info_map, 220 extensions::InfoMap* extension_info_map,
221 net::URLRequest* request, 221 net::URLRequest* request,
222 bool started); 222 bool started);
223 223
224 // Notifications when objects are going away. 224 // Notifications when objects are going away.
225 void OnURLRequestDestroyed(void* profile, net::URLRequest* request); 225 void OnURLRequestDestroyed(void* profile, net::URLRequest* request);
226 226
227 // Called when an event listener handles a blocking event and responds. 227 // Called when an event listener handles a blocking event and responds.
228 void OnEventHandled( 228 void OnEventHandled(
229 void* profile, 229 void* profile,
230 const std::string& extension_id, 230 const std::string& extension_id,
231 const std::string& event_name, 231 const std::string& event_name,
232 const std::string& sub_event_name, 232 const std::string& sub_event_name,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void* profile, 297 void* profile,
298 net::URLRequest* request, 298 net::URLRequest* request,
299 const std::vector<const EventListener*>& listeners, 299 const std::vector<const EventListener*>& listeners,
300 const base::ListValue& args); 300 const base::ListValue& args);
301 301
302 // Returns a list of event listeners that care about the given event, based 302 // Returns a list of event listeners that care about the given event, based
303 // on their filter parameters. |extra_info_spec| will contain the combined 303 // on their filter parameters. |extra_info_spec| will contain the combined
304 // set of extra_info_spec flags that every matching listener asked for. 304 // set of extra_info_spec flags that every matching listener asked for.
305 std::vector<const EventListener*> GetMatchingListeners( 305 std::vector<const EventListener*> GetMatchingListeners(
306 void* profile, 306 void* profile,
307 ExtensionInfoMap* extension_info_map, 307 extensions::InfoMap* extension_info_map,
308 const std::string& event_name, 308 const std::string& event_name,
309 net::URLRequest* request, 309 net::URLRequest* request,
310 int* extra_info_spec); 310 int* extra_info_spec);
311 311
312 // Helper for the above functions. This is called twice: once for the profile 312 // Helper for the above functions. This is called twice: once for the profile
313 // of the event, the next time for the "cross" profile (i.e. the incognito 313 // of the event, the next time for the "cross" profile (i.e. the incognito
314 // profile if the event is originally for the normal profile, or vice versa). 314 // profile if the event is originally for the normal profile, or vice versa).
315 void GetMatchingListenersImpl( 315 void GetMatchingListenersImpl(
316 void* profile, 316 void* profile,
317 ExtensionInfoMap* extension_info_map, 317 extensions::InfoMap* extension_info_map,
318 bool crosses_incognito, 318 bool crosses_incognito,
319 const std::string& event_name, 319 const std::string& event_name,
320 const GURL& url, 320 const GURL& url,
321 int tab_id, 321 int tab_id,
322 int window_id, 322 int window_id,
323 int render_process_host_id, 323 int render_process_host_id,
324 int routing_id, 324 int routing_id,
325 ResourceType::Type resource_type, 325 ResourceType::Type resource_type,
326 bool is_async_request, 326 bool is_async_request,
327 bool is_request_from_extension, 327 bool is_request_from_extension,
(...skipping 21 matching lines...) Expand all
349 // and wants to return the correct network error code himself. 349 // and wants to return the correct network error code himself.
350 int ExecuteDeltas(void* profile, uint64 request_id, bool call_callback); 350 int ExecuteDeltas(void* profile, uint64 request_id, bool call_callback);
351 351
352 // Evaluates the rules of the declarative webrequest API and stores 352 // Evaluates the rules of the declarative webrequest API and stores
353 // modifications to the request that result from WebRequestActions as 353 // modifications to the request that result from WebRequestActions as
354 // deltas in |blocked_requests_|. |original_response_headers| should only be 354 // deltas in |blocked_requests_|. |original_response_headers| should only be
355 // set for the OnHeadersReceived stage and NULL otherwise. Returns whether any 355 // set for the OnHeadersReceived stage and NULL otherwise. Returns whether any
356 // deltas were generated. 356 // deltas were generated.
357 bool ProcessDeclarativeRules( 357 bool ProcessDeclarativeRules(
358 void* profile, 358 void* profile,
359 ExtensionInfoMap* extension_info_map, 359 extensions::InfoMap* extension_info_map,
360 const std::string& event_name, 360 const std::string& event_name,
361 net::URLRequest* request, 361 net::URLRequest* request,
362 extensions::RequestStage request_stage, 362 extensions::RequestStage request_stage,
363 const net::HttpResponseHeaders* original_response_headers); 363 const net::HttpResponseHeaders* original_response_headers);
364 364
365 // If the BlockedRequest contains messages_to_extension entries in the event 365 // If the BlockedRequest contains messages_to_extension entries in the event
366 // deltas, we send them to subscribers of 366 // deltas, we send them to subscribers of
367 // chrome.declarativeWebRequest.onMessage. 367 // chrome.declarativeWebRequest.onMessage.
368 void SendMessages(void* profile, const BlockedRequest& blocked_request); 368 void SendMessages(void* profile, const BlockedRequest& blocked_request);
369 369
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 : public SyncIOThreadExtensionFunction { 457 : public SyncIOThreadExtensionFunction {
458 public: 458 public:
459 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged", 459 DECLARE_EXTENSION_FUNCTION("webRequest.handlerBehaviorChanged",
460 WEBREQUEST_HANDLERBEHAVIORCHANGED) 460 WEBREQUEST_HANDLERBEHAVIORCHANGED)
461 461
462 protected: 462 protected:
463 virtual ~WebRequestHandlerBehaviorChangedFunction() {} 463 virtual ~WebRequestHandlerBehaviorChangedFunction() {}
464 464
465 // ExtensionFunction: 465 // ExtensionFunction:
466 virtual void GetQuotaLimitHeuristics( 466 virtual void GetQuotaLimitHeuristics(
467 QuotaLimitHeuristics* heuristics) const OVERRIDE; 467 extensions::QuotaLimitHeuristics* heuristics) const OVERRIDE;
468 // Handle quota exceeded gracefully: Only warn the user but still execute the 468 // Handle quota exceeded gracefully: Only warn the user but still execute the
469 // function. 469 // function.
470 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE; 470 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE;
471 virtual bool RunImpl() OVERRIDE; 471 virtual bool RunImpl() OVERRIDE;
472 }; 472 };
473 473
474 // Send updates to |host| with information about what webRequest-related 474 // Send updates to |host| with information about what webRequest-related
475 // extensions are installed. 475 // extensions are installed.
476 // TODO(mpcomplete): remove. http://crbug.com/100411 476 // TODO(mpcomplete): remove. http://crbug.com/100411
477 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); 477 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host);
478 478
479 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 479 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/test/test_api.cc ('k') | chrome/browser/extensions/api/web_request/web_request_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698