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