| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| 6 #define CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| 7 |
| 8 #include <chrome/browser/pref_service.h> |
| 9 |
| 10 // A PrefService subclass for testing. It operates totally in memory and |
| 11 // provides additional API for manipulating preferences at the different levels |
| 12 // (managed, extension, user) conveniently. |
| 13 class TestingPrefService : public PrefService { |
| 14 public: |
| 15 // Create an empty instance. |
| 16 TestingPrefService(); |
| 17 |
| 18 // Read the value of a preference from the managed layer. Returns NULL if the |
| 19 // preference is not defined at the managed layer. |
| 20 const Value* GetManagedPref(const wchar_t* path); |
| 21 |
| 22 // Set a preference on the managed layer and fire observers if the preference |
| 23 // changed. Assumes ownership of |value|. |
| 24 void SetManagedPref(const wchar_t* path, Value* value); |
| 25 |
| 26 // Clear the preference on the managed layer and fire observers if the |
| 27 // preference has been defined previously. |
| 28 void RemoveManagedPref(const wchar_t* path); |
| 29 |
| 30 // Similar to the above, but for user preferences. |
| 31 const Value* GetUserPref(const wchar_t* path); |
| 32 void SetUserPref(const wchar_t* path, Value* value); |
| 33 void RemoveUserPref(const wchar_t* path); |
| 34 |
| 35 private: |
| 36 // Reads the value of the preference indicated by |path| from |pref_store|. |
| 37 // Returns NULL if the preference was not found. |
| 38 const Value* GetPref(PrefStore* pref_store, const wchar_t* path); |
| 39 |
| 40 // Sets the value for |path| in |pref_store|. |
| 41 void SetPref(PrefStore* pref_store, const wchar_t* path, Value* value); |
| 42 |
| 43 // Removes the preference identified by |path| from |pref_store|. |
| 44 void RemovePref(PrefStore* pref_store, const wchar_t* path); |
| 45 |
| 46 // Pointers to the pref stores our value store uses. |
| 47 PrefStore* managed_prefs_; |
| 48 PrefStore* user_prefs_; |
| 49 }; |
| 50 |
| 51 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| OLD | NEW |