Index: chrome/browser/io_thread.cc |
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc |
index 4bdc0aa784d88970b713ab4a64e544c4f695963d..3754e2b3d1bad60d6964ab4bee3e84f537e5fa08 100644 |
--- a/chrome/browser/io_thread.cc |
+++ b/chrome/browser/io_thread.cc |
@@ -32,6 +32,7 @@ |
#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/pref_names.h" |
+#include "chrome/common/url_constants.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/common/content_client.h" |
#include "content/public/common/url_fetcher.h" |
@@ -53,6 +54,7 @@ |
#include "net/proxy/proxy_config_service.h" |
#include "net/proxy/proxy_script_fetcher_impl.h" |
#include "net/proxy/proxy_service.h" |
+#include "net/url_request/url_request.h" |
#include "net/url_request/url_request_throttler_manager.h" |
#if defined(USE_NSS) |
@@ -72,6 +74,28 @@ class SafeBrowsingURLRequestContext; |
namespace { |
+// Makes it so that the URLRequestThrottlerManager may only reject |
+// requests that originate from extensions. |
+class ChromeURLRequestThrottlerManagerDelegate |
+ : public net::URLRequestThrottlerManagerDelegate { |
+ public: |
+ explicit ChromeURLRequestThrottlerManagerDelegate(bool enforce) |
+ : enforce_(enforce) { |
+ } |
+ |
+ virtual bool MayRejectRequest(net::URLRequest* request) OVERRIDE { |
+ if (enforce_) { |
+ return request->first_party_for_cookies().scheme() != |
+ chrome::kExtensionScheme; |
+ } else { |
+ return false; |
+ } |
+ } |
+ |
+ private: |
+ bool enforce_; |
+}; |
+ |
// Custom URLRequestContext used by requests which aren't associated with a |
// particular profile. We need to use a subclass of URLRequestContext in order |
// to provide the correct User-Agent. |
@@ -446,13 +470,15 @@ void IOThread::Init() { |
globals_->proxy_script_fetcher_ftp_transaction_factory.reset( |
new net::FtpNetworkLayer(globals_->host_resolver.get())); |
- globals_->throttler_manager.reset(new net::URLRequestThrottlerManager()); |
+ bool enforce_throttling = CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kDisableExtensionsHttpThrottling); |
+ globals_->throttler_manager_delegate.reset( |
+ new ChromeURLRequestThrottlerManagerDelegate(enforce_throttling)); |
+ |
+ globals_->throttler_manager.reset(new net::URLRequestThrottlerManager( |
+ globals_->throttler_manager_delegate.get())); |
// Always done in production, disabled only for unit tests. |
globals_->throttler_manager->set_enable_thread_checks(true); |
- if (CommandLine::ForCurrentProcess()->HasSwitch( |
- switches::kDisableExtensionsHttpThrottling)) { |
- globals_->throttler_manager->set_enforce_throttling(false); |
- } |
globals_->throttler_manager->set_net_log(net_log_); |
globals_->proxy_script_fetcher_context.reset( |