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_impl.h" | 5 #include "chrome/browser/profiles/profile_impl.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 #include "chrome/browser/download/download_service.h" | 41 #include "chrome/browser/download/download_service.h" |
42 #include "chrome/browser/download/download_service_factory.h" | 42 #include "chrome/browser/download/download_service_factory.h" |
43 #include "chrome/browser/extensions/extension_service.h" | 43 #include "chrome/browser/extensions/extension_service.h" |
44 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 44 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
45 #include "chrome/browser/history/top_sites.h" | 45 #include "chrome/browser/history/top_sites.h" |
46 #include "chrome/browser/net/chrome_url_request_context.h" | 46 #include "chrome/browser/net/chrome_url_request_context.h" |
47 #include "chrome/browser/net/net_pref_observer.h" | 47 #include "chrome/browser/net/net_pref_observer.h" |
48 #include "chrome/browser/net/predictor.h" | 48 #include "chrome/browser/net/predictor.h" |
49 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 49 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
50 #include "chrome/browser/net/proxy_service_factory.h" | 50 #include "chrome/browser/net/proxy_service_factory.h" |
| 51 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" |
51 #include "chrome/browser/net/ssl_config_service_manager.h" | 52 #include "chrome/browser/net/ssl_config_service_manager.h" |
52 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 53 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
53 #include "chrome/browser/plugins/plugin_prefs.h" | 54 #include "chrome/browser/plugins/plugin_prefs.h" |
54 #include "chrome/browser/policy/profile_policy_connector.h" | 55 #include "chrome/browser/policy/profile_policy_connector.h" |
55 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 56 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
56 #include "chrome/browser/prefs/browser_prefs.h" | 57 #include "chrome/browser/prefs/browser_prefs.h" |
57 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 58 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
58 #include "chrome/browser/prefs/pref_service_syncable.h" | 59 #include "chrome/browser/prefs/pref_service_syncable.h" |
59 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" | 60 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" |
60 #include "chrome/browser/prerender/prerender_manager_factory.h" | 61 #include "chrome/browser/prerender/prerender_manager_factory.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" | 112 #include "chrome/browser/media/protected_media_identifier_permission_context_fac
tory.h" |
112 #endif | 113 #endif |
113 | 114 |
114 #if defined(OS_CHROMEOS) | 115 #if defined(OS_CHROMEOS) |
115 #include "chrome/browser/chromeos/locale_change_guard.h" | 116 #include "chrome/browser/chromeos/locale_change_guard.h" |
116 #include "chrome/browser/chromeos/login/users/user_manager.h" | 117 #include "chrome/browser/chromeos/login/users/user_manager.h" |
117 #include "chrome/browser/chromeos/preferences.h" | 118 #include "chrome/browser/chromeos/preferences.h" |
118 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 119 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
119 #endif | 120 #endif |
120 | 121 |
| 122 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 123 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_configurator.
h" |
| 124 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" |
| 125 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
| 126 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
| 127 #endif |
| 128 |
121 #if defined(ENABLE_CONFIGURATION_POLICY) | 129 #if defined(ENABLE_CONFIGURATION_POLICY) |
122 #include "chrome/browser/policy/schema_registry_service.h" | 130 #include "chrome/browser/policy/schema_registry_service.h" |
123 #include "chrome/browser/policy/schema_registry_service_factory.h" | 131 #include "chrome/browser/policy/schema_registry_service_factory.h" |
124 #include "components/policy/core/browser/browser_policy_connector.h" | 132 #include "components/policy/core/browser/browser_policy_connector.h" |
125 #if defined(OS_CHROMEOS) | 133 #if defined(OS_CHROMEOS) |
126 #include "chrome/browser/chromeos/login/login_utils.h" | 134 #include "chrome/browser/chromeos/login/login_utils.h" |
127 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 135 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
128 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 136 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
129 #else | 137 #else |
130 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" | 138 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 Delegate* delegate, | 384 Delegate* delegate, |
377 CreateMode create_mode, | 385 CreateMode create_mode, |
378 base::SequencedTaskRunner* sequenced_task_runner) | 386 base::SequencedTaskRunner* sequenced_task_runner) |
379 : path_(path), | 387 : path_(path), |
380 pref_registry_(new user_prefs::PrefRegistrySyncable), | 388 pref_registry_(new user_prefs::PrefRegistrySyncable), |
381 io_data_(this), | 389 io_data_(this), |
382 host_content_settings_map_(NULL), | 390 host_content_settings_map_(NULL), |
383 last_session_exit_type_(EXIT_NORMAL), | 391 last_session_exit_type_(EXIT_NORMAL), |
384 start_time_(Time::Now()), | 392 start_time_(Time::Now()), |
385 delegate_(delegate), | 393 delegate_(delegate), |
386 predictor_(NULL) { | 394 predictor_(NULL), |
| 395 data_reduction_proxy_chrome_settings_(NULL) { |
387 TRACE_EVENT0("browser", "ProfileImpl::ctor") | 396 TRACE_EVENT0("browser", "ProfileImpl::ctor") |
388 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << | 397 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
389 "profile files to the root directory!"; | 398 "profile files to the root directory!"; |
390 | 399 |
391 #if defined(ENABLE_SESSION_SERVICE) | 400 #if defined(ENABLE_SESSION_SERVICE) |
392 create_session_service_timer_.Start(FROM_HERE, | 401 create_session_service_timer_.Start(FROM_HERE, |
393 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, | 402 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
394 &ProfileImpl::EnsureSessionServiceCreated); | 403 &ProfileImpl::EnsureSessionServiceCreated); |
395 #endif | 404 #endif |
396 | 405 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 #endif | 600 #endif |
592 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = | 601 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = |
593 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; | 602 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; |
594 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || | 603 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || |
595 startup_pref_type == SessionStartupPref::LAST) { | 604 startup_pref_type == SessionStartupPref::LAST) { |
596 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; | 605 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; |
597 } | 606 } |
598 | 607 |
599 InitHostZoomMap(); | 608 InitHostZoomMap(); |
600 | 609 |
| 610 base::Callback<void(bool)> data_reduction_proxy_unavailable; |
| 611 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> |
| 612 data_reduction_proxy_params; |
| 613 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 614 InitDataReductionProxy(&data_reduction_proxy_params, |
| 615 &data_reduction_proxy_unavailable); |
| 616 #endif |
| 617 |
601 // Make sure we initialize the ProfileIOData after everything else has been | 618 // Make sure we initialize the ProfileIOData after everything else has been |
602 // initialized that we might be reading from the IO thread. | 619 // initialized that we might be reading from the IO thread. |
603 | 620 |
604 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, | 621 io_data_.Init(cookie_path, server_bound_cert_path, cache_path, |
605 cache_max_size, media_cache_path, media_cache_max_size, | 622 cache_max_size, media_cache_path, media_cache_max_size, |
606 extensions_cookie_path, GetPath(), infinite_cache_path, | 623 extensions_cookie_path, GetPath(), infinite_cache_path, |
607 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), | 624 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), |
608 CreateDomainReliabilityMonitor()); | 625 CreateDomainReliabilityMonitor(), |
| 626 data_reduction_proxy_unavailable, |
| 627 data_reduction_proxy_params.Pass()); |
609 | 628 |
610 #if defined(ENABLE_PLUGINS) | 629 #if defined(ENABLE_PLUGINS) |
611 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 630 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
612 PluginPrefs::GetForProfile(this).get(), | 631 PluginPrefs::GetForProfile(this).get(), |
613 io_data_.GetResourceContextNoInit()); | 632 io_data_.GetResourceContextNoInit()); |
614 #endif | 633 #endif |
615 | 634 |
616 // Delay README creation to not impact startup performance. | 635 // Delay README creation to not impact startup performance. |
617 BrowserThread::PostDelayedTask( | 636 BrowserThread::PostDelayedTask( |
618 BrowserThread::FILE, FROM_HERE, | 637 BrowserThread::FILE, FROM_HERE, |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 for (std::vector<std::string>::const_iterator it = keys_to_remove.begin(); | 719 for (std::vector<std::string>::const_iterator it = keys_to_remove.begin(); |
701 it != keys_to_remove.end(); ++it) { | 720 it != keys_to_remove.end(); ++it) { |
702 host_zoom_dictionary->RemoveWithoutPathExpansion(*it, NULL); | 721 host_zoom_dictionary->RemoveWithoutPathExpansion(*it, NULL); |
703 } | 722 } |
704 } | 723 } |
705 | 724 |
706 zoom_subscription_ = host_zoom_map->AddZoomLevelChangedCallback( | 725 zoom_subscription_ = host_zoom_map->AddZoomLevelChangedCallback( |
707 base::Bind(&ProfileImpl::OnZoomLevelChanged, base::Unretained(this))); | 726 base::Bind(&ProfileImpl::OnZoomLevelChanged, base::Unretained(this))); |
708 } | 727 } |
709 | 728 |
| 729 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
| 730 void ProfileImpl::InitDataReductionProxy( |
| 731 scoped_ptr<data_reduction_proxy::DataReductionProxyParams>* params, |
| 732 base::Callback<void(bool)>* unavailable_callback) { |
| 733 data_reduction_proxy_chrome_settings_ = |
| 734 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); |
| 735 DCHECK(params); |
| 736 params->reset(new data_reduction_proxy::DataReductionProxyParams( |
| 737 *(data_reduction_proxy_chrome_settings_->params()))); |
| 738 *unavailable_callback = |
| 739 base::Bind( |
| 740 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, |
| 741 base::Unretained(data_reduction_proxy_chrome_settings_)); |
| 742 // Post to prevent a Profile initialization loop. |
| 743 BrowserThread::PostTask( |
| 744 BrowserThread::UI, FROM_HERE, |
| 745 base::Bind(&ProfileImpl::RunInitDataReductionProxyTask, |
| 746 base::Unretained(this))); |
| 747 } |
| 748 |
| 749 void ProfileImpl::RunInitDataReductionProxyTask() { |
| 750 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
| 751 configurator(new DataReductionProxyChromeConfigurator(prefs_.get())); |
| 752 data_reduction_proxy_chrome_settings_->InitDataReductionProxySettings( |
| 753 configurator.Pass(), |
| 754 prefs_.get(), |
| 755 g_browser_process->local_state(), |
| 756 GetRequestContext()); |
| 757 } |
| 758 #endif // defined(SPDY_PROXY_AUTH_ORIGIN) |
| 759 |
710 base::FilePath ProfileImpl::last_selected_directory() { | 760 base::FilePath ProfileImpl::last_selected_directory() { |
711 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); | 761 return GetPrefs()->GetFilePath(prefs::kSelectFileLastDirectory); |
712 } | 762 } |
713 | 763 |
714 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { | 764 void ProfileImpl::set_last_selected_directory(const base::FilePath& path) { |
715 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 765 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
716 } | 766 } |
717 | 767 |
718 ProfileImpl::~ProfileImpl() { | 768 ProfileImpl::~ProfileImpl() { |
719 MaybeSendDestroyedNotification(); | 769 MaybeSendDestroyedNotification(); |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1320 ProfileImpl::CreateDomainReliabilityMonitor() { | 1370 ProfileImpl::CreateDomainReliabilityMonitor() { |
1321 domain_reliability::DomainReliabilityService* service = | 1371 domain_reliability::DomainReliabilityService* service = |
1322 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1372 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
1323 GetForBrowserContext(this); | 1373 GetForBrowserContext(this); |
1324 if (!service) | 1374 if (!service) |
1325 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1375 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
1326 | 1376 |
1327 return service->CreateMonitor( | 1377 return service->CreateMonitor( |
1328 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1378 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
1329 } | 1379 } |
OLD | NEW |