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

Side by Side Diff: components/prefs/pref_value_store.h

Issue 2635153002: Pref service: expose all read-only PrefStores through Mojo (Closed)
Patch Set: Create and register service 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 COMPONENTS_PREFS_PREF_VALUE_STORE_H_ 5 #ifndef COMPONENTS_PREFS_PREF_VALUE_STORE_H_
6 #define COMPONENTS_PREFS_PREF_VALUE_STORE_H_ 6 #define COMPONENTS_PREFS_PREF_VALUE_STORE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // there is no higher-priority source controlling it. 110 // there is no higher-priority source controlling it.
111 bool PrefValueUserModifiable(const std::string& name) const; 111 bool PrefValueUserModifiable(const std::string& name) const;
112 112
113 // Check whether a Preference value is modifiable by an extension, i.e. 113 // Check whether a Preference value is modifiable by an extension, i.e.
114 // whether there is no higher-priority source controlling it. 114 // whether there is no higher-priority source controlling it.
115 bool PrefValueExtensionModifiable(const std::string& name) const; 115 bool PrefValueExtensionModifiable(const std::string& name) const;
116 116
117 // Update the command line PrefStore with |command_line_prefs|. 117 // Update the command line PrefStore with |command_line_prefs|.
118 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs); 118 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs);
119 119
120 private:
121 // PrefStores must be listed here in order from highest to lowest priority. 120 // PrefStores must be listed here in order from highest to lowest priority.
122 // MANAGED contains all managed preference values that are provided by 121 // MANAGED contains all managed preference values that are provided by
123 // mandatory policies (e.g. Windows Group Policy or cloud policy). 122 // mandatory policies (e.g. Windows Group Policy or cloud policy).
124 // SUPERVISED_USER contains preferences that are valid for supervised users. 123 // SUPERVISED_USER contains preferences that are valid for supervised users.
125 // EXTENSION contains preference values set by extensions. 124 // EXTENSION contains preference values set by extensions.
126 // COMMAND_LINE contains preference values set by command-line switches. 125 // COMMAND_LINE contains preference values set by command-line switches.
127 // USER contains all user-set preference values. 126 // USER contains all user-set preference values.
128 // RECOMMENDED contains all preferences that are provided by recommended 127 // RECOMMENDED contains all preferences that are provided by recommended
129 // policies. 128 // policies.
130 // DEFAULT contains all application default preference values. 129 // DEFAULT contains all application default preference values.
131 enum PrefStoreType { 130 enum PrefStoreType {
Sam McNally 2017/02/24 04:14:53 Types before constructors.
tibell 2017/02/27 00:02:53 Done.
132 // INVALID_STORE is not associated with an actual PrefStore but used as 131 // INVALID_STORE is not associated with an actual PrefStore but used as
133 // an invalid marker, e.g. as a return value. 132 // an invalid marker, e.g. as a return value.
134 INVALID_STORE = -1, 133 INVALID_STORE = -1,
135 MANAGED_STORE = 0, 134 MANAGED_STORE = 0,
136 SUPERVISED_USER_STORE, 135 SUPERVISED_USER_STORE,
137 EXTENSION_STORE, 136 EXTENSION_STORE,
138 COMMAND_LINE_STORE, 137 COMMAND_LINE_STORE,
139 USER_STORE, 138 USER_STORE,
140 RECOMMENDED_STORE, 139 RECOMMENDED_STORE,
141 DEFAULT_STORE, 140 DEFAULT_STORE,
142 PREF_STORE_TYPE_MAX = DEFAULT_STORE 141 PREF_STORE_TYPE_MAX = DEFAULT_STORE
143 }; 142 };
144 143
144 private:
145 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors 145 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors
146 // the PrefStore for changes, forwarding notifications to PrefValueStore. This 146 // the PrefStore for changes, forwarding notifications to PrefValueStore. This
147 // indirection is here for the sake of disambiguating notifications from the 147 // indirection is here for the sake of disambiguating notifications from the
148 // individual PrefStores. 148 // individual PrefStores.
149 class PrefStoreKeeper : public PrefStore::Observer { 149 class PrefStoreKeeper : public PrefStore::Observer {
150 public: 150 public:
151 PrefStoreKeeper(); 151 PrefStoreKeeper();
152 ~PrefStoreKeeper() override; 152 ~PrefStoreKeeper() override;
153 153
154 // Takes ownership of |pref_store|. 154 // Takes ownership of |pref_store|.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 // A mapping of preference names to their registered types. 251 // A mapping of preference names to their registered types.
252 PrefTypeMap pref_types_; 252 PrefTypeMap pref_types_;
253 253
254 // True if not all of the PrefStores were initialized successfully. 254 // True if not all of the PrefStores were initialized successfully.
255 bool initialization_failed_; 255 bool initialization_failed_;
256 256
257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); 257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore);
258 }; 258 };
259 259
260 namespace std {
261
262 template <>
263 struct hash<PrefValueStore::PrefStoreType> {
264 size_t operator()(const PrefValueStore::PrefStoreType& type) const {
265 return static_cast<std::size_t>(type);
Sam McNally 2017/02/24 04:14:53 size_t for an enum with a -1?
tibell 2017/02/27 00:02:53 Done.
266 }
267 };
268
269 } // namespace std
270
260 #endif // COMPONENTS_PREFS_PREF_VALUE_STORE_H_ 271 #endif // COMPONENTS_PREFS_PREF_VALUE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698