| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ |
| 6 #define CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ | 6 #define CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ |
| 7 | 7 |
| 8 #include <vector> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "components/prefs/pref_value_store.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "services/preferences/public/interfaces/preferences.mojom.h" | 13 #include "services/preferences/public/interfaces/preferences.mojom.h" |
| 11 #include "services/service_manager/public/cpp/interface_factory.h" | 14 #include "services/service_manager/public/cpp/interface_factory.h" |
| 12 #include "services/service_manager/public/cpp/service.h" | 15 #include "services/service_manager/public/cpp/service.h" |
| 13 | 16 |
| 14 // A |prefs::mojom::PrefStoreConnector| implementation that forwards connection | 17 // A |prefs::mojom::PrefStoreConnector| implementation that forwards connection |
| 15 // calls from the root service to the active profile. Used by mash, which runs | 18 // calls from the root service to the active profile. Used by mash, which runs |
| 16 // as the root user, to talk to prefs. | 19 // as the root user, to talk to prefs. |
| 17 // | 20 // |
| 18 // TODO(http://crbug.com/705347): Once mash supports several profiles, remove | 21 // TODO(http://crbug.com/705347): Once mash supports several profiles, remove |
| 19 // this class and the forwarder service. | 22 // this class and the forwarder service. |
| 20 class ActiveProfilePrefService : public prefs::mojom::PrefStoreConnector, | 23 class ActiveProfilePrefService : public prefs::mojom::PrefStoreConnector, |
| 21 public service_manager::InterfaceFactory< | 24 public service_manager::InterfaceFactory< |
| 22 prefs::mojom::PrefStoreConnector>, | 25 prefs::mojom::PrefStoreConnector>, |
| 23 public service_manager::Service { | 26 public service_manager::Service { |
| 24 public: | 27 public: |
| 25 ActiveProfilePrefService(); | 28 ActiveProfilePrefService(); |
| 26 ~ActiveProfilePrefService() override; | 29 ~ActiveProfilePrefService() override; |
| 27 | 30 |
| 28 private: | 31 private: |
| 29 // prefs::mojom::PrefStoreConnector: | 32 // prefs::mojom::PrefStoreConnector: |
| 30 void Connect(prefs::mojom::PrefRegistryPtr pref_registry, | 33 void Connect( |
| 31 const ConnectCallback& callback) override; | 34 prefs::mojom::PrefRegistryPtr pref_registry, |
| 35 const std::vector<PrefValueStore::PrefStoreType>& already_connected_types, |
| 36 const ConnectCallback& callback) override; |
| 32 | 37 |
| 33 // service_manager::InterfaceFactory<PrefStoreConnector>: | 38 // service_manager::InterfaceFactory<PrefStoreConnector>: |
| 34 void Create(const service_manager::Identity& remote_identity, | 39 void Create(const service_manager::Identity& remote_identity, |
| 35 prefs::mojom::PrefStoreConnectorRequest request) override; | 40 prefs::mojom::PrefStoreConnectorRequest request) override; |
| 36 | 41 |
| 37 // service_manager::Service: | 42 // service_manager::Service: |
| 38 void OnStart() override; | 43 void OnStart() override; |
| 39 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 44 bool OnConnect(const service_manager::ServiceInfo& remote_info, |
| 40 service_manager::InterfaceRegistry* registry) override; | 45 service_manager::InterfaceRegistry* registry) override; |
| 41 | 46 |
| 42 // Called if forwarding the connection request to the per-profile service | 47 // Called if forwarding the connection request to the per-profile service |
| 43 // instance failed. | 48 // instance failed. |
| 44 void OnConnectError(); | 49 void OnConnectError(); |
| 45 | 50 |
| 46 prefs::mojom::PrefStoreConnectorPtr connector_ptr_; | 51 prefs::mojom::PrefStoreConnectorPtr connector_ptr_; |
| 47 mojo::BindingSet<prefs::mojom::PrefStoreConnector> connector_bindings_; | 52 mojo::BindingSet<prefs::mojom::PrefStoreConnector> connector_bindings_; |
| 48 | 53 |
| 49 DISALLOW_COPY_AND_ASSIGN(ActiveProfilePrefService); | 54 DISALLOW_COPY_AND_ASSIGN(ActiveProfilePrefService); |
| 50 }; | 55 }; |
| 51 | 56 |
| 52 #endif // CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ | 57 #endif // CHROME_BROWSER_PREFS_ACTIVE_PROFILE_PREF_SERVICE_H_ |
| OLD | NEW |