| 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_TEST_TESTING_PREF_SERVICE_H_ | 5 #ifndef CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| 6 #define CHROME_TEST_TESTING_PREF_SERVICE_H_ | 6 #define CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <chrome/browser/pref_service.h> | 9 #include <chrome/browser/pref_service.h> |
| 10 | 10 |
| 11 class PrefStore; |
| 12 |
| 11 // A PrefService subclass for testing. It operates totally in memory and | 13 // A PrefService subclass for testing. It operates totally in memory and |
| 12 // provides additional API for manipulating preferences at the different levels | 14 // provides additional API for manipulating preferences at the different levels |
| 13 // (managed, extension, user) conveniently. | 15 // (managed, extension, user) conveniently. |
| 14 class TestingPrefService : public PrefService { | 16 class TestingPrefService : public PrefService { |
| 15 public: | 17 public: |
| 18 // Subclass to allow directly setting PrefStores. |
| 19 class TestingPrefValueStore : public PrefValueStore { |
| 20 public: |
| 21 TestingPrefValueStore(PrefStore* managed_prefs, |
| 22 PrefStore* extension_prefs, |
| 23 PrefStore* command_line_prefs, |
| 24 PrefStore* user_prefs, |
| 25 PrefStore* recommended_prefs); |
| 26 }; |
| 27 |
| 16 // Create an empty instance. | 28 // Create an empty instance. |
| 17 TestingPrefService(); | 29 TestingPrefService(); |
| 18 | 30 |
| 19 // Read the value of a preference from the managed layer. Returns NULL if the | 31 // Read the value of a preference from the managed layer. Returns NULL if the |
| 20 // preference is not defined at the managed layer. | 32 // preference is not defined at the managed layer. |
| 21 const Value* GetManagedPref(const wchar_t* path); | 33 const Value* GetManagedPref(const wchar_t* path); |
| 22 | 34 |
| 23 // Set a preference on the managed layer and fire observers if the preference | 35 // Set a preference on the managed layer and fire observers if the preference |
| 24 // changed. Assumes ownership of |value|. | 36 // changed. Assumes ownership of |value|. |
| 25 void SetManagedPref(const wchar_t* path, Value* value); | 37 void SetManagedPref(const wchar_t* path, Value* value); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 43 | 55 |
| 44 // Removes the preference identified by |path| from |pref_store|. | 56 // Removes the preference identified by |path| from |pref_store|. |
| 45 void RemovePref(PrefStore* pref_store, const wchar_t* path); | 57 void RemovePref(PrefStore* pref_store, const wchar_t* path); |
| 46 | 58 |
| 47 // Pointers to the pref stores our value store uses. | 59 // Pointers to the pref stores our value store uses. |
| 48 PrefStore* managed_prefs_; | 60 PrefStore* managed_prefs_; |
| 49 PrefStore* user_prefs_; | 61 PrefStore* user_prefs_; |
| 50 }; | 62 }; |
| 51 | 63 |
| 52 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ | 64 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ |
| OLD | NEW |