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

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

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed nits 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
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/rules_registry_service.h"
17 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h" 18 #include "chrome/browser/extensions/api/declarative_webrequest/request_stage.h"
18 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h" 19 #include "chrome/browser/extensions/api/web_request/web_request_api_helpers.h"
19 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h" 20 #include "chrome/browser/extensions/api/web_request/web_request_permissions.h"
20 #include "chrome/browser/extensions/extension_function.h" 21 #include "chrome/browser/extensions/extension_function.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/chrome_version_info.h" 23 #include "chrome/common/chrome_version_info.h"
23 #include "extensions/common/url_pattern_set.h" 24 #include "extensions/common/url_pattern_set.h"
24 #include "ipc/ipc_sender.h" 25 #include "ipc/ipc_sender.h"
25 #include "net/base/completion_callback.h" 26 #include "net/base/completion_callback.h"
26 #include "net/base/network_delegate.h" 27 #include "net/base/network_delegate.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 133
133 DISALLOW_COPY_AND_ASSIGN(EventResponse); 134 DISALLOW_COPY_AND_ASSIGN(EventResponse);
134 }; 135 };
135 136
136 static ExtensionWebRequestEventRouter* GetInstance(); 137 static ExtensionWebRequestEventRouter* GetInstance();
137 138
138 // Registers a rule registry. Pass null for |rules_registry| to unregister 139 // Registers a rule registry. Pass null for |rules_registry| to unregister
139 // the rule registry for |profile|. 140 // the rule registry for |profile|.
140 void RegisterRulesRegistry( 141 void RegisterRulesRegistry(
141 void* profile, 142 void* profile,
143 const extensions::RulesRegistryService::WebViewKey& webview_key,
142 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); 144 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry);
143 145
144 // Dispatches the OnBeforeRequest event to any extensions whose filters match 146 // Dispatches the OnBeforeRequest event to any extensions whose filters match
145 // the given request. Returns net::ERR_IO_PENDING if an extension is 147 // the given request. Returns net::ERR_IO_PENDING if an extension is
146 // intercepting the request, OK otherwise. 148 // intercepting the request, OK otherwise.
147 int OnBeforeRequest(void* profile, 149 int OnBeforeRequest(void* profile,
148 extensions::InfoMap* extension_info_map, 150 extensions::InfoMap* extension_info_map,
149 net::URLRequest* request, 151 net::URLRequest* request,
150 const net::CompletionCallback& callback, 152 const net::CompletionCallback& callback,
151 GURL* new_url); 153 GURL* new_url);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // A map of original profile -> corresponding incognito profile (and vice 417 // A map of original profile -> corresponding incognito profile (and vice
416 // versa). 418 // versa).
417 CrossProfileMap cross_profile_map_; 419 CrossProfileMap cross_profile_map_;
418 420
419 // Keeps track of time spent waiting on extensions using the blocking 421 // Keeps track of time spent waiting on extensions using the blocking
420 // webRequest API. 422 // webRequest API.
421 scoped_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_; 423 scoped_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_;
422 424
423 CallbacksForPageLoad callbacks_for_page_load_; 425 CallbacksForPageLoad callbacks_for_page_load_;
424 426
425 // Maps each profile (and OTRProfile) to its respective rules registry. 427 typedef std::pair<void*, extensions::RulesRegistryService::WebViewKey>
426 std::map<void*, scoped_refptr<extensions::WebRequestRulesRegistry> > 428 RulesRegistryKey;
427 rules_registries_; 429 // Maps each profile (and OTRProfile) and a webview key to its respective
430 // rules registry.
431 std::map<RulesRegistryKey,
432 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_;
428 433
429 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); 434 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter);
430 }; 435 };
431 436
432 class WebRequestAddEventListener : public SyncIOThreadExtensionFunction { 437 class WebRequestAddEventListener : public SyncIOThreadExtensionFunction {
433 public: 438 public:
434 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener", 439 DECLARE_EXTENSION_FUNCTION("webRequestInternal.addEventListener",
435 WEBREQUESTINTERNAL_ADDEVENTLISTENER) 440 WEBREQUESTINTERNAL_ADDEVENTLISTENER)
436 441
437 protected: 442 protected:
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE; 475 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE;
471 virtual bool RunImpl() OVERRIDE; 476 virtual bool RunImpl() OVERRIDE;
472 }; 477 };
473 478
474 // Send updates to |host| with information about what webRequest-related 479 // Send updates to |host| with information about what webRequest-related
475 // extensions are installed. 480 // extensions are installed.
476 // TODO(mpcomplete): remove. http://crbug.com/100411 481 // TODO(mpcomplete): remove. http://crbug.com/100411
477 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host); 482 void SendExtensionWebRequestStatusToHost(content::RenderProcessHost* host);
478 483
479 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ 484 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698