| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/leak_tracker.h" | 8 #include "base/leak_tracker.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/chrome_thread.h" | 13 #include "chrome/browser/chrome_thread.h" |
| 14 #include "chrome/browser/gpu_process_host.h" | 14 #include "chrome/browser/gpu_process_host.h" |
| 15 #include "chrome/browser/net/chrome_net_log.h" | 15 #include "chrome/browser/net/chrome_net_log.h" |
| 16 #include "chrome/browser/net/predictor_api.h" | 16 #include "chrome/browser/net/predictor_api.h" |
| 17 #include "chrome/browser/net/passive_log_collector.h" | 17 #include "chrome/browser/net/passive_log_collector.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/net/url_fetcher.h" | 19 #include "chrome/common/net/url_fetcher.h" |
| 20 #include "net/base/mapped_host_resolver.h" | 20 #include "net/base/mapped_host_resolver.h" |
| 21 #include "net/base/host_cache.h" | 21 #include "net/base/host_cache.h" |
| 22 #include "net/base/host_resolver.h" | 22 #include "net/base/host_resolver.h" |
| 23 #include "net/base/host_resolver_impl.h" | 23 #include "net/base/host_resolver_impl.h" |
| 24 #include "net/base/net_util.h" | 24 #include "net/base/net_util.h" |
| 25 #include "net/http/http_auth_filter.h" | 25 #include "net/http/http_auth_filter.h" |
| 26 #include "net/http/http_auth_handler_factory.h" | 26 #include "net/http/http_auth_handler_factory.h" |
| 27 #include "net/http/http_auth_handler_negotiate.h" | |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 net::HostResolver* CreateGlobalHostResolver() { | 30 net::HostResolver* CreateGlobalHostResolver() { |
| 32 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 31 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 33 | 32 |
| 34 size_t parallelism = net::HostResolver::kDefaultParallelism; | 33 size_t parallelism = net::HostResolver::kDefaultParallelism; |
| 35 | 34 |
| 36 // Use the concurrency override from the command-line, if any. | 35 // Use the concurrency override from the command-line, if any. |
| 37 if (command_line.HasSwitch(switches::kHostResolverParallelism)) { | 36 if (command_line.HasSwitch(switches::kHostResolverParallelism)) { |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 // TODO(eroman): get rid of this special case for 39723. If we could instead | 237 // TODO(eroman): get rid of this special case for 39723. If we could instead |
| 239 // have a method that runs after the message loop destruction obsevers have | 238 // have a method that runs after the message loop destruction obsevers have |
| 240 // run, but before the message loop itself is destroyed, we could safely | 239 // run, but before the message loop itself is destroyed, we could safely |
| 241 // combine the two cleanups. | 240 // combine the two cleanups. |
| 242 deferred_net_log_to_delete_.reset(); | 241 deferred_net_log_to_delete_.reset(); |
| 243 BrowserProcessSubThread::CleanUpAfterMessageLoopDestruction(); | 242 BrowserProcessSubThread::CleanUpAfterMessageLoopDestruction(); |
| 244 } | 243 } |
| 245 | 244 |
| 246 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 245 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( |
| 247 net::HostResolver* resolver) { | 246 net::HostResolver* resolver) { |
| 248 net::HttpAuthFilterWhitelist* auth_filter = NULL; | 247 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 249 | 248 |
| 250 // Get the whitelist information from the command line, create an | 249 // Get the whitelist information from the command line, create an |
| 251 // HttpAuthFilterWhitelist, and attach it to the HttpAuthHandlerFactory. | 250 // HttpAuthFilterWhitelist, and attach it to the HttpAuthHandlerFactory. |
| 252 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 251 net::HttpAuthFilterWhitelist* auth_filter = NULL; |
| 253 | |
| 254 if (command_line.HasSwitch(switches::kAuthServerWhitelist)) { | 252 if (command_line.HasSwitch(switches::kAuthServerWhitelist)) { |
| 255 std::string auth_server_whitelist = | 253 std::string auth_server_whitelist = |
| 256 command_line.GetSwitchValueASCII(switches::kAuthServerWhitelist); | 254 command_line.GetSwitchValueASCII(switches::kAuthServerWhitelist); |
| 257 | |
| 258 // Create a whitelist filter. | 255 // Create a whitelist filter. |
| 259 auth_filter = new net::HttpAuthFilterWhitelist(); | 256 auth_filter = new net::HttpAuthFilterWhitelist(); |
| 260 auth_filter->SetWhitelist(auth_server_whitelist); | 257 auth_filter->SetWhitelist(auth_server_whitelist); |
| 261 } | 258 } |
| 262 | |
| 263 // Set the flag that enables or disables the Negotiate auth handler. | |
| 264 static const bool kNegotiateAuthEnabledDefault = true; | |
| 265 | |
| 266 bool negotiate_auth_enabled = kNegotiateAuthEnabledDefault; | |
| 267 if (command_line.HasSwitch(switches::kExperimentalEnableNegotiateAuth)) { | |
| 268 std::string enable_negotiate_auth = command_line.GetSwitchValueASCII( | |
| 269 switches::kExperimentalEnableNegotiateAuth); | |
| 270 // Enabled if no value, or value is 'true'. Disabled otherwise. | |
| 271 negotiate_auth_enabled = | |
| 272 enable_negotiate_auth.empty() || | |
| 273 (StringToLowerASCII(enable_negotiate_auth) == "true"); | |
| 274 } | |
| 275 | |
| 276 net::HttpAuthHandlerRegistryFactory* registry_factory = | |
| 277 net::HttpAuthHandlerFactory::CreateDefault(); | |
| 278 | |
| 279 globals_->url_security_manager.reset( | 259 globals_->url_security_manager.reset( |
| 280 net::URLSecurityManager::Create(auth_filter)); | 260 net::URLSecurityManager::Create(auth_filter)); |
| 281 | 261 |
| 282 // Add the security manager to the auth factories that need it. | 262 // Determine which schemes are supported. |
| 283 registry_factory->SetURLSecurityManager("ntlm", | 263 std::string csv_auth_schemes = "basic,digest,ntlm,negotiate"; |
| 284 globals_->url_security_manager.get()); | 264 if (command_line.HasSwitch(switches::kAuthSchemes)) |
| 285 registry_factory->SetURLSecurityManager("negotiate", | 265 csv_auth_schemes = StringToLowerASCII( |
| 286 globals_->url_security_manager.get()); | 266 command_line.GetSwitchValueASCII(switches::kAuthSchemes)); |
| 287 if (negotiate_auth_enabled) { | 267 std::vector<std::string> supported_schemes; |
| 288 // Configure the Negotiate settings for the Kerberos SPN. | 268 SplitString(csv_auth_schemes, ',', &supported_schemes); |
| 289 // TODO(cbentzel): Read the related IE registry settings on Windows builds. | 269 |
| 290 // TODO(cbentzel): Ugly use of static_cast here. | 270 return net::HttpAuthHandlerRegistryFactory::Create( |
| 291 net::HttpAuthHandlerNegotiate::Factory* negotiate_factory = | 271 supported_schemes, |
| 292 static_cast<net::HttpAuthHandlerNegotiate::Factory*>( | 272 globals_->url_security_manager.get(), |
| 293 registry_factory->GetSchemeFactory("negotiate")); | 273 resolver, |
| 294 DCHECK(negotiate_factory); | 274 command_line.HasSwitch(switches::kDisableAuthNegotiateCnameLookup), |
| 295 negotiate_factory->set_host_resolver(resolver); | 275 command_line.HasSwitch(switches::kEnableAuthNegotiatePort)); |
| 296 if (command_line.HasSwitch(switches::kDisableAuthNegotiateCnameLookup)) | |
| 297 negotiate_factory->set_disable_cname_lookup(true); | |
| 298 if (command_line.HasSwitch(switches::kEnableAuthNegotiatePort)) | |
| 299 negotiate_factory->set_use_port(true); | |
| 300 } else { | |
| 301 // Disable the Negotiate authentication handler. | |
| 302 registry_factory->RegisterSchemeFactory("negotiate", NULL); | |
| 303 } | |
| 304 return registry_factory; | |
| 305 } | 276 } |
| 306 | 277 |
| 307 void IOThread::InitNetworkPredictorOnIOThread( | 278 void IOThread::InitNetworkPredictorOnIOThread( |
| 308 bool prefetching_enabled, | 279 bool prefetching_enabled, |
| 309 base::TimeDelta max_dns_queue_delay, | 280 base::TimeDelta max_dns_queue_delay, |
| 310 size_t max_concurrent, | 281 size_t max_concurrent, |
| 311 const chrome_common_net::UrlList& startup_urls, | 282 const chrome_common_net::UrlList& startup_urls, |
| 312 ListValue* referral_list, | 283 ListValue* referral_list, |
| 313 bool preconnect_enabled) { | 284 bool preconnect_enabled) { |
| 314 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); | 285 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 344 net::HostCache* host_cache = | 315 net::HostCache* host_cache = |
| 345 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); | 316 globals_->host_resolver.get()->GetAsHostResolverImpl()->cache(); |
| 346 if (host_cache) | 317 if (host_cache) |
| 347 host_cache->clear(); | 318 host_cache->clear(); |
| 348 } | 319 } |
| 349 // Clear all of the passively logged data. | 320 // Clear all of the passively logged data. |
| 350 // TODO(eroman): this is a bit heavy handed, really all we need to do is | 321 // TODO(eroman): this is a bit heavy handed, really all we need to do is |
| 351 // clear the data pertaining to off the record context. | 322 // clear the data pertaining to off the record context. |
| 352 globals_->net_log->passive_collector()->Clear(); | 323 globals_->net_log->passive_collector()->Clear(); |
| 353 } | 324 } |
| OLD | NEW |