OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_PREF_VALUE_STORE_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ |
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 15 matching lines...) Expand all Loading... |
26 // the value of a Preference from the source with the highest priority, and | 26 // the value of a Preference from the source with the highest priority, and |
27 // allows setting user-defined values for preferences that are not managed. | 27 // allows setting user-defined values for preferences that are not managed. |
28 // | 28 // |
29 // Unless otherwise explicitly noted, all of the methods of this class must | 29 // Unless otherwise explicitly noted, all of the methods of this class must |
30 // be called on the UI thread. | 30 // be called on the UI thread. |
31 class PrefValueStore { | 31 class PrefValueStore { |
32 public: | 32 public: |
33 // In decreasing order of precedence: | 33 // In decreasing order of precedence: |
34 // |managed_platform_prefs| contains all managed platform (non-cloud policy) | 34 // |managed_platform_prefs| contains all managed platform (non-cloud policy) |
35 // preference values. | 35 // preference values. |
36 // |device_management_prefs| contains all device management (cloud policy) | 36 // |managed_cloud_prefs| contains all managed cloud policy preference |
37 // preference values. | 37 // values. |
38 // |extension_prefs| contains preference values set by extensions. | 38 // |extension_prefs| contains preference values set by extensions. |
39 // |command_line_prefs| contains preference values set by command-line | 39 // |command_line_prefs| contains preference values set by command-line |
40 // switches. | 40 // switches. |
41 // |user_prefs| contains all user-set preference values. | 41 // |user_prefs| contains all user-set preference values. |
42 // |recommended_prefs| contains all recommended (policy) preference values. | 42 // |recommended_platform_prefs| contains all recommended platform policy |
| 43 // preference values. |
| 44 // |recommended_cloud_prefs| contains all recommended cloud policy |
| 45 // preference values. |
43 // |default_prefs| contains application-default preference values. It must | 46 // |default_prefs| contains application-default preference values. It must |
44 // be non-null if any preferences are to be registered. | 47 // be non-null if any preferences are to be registered. |
45 // | 48 // |
46 // |pref_notifier| facilitates broadcasting preference change notifications | 49 // |pref_notifier| facilitates broadcasting preference change notifications |
47 // to the world. | 50 // to the world. |
48 PrefValueStore(PrefStore* managed_platform_prefs, | 51 PrefValueStore(PrefStore* managed_platform_prefs, |
49 PrefStore* device_management_prefs, | 52 PrefStore* managed_cloud_prefs, |
50 PrefStore* extension_prefs, | 53 PrefStore* extension_prefs, |
51 PrefStore* command_line_prefs, | 54 PrefStore* command_line_prefs, |
52 PrefStore* user_prefs, | 55 PrefStore* user_prefs, |
53 PrefStore* recommended_prefs, | 56 PrefStore* recommended_platform_prefs, |
| 57 PrefStore* recommended_cloud_prefs, |
54 PrefStore* default_prefs, | 58 PrefStore* default_prefs, |
55 PrefNotifier* pref_notifier); | 59 PrefNotifier* pref_notifier); |
56 virtual ~PrefValueStore(); | 60 virtual ~PrefValueStore(); |
57 | 61 |
58 // Creates a clone of this PrefValueStore with PrefStores overwritten | 62 // Creates a clone of this PrefValueStore with PrefStores overwritten |
59 // by the parameters passed, if unequal NULL. | 63 // by the parameters passed, if unequal NULL. |
60 PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs, | 64 PrefValueStore* CloneAndSpecialize(PrefStore* managed_platform_prefs, |
61 PrefStore* device_management_prefs, | 65 PrefStore* managed_cloud_prefs, |
62 PrefStore* extension_prefs, | 66 PrefStore* extension_prefs, |
63 PrefStore* command_line_prefs, | 67 PrefStore* command_line_prefs, |
64 PrefStore* user_prefs, | 68 PrefStore* user_prefs, |
65 PrefStore* recommended_prefs, | 69 PrefStore* recommended_platform_prefs, |
| 70 PrefStore* recommended_cloud_prefs, |
66 PrefStore* default_prefs, | 71 PrefStore* default_prefs, |
67 PrefNotifier* pref_notifier); | 72 PrefNotifier* pref_notifier); |
68 | 73 |
69 // Gets the value for the given preference name that has the specified value | 74 // Gets the value for the given preference name that has the specified value |
70 // type. Values stored in a PrefStore that have the matching |name| but | 75 // type. Values stored in a PrefStore that have the matching |name| but |
71 // a non-matching |type| are silently skipped. Returns true if a valid value | 76 // a non-matching |type| are silently skipped. Returns true if a valid value |
72 // was found in any of the available PrefStores. Most callers should use | 77 // was found in any of the available PrefStores. Most callers should use |
73 // Preference::GetValue() instead of calling this method directly. | 78 // Preference::GetValue() instead of calling this method directly. |
74 bool GetValue(const std::string& name, | 79 bool GetValue(const std::string& name, |
75 Value::ValueType type, | 80 Value::ValueType type, |
76 Value** out_value) const; | 81 Value** out_value) const; |
77 | 82 |
78 // These methods return true if a preference with the given name is in the | 83 // These methods return true if a preference with the given name is in the |
79 // indicated pref store, even if that value is currently being overridden by | 84 // indicated pref store, even if that value is currently being overridden by |
80 // a higher-priority source. | 85 // a higher-priority source. |
81 bool PrefValueInManagedPlatformStore(const char* name) const; | 86 bool PrefValueInManagedStore(const char* name) const; |
82 bool PrefValueInDeviceManagementStore(const char* name) const; | |
83 bool PrefValueInExtensionStore(const char* name) const; | 87 bool PrefValueInExtensionStore(const char* name) const; |
84 bool PrefValueInUserStore(const char* name) const; | 88 bool PrefValueInUserStore(const char* name) const; |
85 | 89 |
86 // These methods return true if a preference with the given name is actually | 90 // These methods return true if a preference with the given name is actually |
87 // being controlled by the indicated pref store and not being overridden by | 91 // being controlled by the indicated pref store and not being overridden by |
88 // a higher-priority source. | 92 // a higher-priority source. |
89 bool PrefValueFromExtensionStore(const char* name) const; | 93 bool PrefValueFromExtensionStore(const char* name) const; |
90 bool PrefValueFromUserStore(const char* name) const; | 94 bool PrefValueFromUserStore(const char* name) const; |
91 bool PrefValueFromDefaultStore(const char* name) const; | 95 bool PrefValueFromDefaultStore(const char* name) const; |
92 | 96 |
(...skipping 11 matching lines...) Expand all Loading... |
104 // EXTENSION contains preference values set by extensions. | 108 // EXTENSION contains preference values set by extensions. |
105 // COMMAND_LINE contains preference values set by command-line switches. | 109 // COMMAND_LINE contains preference values set by command-line switches. |
106 // USER contains all user-set preference values. | 110 // USER contains all user-set preference values. |
107 // RECOMMENDED contains all recommended (policy) preference values. | 111 // RECOMMENDED contains all recommended (policy) preference values. |
108 // DEFAULT contains all application default preference values. | 112 // DEFAULT contains all application default preference values. |
109 enum PrefStoreType { | 113 enum PrefStoreType { |
110 // INVALID_STORE is not associated with an actual PrefStore but used as | 114 // INVALID_STORE is not associated with an actual PrefStore but used as |
111 // an invalid marker, e.g. as a return value. | 115 // an invalid marker, e.g. as a return value. |
112 INVALID_STORE = -1, | 116 INVALID_STORE = -1, |
113 MANAGED_PLATFORM_STORE = 0, | 117 MANAGED_PLATFORM_STORE = 0, |
114 DEVICE_MANAGEMENT_STORE, | 118 MANAGED_CLOUD_STORE, |
115 EXTENSION_STORE, | 119 EXTENSION_STORE, |
116 COMMAND_LINE_STORE, | 120 COMMAND_LINE_STORE, |
117 USER_STORE, | 121 USER_STORE, |
118 RECOMMENDED_STORE, | 122 RECOMMENDED_PLATFORM_STORE, |
| 123 RECOMMENDED_CLOUD_STORE, |
119 DEFAULT_STORE, | 124 DEFAULT_STORE, |
120 PREF_STORE_TYPE_MAX = DEFAULT_STORE | 125 PREF_STORE_TYPE_MAX = DEFAULT_STORE |
121 }; | 126 }; |
122 | 127 |
123 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors | 128 // Keeps a PrefStore reference on behalf of the PrefValueStore and monitors |
124 // the PrefStore for changes, forwarding notifications to PrefValueStore. This | 129 // the PrefStore for changes, forwarding notifications to PrefValueStore. This |
125 // indirection is here for the sake of disambiguating notifications from the | 130 // indirection is here for the sake of disambiguating notifications from the |
126 // individual PrefStores. | 131 // individual PrefStores. |
127 class PrefStoreKeeper : public PrefStore::Observer { | 132 class PrefStoreKeeper : public PrefStore::Observer { |
128 public: | 133 public: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // corresponding PrefService. | 231 // corresponding PrefService. |
227 PrefNotifier* pref_notifier_; | 232 PrefNotifier* pref_notifier_; |
228 | 233 |
229 // A mapping of preference names to their registered types. | 234 // A mapping of preference names to their registered types. |
230 PrefTypeMap pref_types_; | 235 PrefTypeMap pref_types_; |
231 | 236 |
232 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 237 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
233 }; | 238 }; |
234 | 239 |
235 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 240 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ |
OLD | NEW |