| 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->accept_language = net::HttpUtil::GenerateAcceptLanguageHeader( | |
| 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 | |
| 154 params->io_thread = g_browser_process->io_thread(); | 148 params->io_thread = g_browser_process->io_thread(); |
| 155 | 149 |
| 156 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); | 150 params->cookie_settings = CookieSettings::Factory::GetForProfile(profile); |
| 157 params->ssl_config_service = profile->GetSSLConfigService(); | 151 params->ssl_config_service = profile->GetSSLConfigService(); |
| 158 base::Callback<Profile*(void)> profile_getter = | 152 base::Callback<Profile*(void)> profile_getter = |
| 159 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), | 153 base::Bind(&GetProfileOnUI, g_browser_process->profile_manager(), |
| 160 profile); | 154 profile); |
| 161 params->cookie_monster_delegate = | 155 params->cookie_monster_delegate = |
| 162 new ChromeCookieMonsterDelegate(profile_getter); | 156 new ChromeCookieMonsterDelegate(profile_getter); |
| 163 params->extension_info_map = | 157 params->extension_info_map = |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 189 |
| 196 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 190 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 197 &enable_referrers_, | 191 &enable_referrers_, |
| 198 &enable_do_not_track_, | 192 &enable_do_not_track_, |
| 199 pref_service); | 193 pref_service); |
| 200 | 194 |
| 201 #if defined(ENABLE_PRINTING) | 195 #if defined(ENABLE_PRINTING) |
| 202 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service, NULL); | 196 printing_enabled_.Init(prefs::kPrintingEnabled, pref_service, NULL); |
| 203 printing_enabled_.MoveToThread(BrowserThread::IO); | 197 printing_enabled_.MoveToThread(BrowserThread::IO); |
| 204 #endif | 198 #endif |
| 199 chrome_http_user_agent_settings_.reset( |
| 200 new ChromeHttpUserAgentSettings(pref_service)); |
| 205 | 201 |
| 206 // The URLBlacklistManager has to be created on the UI thread to register | 202 // The URLBlacklistManager has to be created on the UI thread to register |
| 207 // observers of |pref_service|, and it also has to clean up on | 203 // observers of |pref_service|, and it also has to clean up on |
| 208 // ShutdownOnUIThread to release these observers on the right thread. | 204 // ShutdownOnUIThread to release these observers on the right thread. |
| 209 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, | 205 // Don't pass it in |profile_params_| to make sure it is correctly cleaned up, |
| 210 // in particular when this ProfileIOData isn't |initialized_| during deletion. | 206 // in particular when this ProfileIOData isn't |initialized_| during deletion. |
| 211 #if defined(ENABLE_CONFIGURATION_POLICY) | 207 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 212 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); | 208 url_blacklist_manager_.reset(new policy::URLBlacklistManager(pref_service)); |
| 213 #endif | 209 #endif |
| 214 | 210 |
| (...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 | 567 |
| 572 LazyInitializeInternal(profile_params_.get()); | 568 LazyInitializeInternal(profile_params_.get()); |
| 573 | 569 |
| 574 profile_params_.reset(); | 570 profile_params_.reset(); |
| 575 initialized_ = true; | 571 initialized_ = true; |
| 576 } | 572 } |
| 577 | 573 |
| 578 void ProfileIOData::ApplyProfileParamsToContext( | 574 void ProfileIOData::ApplyProfileParamsToContext( |
| 579 ChromeURLRequestContext* context) const { | 575 ChromeURLRequestContext* context) const { |
| 580 context->set_is_incognito(is_incognito()); | 576 context->set_is_incognito(is_incognito()); |
| 581 context->set_accept_language(profile_params_->accept_language); | 577 context->set_http_user_agent_settings( |
| 582 context->set_accept_charset(profile_params_->accept_charset); | 578 chrome_http_user_agent_settings_.get()); |
| 583 context->set_ssl_config_service(profile_params_->ssl_config_service); | 579 context->set_ssl_config_service(profile_params_->ssl_config_service); |
| 584 } | 580 } |
| 585 | 581 |
| 586 void ProfileIOData::SetUpJobFactoryDefaults( | 582 void ProfileIOData::SetUpJobFactoryDefaults( |
| 587 net::URLRequestJobFactory* job_factory, | 583 net::URLRequestJobFactory* job_factory, |
| 588 scoped_ptr<net::URLRequestJobFactory::Interceptor> | 584 scoped_ptr<net::URLRequestJobFactory::Interceptor> |
| 589 protocol_handler_interceptor, | 585 protocol_handler_interceptor, |
| 590 net::NetworkDelegate* network_delegate, | 586 net::NetworkDelegate* network_delegate, |
| 591 net::FtpTransactionFactory* ftp_transaction_factory, | 587 net::FtpTransactionFactory* ftp_transaction_factory, |
| 592 net::FtpAuthCache* ftp_auth_cache) const { | 588 net::FtpAuthCache* ftp_auth_cache) const { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 #if !defined(OS_CHROMEOS) | 652 #if !defined(OS_CHROMEOS) |
| 657 enable_metrics_.Destroy(); | 653 enable_metrics_.Destroy(); |
| 658 #endif | 654 #endif |
| 659 safe_browsing_enabled_.Destroy(); | 655 safe_browsing_enabled_.Destroy(); |
| 660 printing_enabled_.Destroy(); | 656 printing_enabled_.Destroy(); |
| 661 session_startup_pref_.Destroy(); | 657 session_startup_pref_.Destroy(); |
| 662 #if defined(ENABLE_CONFIGURATION_POLICY) | 658 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 663 if (url_blacklist_manager_.get()) | 659 if (url_blacklist_manager_.get()) |
| 664 url_blacklist_manager_->ShutdownOnUIThread(); | 660 url_blacklist_manager_->ShutdownOnUIThread(); |
| 665 #endif | 661 #endif |
| 662 if (chrome_http_user_agent_settings_.get()) |
| 663 chrome_http_user_agent_settings_->CleanupOnUIThread(); |
| 666 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); | 664 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); |
| 667 if (!posted) | 665 if (!posted) |
| 668 delete this; | 666 delete this; |
| 669 } | 667 } |
| 670 | 668 |
| 671 void ProfileIOData::set_server_bound_cert_service( | 669 void ProfileIOData::set_server_bound_cert_service( |
| 672 net::ServerBoundCertService* server_bound_cert_service) const { | 670 net::ServerBoundCertService* server_bound_cert_service) const { |
| 673 server_bound_cert_service_.reset(server_bound_cert_service); | 671 server_bound_cert_service_.reset(server_bound_cert_service); |
| 674 } | 672 } |
| 675 | 673 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 702 params->http_pipelining_enabled = globals->http_pipelining_enabled; | 700 params->http_pipelining_enabled = globals->http_pipelining_enabled; |
| 703 params->testing_fixed_http_port = globals->testing_fixed_http_port; | 701 params->testing_fixed_http_port = globals->testing_fixed_http_port; |
| 704 params->testing_fixed_https_port = globals->testing_fixed_https_port; | 702 params->testing_fixed_https_port = globals->testing_fixed_https_port; |
| 705 | 703 |
| 706 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 704 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 707 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) { | 705 if (command_line.HasSwitch(switches::kTrustedSpdyProxy)) { |
| 708 params->trusted_spdy_proxy = command_line.GetSwitchValueASCII( | 706 params->trusted_spdy_proxy = command_line.GetSwitchValueASCII( |
| 709 switches::kTrustedSpdyProxy); | 707 switches::kTrustedSpdyProxy); |
| 710 } | 708 } |
| 711 } | 709 } |
| OLD | NEW |