Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/profiles/profile_impl.cc

Issue 2740493002: Pref service: create service at browser startup (Closed)
Patch Set: Merge Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | components/sync_preferences/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" 69 #include "chrome/browser/push_messaging/push_messaging_service_factory.h"
70 #include "chrome/browser/push_messaging/push_messaging_service_impl.h" 70 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
71 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 71 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
72 #include "chrome/browser/sessions/session_service_factory.h" 72 #include "chrome/browser/sessions/session_service_factory.h"
73 #include "chrome/browser/signin/signin_manager_factory.h" 73 #include "chrome/browser/signin/signin_manager_factory.h"
74 #include "chrome/browser/signin/signin_ui_util.h" 74 #include "chrome/browser/signin/signin_ui_util.h"
75 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h" 75 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
76 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h" 76 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
77 #include "chrome/browser/ui/startup/startup_browser_creator.h" 77 #include "chrome/browser/ui/startup/startup_browser_creator.h"
78 #include "chrome/common/chrome_constants.h" 78 #include "chrome/common/chrome_constants.h"
79 #include "chrome/common/chrome_features.h"
79 #include "chrome/common/chrome_paths.h" 80 #include "chrome/common/chrome_paths.h"
80 #include "chrome/common/chrome_paths_internal.h" 81 #include "chrome/common/chrome_paths_internal.h"
81 #include "chrome/common/chrome_switches.h" 82 #include "chrome/common/chrome_switches.h"
82 #include "chrome/common/features.h" 83 #include "chrome/common/features.h"
83 #include "chrome/common/pref_names.h" 84 #include "chrome/common/pref_names.h"
84 #include "chrome/common/url_constants.h" 85 #include "chrome/common/url_constants.h"
85 #include "chrome/grit/chromium_strings.h" 86 #include "chrome/grit/chromium_strings.h"
86 #include "components/bookmarks/browser/bookmark_model.h" 87 #include "components/bookmarks/browser/bookmark_model.h"
87 #include "components/content_settings/core/browser/cookie_settings.h" 88 #include "components/content_settings/core/browser/cookie_settings.h"
88 #include "components/content_settings/core/browser/host_content_settings_map.h" 89 #include "components/content_settings/core/browser/host_content_settings_map.h"
(...skipping 20 matching lines...) Expand all
109 #include "content/public/browser/notification_service.h" 110 #include "content/public/browser/notification_service.h"
110 #include "content/public/browser/render_process_host.h" 111 #include "content/public/browser/render_process_host.h"
111 #include "content/public/browser/storage_partition.h" 112 #include "content/public/browser/storage_partition.h"
112 #include "content/public/browser/url_data_source.h" 113 #include "content/public/browser/url_data_source.h"
113 #include "content/public/browser/user_metrics.h" 114 #include "content/public/browser/user_metrics.h"
114 #include "content/public/common/content_constants.h" 115 #include "content/public/common/content_constants.h"
115 #include "content/public/common/page_zoom.h" 116 #include "content/public/common/page_zoom.h"
116 #include "extensions/features/features.h" 117 #include "extensions/features/features.h"
117 #include "ppapi/features/features.h" 118 #include "ppapi/features/features.h"
118 #include "printing/features/features.h" 119 #include "printing/features/features.h"
120 #include "services/preferences/public/cpp/pref_store_manager_impl.h"
121 #include "services/preferences/public/interfaces/preferences.mojom.h"
119 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h" 122 #include "services/preferences/public/interfaces/tracked_preference_validation_d elegate.mojom.h"
120 #include "ui/base/l10n/l10n_util.h" 123 #include "ui/base/l10n/l10n_util.h"
121 124
122 #if defined(OS_CHROMEOS) 125 #if defined(OS_CHROMEOS)
123 #include "chrome/browser/chromeos/locale_change_guard.h" 126 #include "chrome/browser/chromeos/locale_change_guard.h"
124 #include "chrome/browser/chromeos/preferences.h" 127 #include "chrome/browser/chromeos/preferences.h"
125 #include "chrome/browser/chromeos/profiles/profile_helper.h" 128 #include "chrome/browser/chromeos/profiles/profile_helper.h"
126 #include "chrome/browser/chromeos/settings/device_settings_service.h" 129 #include "chrome/browser/chromeos/settings/device_settings_service.h"
127 #include "components/user_manager/user_manager.h" 130 #include "components/user_manager/user_manager.h"
128 #endif 131 #endif
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service( 484 scoped_refptr<safe_browsing::SafeBrowsingService> safe_browsing_service(
482 g_browser_process->safe_browsing_service()); 485 g_browser_process->safe_browsing_service());
483 if (safe_browsing_service.get()) { 486 if (safe_browsing_service.get()) {
484 pref_validation_delegate_ = 487 pref_validation_delegate_ =
485 safe_browsing_service->CreatePreferenceValidationDelegate(this); 488 safe_browsing_service->CreatePreferenceValidationDelegate(this);
486 } 489 }
487 490
488 content::BrowserContext::Initialize(this, path_); 491 content::BrowserContext::Initialize(this, path_);
489 492
490 { 493 {
494 service_manager::Connector* connector = nullptr;
495 if (base::FeatureList::IsEnabled(features::kPrefService)) {
496 connector = content::BrowserContext::GetConnectorFor(this);
497 }
491 prefs_ = chrome_prefs::CreateProfilePrefs( 498 prefs_ = chrome_prefs::CreateProfilePrefs(
492 path_, sequenced_task_runner, pref_validation_delegate_.get(), 499 path_, sequenced_task_runner, pref_validation_delegate_.get(),
493 profile_policy_connector_->policy_service(), supervised_user_settings, 500 profile_policy_connector_->policy_service(), supervised_user_settings,
494 CreateExtensionPrefStore(this, false), pref_registry_, async_prefs); 501 CreateExtensionPrefStore(this, false), pref_registry_, async_prefs,
502 connector);
495 // Register on BrowserContext. 503 // Register on BrowserContext.
496 user_prefs::UserPrefs::Set(this, prefs_.get()); 504 user_prefs::UserPrefs::Set(this, prefs_.get());
497 } 505 }
498 506
499 if (async_prefs) { 507 if (async_prefs) {
500 // Wait for the notification that prefs has been loaded 508 // Wait for the notification that prefs has been loaded
501 // (successfully or not). Note that we can use base::Unretained 509 // (successfully or not). Note that we can use base::Unretained
502 // because the PrefService is owned by this class and lives on 510 // because the PrefService is owned by this class and lives on
503 // the same thread. 511 // the same thread.
504 prefs_->AddPrefInitObserver(base::Bind( 512 prefs_->AddPrefInitObserver(base::Bind(
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 } 1044 }
1037 1045
1038 net::URLRequestContextGetter* 1046 net::URLRequestContextGetter*
1039 ProfileImpl::CreateMediaRequestContextForStoragePartition( 1047 ProfileImpl::CreateMediaRequestContextForStoragePartition(
1040 const base::FilePath& partition_path, 1048 const base::FilePath& partition_path,
1041 bool in_memory) { 1049 bool in_memory) {
1042 return io_data_ 1050 return io_data_
1043 .GetIsolatedMediaRequestContextGetter(partition_path, in_memory).get(); 1051 .GetIsolatedMediaRequestContextGetter(partition_path, in_memory).get();
1044 } 1052 }
1045 1053
1054 void ProfileImpl::RegisterInProcessServices(StaticServiceMap* services) {
1055 if (base::FeatureList::IsEnabled(features::kPrefService)) {
1056 content::ServiceInfo info;
1057 info.factory =
1058 base::Bind([]() -> std::unique_ptr<service_manager::Service> {
1059 return base::MakeUnique<prefs::PrefStoreManagerImpl>(
1060 prefs::PrefStoreManagerImpl::PrefStoreTypes());
1061 });
1062 services->insert(std::make_pair(prefs::mojom::kPrefStoreServiceName, info));
1063 }
1064 }
1065
1046 bool ProfileImpl::IsSameProfile(Profile* profile) { 1066 bool ProfileImpl::IsSameProfile(Profile* profile) {
1047 if (profile == static_cast<Profile*>(this)) 1067 if (profile == static_cast<Profile*>(this))
1048 return true; 1068 return true;
1049 Profile* otr_profile = off_the_record_profile_.get(); 1069 Profile* otr_profile = off_the_record_profile_.get();
1050 return otr_profile && profile == otr_profile; 1070 return otr_profile && profile == otr_profile;
1051 } 1071 }
1052 1072
1053 Time ProfileImpl::GetStartTime() const { 1073 Time ProfileImpl::GetStartTime() const {
1054 return start_time_; 1074 return start_time_;
1055 } 1075 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) { 1312 ProfileImpl::CreateDomainReliabilityMonitor(PrefService* local_state) {
1293 domain_reliability::DomainReliabilityService* service = 1313 domain_reliability::DomainReliabilityService* service =
1294 domain_reliability::DomainReliabilityServiceFactory::GetInstance()-> 1314 domain_reliability::DomainReliabilityServiceFactory::GetInstance()->
1295 GetForBrowserContext(this); 1315 GetForBrowserContext(this);
1296 if (!service) 1316 if (!service)
1297 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>(); 1317 return std::unique_ptr<domain_reliability::DomainReliabilityMonitor>();
1298 1318
1299 return service->CreateMonitor( 1319 return service->CreateMonitor(
1300 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO)); 1320 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO));
1301 } 1321 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | components/sync_preferences/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698