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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 // |callback|. |callback| is called with the set of preferences changed by the | 165 // |callback|. |callback| is called with the set of preferences changed by the |
| 166 // policy refresh. |callback| is called on the caller's thread as a Task | 166 // policy refresh. |callback| is called on the caller's thread as a Task |
| 167 // after RefreshPolicyPrefs has returned. | 167 // after RefreshPolicyPrefs has returned. |
| 168 void RefreshPolicyPrefs(AfterRefreshCallback* callback); | 168 void RefreshPolicyPrefs(AfterRefreshCallback* callback); |
| 169 | 169 |
| 170 // Returns true if there are proxy preferences in user-modifiable | 170 // Returns true if there are proxy preferences in user-modifiable |
| 171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) | 171 // preference stores (e.g. CommandLinePrefStore, ExtensionPrefStore) |
| 172 // that conflict with proxy settings specified by proxy policy. | 172 // that conflict with proxy settings specified by proxy policy. |
| 173 bool HasPolicyConflictingUserProxySettings(); | 173 bool HasPolicyConflictingUserProxySettings(); |
| 174 | 174 |
| 175 protected: | 175 protected: |
| 176 // In decreasing order of precedence: | 176 // In decreasing order of precedence: |
| 177 // |managed_platform_prefs| contains all managed platform (non-cloud policy) | 177 // |managed_platform_prefs| contains all managed platform (non-cloud policy) |
| 178 // preference values. | 178 // preference values. |
| 179 // |device_management_prefs| contains all device management (cloud policy) | 179 // |device_management_prefs| contains all device management (cloud policy) |
| 180 // preference values. | 180 // preference values. |
| 181 // |extension_prefs| contains preference values set by extensions. | 181 // |extension_prefs| contains preference values set by extensions. |
| 182 // |command_line_prefs| contains preference values set by command-line | 182 // |command_line_prefs| contains preference values set by command-line |
| 183 // switches. | 183 // switches. |
| 184 // |user_prefs| contains all user-set preference values. | 184 // |user_prefs| contains all user-set preference values. |
| 185 // |recommended_prefs| contains all recommended (policy) preference values. | 185 // |recommended_prefs| contains all recommended (policy) preference values. |
| 186 // |default_prefs| contains application-default preference values. It must | 186 // |default_prefs| contains application-default preference values. It must |
| 187 // be non-null if any preferences are to be registered. | 187 // be non-null if any preferences are to be registered. |
| 188 // | 188 // |
| 189 // The |profile| parameter is used to construct a replacement device | |
| 190 // management pref store in case of policy refresh, may be NULL for the local | |
| 191 // state preferences. | |
|
markusheintz_
2010/11/18 15:42:33
I'm so sorry to bother you with comments, but I do
Mattias Nissler (ping if slow)
2010/11/18 16:06:38
Na, the comment is really about this: The device m
markusheintz_
2010/11/19 09:53:08
That's how I understood it too. But I had to read
| |
| 192 // | |
| 193 // TODO(mnissler, danno): Refactor the pref store interface and refresh logic | |
| 194 // so refreshes can be handled by the pref store itself and the profile | |
| 195 // parameter be removed here. | |
| 196 // | |
| 189 // This constructor should only be used internally, or by subclasses in | 197 // This constructor should only be used internally, or by subclasses in |
| 190 // testing. The usual way to create a PrefValueStore is by creating a | 198 // testing. The usual way to create a PrefValueStore is by creating a |
| 191 // PrefService. | 199 // PrefService. |
| 192 PrefValueStore(PrefStore* managed_platform_prefs, | 200 PrefValueStore(PrefStore* managed_platform_prefs, |
| 193 PrefStore* device_management_prefs, | 201 PrefStore* device_management_prefs, |
| 194 PrefStore* extension_prefs, | 202 PrefStore* extension_prefs, |
| 195 PrefStore* command_line_prefs, | 203 PrefStore* command_line_prefs, |
| 196 PrefStore* user_prefs, | 204 PrefStore* user_prefs, |
| 197 PrefStore* recommended_prefs, | 205 PrefStore* recommended_prefs, |
| 198 PrefStore* default_prefs); | 206 PrefStore* default_prefs, |
| 207 Profile* profile); | |
| 199 | 208 |
| 200 private: | 209 private: |
| 210 typedef std::map<std::string, Value::ValueType> PrefTypeMap; | |
| 211 | |
| 201 friend class PrefValueStoreTest; | 212 friend class PrefValueStoreTest; |
| 202 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, | 213 FRIEND_TEST_ALL_PREFIXES(PrefValueStoreTest, |
| 203 TestRefreshPolicyPrefsCompletion); | 214 TestRefreshPolicyPrefsCompletion); |
| 204 | 215 |
| 205 scoped_ptr<PrefStore> pref_stores_[PrefNotifier::PREF_STORE_TYPE_MAX + 1]; | |
| 206 | |
| 207 // A mapping of preference names to their registered types. | |
| 208 typedef std::map<std::string, Value::ValueType> PrefTypeMap; | |
| 209 PrefTypeMap pref_types_; | |
| 210 | |
| 211 // Returns true if the preference with the given name has a value in the | 216 // Returns true if the preference with the given name has a value in the |
| 212 // given PrefStoreType, of the same value type as the preference was | 217 // given PrefStoreType, of the same value type as the preference was |
| 213 // registered with. | 218 // registered with. |
| 214 bool PrefValueInStore(const char* name, | 219 bool PrefValueInStore(const char* name, |
| 215 PrefNotifier::PrefStoreType store) const; | 220 PrefNotifier::PrefStoreType store) const; |
| 216 | 221 |
| 217 // Get a value from the specified store type. | 222 // Get a value from the specified store type. |
| 218 bool GetValueFromStore(const char* name, | 223 bool GetValueFromStore(const char* name, |
| 219 PrefNotifier::PrefStoreType store, | 224 PrefNotifier::PrefStoreType store, |
| 220 Value** out_value) const; | 225 Value** out_value) const; |
| 221 | 226 |
| 222 // Called during policy refresh after ReadPrefs completes on the thread | 227 // Called during policy refresh after ReadPrefs completes on the thread |
| 223 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes | 228 // that initiated the policy refresh. RefreshPolicyPrefsCompletion takes |
| 224 // ownership of the |callback| object. | 229 // ownership of the |callback| object. |
| 225 void RefreshPolicyPrefsCompletion( | 230 void RefreshPolicyPrefsCompletion( |
| 226 PrefStore* new_managed_platform_pref_store, | 231 PrefStore* new_managed_platform_pref_store, |
| 227 PrefStore* new_device_management_pref_store, | 232 PrefStore* new_device_management_pref_store, |
| 228 PrefStore* new_recommended_pref_store, | 233 PrefStore* new_recommended_pref_store, |
| 229 AfterRefreshCallback* callback); | 234 AfterRefreshCallback* callback); |
| 230 | 235 |
| 231 // Called during policy refresh to do the ReadPrefs on the FILE thread. | 236 // Called during policy refresh to do the ReadPrefs on the FILE thread. |
| 232 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. | 237 // RefreshPolicyPrefsOnFileThread takes ownership of the |callback| object. |
| 233 void RefreshPolicyPrefsOnFileThread( | 238 void RefreshPolicyPrefsOnFileThread( |
| 234 BrowserThread::ID calling_thread_id, | 239 BrowserThread::ID calling_thread_id, |
| 235 PrefStore* new_managed_platform_pref_store, | 240 PrefStore* new_managed_platform_pref_store, |
| 236 PrefStore* new_device_management_pref_store, | 241 PrefStore* new_device_management_pref_store, |
| 237 PrefStore* new_recommended_pref_store, | 242 PrefStore* new_recommended_pref_store, |
| 238 AfterRefreshCallback* callback); | 243 AfterRefreshCallback* callback); |
| 239 | 244 |
| 245 scoped_ptr<PrefStore> pref_stores_[PrefNotifier::PREF_STORE_TYPE_MAX + 1]; | |
| 246 | |
| 247 // A mapping of preference names to their registered types. | |
| 248 PrefTypeMap pref_types_; | |
| 249 | |
| 250 // The associated profile, if applicable. | |
|
markusheintz_
2010/11/18 15:42:33
When is it not applicable? Maybe it's worth to add
Mattias Nissler (ping if slow)
2010/11/18 16:06:38
It's only applicable if this pref_value_store is a
markusheintz_
2010/11/19 09:53:08
I understood this comment, but I think if someone
| |
| 251 Profile* profile_; | |
| 252 | |
| 240 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); | 253 DISALLOW_COPY_AND_ASSIGN(PrefValueStore); |
| 241 }; | 254 }; |
| 242 | 255 |
| 243 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ | 256 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_STORE_H_ |
| OLD | NEW |