Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: chrome/test/testing_pref_service.h

Issue 5441002: Clean up pref change notification handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix extension prefs breakage Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/pref_store_observer_mock.h ('k') | chrome/test/testing_pref_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 CommandLine; 11 class CommandLine;
12 namespace policy { 12 namespace policy {
13 class ConfigurationPolicyProvider; 13 class ConfigurationPolicyProvider;
14 } 14 }
15 class PrefStore; 15 class PrefStore;
16 16
17 // A PrefService subclass for testing. It operates totally in memory and 17 // A PrefService subclass for testing. It operates totally in memory and
18 // provides additional API for manipulating preferences at the different levels 18 // provides additional API for manipulating preferences at the different levels
19 // (managed, extension, user) conveniently. 19 // (managed, extension, user) conveniently.
20 class TestingPrefService : public PrefService { 20 class TestingPrefService : public PrefService {
21 public: 21 public:
22 // Create an empty instance. 22 // Create an empty instance.
23 TestingPrefService(); 23 TestingPrefService();
24 24
25 // Create an instance that has a managed PrefStore and a command- line 25 // Create an instance that has a managed PrefStore and a command- line
26 // PrefStore. |managed_platform_provider| contains the provider with which to 26 // PrefStore. |managed_platform_provider| contains the provider with which to
27 // initialize the managed platform PrefStore. If it is NULL, then a 27 // initialize the managed platform PrefStore. If it is NULL, then a
28 // DummyPrefStore will be created. |device_management_provider| contains the 28 // TestingPrefStore will be created. |device_management_provider| contains the
29 // provider with which to initialize the device management 29 // provider with which to initialize the device management
30 // PrefStore. |command_line| contains the provider with which to initialize 30 // PrefStore. |command_line| contains the provider with which to initialize
31 // the command line PrefStore. If it is NULL then a DummyPrefStore will be 31 // the command line PrefStore. If it is NULL then a TestingPrefStore will be
32 // created as the command line PrefStore. 32 // created as the command line PrefStore.
33 TestingPrefService( 33 TestingPrefService(
34 policy::ConfigurationPolicyProvider* managed_platform_provider, 34 policy::ConfigurationPolicyProvider* managed_platform_provider,
35 policy::ConfigurationPolicyProvider* device_management_provider, 35 policy::ConfigurationPolicyProvider* device_management_provider,
36 CommandLine* command_line); 36 CommandLine* command_line);
37 37
38 // Read the value of a preference from the managed layer. Returns NULL if the 38 // Read the value of a preference from the managed layer. Returns NULL if the
39 // preference is not defined at the managed layer. 39 // preference is not defined at the managed layer.
40 const Value* GetManagedPref(const char* path); 40 const Value* GetManagedPref(const char* path);
41 41
(...skipping 17 matching lines...) Expand all
59 // ConfigurationPolicyPrefStore::ReadPrefs(). 59 // ConfigurationPolicyPrefStore::ReadPrefs().
60 void RemoveManagedPrefWithoutNotification(const char* path); 60 void RemoveManagedPrefWithoutNotification(const char* path);
61 61
62 // Similar to the above, but for user preferences. 62 // Similar to the above, but for user preferences.
63 const Value* GetUserPref(const char* path); 63 const Value* GetUserPref(const char* path);
64 void SetUserPref(const char* path, Value* value); 64 void SetUserPref(const char* path, Value* value);
65 void RemoveUserPref(const char* path); 65 void RemoveUserPref(const char* path);
66 66
67 private: 67 private:
68 // Creates a ConfigurationPolicyPrefStore based on the provided 68 // Creates a ConfigurationPolicyPrefStore based on the provided
69 // |provider| or a DummyPrefStore if |provider| is NULL. 69 // |provider| or a TestingPrefStore if |provider| is NULL.
70 PrefStore* CreatePolicyPrefStoreFromProvider( 70 PrefStore* CreatePolicyPrefStoreFromProvider(
71 policy::ConfigurationPolicyProvider* provider); 71 policy::ConfigurationPolicyProvider* provider);
72 72
73 // Creates a CommandLinePrefStore based on the supplied 73 // Creates a CommandLinePrefStore based on the supplied
74 // |command_line| or a DummyPrefStore if |command_line| is NULL. 74 // |command_line| or a TestingPrefStore if |command_line| is NULL.
75 PrefStore* CreateCommandLinePrefStore(CommandLine* command_line); 75 PrefStore* CreateCommandLinePrefStore(CommandLine* command_line);
76 76
77 // Reads the value of the preference indicated by |path| from |pref_store|. 77 // Reads the value of the preference indicated by |path| from |pref_store|.
78 // Returns NULL if the preference was not found. 78 // Returns NULL if the preference was not found.
79 const Value* GetPref(PrefStore* pref_store, const char* path); 79 const Value* GetPref(PrefStore* pref_store, const char* path);
80 80
81 // Sets the value for |path| in |pref_store|. 81 // Sets the value for |path| in |pref_store|.
82 void SetPref(PrefStore* pref_store, const char* path, Value* value); 82 void SetPref(PrefStore* pref_store, const char* path, Value* value);
83 83
84 // Removes the preference identified by |path| from |pref_store|. 84 // Removes the preference identified by |path| from |pref_store|.
85 void RemovePref(PrefStore* pref_store, const char* path); 85 void RemovePref(PrefStore* pref_store, const char* path);
86 86
87 // Pointers to the pref stores our value store uses. 87 // Pointers to the pref stores our value store uses.
88 PrefStore* managed_platform_prefs_; // weak 88 PrefStore* managed_platform_prefs_; // weak
89 PrefStore* device_management_prefs_; // weak 89 PrefStore* device_management_prefs_; // weak
90 PrefStore* user_prefs_; // weak 90 PrefStore* user_prefs_; // weak
91 PrefStore* default_prefs_; // weak 91 PrefStore* default_prefs_; // weak
92 92
93 DISALLOW_COPY_AND_ASSIGN(TestingPrefService); 93 DISALLOW_COPY_AND_ASSIGN(TestingPrefService);
94 }; 94 };
95 95
96 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ 96 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/common/pref_store_observer_mock.h ('k') | chrome/test/testing_pref_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698