summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/io_thread.cc15
-rw-r--r--chrome/browser/net/chrome_network_delegate.cc16
-rw-r--r--chrome/browser/net/chrome_network_delegate.h8
3 files changed, 32 insertions, 7 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc
index 4bdc0aa..e252afa 100644
--- a/chrome/browser/io_thread.cc
+++ b/chrome/browser/io_thread.cc
@@ -395,13 +395,18 @@ void IOThread::Init() {
globals_->extension_event_router_forwarder =
extension_event_router_forwarder_;
- globals_->system_network_delegate.reset(new ChromeNetworkDelegate(
+ ChromeNetworkDelegate* network_delegate = new ChromeNetworkDelegate(
extension_event_router_forwarder_,
NULL,
NULL,
NULL,
NULL,
- &system_enable_referrers_));
+ &system_enable_referrers_);
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableExtensionsHttpThrottling)) {
+ network_delegate->NeverThrottleRequests();
+ }
+ globals_->system_network_delegate.reset(network_delegate);
globals_->host_resolver.reset(
CreateGlobalHostResolver(net_log_));
globals_->cert_verifier.reset(net::CertVerifier::CreateDefault());
@@ -447,13 +452,9 @@ void IOThread::Init() {
new net::FtpNetworkLayer(globals_->host_resolver.get()));
globals_->throttler_manager.reset(new net::URLRequestThrottlerManager());
+ globals_->throttler_manager->set_net_log(net_log_);
// 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(
ConstructProxyScriptFetcherContext(globals_, net_log_));
diff --git a/chrome/browser/net/chrome_network_delegate.cc b/chrome/browser/net/chrome_network_delegate.cc
index 9abf6c4..6ea4eb8 100644
--- a/chrome/browser/net/chrome_network_delegate.cc
+++ b/chrome/browser/net/chrome_network_delegate.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/task_manager/task_manager.h"
#include "chrome/common/pref_names.h"
+#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_request_info.h"
@@ -129,6 +130,7 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
cookie_settings_(cookie_settings),
extension_info_map_(extension_info_map),
enable_referrers_(enable_referrers),
+ never_throttle_requests_(false),
url_blacklist_manager_(url_blacklist_manager) {
DCHECK(event_router);
DCHECK(enable_referrers);
@@ -137,6 +139,10 @@ ChromeNetworkDelegate::ChromeNetworkDelegate(
ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
+void ChromeNetworkDelegate::NeverThrottleRequests() {
+ never_throttle_requests_ = true;
+}
+
// static
void ChromeNetworkDelegate::InitializeReferrersEnabled(
BooleanPrefMember* enable_referrers,
@@ -354,3 +360,13 @@ bool ChromeNetworkDelegate::OnCanAccessFile(const net::URLRequest& request,
return true;
#endif // defined(OS_CHROMEOS)
}
+
+bool ChromeNetworkDelegate::OnCanThrottleRequest(
+ const net::URLRequest& request) const {
+ if (never_throttle_requests_) {
+ return false;
+ }
+
+ return request.first_party_for_cookies().scheme() !=
+ chrome::kExtensionScheme;
+}
diff --git a/chrome/browser/net/chrome_network_delegate.h b/chrome/browser/net/chrome_network_delegate.h
index dda92d5..2ff6843 100644
--- a/chrome/browser/net/chrome_network_delegate.h
+++ b/chrome/browser/net/chrome_network_delegate.h
@@ -42,6 +42,9 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
BooleanPrefMember* enable_referrers);
virtual ~ChromeNetworkDelegate();
+ // Causes |OnCanThrottleRequest| to never return true.
+ void NeverThrottleRequests();
+
// Binds |enable_referrers| to |pref_service| and moves it to the IO thread.
// This method should be called on the UI thread.
static void InitializeReferrersEnabled(BooleanPrefMember* enable_referrers,
@@ -88,6 +91,8 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
net::CookieOptions* options) OVERRIDE;
virtual bool OnCanAccessFile(const net::URLRequest& request,
const FilePath& path) const OVERRIDE;
+ virtual bool OnCanThrottleRequest(
+ const net::URLRequest& request) const OVERRIDE;
scoped_refptr<ExtensionEventRouterForwarder> event_router_;
void* profile_;
@@ -98,6 +103,9 @@ class ChromeNetworkDelegate : public net::NetworkDelegate {
// Weak, owned by our owner.
BooleanPrefMember* enable_referrers_;
+ // True if OnCanThrottleRequest should always return false.
+ bool never_throttle_requests_;
+
// Weak, owned by our owner.
const policy::URLBlacklistManager* url_blacklist_manager_;