| 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 // This provides a way to access the application's current preferences. | 5 // This provides a way to access the application's current preferences. |
| 6 | 6 |
| 7 // Chromium settings and storage represent user-selected preferences and | 7 // Chromium settings and storage represent user-selected preferences and |
| 8 // information and MUST not be extracted, overwritten or modified except | 8 // information and MUST not be extracted, overwritten or modified except |
| 9 // through Chromium defined APIs. | 9 // through Chromium defined APIs. |
| 10 | 10 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // Returns true if the user can change the Preference value, which is the | 121 // Returns true if the user can change the Preference value, which is the |
| 122 // case if no higher-priority source than the user store controls the | 122 // case if no higher-priority source than the user store controls the |
| 123 // Preference. | 123 // Preference. |
| 124 bool IsUserModifiable() const; | 124 bool IsUserModifiable() const; |
| 125 | 125 |
| 126 // Returns true if an extension can change the Preference value, which is | 126 // Returns true if an extension can change the Preference value, which is |
| 127 // the case if no higher-priority source than the extension store controls | 127 // the case if no higher-priority source than the extension store controls |
| 128 // the Preference. | 128 // the Preference. |
| 129 bool IsExtensionModifiable() const; | 129 bool IsExtensionModifiable() const; |
| 130 | 130 |
| 131 // Return the registration flags for this pref as a bitmask of |
| 132 // PrefRegistry::PrefRegistrationFlags. |
| 133 uint32 registration_flags() const { return registration_flags_; } |
| 134 |
| 131 private: | 135 private: |
| 132 friend class PrefService; | 136 friend class PrefService; |
| 133 | 137 |
| 134 PrefValueStore* pref_value_store() const { | 138 PrefValueStore* pref_value_store() const { |
| 135 return pref_service_->pref_value_store_.get(); | 139 return pref_service_->pref_value_store_.get(); |
| 136 } | 140 } |
| 137 | 141 |
| 138 const std::string name_; | 142 const std::string name_; |
| 139 | 143 |
| 140 const base::Value::Type type_; | 144 const base::Value::Type type_; |
| 141 | 145 |
| 146 uint32 registration_flags_; |
| 147 |
| 142 // Reference to the PrefService in which this pref was created. | 148 // Reference to the PrefService in which this pref was created. |
| 143 const PrefService* pref_service_; | 149 const PrefService* pref_service_; |
| 144 }; | 150 }; |
| 145 | 151 |
| 146 // You may wish to use PrefServiceFactory or one of its subclasses | 152 // You may wish to use PrefServiceFactory or one of its subclasses |
| 147 // for simplified construction. | 153 // for simplified construction. |
| 148 PrefService( | 154 PrefService( |
| 149 PrefNotifierImpl* pref_notifier, | 155 PrefNotifierImpl* pref_notifier, |
| 150 PrefValueStore* pref_value_store, | 156 PrefValueStore* pref_value_store, |
| 151 PersistentPrefStore* user_prefs, | 157 PersistentPrefStore* user_prefs, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 306 |
| 301 private: | 307 private: |
| 302 // Hash map expected to be fastest here since it minimises expensive | 308 // Hash map expected to be fastest here since it minimises expensive |
| 303 // string comparisons. Order is unimportant, and deletions are rare. | 309 // string comparisons. Order is unimportant, and deletions are rare. |
| 304 // Confirmed on Android where this speeded Chrome startup by roughly 50ms | 310 // Confirmed on Android where this speeded Chrome startup by roughly 50ms |
| 305 // vs. std::map, and by roughly 180ms vs. std::set of Preference pointers. | 311 // vs. std::map, and by roughly 180ms vs. std::set of Preference pointers. |
| 306 typedef base::hash_map<std::string, Preference> PreferenceMap; | 312 typedef base::hash_map<std::string, Preference> PreferenceMap; |
| 307 | 313 |
| 308 // Give access to ReportUserPrefChanged() and GetMutableUserPref(). | 314 // Give access to ReportUserPrefChanged() and GetMutableUserPref(). |
| 309 friend class subtle::ScopedUserPrefUpdateBase; | 315 friend class subtle::ScopedUserPrefUpdateBase; |
| 316 friend class PrefServiceTest_WriteablePrefStoreFlags_Test; |
| 310 | 317 |
| 311 // Registration of pref change observers must be done using the | 318 // Registration of pref change observers must be done using the |
| 312 // PrefChangeRegistrar, which is declared as a friend here to grant it | 319 // PrefChangeRegistrar, which is declared as a friend here to grant it |
| 313 // access to the otherwise protected members Add/RemovePrefObserver. | 320 // access to the otherwise protected members Add/RemovePrefObserver. |
| 314 // PrefMember registers for preferences changes notification directly to | 321 // PrefMember registers for preferences changes notification directly to |
| 315 // avoid the storage overhead of the registrar, so its base class must be | 322 // avoid the storage overhead of the registrar, so its base class must be |
| 316 // declared as a friend, too. | 323 // declared as a friend, too. |
| 317 friend class PrefChangeRegistrar; | 324 friend class PrefChangeRegistrar; |
| 318 friend class subtle::PrefMemberBase; | 325 friend class subtle::PrefMemberBase; |
| 319 | 326 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 | 367 |
| 361 // Local cache of registered Preference objects. The pref_registry_ | 368 // Local cache of registered Preference objects. The pref_registry_ |
| 362 // is authoritative with respect to what the types and default values | 369 // is authoritative with respect to what the types and default values |
| 363 // of registered preferences are. | 370 // of registered preferences are. |
| 364 mutable PreferenceMap prefs_map_; | 371 mutable PreferenceMap prefs_map_; |
| 365 | 372 |
| 366 DISALLOW_COPY_AND_ASSIGN(PrefService); | 373 DISALLOW_COPY_AND_ASSIGN(PrefService); |
| 367 }; | 374 }; |
| 368 | 375 |
| 369 #endif // BASE_PREFS_PREF_SERVICE_H_ | 376 #endif // BASE_PREFS_PREF_SERVICE_H_ |
| OLD | NEW |