| 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 15 matching lines...) Expand all Loading... |
| 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. |
| 36 // |supervised_user_prefs| contains all preferences from supervised user |
| 37 // settings, i.e. settings configured for a supervised user by their |
| 38 // custodian. |
| 36 // |extension_prefs| contains preference values set by extensions. | 39 // |extension_prefs| contains preference values set by extensions. |
| 37 // |command_line_prefs| contains preference values set by command-line | 40 // |command_line_prefs| contains preference values set by command-line |
| 38 // switches. | 41 // switches. |
| 39 // |user_prefs| contains all user-set preference values. | 42 // |user_prefs| contains all user-set preference values. |
| 40 // |recommended_prefs| contains all preferences from recommended policies. | 43 // |recommended_prefs| contains all preferences from recommended policies. |
| 41 // |default_prefs| contains application-default preference values. It must | 44 // |default_prefs| contains application-default preference values. It must |
| 42 // be non-null if any preferences are to be registered. | 45 // be non-null if any preferences are to be registered. |
| 43 // | 46 // |
| 44 // |pref_notifier| facilitates broadcasting preference change notifications | 47 // |pref_notifier| facilitates broadcasting preference change notifications |
| 45 // to the world. | 48 // to the world. |
| 46 PrefValueStore(PrefStore* managed_prefs, | 49 PrefValueStore(PrefStore* managed_prefs, |
| 47 PrefStore* managed_user_prefs, | 50 PrefStore* supervised_user_prefs, |
| 48 PrefStore* extension_prefs, | 51 PrefStore* extension_prefs, |
| 49 PrefStore* command_line_prefs, | 52 PrefStore* command_line_prefs, |
| 50 PrefStore* user_prefs, | 53 PrefStore* user_prefs, |
| 51 PrefStore* recommended_prefs, | 54 PrefStore* recommended_prefs, |
| 52 PrefStore* default_prefs, | 55 PrefStore* default_prefs, |
| 53 PrefNotifier* pref_notifier); | 56 PrefNotifier* pref_notifier); |
| 54 virtual ~PrefValueStore(); | 57 virtual ~PrefValueStore(); |
| 55 | 58 |
| 56 // Creates a clone of this PrefValueStore with PrefStores overwritten | 59 // Creates a clone of this PrefValueStore with PrefStores overwritten |
| 57 // by the parameters passed, if unequal NULL. | 60 // by the parameters passed, if unequal NULL. |
| 58 PrefValueStore* CloneAndSpecialize(PrefStore* managed_prefs, | 61 PrefValueStore* CloneAndSpecialize(PrefStore* managed_prefs, |
| 59 PrefStore* managed_user_prefs, | 62 PrefStore* supervised_user_prefs, |
| 60 PrefStore* extension_prefs, | 63 PrefStore* extension_prefs, |
| 61 PrefStore* command_line_prefs, | 64 PrefStore* command_line_prefs, |
| 62 PrefStore* user_prefs, | 65 PrefStore* user_prefs, |
| 63 PrefStore* recommended_prefs, | 66 PrefStore* recommended_prefs, |
| 64 PrefStore* default_prefs, | 67 PrefStore* default_prefs, |
| 65 PrefNotifier* pref_notifier); | 68 PrefNotifier* pref_notifier); |
| 66 | 69 |
| 67 // A PrefValueStore can have exactly one callback that is directly | 70 // A PrefValueStore can have exactly one callback that is directly |
| 68 // notified of preferences changing in the store. This does not | 71 // notified of preferences changing in the store. This does not |
| 69 // filter through the PrefNotifier mechanism, which may not forward | 72 // filter through the PrefNotifier mechanism, which may not forward |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 // whether there is no higher-priority source controlling it. | 114 // whether there is no higher-priority source controlling it. |
| 112 bool PrefValueExtensionModifiable(const char* name) const; | 115 bool PrefValueExtensionModifiable(const char* name) const; |
| 113 | 116 |
| 114 // Update the command line PrefStore with |command_line_prefs|. | 117 // Update the command line PrefStore with |command_line_prefs|. |
| 115 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs); | 118 void UpdateCommandLinePrefStore(PrefStore* command_line_prefs); |
| 116 | 119 |
| 117 private: | 120 private: |
| 118 // PrefStores must be listed here in order from highest to lowest priority. | 121 // PrefStores must be listed here in order from highest to lowest priority. |
| 119 // MANAGED contains all managed preference values that are provided by | 122 // MANAGED contains all managed preference values that are provided by |
| 120 // mandatory policies (e.g. Windows Group Policy or cloud policy). | 123 // mandatory policies (e.g. Windows Group Policy or cloud policy). |
| 121 // MANAGED_USER contains preferences that are valid for managed users. | 124 // SUPERVISED_USER contains preferences that are valid for supervised users. |
| 122 // EXTENSION contains preference values set by extensions. | 125 // EXTENSION contains preference values set by extensions. |
| 123 // COMMAND_LINE contains preference values set by command-line switches. | 126 // COMMAND_LINE contains preference values set by command-line switches. |
| 124 // USER contains all user-set preference values. | 127 // USER contains all user-set preference values. |
| 125 // RECOMMENDED contains all preferences that are provided by recommended | 128 // RECOMMENDED contains all preferences that are provided by recommended |
| 126 // policies. | 129 // policies. |
| 127 // DEFAULT contains all application default preference values. | 130 // DEFAULT contains all application default preference values. |
| 128 enum PrefStoreType { | 131 enum PrefStoreType { |
| 129 // INVALID_STORE is not associated with an actual PrefStore but used as | 132 // INVALID_STORE is not associated with an actual PrefStore but used as |
| 130 // an invalid marker, e.g. as a return value. | 133 // an invalid marker, e.g. as a return value. |
| 131 INVALID_STORE = -1, | 134 INVALID_STORE = -1, |
| 132 MANAGED_STORE = 0, | 135 MANAGED_STORE = 0, |
| 133 MANAGED_USER_STORE, | 136 SUPERVISED_USER_STORE, |
| 134 EXTENSION_STORE, | 137 EXTENSION_STORE, |
| 135 COMMAND_LINE_STORE, | 138 COMMAND_LINE_STORE, |
| 136 USER_STORE, | 139 USER_STORE, |
| 137 RECOMMENDED_STORE, | 140 RECOMMENDED_STORE, |
| 138 DEFAULT_STORE, | 141 DEFAULT_STORE, |
| 139 PREF_STORE_TYPE_MAX = DEFAULT_STORE | 142 PREF_STORE_TYPE_MAX = DEFAULT_STORE |
| 140 }; | 143 }; |
| 141 | 144 |
| 142 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors | 145 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors |
| 143 // the PrefStore for changes, forwarding notifications to PrefValueStore. This | 146 // the PrefStore for changes, forwarding notifications to PrefValueStore. This |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 // A mapping of preference names to their registered types. | 258 // A mapping of preference names to their registered types. |
| 256 PrefTypeMap pref_types_; | 259 PrefTypeMap pref_types_; |
| 257 | 260 |
| 258 // True if not all of the PrefStores were initialized successfully. | 261 // True if not all of the PrefStores were initialized successfully. |
| 259 bool initialization_failed_; | 262 bool initialization_failed_; |
| 260 | 263 |
| 261 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 264 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
| 262 }; | 265 }; |
| 263 | 266 |
| 264 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ | 267 #endif // BASE_PREFS_PREF_VALUE_STORE_H_ |
| OLD | NEW |