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

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

Issue 5915004: Introduce incognito preference settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments 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
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 "base/ref_counted.h"
9 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
10 11
12 class ExtensionPrefStore;
11 class TestingPrefStore; 13 class TestingPrefStore;
12 14
15 // Helper base class to allow simple construction of TestPrefService objects.
16 class TestingPrefServiceBase : public PrefService {
17 public:
18 virtual ~TestingPrefServiceBase();
19
20 protected:
21 TestingPrefServiceBase(
22 TestingPrefStore* managed_platform_prefs,
23 TestingPrefStore* device_management_prefs,
24 ExtensionPrefStore* extension_prefs,
25 TestingPrefStore* user_prefs);
26
27 // Pointers to the pref stores our value store uses.
28 scoped_refptr<TestingPrefStore> managed_platform_prefs_;
29 scoped_refptr<TestingPrefStore> device_management_prefs_;
30 scoped_refptr<ExtensionPrefStore> extension_prefs_;
31 scoped_refptr<TestingPrefStore> user_prefs_;
Mattias Nissler (ping if slow) 2010/12/22 12:09:03 Didn't we agree to just move all the interface int
battre 2010/12/22 18:34:53 Done.
32
33 DISALLOW_COPY_AND_ASSIGN(TestingPrefServiceBase);
34 };
35
13 // A PrefService subclass for testing. It operates totally in memory and 36 // A PrefService subclass for testing. It operates totally in memory and
14 // provides additional API for manipulating preferences at the different levels 37 // provides additional API for manipulating preferences at the different levels
15 // (managed, extension, user) conveniently. 38 // (managed, extension, user) conveniently.
16 class TestingPrefService : public PrefService { 39 class TestingPrefService : public TestingPrefServiceBase {
17 public: 40 public:
18 // Create an empty instance.
19 TestingPrefService(); 41 TestingPrefService();
20 virtual ~TestingPrefService() {} 42 virtual ~TestingPrefService();
21 43
22 // Read the value of a preference from the managed layer. Returns NULL if the 44 // Read the value of a preference from the managed layer. Returns NULL if the
23 // preference is not defined at the managed layer. 45 // preference is not defined at the managed layer.
24 const Value* GetManagedPref(const char* path) const; 46 const Value* GetManagedPref(const char* path) const;
25 47
26 // Set a preference on the managed layer and fire observers if the preference 48 // Set a preference on the managed layer and fire observers if the preference
27 // changed. Assumes ownership of |value|. 49 // changed. Assumes ownership of |value|.
28 void SetManagedPref(const char* path, Value* value); 50 void SetManagedPref(const char* path, Value* value);
29 51
30 // Clear the preference on the managed layer and fire observers if the 52 // Clear the preference on the managed layer and fire observers if the
31 // preference has been defined previously. 53 // preference has been defined previously.
32 void RemoveManagedPref(const char* path); 54 void RemoveManagedPref(const char* path);
33 55
34 // Similar to the above, but for user preferences. 56 // Similar to the above, but for user preferences.
35 const Value* GetUserPref(const char* path) const; 57 const Value* GetUserPref(const char* path) const;
36 void SetUserPref(const char* path, Value* value); 58 void SetUserPref(const char* path, Value* value);
37 void RemoveUserPref(const char* path); 59 void RemoveUserPref(const char* path);
38 60
61 ExtensionPrefStore* GetExtensionPrefs();
Mattias Nissler (ping if slow) 2010/12/22 12:09:03 No! This class is meant for the case when you need
battre 2010/12/22 18:34:53 This method was introduced because the ExtensionPr
62
39 private: 63 private:
40 // Reads the value of the preference indicated by |path| from |pref_store|. 64 // Reads the value of the preference indicated by |path| from |pref_store|.
41 // Returns NULL if the preference was not found. 65 // Returns NULL if the preference was not found.
42 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const; 66 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const;
43 67
44 // Sets the value for |path| in |pref_store|. 68 // Sets the value for |path| in |pref_store|.
45 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value); 69 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value);
46 70
47 // Removes the preference identified by |path| from |pref_store|. 71 // Removes the preference identified by |path| from |pref_store|.
48 void RemovePref(TestingPrefStore* pref_store, const char* path); 72 void RemovePref(TestingPrefStore* pref_store, const char* path);
49 73
50 // Pointers to the pref stores our value store uses.
51 TestingPrefStore* managed_platform_prefs_; // weak
52 TestingPrefStore* device_management_prefs_; // weak
53 TestingPrefStore* user_prefs_; // weak
54
55 DISALLOW_COPY_AND_ASSIGN(TestingPrefService); 74 DISALLOW_COPY_AND_ASSIGN(TestingPrefService);
56 }; 75 };
57 76
58 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ 77 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698