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

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: Whitespaces + fixes for trybot 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
13 // A PrefService subclass for testing. It operates totally in memory and 15 // A PrefService subclass for testing. It operates totally in memory and
14 // provides additional API for manipulating preferences at the different levels 16 // provides additional API for manipulating preferences at the different levels
15 // (managed, extension, user) conveniently. 17 // (managed, extension, user) conveniently.
16 class TestingPrefService : public PrefService { 18 class TestingPrefService : public PrefService {
17 public: 19 public:
20 virtual ~TestingPrefService();
21
18 // Create an empty instance. 22 // Create an empty instance.
19 TestingPrefService(); 23 static TestingPrefService* CreateTestingPrefService();
Mattias Nissler (ping if slow) 2010/12/20 14:50:02 Introducing a factory function here makes it harde
battre 2010/12/21 18:51:59 Done.
20 virtual ~TestingPrefService() {}
21 24
22 // Read the value of a preference from the managed layer. Returns NULL if the 25 // Read the value of a preference from the managed layer. Returns NULL if the
23 // preference is not defined at the managed layer. 26 // preference is not defined at the managed layer.
24 const Value* GetManagedPref(const char* path) const; 27 const Value* GetManagedPref(const char* path) const;
25 28
26 // Set a preference on the managed layer and fire observers if the preference 29 // Set a preference on the managed layer and fire observers if the preference
27 // changed. Assumes ownership of |value|. 30 // changed. Assumes ownership of |value|.
28 void SetManagedPref(const char* path, Value* value); 31 void SetManagedPref(const char* path, Value* value);
29 32
30 // Clear the preference on the managed layer and fire observers if the 33 // Clear the preference on the managed layer and fire observers if the
31 // preference has been defined previously. 34 // preference has been defined previously.
32 void RemoveManagedPref(const char* path); 35 void RemoveManagedPref(const char* path);
33 36
34 // Similar to the above, but for user preferences. 37 // Similar to the above, but for user preferences.
35 const Value* GetUserPref(const char* path) const; 38 const Value* GetUserPref(const char* path) const;
36 void SetUserPref(const char* path, Value* value); 39 void SetUserPref(const char* path, Value* value);
37 void RemoveUserPref(const char* path); 40 void RemoveUserPref(const char* path);
38 41
42 scoped_refptr<ExtensionPrefStore> GetExtensionPrefs();
43 protected:
44 TestingPrefService(
45 scoped_refptr<TestingPrefStore> managed_platform_prefs,
46 scoped_refptr<TestingPrefStore> device_management_prefs,
47 scoped_refptr<ExtensionPrefStore> extension_prefs,
48 scoped_refptr<TestingPrefStore> user_prefs);
49
39 private: 50 private:
40 // Reads the value of the preference indicated by |path| from |pref_store|. 51 // Reads the value of the preference indicated by |path| from |pref_store|.
41 // Returns NULL if the preference was not found. 52 // Returns NULL if the preference was not found.
42 const Value* GetPref(TestingPrefStore* pref_store, const char* path) const; 53 const Value* GetPref(scoped_refptr<TestingPrefStore> pref_store,
54 const char* path) const;
43 55
44 // Sets the value for |path| in |pref_store|. 56 // Sets the value for |path| in |pref_store|.
45 void SetPref(TestingPrefStore* pref_store, const char* path, Value* value); 57 void SetPref(scoped_refptr<TestingPrefStore> pref_store,
58 const char* path, Value* value);
46 59
47 // Removes the preference identified by |path| from |pref_store|. 60 // Removes the preference identified by |path| from |pref_store|.
48 void RemovePref(TestingPrefStore* pref_store, const char* path); 61 void RemovePref(scoped_refptr<TestingPrefStore> pref_store, const char* path);
49 62
50 // Pointers to the pref stores our value store uses. 63 // Pointers to the pref stores our value store uses.
51 TestingPrefStore* managed_platform_prefs_; // weak 64 scoped_refptr<TestingPrefStore> managed_platform_prefs_;
52 TestingPrefStore* device_management_prefs_; // weak 65 scoped_refptr<TestingPrefStore> device_management_prefs_;
53 TestingPrefStore* user_prefs_; // weak 66 scoped_refptr<ExtensionPrefStore> extension_prefs_;
67 scoped_refptr<TestingPrefStore> user_prefs_;
54 68
55 DISALLOW_COPY_AND_ASSIGN(TestingPrefService); 69 DISALLOW_COPY_AND_ASSIGN(TestingPrefService);
56 }; 70 };
57 71
58 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_ 72 #endif // CHROME_TEST_TESTING_PREF_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698