Pref service: Expose local state prefs to mash as a service.
Expose local state prefs from the browser using a
InProcessPrefServiceFactory in BrowserProcessImpl and register it as a
embedded service factory in ChromeContentBrowserClient.
Add plumbing of a PrefValueStore::Delegate to PrefServiceFactory to
match PrefServiceSyncableFactory to capture the PrefStores to be
exposed via the local state pref service.
Duplicate the existing pref service manifest as "local_state" to avoid
colliding with the per-profile pref service; each service may only be
packaged in a single service so a distinct service name is required.
Bug: 714855
Change-Id: I31131be6b5c720fa28e83a81febeea9c524c3cfe
Reviewed-on: https://chromium-review.googlesource.com/557580
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Noel Gordon <[email protected]>
Reviewed-by: Bernhard Bauer <[email protected]>
Reviewed-by: Tom Sepez <[email protected]>
Commit-Queue: Sam McNally <[email protected]>
Cr-Commit-Position: refs/heads/master@{#488070}
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 99bbf83..aa35aa5 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -129,6 +129,7 @@
#include "net/url_request/url_request_context_getter.h"
#include "ppapi/features/features.h"
#include "printing/features/features.h"
+#include "services/preferences/public/cpp/in_process_service_factory.h"
#include "ui/base/idle/idle.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/message_center/message_center.h"
@@ -226,7 +227,9 @@
tearing_down_(false),
download_status_updater_(new DownloadStatusUpdater),
local_state_task_runner_(local_state_task_runner),
- cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT) {
+ cached_default_web_client_state_(shell_integration::UNKNOWN_DEFAULT),
+ pref_service_factory_(
+ base::MakeUnique<prefs::InProcessPrefServiceFactory>()) {
g_browser_process = this;
rappor::SetDefaultServiceAccessor(&GetBrowserRapporService);
platform_part_.reset(new BrowserProcessPlatformPart());
@@ -821,6 +824,11 @@
#endif
}
+prefs::InProcessPrefServiceFactory* BrowserProcessImpl::pref_service_factory()
+ const {
+ return pref_service_factory_.get();
+}
+
// static
void BrowserProcessImpl::RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterBooleanPref(prefs::kDefaultBrowserSettingEnabled,
@@ -1030,9 +1038,11 @@
// Register local state preferences.
chrome::RegisterLocalState(pref_registry.get());
+ auto delegate = pref_service_factory_->CreateDelegate();
+ delegate->InitPrefRegistry(pref_registry.get());
local_state_ = chrome_prefs::CreateLocalState(
local_state_path, local_state_task_runner_.get(), policy_service(),
- pref_registry, false);
+ pref_registry, false, std::move(delegate));
pref_change_registrar_.Init(local_state_.get());