Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 module prefs.mojom; | 5 module prefs.mojom; |
| 6 | 6 |
| 7 import "mojo/common/values.mojom"; | 7 import "mojo/common/values.mojom"; |
| 8 | 8 |
| 9 const string kServiceName = "preferences"; | 9 const string kServiceName = "preferences"; |
| 10 | 10 |
| 11 // Used for the creation of a PreferencesService and to ensure that the | 11 // Used for the creation of a PreferencesService and to ensure that the |
| 12 // PreferencesServiceClient is bound at creation time. | 12 // PreferencesServiceClient is bound at creation time. |
| 13 interface PreferencesServiceFactory { | 13 interface PreferencesServiceFactory { |
| 14 // Creates a PreferencesService bound to the provided |observer|. | 14 // Creates a PreferencesService bound to the provided |observer|. |
| 15 Create(PreferencesServiceClient observer, PreferencesService& service); | 15 Create(PreferencesServiceClient observer, PreferencesService& service); |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 // Used to subscribe to preference changes within PreferenceManager. After | 18 // Used to subscribe to preference changes within PreferenceManager. After |
| 19 // requesting to observe, the current values for all requested keys are sent. | 19 // requesting to observe, the current values for all requested keys are sent. |
| 20 interface PreferencesServiceClient { | 20 interface PreferencesServiceClient { |
| 21 OnPreferencesChanged(mojo.common.mojom.DictionaryValue preferences); | 21 OnPreferencesChanged(mojo.common.mojom.DictionaryValue preferences); |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 // Manages actual read/write of preference data. Accepts observers who subscribe | 24 // Manages actual read/write of preference data. Accepts observers who subscribe |
| 25 // to preferences, notifying them of changes. | 25 // to preferences, notifying them of changes. |
| 26 interface PreferencesService { | 26 interface PreferencesService { |
| 27 SetPreferences(mojo.common.mojom.DictionaryValue preferences); | 27 SetPreferences(mojo.common.mojom.DictionaryValue preferences); |
| 28 Subscribe(array<string> preferences); | 28 Subscribe(array<string> preferences); |
| 29 }; | 29 }; |
| 30 | |
| 31 const string kPrefStoreServiceName = "preferences2"; | |
| 32 | |
| 33 // The know pref store types. | |
| 34 // | |
| 35 // Should be kept in sync with PrefValueStore::PrefStoreType. | |
| 36 enum PrefStoreType { | |
| 37 MANAGED, | |
| 38 SUPERVISED_USER, | |
| 39 EXTENSION, | |
| 40 COMMAND_LINE, | |
| 41 USER, | |
| 42 RECOMMENDED, | |
| 43 DEFAULT, | |
| 44 }; | |
| 45 | |
| 46 // Allows observing changes to prefs stored in a |PrefStore|. | |
| 47 interface PrefStoreObserver { | |
| 48 // The preference with the given |key| has changed. If |value| is null then | |
| 49 // the preference was deleted. | |
| 50 OnPrefChanged(string key, mojo.common.mojom.Value? value); | |
| 51 | |
| 52 // The PrefStore has been initialized (asynchronously). | |
| 53 OnInitializationCompleted(bool succeeded); | |
| 54 }; | |
| 55 | |
| 56 // Captures the connections to a PrefStore by supplying the initial state of the | |
| 57 // store and a handle to receive notifications on. | |
| 58 struct PrefStoreConnection { | |
| 59 // Handle to receive updates on. | |
| 60 PrefStoreObserver& observer; | |
| 61 | |
| 62 // Initial values of the PrefStore. These will not be communicated through | |
| 63 // OnPrefChanged. | |
| 64 mojo.common.mojom.DictionaryValue initial_prefs; | |
| 65 | |
| 66 // Is the PrefStore initialized? If not it should not be used before | |
| 67 // OnInitializationCompleted has been called. | |
| 68 bool is_initialized; | |
|
Sam McNally
2017/02/27 03:22:20
Can we get rid of this?
| |
| 69 }; | |
| 70 | |
| 71 // Manages actual read of preference data. Accepts observers who subscribe to | |
| 72 // preferences, notifying them of changes. | |
| 73 interface PrefStore { | |
| 74 // Add an observer of changes. This current values of all prefs will not be | |
| 75 // communicated through a call to |observer| but instead be returned in | |
| 76 // |initial_prefs|. | |
| 77 AddObserver() => (PrefStoreConnection connection); | |
| 78 }; | |
| 79 | |
| 80 // Manages a registry of all pref stores. Registered pref stores can be | |
| 81 // connected to through the |PrefStoreConnector| interface. | |
| 82 interface PrefStoreRegistry { | |
| 83 // Register a pref store. | |
| 84 Register(PrefStoreType type, PrefStore pref_store); | |
| 85 }; | |
| 86 | |
| 87 // Allows connections to pref stores registered with |PrefStoreRegistry|. | |
| 88 interface PrefStoreConnector { | |
| 89 // Connect to all registered pref stores, retrieving the current values of all | |
| 90 // prefs in each store and an |observer| interfaces through which updates can | |
| 91 // be received. | |
| 92 Connect() => (map<PrefStoreType, PrefStoreConnection> connections); | |
| 93 }; | |
| OLD | NEW |