| 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 28 matching lines...) Expand all Loading... |
| 39 #include "chrome/browser/net/chrome_cookie_notification_details.h" | 39 #include "chrome/browser/net/chrome_cookie_notification_details.h" |
| 40 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" | 40 #include "chrome/browser/net/chrome_fraudulent_certificate_reporter.h" |
| 41 #include "chrome/browser/net/chrome_http_user_agent_settings.h" | 41 #include "chrome/browser/net/chrome_http_user_agent_settings.h" |
| 42 #include "chrome/browser/net/chrome_net_log.h" | 42 #include "chrome/browser/net/chrome_net_log.h" |
| 43 #include "chrome/browser/net/chrome_network_delegate.h" | 43 #include "chrome/browser/net/chrome_network_delegate.h" |
| 44 #include "chrome/browser/net/evicted_domain_cookie_counter.h" | 44 #include "chrome/browser/net/evicted_domain_cookie_counter.h" |
| 45 #include "chrome/browser/net/load_time_stats.h" | 45 #include "chrome/browser/net/load_time_stats.h" |
| 46 #include "chrome/browser/net/proxy_service_factory.h" | 46 #include "chrome/browser/net/proxy_service_factory.h" |
| 47 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" | 47 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| 48 #include "chrome/browser/net/transport_security_persister.h" | 48 #include "chrome/browser/net/transport_security_persister.h" |
| 49 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | |
| 50 #include "chrome/browser/policy/url_blacklist_manager.h" | 49 #include "chrome/browser/policy/url_blacklist_manager.h" |
| 51 #include "chrome/browser/predictors/resource_prefetch_predictor.h" | 50 #include "chrome/browser/predictors/resource_prefetch_predictor.h" |
| 52 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" | 51 #include "chrome/browser/predictors/resource_prefetch_predictor_factory.h" |
| 53 #include "chrome/browser/profiles/profile.h" | 52 #include "chrome/browser/profiles/profile.h" |
| 54 #include "chrome/browser/profiles/profile_manager.h" | 53 #include "chrome/browser/profiles/profile_manager.h" |
| 55 #include "chrome/browser/signin/signin_names_io_thread.h" | 54 #include "chrome/browser/signin/signin_names_io_thread.h" |
| 56 #include "chrome/common/chrome_paths.h" | 55 #include "chrome/common/chrome_paths.h" |
| 57 #include "chrome/common/chrome_switches.h" | 56 #include "chrome/common/chrome_switches.h" |
| 58 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 59 #include "chrome/common/url_constants.h" | 58 #include "chrome/common/url_constants.h" |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 params->extension_info_map = | 264 params->extension_info_map = |
| 266 extensions::ExtensionSystem::Get(profile)->info_map(); | 265 extensions::ExtensionSystem::Get(profile)->info_map(); |
| 267 | 266 |
| 268 if (predictors::ResourcePrefetchPredictor* predictor = | 267 if (predictors::ResourcePrefetchPredictor* predictor = |
| 269 predictors::ResourcePrefetchPredictorFactory::GetForProfile( | 268 predictors::ResourcePrefetchPredictorFactory::GetForProfile( |
| 270 profile)) { | 269 profile)) { |
| 271 resource_prefetch_predictor_observer_.reset( | 270 resource_prefetch_predictor_observer_.reset( |
| 272 new chrome_browser_net::ResourcePrefetchPredictorObserver(predictor)); | 271 new chrome_browser_net::ResourcePrefetchPredictorObserver(predictor)); |
| 273 } | 272 } |
| 274 | 273 |
| 275 #if defined(ENABLE_NOTIFICATIONS) | |
| 276 params->notification_service = | |
| 277 DesktopNotificationServiceFactory::GetForProfile(profile); | |
| 278 #endif | |
| 279 | |
| 280 ProtocolHandlerRegistry* protocol_handler_registry = | 274 ProtocolHandlerRegistry* protocol_handler_registry = |
| 281 ProtocolHandlerRegistryFactory::GetForProfile(profile); | 275 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
| 282 DCHECK(protocol_handler_registry); | 276 DCHECK(protocol_handler_registry); |
| 283 | 277 |
| 284 // The profile instance is only available here in the InitializeOnUIThread | 278 // The profile instance is only available here in the InitializeOnUIThread |
| 285 // method, so we create the url job factory here, then save it for | 279 // method, so we create the url job factory here, then save it for |
| 286 // later delivery to the job factory in Init(). | 280 // later delivery to the job factory in Init(). |
| 287 params->protocol_handler_interceptor = | 281 params->protocol_handler_interceptor = |
| 288 protocol_handler_registry->CreateJobInterceptorFactory(); | 282 protocol_handler_registry->CreateJobInterceptorFactory(); |
| 289 | 283 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 void ProfileIOData::AppRequestContext::SetJobFactory( | 392 void ProfileIOData::AppRequestContext::SetJobFactory( |
| 399 scoped_ptr<net::URLRequestJobFactory> job_factory) { | 393 scoped_ptr<net::URLRequestJobFactory> job_factory) { |
| 400 job_factory_ = job_factory.Pass(); | 394 job_factory_ = job_factory.Pass(); |
| 401 set_job_factory(job_factory_.get()); | 395 set_job_factory(job_factory_.get()); |
| 402 } | 396 } |
| 403 | 397 |
| 404 ProfileIOData::AppRequestContext::~AppRequestContext() {} | 398 ProfileIOData::AppRequestContext::~AppRequestContext() {} |
| 405 | 399 |
| 406 ProfileIOData::ProfileParams::ProfileParams() | 400 ProfileIOData::ProfileParams::ProfileParams() |
| 407 : io_thread(NULL), | 401 : io_thread(NULL), |
| 408 #if defined(ENABLE_NOTIFICATIONS) | |
| 409 notification_service(NULL), | |
| 410 #endif | |
| 411 profile(NULL) { | 402 profile(NULL) { |
| 412 } | 403 } |
| 413 | 404 |
| 414 ProfileIOData::ProfileParams::~ProfileParams() {} | 405 ProfileIOData::ProfileParams::~ProfileParams() {} |
| 415 | 406 |
| 416 ProfileIOData::ProfileIOData(bool is_incognito) | 407 ProfileIOData::ProfileIOData(bool is_incognito) |
| 417 : initialized_(false), | 408 : initialized_(false), |
| 418 #if defined(ENABLE_NOTIFICATIONS) | |
| 419 notification_service_(NULL), | |
| 420 #endif | |
| 421 resource_context_(new ResourceContext(this)), | 409 resource_context_(new ResourceContext(this)), |
| 422 load_time_stats_(NULL), | 410 load_time_stats_(NULL), |
| 423 initialized_on_UI_thread_(false), | 411 initialized_on_UI_thread_(false), |
| 424 is_incognito_(is_incognito) { | 412 is_incognito_(is_incognito) { |
| 425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 426 } | 414 } |
| 427 | 415 |
| 428 ProfileIOData::~ProfileIOData() { | 416 ProfileIOData::~ProfileIOData() { |
| 429 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 417 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
| 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 418 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 // Allow either Init() or SetCookieSettingsForTesting() to initialize. | 619 // Allow either Init() or SetCookieSettingsForTesting() to initialize. |
| 632 DCHECK(initialized_ || cookie_settings_.get()); | 620 DCHECK(initialized_ || cookie_settings_.get()); |
| 633 return cookie_settings_.get(); | 621 return cookie_settings_.get(); |
| 634 } | 622 } |
| 635 | 623 |
| 636 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | 624 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { |
| 637 DCHECK(initialized_); | 625 DCHECK(initialized_); |
| 638 return host_content_settings_map_.get(); | 626 return host_content_settings_map_.get(); |
| 639 } | 627 } |
| 640 | 628 |
| 641 #if defined(ENABLE_NOTIFICATIONS) | |
| 642 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | |
| 643 DCHECK(initialized_); | |
| 644 return notification_service_; | |
| 645 } | |
| 646 #endif | |
| 647 | |
| 648 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { | 629 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { |
| 649 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 630 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 650 #if defined(OS_CHROMEOS) | 631 #if defined(OS_CHROMEOS) |
| 651 // Just fetch the value from ChromeOS' settings while we're on the UI thread. | 632 // Just fetch the value from ChromeOS' settings while we're on the UI thread. |
| 652 // TODO(stevet): For now, this value is only set on profile initialization. | 633 // TODO(stevet): For now, this value is only set on profile initialization. |
| 653 // We will want to do something similar to the PrefMember method below in the | 634 // We will want to do something similar to the PrefMember method below in the |
| 654 // future to more accurately capture this state. | 635 // future to more accurately capture this state. |
| 655 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 636 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
| 656 &enable_metrics_); | 637 &enable_metrics_); |
| 657 #elif defined(OS_ANDROID) | 638 #elif defined(OS_ANDROID) |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 | 796 |
| 816 transport_security_state_.reset(new net::TransportSecurityState()); | 797 transport_security_state_.reset(new net::TransportSecurityState()); |
| 817 transport_security_persister_.reset( | 798 transport_security_persister_.reset( |
| 818 new TransportSecurityPersister(transport_security_state_.get(), | 799 new TransportSecurityPersister(transport_security_state_.get(), |
| 819 profile_params_->path, | 800 profile_params_->path, |
| 820 is_incognito())); | 801 is_incognito())); |
| 821 | 802 |
| 822 // Take ownership over these parameters. | 803 // Take ownership over these parameters. |
| 823 cookie_settings_ = profile_params_->cookie_settings; | 804 cookie_settings_ = profile_params_->cookie_settings; |
| 824 host_content_settings_map_ = profile_params_->host_content_settings_map; | 805 host_content_settings_map_ = profile_params_->host_content_settings_map; |
| 825 #if defined(ENABLE_NOTIFICATIONS) | |
| 826 notification_service_ = profile_params_->notification_service; | |
| 827 #endif | |
| 828 extension_info_map_ = profile_params_->extension_info_map; | 806 extension_info_map_ = profile_params_->extension_info_map; |
| 829 | 807 |
| 830 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | 808 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
| 831 resource_context_->request_context_ = main_request_context_.get(); | 809 resource_context_->request_context_ = main_request_context_.get(); |
| 832 | 810 |
| 833 if (profile_params_->resource_prefetch_predictor_observer_) { | 811 if (profile_params_->resource_prefetch_predictor_observer_) { |
| 834 resource_prefetch_predictor_observer_.reset( | 812 resource_prefetch_predictor_observer_.reset( |
| 835 profile_params_->resource_prefetch_predictor_observer_.release()); | 813 profile_params_->resource_prefetch_predictor_observer_.release()); |
| 836 } | 814 } |
| 837 | 815 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 void ProfileIOData::SetCookieSettingsForTesting( | 971 void ProfileIOData::SetCookieSettingsForTesting( |
| 994 CookieSettings* cookie_settings) { | 972 CookieSettings* cookie_settings) { |
| 995 DCHECK(!cookie_settings_.get()); | 973 DCHECK(!cookie_settings_.get()); |
| 996 cookie_settings_ = cookie_settings; | 974 cookie_settings_ = cookie_settings; |
| 997 } | 975 } |
| 998 | 976 |
| 999 void ProfileIOData::set_signin_names_for_testing( | 977 void ProfileIOData::set_signin_names_for_testing( |
| 1000 SigninNamesOnIOThread* signin_names) { | 978 SigninNamesOnIOThread* signin_names) { |
| 1001 signin_names_.reset(signin_names); | 979 signin_names_.reset(signin_names); |
| 1002 } | 980 } |
| OLD | NEW |