OLD | NEW |
---|---|
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 BASE_PREFS_PREF_VALUE_STORE_H_ | 5 #ifndef BASE_PREFS_PREF_VALUE_STORE_H_ |
6 #define BASE_PREFS_PREF_VALUE_STORE_H_ | 6 #define BASE_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 14 matching lines...) Expand all Loading... | |
25 // the value of a Preference from the source with the highest priority, and | 25 // the value of a Preference from the source with the highest priority, and |
26 // allows setting user-defined values for preferences that are not managed. | 26 // allows setting user-defined values for preferences that are not managed. |
27 // | 27 // |
28 // Unless otherwise explicitly noted, all of the methods of this class must | 28 // Unless otherwise explicitly noted, all of the methods of this class must |
29 // be called on the UI thread. | 29 // be called on the UI thread. |
30 class BASE_PREFS_EXPORT PrefValueStore { | 30 class BASE_PREFS_EXPORT PrefValueStore { |
31 public: | 31 public: |
32 typedef base::Callback<void(const std::string&)> PrefChangedCallback; | 32 typedef base::Callback<void(const std::string&)> PrefChangedCallback; |
33 | 33 |
34 // In decreasing order of precedence: | 34 // In decreasing order of precedence: |
35 // |managed_prefs| contains all preferences from mandatory policies. | 35 // |managed_prefs| contains all preferences from mandatory policies. |
bartfab (slow)
2013/08/29 12:02:02
|managed_user_prefs| is missing in this comment.
| |
36 // |extension_prefs| contains preference values set by extensions. | 36 // |extension_prefs| contains preference values set by extensions. |
37 // |command_line_prefs| contains preference values set by command-line | 37 // |command_line_prefs| contains preference values set by command-line |
38 // switches. | 38 // switches. |
39 // |user_prefs| contains all user-set preference values. | 39 // |user_prefs| contains all user-set preference values. |
40 // |recommended_prefs| contains all preferences from recommended policies. | 40 // |recommended_prefs| contains all preferences from recommended policies. |
41 // |default_prefs| contains application-default preference values. It must | 41 // |default_prefs| contains application-default preference values. It must |
42 // be non-null if any preferences are to be registered. | 42 // be non-null if any preferences are to be registered. |
43 // | 43 // |
44 // |pref_notifier| facilitates broadcasting preference change notifications | 44 // |pref_notifier| facilitates broadcasting preference change notifications |
45 // to the world. | 45 // to the world. |
46 PrefValueStore(PrefStore* managed_prefs, | 46 PrefValueStore(PrefStore* managed_prefs, |
47 PrefStore* managed_user_prefs, | |
47 PrefStore* extension_prefs, | 48 PrefStore* extension_prefs, |
48 PrefStore* command_line_prefs, | 49 PrefStore* command_line_prefs, |
49 PrefStore* user_prefs, | 50 PrefStore* user_prefs, |
50 PrefStore* recommended_prefs, | 51 PrefStore* recommended_prefs, |
51 PrefStore* default_prefs, | 52 PrefStore* default_prefs, |
52 PrefNotifier* pref_notifier); | 53 PrefNotifier* pref_notifier); |
53 virtual ~PrefValueStore(); | 54 virtual ~PrefValueStore(); |
54 | 55 |
55 // Creates a clone of this PrefValueStore with PrefStores overwritten | 56 // Creates a clone of this PrefValueStore with PrefStores overwritten |
56 // by the parameters passed, if unequal NULL. | 57 // by the parameters passed, if unequal NULL. |
57 PrefValueStore* CloneAndSpecialize(PrefStore* managed_prefs, | 58 PrefValueStore* CloneAndSpecialize(PrefStore* managed_prefs, |
59 PrefStore* managed_user_prefs, | |
58 PrefStore* extension_prefs, | 60 PrefStore* extension_prefs, |
59 PrefStore* command_line_prefs, | 61 PrefStore* command_line_prefs, |
60 PrefStore* user_prefs, | 62 PrefStore* user_prefs, |
61 PrefStore* recommended_prefs, | 63 PrefStore* recommended_prefs, |
62 PrefStore* default_prefs, | 64 PrefStore* default_prefs, |
63 PrefNotifier* pref_notifier); | 65 PrefNotifier* pref_notifier); |
64 | 66 |
65 // A PrefValueStore can have exactly one callback that is directly | 67 // A PrefValueStore can have exactly one callback that is directly |
66 // notified of preferences changing in the store. This does not | 68 // notified of preferences changing in the store. This does not |
67 // filter through the PrefNotifier mechanism, which may not forward | 69 // filter through the PrefNotifier mechanism, which may not forward |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // whether there is no higher-priority source controlling it. | 111 // whether there is no higher-priority source controlling it. |
110 bool PrefValueExtensionModifiable(const char* name) const; | 112 bool PrefValueExtensionModifiable(const char* name) const; |
111 | 113 |
112 // Update the command line PrefStore with |command_line_prefs|. | 114 // Update the command line PrefStore with |command_line_prefs|. |
113 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs); | 115 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs); |
114 | 116 |
115 private: | 117 private: |
116 // PrefStores must be listed here in order from highest to lowest priority. | 118 // PrefStores must be listed here in order from highest to lowest priority. |
117 // MANAGED contains all managed preference values that are provided by | 119 // MANAGED contains all managed preference values that are provided by |
118 // mandatory policies (e.g. Windows Group Policy or cloud policy). | 120 // mandatory policies (e.g. Windows Group Policy or cloud policy). |
121 // MANAGED_USER contains preferences that are valid for managed users. | |
119 // EXTENSION contains preference values set by extensions. | 122 // EXTENSION contains preference values set by extensions. |
120 // COMMAND_LINE contains preference values set by command-line switches. | 123 // COMMAND_LINE contains preference values set by command-line switches. |
121 // USER contains all user-set preference values. | 124 // USER contains all user-set preference values. |
122 // RECOMMENDED contains all preferences that are provided by recommended | 125 // RECOMMENDED contains all preferences that are provided by recommended |
123 // policies. | 126 // policies. |
124 // DEFAULT contains all application default preference values. | 127 // DEFAULT contains all application default preference values. |
125 enum PrefStoreType { | 128 enum PrefStoreType { |
126 // INVALID_STORE is not associated with an actual PrefStore but used as | 129 // INVALID_STORE is not associated with an actual PrefStore but used as |
127 // an invalid marker, e.g. as a return value. | 130 // an invalid marker, e.g. as a return value. |
128 INVALID_STORE = -1, | 131 INVALID_STORE = -1, |
129 MANAGED_STORE = 0, | 132 MANAGED_STORE = 0, |
133 MANAGED_USER_STORE, | |
130 EXTENSION_STORE, | 134 EXTENSION_STORE, |
131 COMMAND_LINE_STORE, | 135 COMMAND_LINE_STORE, |
132 USER_STORE, | 136 USER_STORE, |
133 RECOMMENDED_STORE, | 137 RECOMMENDED_STORE, |
134 DEFAULT_STORE, | 138 DEFAULT_STORE, |
135 PREF_STORE_TYPE_MAX = DEFAULT_STORE | 139 PREF_STORE_TYPE_MAX = DEFAULT_STORE |
136 }; | 140 }; |
137 | 141 |
138 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors | 142 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors |
139 // the PrefStore for changes, forwarding notifications to PrefValueStore. This | 143 // the PrefStore for changes, forwarding notifications to PrefValueStore. This |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 // A mapping of preference names to their registered types. | 255 // A mapping of preference names to their registered types. |
252 PrefTypeMap pref_types_; | 256 PrefTypeMap pref_types_; |
253 | 257 |
254 // True if not all of the PrefStores were initialized successfully. | 258 // True if not all of the PrefStores were initialized successfully. |
255 bool initialization_failed_; | 259 bool initialization_failed_; |
256 | 260 |
257 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 261 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
258 }; | 262 }; |
259 | 263 |
260 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ | 264 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ |
OLD | NEW |