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" |
60 #include "components/startup_metric_utils/startup_metric_utils.h" | 59 #include "components/startup_metric_utils/startup_metric_utils.h" |
61 #include "content/public/browser/browser_thread.h" | 60 #include "content/public/browser/browser_thread.h" |
62 #include "content/public/browser/host_zoom_map.h" | 61 #include "content/public/browser/host_zoom_map.h" |
63 #include "content/public/browser/notification_service.h" | |
64 #include "content/public/browser/resource_context.h" | 62 #include "content/public/browser/resource_context.h" |
65 #include "extensions/common/constants.h" | 63 #include "extensions/common/constants.h" |
66 #include "net/cert/cert_verifier.h" | 64 #include "net/cert/cert_verifier.h" |
67 #include "net/cookies/canonical_cookie.h" | 65 #include "net/cookies/canonical_cookie.h" |
68 #include "net/cookies/cookie_monster.h" | 66 #include "net/cookies/cookie_monster.h" |
69 #include "net/http/http_transaction_factory.h" | 67 #include "net/http/http_transaction_factory.h" |
70 #include "net/http/http_util.h" | 68 #include "net/http/http_util.h" |
71 #include "net/proxy/proxy_config_service_fixed.h" | 69 #include "net/proxy/proxy_config_service_fixed.h" |
72 #include "net/proxy/proxy_script_fetcher_impl.h" | 70 #include "net/proxy/proxy_script_fetcher_impl.h" |
73 #include "net/proxy/proxy_service.h" | 71 #include "net/proxy/proxy_service.h" |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 params->extension_info_map = | 261 params->extension_info_map = |
264 extensions::ExtensionSystem::Get(profile)->info_map(); | 262 extensions::ExtensionSystem::Get(profile)->info_map(); |
265 | 263 |
266 if (predictors::ResourcePrefetchPredictor* predictor = | 264 if (predictors::ResourcePrefetchPredictor* predictor = |
267 predictors::ResourcePrefetchPredictorFactory::GetForProfile( | 265 predictors::ResourcePrefetchPredictorFactory::GetForProfile( |
268 profile)) { | 266 profile)) { |
269 resource_prefetch_predictor_observer_.reset( | 267 resource_prefetch_predictor_observer_.reset( |
270 new chrome_browser_net::ResourcePrefetchPredictorObserver(predictor)); | 268 new chrome_browser_net::ResourcePrefetchPredictorObserver(predictor)); |
271 } | 269 } |
272 | 270 |
273 #if defined(ENABLE_NOTIFICATIONS) | |
274 params->notification_service = | |
275 DesktopNotificationServiceFactory::GetForProfile(profile); | |
276 #endif | |
277 | |
278 ProtocolHandlerRegistry* protocol_handler_registry = | 271 ProtocolHandlerRegistry* protocol_handler_registry = |
279 ProtocolHandlerRegistryFactory::GetForProfile(profile); | 272 ProtocolHandlerRegistryFactory::GetForProfile(profile); |
280 DCHECK(protocol_handler_registry); | 273 DCHECK(protocol_handler_registry); |
281 | 274 |
282 // The profile instance is only available here in the InitializeOnUIThread | 275 // The profile instance is only available here in the InitializeOnUIThread |
283 // method, so we create the url job factory here, then save it for | 276 // method, so we create the url job factory here, then save it for |
284 // later delivery to the job factory in Init(). | 277 // later delivery to the job factory in Init(). |
285 params->protocol_handler_interceptor = | 278 params->protocol_handler_interceptor = |
286 protocol_handler_registry->CreateJobInterceptorFactory(); | 279 protocol_handler_registry->CreateJobInterceptorFactory(); |
287 | 280 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 | 388 |
396 void ProfileIOData::AppRequestContext::SetJobFactory( | 389 void ProfileIOData::AppRequestContext::SetJobFactory( |
397 scoped_ptr<net::URLRequestJobFactory> job_factory) { | 390 scoped_ptr<net::URLRequestJobFactory> job_factory) { |
398 job_factory_ = job_factory.Pass(); | 391 job_factory_ = job_factory.Pass(); |
399 set_job_factory(job_factory_.get()); | 392 set_job_factory(job_factory_.get()); |
400 } | 393 } |
401 | 394 |
402 ProfileIOData::AppRequestContext::~AppRequestContext() {} | 395 ProfileIOData::AppRequestContext::~AppRequestContext() {} |
403 | 396 |
404 ProfileIOData::ProfileParams::ProfileParams() | 397 ProfileIOData::ProfileParams::ProfileParams() |
405 : io_thread(NULL), | 398 : io_thread(NULL), profile(NULL) {} |
406 #if defined(ENABLE_NOTIFICATIONS) | |
407 notification_service(NULL), | |
408 #endif | |
409 profile(NULL) { | |
410 } | |
411 | 399 |
412 ProfileIOData::ProfileParams::~ProfileParams() {} | 400 ProfileIOData::ProfileParams::~ProfileParams() {} |
413 | 401 |
414 ProfileIOData::ProfileIOData(bool is_incognito) | 402 ProfileIOData::ProfileIOData(bool is_incognito) |
415 : initialized_(false), | 403 : initialized_(false), |
416 #if defined(ENABLE_NOTIFICATIONS) | |
417 notification_service_(NULL), | |
418 #endif | |
419 resource_context_(new ResourceContext(this)), | 404 resource_context_(new ResourceContext(this)), |
420 load_time_stats_(NULL), | 405 load_time_stats_(NULL), |
421 initialized_on_UI_thread_(false), | 406 initialized_on_UI_thread_(false), |
422 is_incognito_(is_incognito) { | 407 is_incognito_(is_incognito) { |
423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 408 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
424 } | 409 } |
425 | 410 |
426 ProfileIOData::~ProfileIOData() { | 411 ProfileIOData::~ProfileIOData() { |
427 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) | 412 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) |
428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 413 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 // Allow either Init() or SetCookieSettingsForTesting() to initialize. | 614 // Allow either Init() or SetCookieSettingsForTesting() to initialize. |
630 DCHECK(initialized_ || cookie_settings_.get()); | 615 DCHECK(initialized_ || cookie_settings_.get()); |
631 return cookie_settings_.get(); | 616 return cookie_settings_.get(); |
632 } | 617 } |
633 | 618 |
634 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { | 619 HostContentSettingsMap* ProfileIOData::GetHostContentSettingsMap() const { |
635 DCHECK(initialized_); | 620 DCHECK(initialized_); |
636 return host_content_settings_map_.get(); | 621 return host_content_settings_map_.get(); |
637 } | 622 } |
638 | 623 |
639 #if defined(ENABLE_NOTIFICATIONS) | |
640 DesktopNotificationService* ProfileIOData::GetNotificationService() const { | |
641 DCHECK(initialized_); | |
642 return notification_service_; | |
643 } | |
644 #endif | |
645 | |
646 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { | 624 void ProfileIOData::InitializeMetricsEnabledStateOnUIThread() { |
647 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 625 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
648 #if defined(OS_CHROMEOS) | 626 #if defined(OS_CHROMEOS) |
649 // Just fetch the value from ChromeOS' settings while we're on the UI thread. | 627 // Just fetch the value from ChromeOS' settings while we're on the UI thread. |
650 // TODO(stevet): For now, this value is only set on profile initialization. | 628 // TODO(stevet): For now, this value is only set on profile initialization. |
651 // We will want to do something similar to the PrefMember method below in the | 629 // We will want to do something similar to the PrefMember method below in the |
652 // future to more accurately capture this state. | 630 // future to more accurately capture this state. |
653 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | 631 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, |
654 &enable_metrics_); | 632 &enable_metrics_); |
655 #elif defined(OS_ANDROID) | 633 #elif defined(OS_ANDROID) |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 776 |
799 transport_security_state_.reset(new net::TransportSecurityState()); | 777 transport_security_state_.reset(new net::TransportSecurityState()); |
800 transport_security_persister_.reset( | 778 transport_security_persister_.reset( |
801 new TransportSecurityPersister(transport_security_state_.get(), | 779 new TransportSecurityPersister(transport_security_state_.get(), |
802 profile_params_->path, | 780 profile_params_->path, |
803 is_incognito())); | 781 is_incognito())); |
804 | 782 |
805 // Take ownership over these parameters. | 783 // Take ownership over these parameters. |
806 cookie_settings_ = profile_params_->cookie_settings; | 784 cookie_settings_ = profile_params_->cookie_settings; |
807 host_content_settings_map_ = profile_params_->host_content_settings_map; | 785 host_content_settings_map_ = profile_params_->host_content_settings_map; |
808 #if defined(ENABLE_NOTIFICATIONS) | |
809 notification_service_ = profile_params_->notification_service; | |
810 #endif | |
811 extension_info_map_ = profile_params_->extension_info_map; | 786 extension_info_map_ = profile_params_->extension_info_map; |
812 | 787 |
813 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); | 788 resource_context_->host_resolver_ = io_thread_globals->host_resolver.get(); |
814 resource_context_->request_context_ = main_request_context_.get(); | 789 resource_context_->request_context_ = main_request_context_.get(); |
815 | 790 |
816 if (profile_params_->resource_prefetch_predictor_observer_) { | 791 if (profile_params_->resource_prefetch_predictor_observer_) { |
817 resource_prefetch_predictor_observer_.reset( | 792 resource_prefetch_predictor_observer_.reset( |
818 profile_params_->resource_prefetch_predictor_observer_.release()); | 793 profile_params_->resource_prefetch_predictor_observer_.release()); |
819 } | 794 } |
820 | 795 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 void ProfileIOData::SetCookieSettingsForTesting( | 951 void ProfileIOData::SetCookieSettingsForTesting( |
977 CookieSettings* cookie_settings) { | 952 CookieSettings* cookie_settings) { |
978 DCHECK(!cookie_settings_.get()); | 953 DCHECK(!cookie_settings_.get()); |
979 cookie_settings_ = cookie_settings; | 954 cookie_settings_ = cookie_settings; |
980 } | 955 } |
981 | 956 |
982 void ProfileIOData::set_signin_names_for_testing( | 957 void ProfileIOData::set_signin_names_for_testing( |
983 SigninNamesOnIOThread* signin_names) { | 958 SigninNamesOnIOThread* signin_names) { |
984 signin_names_.reset(signin_names); | 959 signin_names_.reset(signin_names); |
985 } | 960 } |
OLD | NEW |