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

Side by Side Diff: chrome/browser/net/chrome_network_delegate.cc

Issue 10854069: Fix a bad inversion of logic (see OnCanThrottleRequest) and a bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months 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 #include "chrome/browser/net/chrome_network_delegate.h" 5 #include "chrome/browser/net/chrome_network_delegate.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/content_settings/cookie_settings.h" 9 #include "chrome/browser/content_settings/cookie_settings.h"
10 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 10 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 using content::ResourceRequestInfo; 46 using content::ResourceRequestInfo;
47 47
48 // By default we don't allow access to all file:// urls on ChromeOS but we do on 48 // By default we don't allow access to all file:// urls on ChromeOS but we do on
49 // other platforms. 49 // other platforms.
50 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
51 bool ChromeNetworkDelegate::g_allow_file_access_ = false; 51 bool ChromeNetworkDelegate::g_allow_file_access_ = false;
52 #else 52 #else
53 bool ChromeNetworkDelegate::g_allow_file_access_ = true; 53 bool ChromeNetworkDelegate::g_allow_file_access_ = true;
54 #endif 54 #endif
55 55
56 // This remains false unless the --disable-extensions-http-throttling
57 // flag is passed to the browser.
58 bool ChromeNetworkDelegate::g_never_throttle_requests_ = false;
59
56 namespace { 60 namespace {
57 61
58 // If the |request| failed due to problems with a proxy, forward the error to 62 // If the |request| failed due to problems with a proxy, forward the error to
59 // the proxy extension API. 63 // the proxy extension API.
60 void ForwardProxyErrors(net::URLRequest* request, 64 void ForwardProxyErrors(net::URLRequest* request,
61 extensions::EventRouterForwarder* event_router, 65 extensions::EventRouterForwarder* event_router,
62 void* profile) { 66 void* profile) {
63 if (request->status().status() == net::URLRequestStatus::FAILED) { 67 if (request->status().status() == net::URLRequestStatus::FAILED) {
64 switch (request->status().error()) { 68 switch (request->status().error()) {
65 case net::ERR_PROXY_AUTH_UNSUPPORTED: 69 case net::ERR_PROXY_AUTH_UNSUPPORTED:
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 const policy::URLBlacklistManager* url_blacklist_manager, 131 const policy::URLBlacklistManager* url_blacklist_manager,
128 void* profile, 132 void* profile,
129 CookieSettings* cookie_settings, 133 CookieSettings* cookie_settings,
130 BooleanPrefMember* enable_referrers, 134 BooleanPrefMember* enable_referrers,
131 chrome_browser_net::CacheStats* cache_stats) 135 chrome_browser_net::CacheStats* cache_stats)
132 : event_router_(event_router), 136 : event_router_(event_router),
133 profile_(profile), 137 profile_(profile),
134 cookie_settings_(cookie_settings), 138 cookie_settings_(cookie_settings),
135 extension_info_map_(extension_info_map), 139 extension_info_map_(extension_info_map),
136 enable_referrers_(enable_referrers), 140 enable_referrers_(enable_referrers),
137 never_throttle_requests_(false),
138 url_blacklist_manager_(url_blacklist_manager), 141 url_blacklist_manager_(url_blacklist_manager),
139 cache_stats_(cache_stats) { 142 cache_stats_(cache_stats) {
140 DCHECK(event_router); 143 DCHECK(event_router);
141 DCHECK(enable_referrers); 144 DCHECK(enable_referrers);
142 DCHECK(!profile || cookie_settings); 145 DCHECK(!profile || cookie_settings);
143 } 146 }
144 147
145 ChromeNetworkDelegate::~ChromeNetworkDelegate() {} 148 ChromeNetworkDelegate::~ChromeNetworkDelegate() {}
146 149
147 void ChromeNetworkDelegate::NeverThrottleRequests() { 150 void ChromeNetworkDelegate::NeverThrottleRequests() {
148 never_throttle_requests_ = true; 151 g_never_throttle_requests_ = true;
149 } 152 }
150 153
151 // static 154 // static
152 void ChromeNetworkDelegate::InitializeReferrersEnabled( 155 void ChromeNetworkDelegate::InitializeReferrersEnabled(
153 BooleanPrefMember* enable_referrers, 156 BooleanPrefMember* enable_referrers,
154 PrefService* pref_service) { 157 PrefService* pref_service) {
155 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
156 enable_referrers->Init(prefs::kEnableReferrers, pref_service, NULL); 159 enable_referrers->Init(prefs::kEnableReferrers, pref_service, NULL);
157 enable_referrers->MoveToThread(BrowserThread::IO); 160 enable_referrers->MoveToThread(BrowserThread::IO);
158 } 161 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 } 364 }
362 } 365 }
363 return false; 366 return false;
364 #else 367 #else
365 return true; 368 return true;
366 #endif // defined(OS_CHROMEOS) 369 #endif // defined(OS_CHROMEOS)
367 } 370 }
368 371
369 bool ChromeNetworkDelegate::OnCanThrottleRequest( 372 bool ChromeNetworkDelegate::OnCanThrottleRequest(
370 const net::URLRequest& request) const { 373 const net::URLRequest& request) const {
371 if (never_throttle_requests_) { 374 if (g_never_throttle_requests_) {
372 return false; 375 return false;
373 } 376 }
374 377
375 return request.first_party_for_cookies().scheme() != 378 return request.first_party_for_cookies().scheme() ==
376 chrome::kExtensionScheme; 379 chrome::kExtensionScheme;
377 } 380 }
378 381
379 int ChromeNetworkDelegate::OnBeforeSocketStreamConnect( 382 int ChromeNetworkDelegate::OnBeforeSocketStreamConnect(
380 net::SocketStream* socket, 383 net::SocketStream* socket,
381 const net::CompletionCallback& callback) { 384 const net::CompletionCallback& callback) {
382 #if defined(ENABLE_CONFIGURATION_POLICY) 385 #if defined(ENABLE_CONFIGURATION_POLICY)
383 if (url_blacklist_manager_ && 386 if (url_blacklist_manager_ &&
384 url_blacklist_manager_->IsURLBlocked(socket->url())) { 387 url_blacklist_manager_->IsURLBlocked(socket->url())) {
385 // URL access blocked by policy. 388 // URL access blocked by policy.
386 socket->net_log()->AddEvent( 389 socket->net_log()->AddEvent(
387 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST, 390 net::NetLog::TYPE_CHROME_POLICY_ABORTED_REQUEST,
388 net::NetLog::StringCallback("url", 391 net::NetLog::StringCallback("url",
389 &socket->url().possibly_invalid_spec())); 392 &socket->url().possibly_invalid_spec()));
390 return net::ERR_NETWORK_ACCESS_DENIED; 393 return net::ERR_NETWORK_ACCESS_DENIED;
391 } 394 }
392 #endif 395 #endif
393 return net::OK; 396 return net::OK;
394 } 397 }
395 398
396 void ChromeNetworkDelegate::OnCacheWaitStateChange( 399 void ChromeNetworkDelegate::OnCacheWaitStateChange(
397 const net::URLRequest& request, 400 const net::URLRequest& request,
398 CacheWaitState state) { 401 CacheWaitState state) {
399 if (cache_stats_) 402 if (cache_stats_)
400 cache_stats_->OnCacheWaitStateChange(request, state); 403 cache_stats_->OnCacheWaitStateChange(request, state);
401 } 404 }
OLDNEW
« chrome/browser/net/chrome_network_delegate.h ('K') | « chrome/browser/net/chrome_network_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698