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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 #include "chrome/common/chrome_paths.h" | 56 #include "chrome/common/chrome_paths.h" |
| 57 #include "chrome/common/chrome_switches.h" | 57 #include "chrome/common/chrome_switches.h" |
| 58 #include "chrome/common/pref_names.h" | 58 #include "chrome/common/pref_names.h" |
| 59 #include "chrome/common/url_constants.h" | 59 #include "chrome/common/url_constants.h" |
| 60 #include "components/startup_metric_utils/startup_metric_utils.h" | 60 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 61 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
| 62 #include "content/public/browser/host_zoom_map.h" | 62 #include "content/public/browser/host_zoom_map.h" |
| 63 #include "content/public/browser/notification_service.h" | 63 #include "content/public/browser/notification_service.h" |
| 64 #include "content/public/browser/resource_context.h" | 64 #include "content/public/browser/resource_context.h" |
| 65 #include "extensions/common/constants.h" | 65 #include "extensions/common/constants.h" |
| 66 #include "net/cert/cert_verifier.h" | |
| 67 #include "net/cookies/canonical_cookie.h" | 66 #include "net/cookies/canonical_cookie.h" |
| 68 #include "net/cookies/cookie_monster.h" | 67 #include "net/cookies/cookie_monster.h" |
| 69 #include "net/http/http_transaction_factory.h" | 68 #include "net/http/http_transaction_factory.h" |
| 70 #include "net/http/http_util.h" | 69 #include "net/http/http_util.h" |
| 71 #include "net/proxy/proxy_config_service_fixed.h" | 70 #include "net/proxy/proxy_config_service_fixed.h" |
| 72 #include "net/proxy/proxy_script_fetcher_impl.h" | 71 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 73 #include "net/proxy/proxy_service.h" | 72 #include "net/proxy/proxy_service.h" |
| 74 #include "net/ssl/server_bound_cert_service.h" | 73 #include "net/ssl/server_bound_cert_service.h" |
| 75 #include "net/url_request/data_protocol_handler.h" | 74 #include "net/url_request/data_protocol_handler.h" |
| 76 #include "net/url_request/file_protocol_handler.h" | 75 #include "net/url_request/file_protocol_handler.h" |
| 77 #include "net/url_request/ftp_protocol_handler.h" | 76 #include "net/url_request/ftp_protocol_handler.h" |
| 78 #include "net/url_request/protocol_intercept_job_factory.h" | 77 #include "net/url_request/protocol_intercept_job_factory.h" |
| 79 #include "net/url_request/url_request.h" | 78 #include "net/url_request/url_request.h" |
| 80 #include "net/url_request/url_request_file_job.h" | 79 #include "net/url_request/url_request_file_job.h" |
| 81 #include "net/url_request/url_request_job_factory_impl.h" | 80 #include "net/url_request/url_request_job_factory_impl.h" |
| 82 | 81 |
| 83 #if defined(ENABLE_MANAGED_USERS) | 82 #if defined(ENABLE_MANAGED_USERS) |
| 84 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" | 83 #include "chrome/browser/managed_mode/managed_mode_url_filter.h" |
| 85 #include "chrome/browser/managed_mode/managed_user_service.h" | 84 #include "chrome/browser/managed_mode/managed_user_service.h" |
| 86 #include "chrome/browser/managed_mode/managed_user_service_factory.h" | 85 #include "chrome/browser/managed_mode/managed_user_service_factory.h" |
| 87 #endif | 86 #endif |
| 88 | 87 |
| 89 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
| 90 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h" | 89 #include "chrome/browser/chromeos/drive/drive_protocol_handler.h" |
| 90 #include "chrome/browser/chromeos/policy/network_policy_service.h" | |
| 91 #include "chrome/browser/chromeos/policy/network_policy_service_factory.h" | |
| 91 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" | 92 #include "chrome/browser/chromeos/policy/policy_cert_verifier.h" |
| 92 #include "chrome/browser/chromeos/settings/cros_settings.h" | 93 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 93 #include "chrome/browser/policy/profile_policy_connector.h" | |
| 94 #include "chrome/browser/policy/profile_policy_connector_factory.h" | |
| 95 #include "chromeos/settings/cros_settings_names.h" | 94 #include "chromeos/settings/cros_settings_names.h" |
| 96 #endif // defined(OS_CHROMEOS) | 95 #endif // defined(OS_CHROMEOS) |
| 97 | 96 |
| 98 using content::BrowserContext; | 97 using content::BrowserContext; |
| 99 using content::BrowserThread; | 98 using content::BrowserThread; |
| 100 using content::ResourceContext; | 99 using content::ResourceContext; |
| 101 | 100 |
| 102 namespace { | 101 namespace { |
| 103 | 102 |
| 104 // ---------------------------------------------------------------------------- | 103 // ---------------------------------------------------------------------------- |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); | 218 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)); |
| 220 | 219 |
| 221 return NULL; | 220 return NULL; |
| 222 } | 221 } |
| 223 }; | 222 }; |
| 224 #endif // defined(DEBUG_DEVTOOLS) | 223 #endif // defined(DEBUG_DEVTOOLS) |
| 225 | 224 |
| 226 #if defined(OS_CHROMEOS) | 225 #if defined(OS_CHROMEOS) |
| 227 scoped_ptr<policy::PolicyCertVerifier> CreatePolicyCertVerifier( | 226 scoped_ptr<policy::PolicyCertVerifier> CreatePolicyCertVerifier( |
| 228 Profile* profile) { | 227 Profile* profile) { |
| 229 policy::ProfilePolicyConnector* connector = | 228 policy::NetworkPolicyService* service = |
| 230 policy::ProfilePolicyConnectorFactory::GetForProfile(profile); | 229 policy::NetworkPolicyServiceFactory::GetForProfile(profile); |
| 231 base::Closure policy_cert_trusted_callback = | 230 if (!service) |
| 232 base::Bind(base::IgnoreResult(&content::BrowserThread::PostTask), | 231 return scoped_ptr<policy::PolicyCertVerifier>(); |
| 233 content::BrowserThread::UI, | 232 |
| 234 FROM_HERE, | |
| 235 connector->GetPolicyCertTrustedCallback()); | |
| 236 scoped_ptr<policy::PolicyCertVerifier> cert_verifier( | 233 scoped_ptr<policy::PolicyCertVerifier> cert_verifier( |
| 237 new policy::PolicyCertVerifier(policy_cert_trusted_callback)); | 234 new policy::PolicyCertVerifier(service->GetPolicyCertTrustedCallback())); |
| 238 connector->SetPolicyCertVerifier(cert_verifier.get()); | 235 service->AddPolicyCertVerifier(cert_verifier.get()); |
| 239 return cert_verifier.Pass(); | 236 return cert_verifier.Pass(); |
| 240 } | 237 } |
| 238 | |
| 239 void ReleasePolicyCertVerifier(policy::PolicyCertVerifier* cert_verifier, | |
| 240 Profile* profile) { | |
| 241 cert_verifier->UnsetTrustAnchorUsedCallback(); | |
| 242 | |
| 243 policy::NetworkPolicyService* service = | |
| 244 policy::NetworkPolicyServiceFactory::GetForProfile(profile); | |
| 245 if (service) | |
| 246 service->RemovePolicyCertVerifier(cert_verifier); | |
| 247 } | |
| 241 #endif | 248 #endif |
| 242 } // namespace | 249 } // namespace |
| 243 | 250 |
| 244 void ProfileIOData::InitializeOnUIThread(Profile* profile) { | 251 void ProfileIOData::InitializeOnUIThread(Profile* profile) { |
| 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 246 PrefService* pref_service = profile->GetPrefs(); | 253 PrefService* pref_service = profile->GetPrefs(); |
| 247 PrefService* local_state_pref_service = g_browser_process->local_state(); | 254 PrefService* local_state_pref_service = g_browser_process->local_state(); |
| 248 | 255 |
| 249 scoped_ptr<ProfileParams> params(new ProfileParams); | 256 scoped_ptr<ProfileParams> params(new ProfileParams); |
| 250 params->path = profile->GetPath(); | 257 params->path = profile->GetPath(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 params->proxy_config_service | 295 params->proxy_config_service |
| 289 .reset(ProxyServiceFactory::CreateProxyConfigService( | 296 .reset(ProxyServiceFactory::CreateProxyConfigService( |
| 290 profile->GetProxyConfigTracker())); | 297 profile->GetProxyConfigTracker())); |
| 291 #if defined(ENABLE_MANAGED_USERS) | 298 #if defined(ENABLE_MANAGED_USERS) |
| 292 ManagedUserService* managed_user_service = | 299 ManagedUserService* managed_user_service = |
| 293 ManagedUserServiceFactory::GetForProfile(profile); | 300 ManagedUserServiceFactory::GetForProfile(profile); |
| 294 params->managed_mode_url_filter = | 301 params->managed_mode_url_filter = |
| 295 managed_user_service->GetURLFilterForIOThread(); | 302 managed_user_service->GetURLFilterForIOThread(); |
| 296 #endif | 303 #endif |
| 297 #if defined(OS_CHROMEOS) | 304 #if defined(OS_CHROMEOS) |
| 298 params->cert_verifier = CreatePolicyCertVerifier(profile); | 305 cert_verifier_ = CreatePolicyCertVerifier(profile); |
|
Joao da Silva
2013/10/25 11:57:10
Move this below, next to the initialization of the
pneubeck (no reviews)
2013/10/25 12:17:00
Done.
| |
| 299 #endif | 306 #endif |
| 300 | 307 |
| 301 params->profile = profile; | 308 params->profile = profile; |
| 302 profile_params_.reset(params.release()); | 309 profile_params_.reset(params.release()); |
| 303 | 310 |
| 304 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 311 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 305 &enable_referrers_, | 312 &enable_referrers_, |
| 306 &enable_do_not_track_, | 313 &enable_do_not_track_, |
| 307 &force_safesearch_, | 314 &force_safesearch_, |
| 308 pref_service); | 315 pref_service); |
| (...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 818 if (profile_params_->resource_prefetch_predictor_observer_) { | 825 if (profile_params_->resource_prefetch_predictor_observer_) { |
| 819 resource_prefetch_predictor_observer_.reset( | 826 resource_prefetch_predictor_observer_.reset( |
| 820 profile_params_->resource_prefetch_predictor_observer_.release()); | 827 profile_params_->resource_prefetch_predictor_observer_.release()); |
| 821 } | 828 } |
| 822 | 829 |
| 823 #if defined(ENABLE_MANAGED_USERS) | 830 #if defined(ENABLE_MANAGED_USERS) |
| 824 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter; | 831 managed_mode_url_filter_ = profile_params_->managed_mode_url_filter; |
| 825 #endif | 832 #endif |
| 826 | 833 |
| 827 #if defined(OS_CHROMEOS) | 834 #if defined(OS_CHROMEOS) |
| 828 profile_params_->cert_verifier->InitializeOnIOThread(); | 835 if (cert_verifier_) { |
| 829 cert_verifier_ = profile_params_->cert_verifier.Pass(); | 836 cert_verifier_->InitializeOnIOThread(); |
| 830 main_request_context_->set_cert_verifier(cert_verifier_.get()); | 837 main_request_context_->set_cert_verifier(cert_verifier_.get()); |
| 838 } else { | |
| 839 main_request_context_->set_cert_verifier( | |
| 840 io_thread_globals->cert_verifier.get()); | |
| 841 } | |
| 831 #else | 842 #else |
| 832 main_request_context_->set_cert_verifier( | 843 main_request_context_->set_cert_verifier( |
| 833 io_thread_globals->cert_verifier.get()); | 844 io_thread_globals->cert_verifier.get()); |
| 834 #endif | 845 #endif |
| 835 | 846 |
| 836 InitializeInternal(profile_params_.get(), protocol_handlers); | 847 InitializeInternal(profile_params_.get(), protocol_handlers); |
| 837 | 848 |
| 838 profile_params_.reset(); | 849 profile_params_.reset(); |
| 839 initialized_ = true; | 850 initialized_ = true; |
| 840 } | 851 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 #endif | 915 #endif |
| 905 | 916 |
| 906 if (protocol_handler_interceptor) { | 917 if (protocol_handler_interceptor) { |
| 907 protocol_handler_interceptor->Chain(top_job_factory.Pass()); | 918 protocol_handler_interceptor->Chain(top_job_factory.Pass()); |
| 908 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); | 919 return protocol_handler_interceptor.PassAs<net::URLRequestJobFactory>(); |
| 909 } else { | 920 } else { |
| 910 return top_job_factory.Pass(); | 921 return top_job_factory.Pass(); |
| 911 } | 922 } |
| 912 } | 923 } |
| 913 | 924 |
| 925 void ProfileIOData::ReleaseFromBrowserContextServices(Profile* profile) { | |
| 926 #if defined(OS_CHROMEOS) | |
| 927 if (cert_verifier_) | |
| 928 ReleasePolicyCertVerifier(cert_verifier_.get(), profile); | |
| 929 #endif | |
| 930 } | |
| 931 | |
| 914 void ProfileIOData::ShutdownOnUIThread() { | 932 void ProfileIOData::ShutdownOnUIThread() { |
| 915 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 933 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 916 | 934 |
| 917 if (signin_names_) | 935 if (signin_names_) |
| 918 signin_names_->ReleaseResourcesOnUIThread(); | 936 signin_names_->ReleaseResourcesOnUIThread(); |
| 919 | 937 |
| 920 google_services_username_.Destroy(); | 938 google_services_username_.Destroy(); |
| 921 google_services_username_pattern_.Destroy(); | 939 google_services_username_pattern_.Destroy(); |
| 922 reverse_autologin_enabled_.Destroy(); | 940 reverse_autologin_enabled_.Destroy(); |
| 923 one_click_signin_rejected_email_list_.Destroy(); | 941 one_click_signin_rejected_email_list_.Destroy(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 978 void ProfileIOData::SetCookieSettingsForTesting( | 996 void ProfileIOData::SetCookieSettingsForTesting( |
| 979 CookieSettings* cookie_settings) { | 997 CookieSettings* cookie_settings) { |
| 980 DCHECK(!cookie_settings_.get()); | 998 DCHECK(!cookie_settings_.get()); |
| 981 cookie_settings_ = cookie_settings; | 999 cookie_settings_ = cookie_settings; |
| 982 } | 1000 } |
| 983 | 1001 |
| 984 void ProfileIOData::set_signin_names_for_testing( | 1002 void ProfileIOData::set_signin_names_for_testing( |
| 985 SigninNamesOnIOThread* signin_names) { | 1003 SigninNamesOnIOThread* signin_names) { |
| 986 signin_names_.reset(signin_names); | 1004 signin_names_.reset(signin_names); |
| 987 } | 1005 } |
| OLD | NEW |