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

Unified Diff: chrome/browser/prefs/active_profile_pref_service.cc

Issue 2772673002: mash: switch to the new pref service (Closed)
Patch Set: Address review comments 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/prefs/active_profile_pref_service.h ('k') | chrome/browser/prefs/forwarder_manifest.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/prefs/active_profile_pref_service.cc
diff --git a/chrome/browser/prefs/active_profile_pref_service.cc b/chrome/browser/prefs/active_profile_pref_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..a99165455b5b78628bda53beb786b6564c656fc1
--- /dev/null
+++ b/chrome/browser/prefs/active_profile_pref_service.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/prefs/active_profile_pref_service.h"
+
+#include "chrome/browser/profiles/profile_manager.h"
+#include "content/public/browser/browser_context.h"
+#include "mojo/public/cpp/bindings/interface_request.h"
+#include "services/service_manager/public/cpp/connector.h"
+#include "services/service_manager/public/cpp/interface_registry.h"
+
+ActiveProfilePrefService::ActiveProfilePrefService() = default;
+
+ActiveProfilePrefService::~ActiveProfilePrefService() = default;
+
+void ActiveProfilePrefService::Connect(
+ prefs::mojom::PrefRegistryPtr pref_registry,
+ const ConnectCallback& callback) {
+ auto* connector = content::BrowserContext::GetConnectorFor(
+ ProfileManager::GetActiveUserProfile());
+ connector->BindInterface(prefs::mojom::kPrefStoreServiceName,
+ &connector_ptr_);
+ connector_ptr_.set_connection_error_handler(base::Bind(
+ &ActiveProfilePrefService::OnConnectError, base::Unretained(this)));
+ connector_ptr_->Connect(std::move(pref_registry), callback);
+}
+
+void ActiveProfilePrefService::Create(
+ const service_manager::Identity& remote_identity,
+ prefs::mojom::PrefStoreConnectorRequest request) {
+ connector_bindings_.AddBinding(this, std::move(request));
+}
+
+void ActiveProfilePrefService::OnStart() {}
+
+bool ActiveProfilePrefService::OnConnect(
+ const service_manager::ServiceInfo& remote_info,
+ service_manager::InterfaceRegistry* registry) {
+ // N.B. This check is important as not doing it would allow one user to read
+ // another user's prefs.
+ if (remote_info.identity.user_id() != service_manager::mojom::kRootUserID) {
+ LOG(WARNING) << "Blocked service instance="
+ << remote_info.identity.instance()
+ << ", name=" << remote_info.identity.name()
+ << ", user_id=" << remote_info.identity.user_id()
+ << " from connecting to the active profile's pref service.";
+ return false;
+ }
+ registry->AddInterface<prefs::mojom::PrefStoreConnector>(this);
+ return true;
+}
+
+void ActiveProfilePrefService::OnConnectError() {
+ connector_bindings_.CloseAllBindings();
+}
« no previous file with comments | « chrome/browser/prefs/active_profile_pref_service.h ('k') | chrome/browser/prefs/forwarder_manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698