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

Side by Side Diff: chrome/browser/prefs/active_profile_pref_service.cc

Issue 2772673002: mash: switch to the new pref service (Closed)
Patch Set: Remove no longer needed tests 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
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/prefs/active_profile_pref_service.h"
6
7 #include "chrome/browser/profiles/profile_manager.h"
8 #include "content/public/browser/browser_context.h"
9 #include "mojo/public/cpp/bindings/interface_request.h"
10 #include "services/service_manager/public/cpp/connector.h"
11 #include "services/service_manager/public/cpp/interface_registry.h"
12
13 namespace prefs {
14
15 ActiveProfilePrefService::ActiveProfilePrefService() = default;
16
17 ActiveProfilePrefService::~ActiveProfilePrefService() = default;
18
19 void ActiveProfilePrefService::Connect(mojom::PrefRegistryPtr pref_registry,
20 const ConnectCallback& callback) {
21 auto* connector = content::BrowserContext::GetConnectorFor(
22 ProfileManager::GetActiveUserProfile());
23 connector->BindInterface(mojom::kPrefStoreServiceName, &connector_ptr_);
24 connector_ptr_.set_connection_error_handler(base::Bind(
25 &ActiveProfilePrefService::OnConnectError, base::Unretained(this)));
jonross 2017/03/27 14:26:38 Shutdown can lead to the deletion of ActiveProfile
tibell 2017/03/28 00:34:31 sammc@ who is wiser in the world of Mojo than me g
jonross 2017/03/28 13:57:26 Acknowledged.
26 connector_ptr_->Connect(std::move(pref_registry), callback);
27 }
28
29 void ActiveProfilePrefService::Create(
30 const service_manager::Identity& remote_identity,
31 prefs::mojom::PrefStoreConnectorRequest request) {
32 connector_bindings_.AddBinding(this, std::move(request));
33 }
34
35 void ActiveProfilePrefService::OnStart() {}
36
37 bool ActiveProfilePrefService::OnConnect(
38 const service_manager::ServiceInfo& remote_info,
39 service_manager::InterfaceRegistry* registry) {
40 // N.B. This check is important as not doing it would allow one user to read
41 // another user's prefs.
42 if (remote_info.identity.user_id() != service_manager::mojom::kRootUserID) {
43 LOG(WARNING) << "Blocked service instance="
44 << remote_info.identity.instance()
45 << ", name=" << remote_info.identity.name()
46 << ", user_id=" << remote_info.identity.user_id()
47 << " from connecting to the active profile's pref service.";
48 return false;
49 }
50 registry->AddInterface<mojom::PrefStoreConnector>(this);
51 return true;
52 }
53
54 void ActiveProfilePrefService::OnConnectError() {
55 connector_bindings_.CloseAllBindings();
56 }
57
58 } // namespace prefs
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698