Chromium Code Reviews| 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 #include "chrome/browser/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 24 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
| 25 #include "chrome/browser/download/download_service.h" | 25 #include "chrome/browser/download/download_service.h" |
| 26 #include "chrome/browser/download/download_service_factory.h" | 26 #include "chrome/browser/download/download_service_factory.h" |
| 27 #include "chrome/browser/extensions/extension_info_map.h" | 27 #include "chrome/browser/extensions/extension_info_map.h" |
| 28 #include "chrome/browser/extensions/extension_protocols.h" | 28 #include "chrome/browser/extensions/extension_protocols.h" |
| 29 #include "chrome/browser/extensions/extension_resource_protocols.h" | 29 #include "chrome/browser/extensions/extension_resource_protocols.h" |
| 30 #include "chrome/browser/extensions/extension_system.h" | 30 #include "chrome/browser/extensions/extension_system.h" |
| 31 #include "chrome/browser/io_thread.h" | 31 #include "chrome/browser/io_thread.h" |
| 32 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 32 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 33 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 33 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
| 34 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | |
| 34 #include "chrome/browser/net/chrome_net_log.h" | 35 #include "chrome/browser/net/chrome_net_log.h" |
| 35 #include "chrome/browser/net/chrome_network_delegate.h" | 36 #include "chrome/browser/net/chrome_network_delegate.h" |
| 36 #include "chrome/browser/net/http_server_properties_manager.h" | 37 #include "chrome/browser/net/http_server_properties_manager.h" |
| 37 #include "chrome/browser/net/load_time_stats.h" | 38 #include "chrome/browser/net/load_time_stats.h" |
| 38 #include "chrome/browser/net/proxy_service_factory.h" | 39 #include "chrome/browser/net/proxy_service_factory.h" |
| 39 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 40 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 40 #include "chrome/browser/net/transport_security_persister.h" | 41 #include "chrome/browser/net/transport_security_persister.h" |
| 41 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 42 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 42 #include "chrome/browser/policy/url_blacklist_manager.h" | 43 #include "chrome/browser/policy/url_blacklist_manager.h" |
| 43 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 44 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 138 |
| 138 } // namespace | 139 } // namespace |
| 139 | 140 |
| 140 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 141 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 142 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 142 PrefService* pref_service = profile->GetPrefs(); | 143 PrefService* pref_service = profile->GetPrefs(); |
| 143 | 144 |
| 144 scoped_ptr<ProfileParams> params(new ProfileParams); | 145 scoped_ptr<ProfileParams> params(new ProfileParams); |
| 145 params->path = profile->GetPath(); | 146 params->path = profile->GetPath(); |
| 146 | 147 |
| 147 // Set up Accept-Language and Accept-Charset header values | 148 params->chrome_http_user_agent_settings.reset( |
| 148 params->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( | 149 new ChromeHttpUserAgentSettings(pref_service)); |
| 149 pref_service->GetString(prefs::kAcceptLanguages)); | |
| 150 std::string default_charset = pref_service->GetString(prefs::kDefaultCharset); | |
| 151 params->accept_charset = | |
| 152 net::HttpUtil::GenerateAcceptCharsetHeader(default_charset); | |
| 153 | 150 |
| 154 params->io_thread = g_browser_process->io_thread(); | 151 params->io_thread = g_browser_process->io_thread(); |
| 155 | 152 |
| 156 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); | 153 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); |
| 157 params->ssl_config_service = profile->GetSSLConfigService(); | 154 params->ssl_config_service = profile->GetSSLConfigService(); |
| 158 base::Callback<Profile*(void)> profile_getter = | 155 base::Callback<Profile*(void)> profile_getter = |
| 159 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), | 156 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), |
| 160 profile); | 157 profile); |
| 161 params->cookie_monster_delegate = | 158 params->cookie_monster_delegate = |
| 162 new ChromeCookieMonsterDelegate(profile_getter); | 159 new ChromeCookieMonsterDelegate(profile_getter); |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 extension_info_map_ = profile_params_->extension_info_map; | 559 extension_info_map_ = profile_params_->extension_info_map; |
| 563 | 560 |
| 564 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | 561 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
| 565 resource_context_->request_context_ = main_request_context_.get(); | 562 resource_context_->request_context_ = main_request_context_.get(); |
| 566 | 563 |
| 567 if (profile_params_->resource_prefetch_predictor_observer_.get()) { | 564 if (profile_params_->resource_prefetch_predictor_observer_.get()) { |
| 568 resource_prefetch_predictor_observer_.reset( | 565 resource_prefetch_predictor_observer_.reset( |
| 569 profile_params_->resource_prefetch_predictor_observer_.release()); | 566 profile_params_->resource_prefetch_predictor_observer_.release()); |
| 570 } | 567 } |
| 571 | 568 |
| 569 chrome_http_user_agent_settings_.reset( | |
| 570 profile_params_->chrome_http_user_agent_settings.release()); | |
| 571 | |
| 572 LazyInitializeInternal(profile_params_.get()); | 572 LazyInitializeInternal(profile_params_.get()); |
| 573 | 573 |
| 574 profile_params_.reset(); | 574 profile_params_.reset(); |
| 575 initialized_ = true; | 575 initialized_ = true; |
| 576 } | 576 } |
| 577 | 577 |
| 578 void ProfileIOData::ApplyProfileParamsToContext( | 578 void ProfileIOData::ApplyProfileParamsToContext( |
| 579 ChromeURLRequestContext* context) const { | 579 ChromeURLRequestContext* context) const { |
| 580 context->set_is_incognito(is_incognito()); | 580 context->set_is_incognito(is_incognito()); |
| 581 context->set_accept_language(profile_params_->accept_language); | 581 context->set_http_user_agent_settings( |
| 582 context->set_accept_charset(profile_params_->accept_charset); | 582 chrome_http_user_agent_settings_.get()); |
|
mmenke
2012/10/25 18:06:33
nit: 4 space indent. Actually, can this all fit
| |
| 583 context->set_ssl_config_service(profile_params_->ssl_config_service); | 583 context->set_ssl_config_service(profile_params_->ssl_config_service); |
| 584 } | 584 } |
| 585 | 585 |
| 586 void ProfileIOData::SetUpJobFactoryDefaults( | 586 void ProfileIOData::SetUpJobFactoryDefaults( |
| 587 net::URLRequestJobFactory* job_factory, | 587 net::URLRequestJobFactory* job_factory, |
| 588 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 588 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 589 protocol_handler_interceptor, | 589 protocol_handler_interceptor, |
| 590 net::NetworkDelegate* network_delegate, | 590 net::NetworkDelegate* network_delegate, |
| 591 net::FtpTransactionFactory* ftp_transaction_factory, | 591 net::FtpTransactionFactory* ftp_transaction_factory, |
| 592 net::FtpAuthCache* ftp_auth_cache) const { | 592 net::FtpAuthCache* ftp_auth_cache) const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 656 #if !defined(OS_CHROMEOS) | 656 #if !defined(OS_CHROMEOS) |
| 657 enable_metrics_.Destroy(); | 657 enable_metrics_.Destroy(); |
| 658 #endif | 658 #endif |
| 659 safe_browsing_enabled_.Destroy(); | 659 safe_browsing_enabled_.Destroy(); |
| 660 printing_enabled_.Destroy(); | 660 printing_enabled_.Destroy(); |
| 661 session_startup_pref_.Destroy(); | 661 session_startup_pref_.Destroy(); |
| 662 #if defined(ENABLE_CONFIGURATION_POLICY) | 662 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 663 if (url_blacklist_manager_.get()) | 663 if (url_blacklist_manager_.get()) |
| 664 url_blacklist_manager_->ShutdownOnUIThread(); | 664 url_blacklist_manager_->ShutdownOnUIThread(); |
| 665 #endif | 665 #endif |
| 666 if (chrome_http_user_agent_settings_.get()) | |
| 667 chrome_http_user_agent_settings_->CleanupOnUIThread(); | |
|
mmenke
2012/10/25 18:06:33
Doesn't this always need to be called? Otherwise,
pauljensen
2012/10/25 21:30:25
I don't think we can construct ChromeHttpUserAgent
mmenke
2012/10/26 18:42:09
Sounds like the best approach to me, too.
| |
| 666 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 668 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 667 if (!posted) | 669 if (!posted) |
| 668 delete this; | 670 delete this; |
| 669 } | 671 } |
| 670 | 672 |
| 671 void ProfileIOData::set_server_bound_cert_service( | 673 void ProfileIOData::set_server_bound_cert_service( |
| 672 net::ServerBoundCertService* server_bound_cert_service) const { | 674 net::ServerBoundCertService* server_bound_cert_service) const { |
| 673 server_bound_cert_service_.reset(server_bound_cert_service); | 675 server_bound_cert_service_.reset(server_bound_cert_service); |
| 674 } | 676 } |
| 675 | 677 |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 702 params->http_pipelining_enabled = globals->http_pipelining_enabled; | 704 params->http_pipelining_enabled = globals->http_pipelining_enabled; |
| 703 params->testing_fixed_http_port = globals->testing_fixed_http_port; | 705 params->testing_fixed_http_port = globals->testing_fixed_http_port; |
| 704 params->testing_fixed_https_port = globals->testing_fixed_https_port; | 706 params->testing_fixed_https_port = globals->testing_fixed_https_port; |
| 705 | 707 |
| 706 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 708 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 707 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) { | 709 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) { |
| 708 params->trusted_spdy_proxy = command_line.GetSwitchValueASCII( | 710 params->trusted_spdy_proxy = command_line.GetSwitchValueASCII( |
| 709 switches::kTrustedSpdyProxy); | 711 switches::kTrustedSpdyProxy); |
| 710 } | 712 } |
| 711 } | 713 } |
| OLD | NEW |