Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 bool HasPrefPath(const char* name) const; | 88 bool HasPrefPath(const char* name) const; |
| 89 | 89 |
| 90 // Called by the PrefNotifier when the value of the preference at |path| has | 90 // Called by the PrefNotifier when the value of the preference at |path| has |
| 91 // changed, been added, or been removed in one of the PrefStores. The | 91 // changed, been added, or been removed in one of the PrefStores. The |
| 92 // |new_store| is the PrefStoreType of the caller. Returns true if the | 92 // |new_store| is the PrefStoreType of the caller. Returns true if the |
| 93 // effective value of the preference has changed, or if the store controlling | 93 // effective value of the preference has changed, or if the store controlling |
| 94 // the pref has changed. Virtual so it can be mocked for a unit test. | 94 // the pref has changed. Virtual so it can be mocked for a unit test. |
| 95 virtual bool PrefHasChanged(const char* path, | 95 virtual bool PrefHasChanged(const char* path, |
| 96 PrefNotifier::PrefStoreType new_store); | 96 PrefNotifier::PrefStoreType new_store); |
| 97 | 97 |
| 98 // Returns true if the PrefValueStore is read-only. | 98 // Returns true if the PrefValueStore is read-only. Because the managed |
| 99 // Because the managed and recommended PrefStores are always read-only, the | 99 // platform, device management and recommended PrefStores are always |
| 100 // PrefValueStore as a whole is read-only if the PrefStore containing the user | 100 // read-only, the PrefValueStore as a whole is read-only if the PrefStore |
| 101 // preferences is read-only. | 101 // containing the user preferences is read-only. |
| 102 bool ReadOnly(); | 102 bool ReadOnly(); |
| 103 | 103 |
| 104 // Alters the user-defined value of a preference. Even if the preference is | 104 // Alters the user-defined value of a preference. Even if the preference is |
| 105 // managed this method allows the user-defined value of the preference to be | 105 // managed this method allows the user-defined value of the preference to be |
| 106 // set. But GetValue calls will not return this value as long as the | 106 // set. But GetValue calls will not return this value as long as the |
| 107 // preference is managed. Instead GetValue will return the managed value | 107 // preference is managed. Instead GetValue will return the managed value |
| 108 // of the preference. Note that the PrefValueStore takes the ownership of | 108 // of the preference. Note that the PrefValueStore takes the ownership of |
| 109 // the value referenced by |in_value|. It is an error to call this when no | 109 // the value referenced by |in_value|. It is an error to call this when no |
| 110 // user PrefStore has been set. Returns true if the user-set value of the | 110 // user PrefStore has been set. Returns true if the user-set value of the |
| 111 // preference was newly added or changed. | 111 // preference was newly added or changed. |
| 112 bool SetUserPrefValue(const char* name, Value* in_value); | 112 bool SetUserPrefValue(const char* name, Value* in_value); |
| 113 | 113 |
| 114 // Removes a value from the user PrefStore. If a preference is managed | 114 // Removes a value from the user PrefStore. If a preference is managed |
| 115 // this function should have no visible effect. Returns true if there was a | 115 // this function should have no visible effect. Returns true if there was a |
| 116 // user-set value to be removed. | 116 // user-set value to be removed. |
| 117 bool RemoveUserPrefValue(const char* name); | 117 bool RemoveUserPrefValue(const char* name); |
| 118 | 118 |
| 119 // Sets a value in the DefaultPrefStore, which takes ownership of the Value. | 119 // Sets a value in the DefaultPrefStore, which takes ownership of the Value. |
| 120 void SetDefaultPrefValue(const char* name, Value* in_value); | 120 void SetDefaultPrefValue(const char* name, Value* in_value); |
| 121 | 121 |
| 122 // These methods return true if a preference with the given name is in the | 122 // These methods return true if a preference with the given name is in the |
| 123 // indicated pref store, even if that value is currently being overridden by | 123 // indicated pref store, even if that value is currently being overridden by |
| 124 // a higher-priority source. | 124 // a higher-priority source. |
| 125 bool PrefValueInManagedStore(const char* name) const; | 125 bool PrefValueInManagedPlatformStore(const char* name) const; |
| 126 bool PrefValueInDeviceManagementStore(const char* name) const; | |
| 126 bool PrefValueInExtensionStore(const char* name) const; | 127 bool PrefValueInExtensionStore(const char* name) const; |
| 127 bool PrefValueInUserStore(const char* name) const; | 128 bool PrefValueInUserStore(const char* name) const; |
| 128 | 129 |
| 129 // Returns true if a preference has an explicit value in any of the | 130 // Returns true if a preference has an explicit value in any of the |
| 130 // stores in the range specified by |first_checked_store| and | 131 // stores in the range specified by |first_checked_store| and |
| 131 // |last_checked_store|, even if that value is currently being | 132 // |last_checked_store|, even if that value is currently being |
| 132 // overridden by a higher-priority store. | 133 // overridden by a higher-priority store. |
| 133 bool PrefValueInStoreRange(const char* name, | 134 bool PrefValueInStoreRange(const char* name, |
| 134 PrefNotifier::PrefStoreType first_checked_store, | 135 PrefNotifier::PrefStoreType first_checked_store, |
| 135 PrefNotifier::PrefStoreType last_checked_store); | 136 PrefNotifier::PrefStoreType last_checked_store); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 151 // should always have a value for any registered preferencem, so INVALID_STORE | 152 // should always have a value for any registered preferencem, so INVALID_STORE |
| 152 // indicates an error. | 153 // indicates an error. |
| 153 PrefNotifier::PrefStoreType ControllingPrefStoreForPref( | 154 PrefNotifier::PrefStoreType ControllingPrefStoreForPref( |
| 154 const char* name) const; | 155 const char* name) const; |
| 155 | 156 |
| 156 // Signature of callback triggered after policy refresh. Parameter is not | 157 // Signature of callback triggered after policy refresh. Parameter is not |
| 157 // passed as reference to prevent passing along a pointer to a set whose | 158 // passed as reference to prevent passing along a pointer to a set whose |
| 158 // lifecycle is managed in another thread. | 159 // lifecycle is managed in another thread. |
| 159 typedef Callback1<std::vector<std::string> >::Type AfterRefreshCallback; | 160 typedef Callback1<std::vector<std::string> >::Type AfterRefreshCallback; |
| 160 | 161 |
| 161 // Called as a result of a notification of policy change. Triggers a | 162 // Called as a result of a notification of policy change. Triggers a reload of |
| 162 // reload of managed preferences from policy from a Task on the FILE | 163 // managed platform, device management and recommended preferences from policy |
| 163 // thread. The Task will take ownership of the |callback|. |callback| is | 164 // from a Task on the FILE thread. The Task will take ownership of the |
| 164 // called with the set of preferences changed by the policy refresh. | 165 // |callback|. |callback| is called with the set of preferences changed by the |
| 165 // |callback| is called on the caller's thread as a Task after | 166 // policy refresh. |callback| is called on the caller's thread as a Task |
|
Mattias Nissler (ping if slow)
2010/11/12 15:02:13
nit: This file doesn't seem to use 2 spaces after
danno
2010/11/12 16:17:30
Done.
| |
| 166 // RefreshPolicyPrefs has returned. | 167 // after RefreshPolicyPrefs has returned. |
| 167 void RefreshPolicyPrefs(AfterRefreshCallback* callback); | 168 void RefreshPolicyPrefs(AfterRefreshCallback* callback); |
| 168 | 169 |
| 169 // Returns true if there are proxy preferences in user-modifiable | 170 // Returns true if there are proxy preferences in user-modifiable |
| 170 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) | 171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) |
| 171 // that conflict with proxy settings specified by proxy policy. | 172 // that conflict with proxy settings specified by proxy policy. |
| 172 bool HasPolicyConflictingUserProxySettings(); | 173 bool HasPolicyConflictingUserProxySettings(); |
| 173 | 174 |
| 174 protected: | 175 protected: |
| 175 // In decreasing order of precedence: | 176 // In decreasing order of precedence: |
| 176 // |managed_prefs| contains all managed (policy) preference values. | 177 // |managed_prefs| contains all managed platform (non-cloud policy) |
|
Mattias Nissler (ping if slow)
2010/11/12 15:02:13
should be managed_platfrom_prefs
danno
2010/11/12 16:17:30
Done.
| |
| 178 // preference values. | |
| 179 // |device_management_prefs| contains all device management (cloud policy) | |
| 180 // preference values. | |
| 177 // |extension_prefs| contains preference values set by extensions. | 181 // |extension_prefs| contains preference values set by extensions. |
| 178 // |command_line_prefs| contains preference values set by command-line | 182 // |command_line_prefs| contains preference values set by command-line |
| 179 // switches. | 183 // switches. |
| 180 // |user_prefs| contains all user-set preference values. | 184 // |user_prefs| contains all user-set preference values. |
| 181 // |recommended_prefs| contains all recommended (policy) preference values. | 185 // |recommended_prefs| contains all recommended (policy) preference values. |
| 182 // |default_prefs| contains application-default preference values. It must | 186 // |default_prefs| contains application-default preference values. It must |
| 183 // be non-null if any preferences are to be registered. | 187 // be non-null if any preferences are to be registered. |
| 184 // | 188 // |
| 185 // This constructor should only be used internally, or by subclasses in | 189 // This constructor should only be used internally, or by subclasses in |
| 186 // testing. The usual way to create a PrefValueStore is by creating a | 190 // testing. The usual way to create a PrefValueStore is by creating a |
| 187 // PrefService. | 191 // PrefService. |
| 188 PrefValueStore(PrefStore* managed_prefs, | 192 PrefValueStore(PrefStore* managed_platform_prefs, |
| 193 PrefStore* device_management_prefs, | |
| 189 PrefStore* extension_prefs, | 194 PrefStore* extension_prefs, |
| 190 PrefStore* command_line_prefs, | 195 PrefStore* command_line_prefs, |
| 191 PrefStore* user_prefs, | 196 PrefStore* user_prefs, |
| 192 PrefStore* recommended_prefs, | 197 PrefStore* recommended_prefs, |
| 193 PrefStore* default_prefs); | 198 PrefStore* default_prefs); |
| 194 | 199 |
| 195 private: | 200 private: |
| 196 friend class PrefValueStoreTest; | 201 friend class PrefValueStoreTest; |
| 197 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, | 202 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, |
| 198 TestRefreshPolicyPrefsCompletion); | 203 TestRefreshPolicyPrefsCompletion); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 211 | 216 |
| 212 // Get a value from the specified store type. | 217 // Get a value from the specified store type. |
| 213 bool GetValueFromStore(const char* name, | 218 bool GetValueFromStore(const char* name, |
| 214 PrefNotifier::PrefStoreType store, | 219 PrefNotifier::PrefStoreType store, |
| 215 Value** out_value) const; | 220 Value** out_value) const; |
| 216 | 221 |
| 217 // Called during policy refresh after ReadPrefs completes on the thread | 222 // Called during policy refresh after ReadPrefs completes on the thread |
| 218 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes | 223 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes |
| 219 // ownership of the |callback| object. | 224 // ownership of the |callback| object. |
| 220 void RefreshPolicyPrefsCompletion( | 225 void RefreshPolicyPrefsCompletion( |
| 221 PrefStore* new_managed_pref_store, | 226 PrefStore* new_managed_platform_pref_store, |
| 227 PrefStore* new_device_management_pref_store, | |
| 222 PrefStore* new_recommended_pref_store, | 228 PrefStore* new_recommended_pref_store, |
| 223 AfterRefreshCallback* callback); | 229 AfterRefreshCallback* callback); |
| 224 | 230 |
| 225 // Called during policy refresh to do the ReadPrefs on the FILE thread. | 231 // Called during policy refresh to do the ReadPrefs on the FILE thread. |
| 226 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. | 232 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. |
| 227 void RefreshPolicyPrefsOnFileThread( | 233 void RefreshPolicyPrefsOnFileThread( |
| 228 BrowserThread::ID calling_thread_id, | 234 BrowserThread::ID calling_thread_id, |
| 229 PrefStore* new_managed_pref_store, | 235 PrefStore* new_managed_platform_pref_store, |
| 236 PrefStore* new_device_management_pref_store, | |
| 230 PrefStore* new_recommended_pref_store, | 237 PrefStore* new_recommended_pref_store, |
| 231 AfterRefreshCallback* callback); | 238 AfterRefreshCallback* callback); |
| 232 | 239 |
| 233 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 240 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
| 234 }; | 241 }; |
| 235 | 242 |
| 236 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 243 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ |
| OLD | NEW |