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