| 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 // A helper class that stays in sync with a preference (bool, int, real, | 5 // A helper class that stays in sync with a preference (bool, int, real, |
| 6 // string or filepath). For example: | 6 // string or filepath). For example: |
| 7 // | 7 // |
| 8 // class MyClass { | 8 // class MyClass { |
| 9 // public: | 9 // public: |
| 10 // MyClass(PrefService* prefs) { | 10 // MyClass(PrefService* prefs) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 NamedChangeCallback observer_; | 145 NamedChangeCallback observer_; |
| 146 PrefServiceBase* prefs_; | 146 PrefServiceBase* prefs_; |
| 147 | 147 |
| 148 protected: | 148 protected: |
| 149 bool setting_value_; | 149 bool setting_value_; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 // This function implements StringListPrefMember::UpdateValue(). | 152 // This function implements StringListPrefMember::UpdateValue(). |
| 153 // It is exposed here for testing purposes. | 153 // It is exposed here for testing purposes. |
| 154 bool BASE_PREFS_EXPORT PrefMemberVectorStringUpdate( | 154 bool BASE_PREFS_EXPORT PrefMemberVectorStringUpdate( |
| 155 const Value& value, | 155 const base::Value& value, |
| 156 std::vector<std::string>* string_vector); | 156 std::vector<std::string>* string_vector); |
| 157 | 157 |
| 158 } // namespace subtle | 158 } // namespace subtle |
| 159 | 159 |
| 160 template <typename ValueType> | 160 template <typename ValueType> |
| 161 class PrefMember : public subtle::PrefMemberBase { | 161 class PrefMember : public subtle::PrefMemberBase { |
| 162 public: | 162 public: |
| 163 // Defer initialization to an Init method so it's easy to make this class be | 163 // Defer initialization to an Init method so it's easy to make this class be |
| 164 // a member variable. | 164 // a member variable. |
| 165 PrefMember() {} | 165 PrefMember() {} |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 template <> | 316 template <> |
| 317 BASE_PREFS_EXPORT bool PrefMember<double>::Internal::UpdateValueInternal( | 317 BASE_PREFS_EXPORT bool PrefMember<double>::Internal::UpdateValueInternal( |
| 318 const Value& value) const; | 318 const Value& value) const; |
| 319 | 319 |
| 320 template <> | 320 template <> |
| 321 BASE_PREFS_EXPORT void PrefMember<std::string>::UpdatePref( | 321 BASE_PREFS_EXPORT void PrefMember<std::string>::UpdatePref( |
| 322 const std::string& value); | 322 const std::string& value); |
| 323 | 323 |
| 324 template <> | 324 template <> |
| 325 BASE_PREFS_EXPORT bool PrefMember<std::string>::Internal::UpdateValueInternal( | 325 BASE_PREFS_EXPORT bool PrefMember<std::string>::Internal::UpdateValueInternal( |
| 326 const Value& value) const; | 326 const base::Value& value) const; |
| 327 | 327 |
| 328 template <> | 328 template <> |
| 329 BASE_PREFS_EXPORT void PrefMember<FilePath>::UpdatePref(const FilePath& value); | 329 BASE_PREFS_EXPORT void PrefMember<base::FilePath>::UpdatePref( |
| 330 const base::FilePath& value); |
| 330 | 331 |
| 331 template <> | 332 template <> |
| 332 BASE_PREFS_EXPORT bool PrefMember<FilePath>::Internal::UpdateValueInternal( | 333 BASE_PREFS_EXPORT bool |
| 333 const Value& value) const; | 334 PrefMember<base::FilePath>::Internal::UpdateValueInternal( |
| 335 const base::Value& value) const; |
| 334 | 336 |
| 335 template <> | 337 template <> |
| 336 BASE_PREFS_EXPORT void PrefMember<std::vector<std::string> >::UpdatePref( | 338 BASE_PREFS_EXPORT void PrefMember<std::vector<std::string> >::UpdatePref( |
| 337 const std::vector<std::string>& value); | 339 const std::vector<std::string>& value); |
| 338 | 340 |
| 339 template <> | 341 template <> |
| 340 BASE_PREFS_EXPORT bool | 342 BASE_PREFS_EXPORT bool |
| 341 PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal( | 343 PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal( |
| 342 const Value& value) const; | 344 const base::Value& value) const; |
| 343 | 345 |
| 344 typedef PrefMember<bool> BooleanPrefMember; | 346 typedef PrefMember<bool> BooleanPrefMember; |
| 345 typedef PrefMember<int> IntegerPrefMember; | 347 typedef PrefMember<int> IntegerPrefMember; |
| 346 typedef PrefMember<double> DoublePrefMember; | 348 typedef PrefMember<double> DoublePrefMember; |
| 347 typedef PrefMember<std::string> StringPrefMember; | 349 typedef PrefMember<std::string> StringPrefMember; |
| 348 typedef PrefMember<FilePath> FilePathPrefMember; | 350 typedef PrefMember<base::FilePath> FilePathPrefMember; |
| 349 // This preference member is expensive for large string arrays. | 351 // This preference member is expensive for large string arrays. |
| 350 typedef PrefMember<std::vector<std::string> > StringListPrefMember; | 352 typedef PrefMember<std::vector<std::string> > StringListPrefMember; |
| 351 | 353 |
| 352 #endif // BASE_PREFS_PUBLIC_PREF_MEMBER_H_ | 354 #endif // BASE_PREFS_PUBLIC_PREF_MEMBER_H_ |
| OLD | NEW |