| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 32 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 33 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
| 34 #include "chrome/browser/chrome_notification_types.h" | 34 #include "chrome/browser/chrome_notification_types.h" |
| 35 #include "chrome/browser/content_settings/cookie_settings.h" | 35 #include "chrome/browser/content_settings/cookie_settings.h" |
| 36 #include "chrome/browser/dom_distiller/profile_utils.h" | 36 #include "chrome/browser/dom_distiller/profile_utils.h" |
| 37 #include "chrome/browser/domain_reliability/service_factory.h" | 37 #include "chrome/browser/domain_reliability/service_factory.h" |
| 38 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 38 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
| 39 #include "chrome/browser/download/download_service.h" | 39 #include "chrome/browser/download/download_service.h" |
| 40 #include "chrome/browser/download/download_service_factory.h" | 40 #include "chrome/browser/download/download_service_factory.h" |
| 41 #include "chrome/browser/history/top_sites.h" | 41 #include "chrome/browser/history/top_sites.h" |
| 42 #include "chrome/browser/net/chrome_net_log.h" | |
| 43 #include "chrome/browser/net/net_pref_observer.h" | 42 #include "chrome/browser/net/net_pref_observer.h" |
| 44 #include "chrome/browser/net/predictor.h" | 43 #include "chrome/browser/net/predictor.h" |
| 45 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 44 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 46 #include "chrome/browser/net/proxy_service_factory.h" | 45 #include "chrome/browser/net/proxy_service_factory.h" |
| 47 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" | |
| 48 #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings_fact
ory.h" | |
| 49 #include "chrome/browser/net/ssl_config_service_manager.h" | 46 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 50 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 47 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 51 #include "chrome/browser/plugins/plugin_prefs.h" | 48 #include "chrome/browser/plugins/plugin_prefs.h" |
| 52 #include "chrome/browser/policy/profile_policy_connector.h" | 49 #include "chrome/browser/policy/profile_policy_connector.h" |
| 53 #include "chrome/browser/policy/profile_policy_connector_factory.h" | 50 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 54 #include "chrome/browser/prefs/browser_prefs.h" | 51 #include "chrome/browser/prefs/browser_prefs.h" |
| 55 #include "chrome/browser/prefs/chrome_pref_service_factory.h" | 52 #include "chrome/browser/prefs/chrome_pref_service_factory.h" |
| 56 #include "chrome/browser/prefs/pref_service_syncable.h" | 53 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 57 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" | 54 #include "chrome/browser/prefs/tracked/tracked_preference_validation_delegate.h" |
| 58 #include "chrome/browser/prerender/prerender_manager_factory.h" | 55 #include "chrome/browser/prerender/prerender_manager_factory.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 76 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 73 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
| 77 #include "chrome/common/chrome_constants.h" | 74 #include "chrome/common/chrome_constants.h" |
| 78 #include "chrome/common/chrome_paths_internal.h" | 75 #include "chrome/common/chrome_paths_internal.h" |
| 79 #include "chrome/common/chrome_switches.h" | 76 #include "chrome/common/chrome_switches.h" |
| 80 #include "chrome/common/chrome_version_info.h" | 77 #include "chrome/common/chrome_version_info.h" |
| 81 #include "chrome/common/pref_names.h" | 78 #include "chrome/common/pref_names.h" |
| 82 #include "chrome/common/url_constants.h" | 79 #include "chrome/common/url_constants.h" |
| 83 #include "chrome/grit/chromium_strings.h" | 80 #include "chrome/grit/chromium_strings.h" |
| 84 #include "components/bookmarks/browser/bookmark_model.h" | 81 #include "components/bookmarks/browser/bookmark_model.h" |
| 85 #include "components/content_settings/core/browser/host_content_settings_map.h" | 82 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 86 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_conf
igurator.h" | |
| 87 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref
s.h" | |
| 88 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_sett
ings.h" | |
| 89 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_stat
istics_prefs.h" | |
| 90 #include "components/data_reduction_proxy/core/common/data_reduction_proxy_param
s.h" | |
| 91 #include "components/domain_reliability/monitor.h" | 83 #include "components/domain_reliability/monitor.h" |
| 92 #include "components/domain_reliability/service.h" | 84 #include "components/domain_reliability/service.h" |
| 93 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 85 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 94 #include "components/metrics/metrics_service.h" | 86 #include "components/metrics/metrics_service.h" |
| 95 #include "components/pref_registry/pref_registry_syncable.h" | 87 #include "components/pref_registry/pref_registry_syncable.h" |
| 96 #include "components/signin/core/browser/signin_manager.h" | 88 #include "components/signin/core/browser/signin_manager.h" |
| 97 #include "components/startup_metric_utils/startup_metric_utils.h" | 89 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 98 #include "components/ui/zoom/zoom_event_manager.h" | 90 #include "components/ui/zoom/zoom_event_manager.h" |
| 99 #include "components/url_fixer/url_fixer.h" | 91 #include "components/url_fixer/url_fixer.h" |
| 100 #include "components/user_prefs/user_prefs.h" | 92 #include "components/user_prefs/user_prefs.h" |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 StartupBrowserCreator::GetSessionStartupPref( | 627 StartupBrowserCreator::GetSessionStartupPref( |
| 636 *base::CommandLine::ForCurrentProcess(), this).type; | 628 *base::CommandLine::ForCurrentProcess(), this).type; |
| 637 #endif | 629 #endif |
| 638 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = | 630 content::CookieStoreConfig::SessionCookieMode session_cookie_mode = |
| 639 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; | 631 content::CookieStoreConfig::PERSISTANT_SESSION_COOKIES; |
| 640 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || | 632 if (GetLastSessionExitType() == Profile::EXIT_CRASHED || |
| 641 startup_pref_type == SessionStartupPref::LAST) { | 633 startup_pref_type == SessionStartupPref::LAST) { |
| 642 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; | 634 session_cookie_mode = content::CookieStoreConfig::RESTORED_SESSION_COOKIES; |
| 643 } | 635 } |
| 644 | 636 |
| 645 ChromeNetLog* const net_log = g_browser_process->io_thread()->net_log(); | |
| 646 | |
| 647 base::Callback<void(bool)> data_reduction_proxy_unavailable; | |
| 648 scoped_ptr<data_reduction_proxy::DataReductionProxyParams> | |
| 649 data_reduction_proxy_params; | |
| 650 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> configurator; | |
| 651 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs> | |
| 652 data_reduction_proxy_statistics_prefs; | |
| 653 scoped_ptr<data_reduction_proxy::DataReductionProxyEventStore> event_store; | |
| 654 DataReductionProxyChromeSettings* data_reduction_proxy_chrome_settings = | |
| 655 DataReductionProxyChromeSettingsFactory::GetForBrowserContext(this); | |
| 656 data_reduction_proxy_params = | |
| 657 data_reduction_proxy_chrome_settings->params()->Clone(); | |
| 658 data_reduction_proxy_unavailable = | |
| 659 base::Bind( | |
| 660 &data_reduction_proxy::DataReductionProxySettings::SetUnreachable, | |
| 661 base::Unretained(data_reduction_proxy_chrome_settings)); | |
| 662 // The event_store is used by DataReductionProxyChromeSettings, configurator, | |
| 663 // and ProfileIOData. Ownership is passed to the latter via | |
| 664 // ProfileIOData::Handle, which is only destroyed after | |
| 665 // BrowserContextKeyedServices, including DataReductionProxyChromeSettings | |
| 666 event_store.reset( | |
| 667 new data_reduction_proxy::DataReductionProxyEventStore( | |
| 668 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI))); | |
| 669 // The configurator is used by DataReductionProxyChromeSettings and | |
| 670 // ProfileIOData. Ownership is passed to the latter via ProfileIOData::Handle, | |
| 671 // which is only destroyed after BrowserContextKeyedServices, | |
| 672 // including DataReductionProxyChromeSettings. | |
| 673 configurator.reset( | |
| 674 new data_reduction_proxy::DataReductionProxyConfigurator( | |
| 675 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | |
| 676 net_log, | |
| 677 event_store.get())); | |
| 678 // Retain a raw pointer to use for initialization of data reduction proxy | |
| 679 // settings after ownership is passed | |
| 680 data_reduction_proxy::DataReductionProxyEventStore* | |
| 681 data_reduction_proxy_event_store = event_store.get(); | |
| 682 // Retain a raw pointer to use for initialization of data reduction proxy | |
| 683 // settings after ownership is passed. | |
| 684 data_reduction_proxy::DataReductionProxyConfigurator* | |
| 685 data_reduction_proxy_configurator = configurator.get(); | |
| 686 #if defined(OS_ANDROID) || defined(OS_IOS) | |
| 687 // On mobile we write data reduction proxy prefs directly to the pref service. | |
| 688 // On desktop we store data reduction proxy prefs in memory, writing to disk | |
| 689 // every 60 minutes and on termination. Shutdown hooks must be added for | |
| 690 // Android and iOS in order for non-zero delays to be supported. | |
| 691 // (http://crbug.com/408264) | |
| 692 base::TimeDelta commit_delay = base::TimeDelta(); | |
| 693 #else | |
| 694 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | |
| 695 #endif | |
| 696 // TODO(bengr): Remove this in M-43. | |
| 697 data_reduction_proxy::MigrateStatisticsPrefs(g_browser_process->local_state(), | |
| 698 prefs_.get()); | |
| 699 data_reduction_proxy_statistics_prefs = | |
| 700 scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>( | |
| 701 new data_reduction_proxy::DataReductionProxyStatisticsPrefs( | |
| 702 prefs_.get(), | |
| 703 base::MessageLoopProxy::current(), | |
| 704 commit_delay)); | |
| 705 data_reduction_proxy_chrome_settings->SetDataReductionProxyStatisticsPrefs( | |
| 706 data_reduction_proxy_statistics_prefs.get()); | |
| 707 | |
| 708 // Make sure we initialize the ProfileIOData after everything else has been | 637 // Make sure we initialize the ProfileIOData after everything else has been |
| 709 // initialized that we might be reading from the IO thread. | 638 // initialized that we might be reading from the IO thread. |
| 710 | 639 |
| 711 io_data_.Init(cookie_path, channel_id_path, cache_path, | 640 io_data_.Init(cookie_path, channel_id_path, cache_path, |
| 712 cache_max_size, media_cache_path, media_cache_max_size, | 641 cache_max_size, media_cache_path, media_cache_max_size, |
| 713 extensions_cookie_path, GetPath(), infinite_cache_path, | 642 extensions_cookie_path, GetPath(), infinite_cache_path, |
| 714 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), | 643 predictor_, session_cookie_mode, GetSpecialStoragePolicy(), |
| 715 CreateDomainReliabilityMonitor(local_state), | 644 CreateDomainReliabilityMonitor(local_state)); |
| 716 data_reduction_proxy_unavailable, | |
| 717 configurator.Pass(), | |
| 718 data_reduction_proxy_params.Pass(), | |
| 719 data_reduction_proxy_statistics_prefs.Pass(), | |
| 720 event_store.Pass()); | |
| 721 data_reduction_proxy_chrome_settings->InitDataReductionProxySettings( | |
| 722 data_reduction_proxy_configurator, | |
| 723 prefs_.get(), | |
| 724 g_browser_process->local_state(), | |
| 725 GetRequestContext(), | |
| 726 net_log, | |
| 727 data_reduction_proxy_event_store); | |
| 728 | 645 |
| 729 #if defined(ENABLE_PLUGINS) | 646 #if defined(ENABLE_PLUGINS) |
| 730 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 647 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 731 PluginPrefs::GetForProfile(this).get(), | 648 PluginPrefs::GetForProfile(this).get(), |
| 732 io_data_.GetResourceContextNoInit()); | 649 io_data_.GetResourceContextNoInit()); |
| 733 #endif | 650 #endif |
| 734 | 651 |
| 735 // Delay README creation to not impact startup performance. | 652 // Delay README creation to not impact startup performance. |
| 736 BrowserThread::PostDelayedTask( | 653 BrowserThread::PostDelayedTask( |
| 737 BrowserThread::FILE, FROM_HERE, | 654 BrowserThread::FILE, FROM_HERE, |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { | 1338 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { |
| 1422 domain_reliability::DomainReliabilityService* service = | 1339 domain_reliability::DomainReliabilityService* service = |
| 1423 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> | 1340 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> |
| 1424 GetForBrowserContext(this); | 1341 GetForBrowserContext(this); |
| 1425 if (!service) | 1342 if (!service) |
| 1426 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); | 1343 return scoped_ptr<domain_reliability::DomainReliabilityMonitor>(); |
| 1427 | 1344 |
| 1428 return service->CreateMonitor( | 1345 return service->CreateMonitor( |
| 1429 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | 1346 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| 1430 } | 1347 } |
| OLD | NEW |