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 #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" | |
18 #include "content/public/common/resource_type.h" | 17 #include "content/public/common/resource_type.h" |
| 18 #include "extensions/browser/api/declarative/rules_registry.h" |
19 #include "extensions/browser/api/declarative_webrequest/request_stage.h" | 19 #include "extensions/browser/api/declarative_webrequest/request_stage.h" |
20 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 20 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
21 #include "extensions/browser/api/web_request/web_request_permissions.h" | 21 #include "extensions/browser/api/web_request/web_request_permissions.h" |
22 #include "extensions/browser/browser_context_keyed_api_factory.h" | 22 #include "extensions/browser/browser_context_keyed_api_factory.h" |
23 #include "extensions/browser/event_router.h" | 23 #include "extensions/browser/event_router.h" |
24 #include "extensions/browser/extension_function.h" | 24 #include "extensions/browser/extension_function.h" |
25 #include "extensions/common/url_pattern_set.h" | 25 #include "extensions/common/url_pattern_set.h" |
26 #include "ipc/ipc_sender.h" | 26 #include "ipc/ipc_sender.h" |
27 #include "net/base/completion_callback.h" | 27 #include "net/base/completion_callback.h" |
28 #include "net/base/network_delegate.h" | 28 #include "net/base/network_delegate.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 DISALLOW_COPY_AND_ASSIGN(EventResponse); | 165 DISALLOW_COPY_AND_ASSIGN(EventResponse); |
166 }; | 166 }; |
167 | 167 |
168 static ExtensionWebRequestEventRouter* GetInstance(); | 168 static ExtensionWebRequestEventRouter* GetInstance(); |
169 | 169 |
170 // Registers a rule registry. Pass null for |rules_registry| to unregister | 170 // Registers a rule registry. Pass null for |rules_registry| to unregister |
171 // the rule registry for |profile|. | 171 // the rule registry for |profile|. |
172 void RegisterRulesRegistry( | 172 void RegisterRulesRegistry( |
173 void* profile, | 173 void* profile, |
174 const extensions::RulesRegistryService::WebViewKey& webview_key, | 174 const extensions::RulesRegistry::WebViewKey& webview_key, |
175 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); | 175 scoped_refptr<extensions::WebRequestRulesRegistry> rules_registry); |
176 | 176 |
177 // Dispatches the OnBeforeRequest event to any extensions whose filters match | 177 // Dispatches the OnBeforeRequest event to any extensions whose filters match |
178 // the given request. Returns net::ERR_IO_PENDING if an extension is | 178 // the given request. Returns net::ERR_IO_PENDING if an extension is |
179 // intercepting the request, OK otherwise. | 179 // intercepting the request, OK otherwise. |
180 int OnBeforeRequest(void* profile, | 180 int OnBeforeRequest(void* profile, |
181 extensions::InfoMap* 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 GURL* new_url); | 184 GURL* new_url); |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 // A map of original profile -> corresponding incognito profile (and vice | 449 // A map of original profile -> corresponding incognito profile (and vice |
450 // versa). | 450 // versa). |
451 CrossProfileMap cross_profile_map_; | 451 CrossProfileMap cross_profile_map_; |
452 | 452 |
453 // Keeps track of time spent waiting on extensions using the blocking | 453 // Keeps track of time spent waiting on extensions using the blocking |
454 // webRequest API. | 454 // webRequest API. |
455 scoped_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_; | 455 scoped_ptr<ExtensionWebRequestTimeTracker> request_time_tracker_; |
456 | 456 |
457 CallbacksForPageLoad callbacks_for_page_load_; | 457 CallbacksForPageLoad callbacks_for_page_load_; |
458 | 458 |
459 typedef std::pair<void*, extensions::RulesRegistryService::WebViewKey> | 459 typedef std::pair<void*, extensions::RulesRegistry::WebViewKey> |
460 RulesRegistryKey; | 460 RulesRegistryKey; |
461 // Maps each profile (and OTRProfile) and a webview key to its respective | 461 // Maps each profile (and OTRProfile) and a webview key to its respective |
462 // rules registry. | 462 // rules registry. |
463 std::map<RulesRegistryKey, | 463 std::map<RulesRegistryKey, |
464 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; | 464 scoped_refptr<extensions::WebRequestRulesRegistry> > rules_registries_; |
465 | 465 |
466 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); | 466 DISALLOW_COPY_AND_ASSIGN(ExtensionWebRequestEventRouter); |
467 }; | 467 }; |
468 | 468 |
469 class WebRequestInternalAddEventListenerFunction | 469 class WebRequestInternalAddEventListenerFunction |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // ExtensionFunction: | 515 // ExtensionFunction: |
516 virtual void GetQuotaLimitHeuristics( | 516 virtual void GetQuotaLimitHeuristics( |
517 extensions::QuotaLimitHeuristics* heuristics) const OVERRIDE; | 517 extensions::QuotaLimitHeuristics* heuristics) const OVERRIDE; |
518 // Handle quota exceeded gracefully: Only warn the user but still execute the | 518 // Handle quota exceeded gracefully: Only warn the user but still execute the |
519 // function. | 519 // function. |
520 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE; | 520 virtual void OnQuotaExceeded(const std::string& error) OVERRIDE; |
521 virtual bool RunSync() OVERRIDE; | 521 virtual bool RunSync() OVERRIDE; |
522 }; | 522 }; |
523 | 523 |
524 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ | 524 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_REQUEST_WEB_REQUEST_API_H_ |
OLD | NEW |