OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "chrome/test/testing_pref_service.h" | 5 #include "chrome/test/testing_pref_service.h" |
6 | 6 |
7 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 7 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
8 #include "chrome/browser/prefs/command_line_pref_store.h" | 8 #include "chrome/browser/prefs/command_line_pref_store.h" |
9 #include "chrome/browser/prefs/default_pref_store.h" | 9 #include "chrome/browser/prefs/default_pref_store.h" |
10 #include "chrome/browser/prefs/pref_notifier.h" | 10 #include "chrome/browser/prefs/pref_notifier.h" |
11 #include "chrome/browser/prefs/pref_value_store.h" | 11 #include "chrome/browser/prefs/pref_value_store.h" |
12 #include "chrome/browser/prefs/testing_pref_store.h" | 12 #include "chrome/browser/prefs/testing_pref_store.h" |
13 | 13 |
14 TestingPrefServiceBase::TestingPrefServiceBase( | 14 TestingPrefServiceBase::TestingPrefServiceBase( |
15 TestingPrefStore* managed_platform_prefs, | 15 TestingPrefStore* managed_platform_prefs, |
16 TestingPrefStore* user_prefs) | 16 TestingPrefStore* user_prefs, |
| 17 TestingPrefStore* recommended_platform_prefs) |
17 : PrefService(managed_platform_prefs, | 18 : PrefService(managed_platform_prefs, |
18 NULL, | 19 NULL, |
19 NULL, | 20 NULL, |
20 NULL, | 21 NULL, |
21 user_prefs, | 22 user_prefs, |
22 NULL, | 23 recommended_platform_prefs, |
23 NULL, | 24 NULL, |
24 new DefaultPrefStore()), | 25 new DefaultPrefStore()), |
25 managed_platform_prefs_(managed_platform_prefs), | 26 managed_platform_prefs_(managed_platform_prefs), |
26 user_prefs_(user_prefs) { | 27 user_prefs_(user_prefs), |
| 28 recommended_platform_prefs_(recommended_platform_prefs) { |
27 } | 29 } |
28 | 30 |
29 TestingPrefServiceBase::~TestingPrefServiceBase() { | 31 TestingPrefServiceBase::~TestingPrefServiceBase() { |
30 } | 32 } |
31 | 33 |
32 const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const { | 34 const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const { |
33 return GetPref(managed_platform_prefs_, path); | 35 return GetPref(managed_platform_prefs_, path); |
34 } | 36 } |
35 | 37 |
36 void TestingPrefServiceBase::SetManagedPref(const char* path, Value* value) { | 38 void TestingPrefServiceBase::SetManagedPref(const char* path, Value* value) { |
37 SetPref(managed_platform_prefs_, path, value); | 39 SetPref(managed_platform_prefs_, path, value); |
38 } | 40 } |
39 | 41 |
40 void TestingPrefServiceBase::RemoveManagedPref(const char* path) { | 42 void TestingPrefServiceBase::RemoveManagedPref(const char* path) { |
41 RemovePref(managed_platform_prefs_, path); | 43 RemovePref(managed_platform_prefs_, path); |
42 } | 44 } |
43 | 45 |
44 const Value* TestingPrefServiceBase::GetUserPref(const char* path) const { | 46 const Value* TestingPrefServiceBase::GetUserPref(const char* path) const { |
45 return GetPref(user_prefs_, path); | 47 return GetPref(user_prefs_, path); |
46 } | 48 } |
47 | 49 |
48 void TestingPrefServiceBase::SetUserPref(const char* path, Value* value) { | 50 void TestingPrefServiceBase::SetUserPref(const char* path, Value* value) { |
49 SetPref(user_prefs_, path, value); | 51 SetPref(user_prefs_, path, value); |
50 } | 52 } |
51 | 53 |
52 void TestingPrefServiceBase::RemoveUserPref(const char* path) { | 54 void TestingPrefServiceBase::RemoveUserPref(const char* path) { |
53 RemovePref(user_prefs_, path); | 55 RemovePref(user_prefs_, path); |
54 } | 56 } |
55 | 57 |
| 58 const Value* TestingPrefServiceBase::GetRecommendedPref( |
| 59 const char* path) const { |
| 60 return GetPref(recommended_platform_prefs_, path); |
| 61 } |
| 62 |
| 63 void TestingPrefServiceBase::SetRecommendedPref( |
| 64 const char* path, Value* value) { |
| 65 SetPref(recommended_platform_prefs_, path, value); |
| 66 } |
| 67 |
| 68 void TestingPrefServiceBase::RemoveRecommendedPref(const char* path) { |
| 69 RemovePref(recommended_platform_prefs_, path); |
| 70 } |
| 71 |
56 const Value* TestingPrefServiceBase::GetPref(TestingPrefStore* pref_store, | 72 const Value* TestingPrefServiceBase::GetPref(TestingPrefStore* pref_store, |
57 const char* path) const { | 73 const char* path) const { |
58 const Value* res; | 74 const Value* res; |
59 return pref_store->GetValue(path, &res) == PrefStore::READ_OK ? res : NULL; | 75 return pref_store->GetValue(path, &res) == PrefStore::READ_OK ? res : NULL; |
60 } | 76 } |
61 | 77 |
62 void TestingPrefServiceBase::SetPref(TestingPrefStore* pref_store, | 78 void TestingPrefServiceBase::SetPref(TestingPrefStore* pref_store, |
63 const char* path, | 79 const char* path, |
64 Value* value) { | 80 Value* value) { |
65 pref_store->SetValue(path, value); | 81 pref_store->SetValue(path, value); |
66 } | 82 } |
67 | 83 |
68 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store, | 84 void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store, |
69 const char* path) { | 85 const char* path) { |
70 pref_store->RemoveValue(path); | 86 pref_store->RemoveValue(path); |
71 } | 87 } |
72 | 88 |
73 TestingPrefService::TestingPrefService() | 89 TestingPrefService::TestingPrefService() |
74 : TestingPrefServiceBase(new TestingPrefStore(), | 90 : TestingPrefServiceBase(new TestingPrefStore(), |
| 91 new TestingPrefStore(), |
75 new TestingPrefStore()) { | 92 new TestingPrefStore()) { |
76 } | 93 } |
77 | 94 |
78 TestingPrefService::~TestingPrefService() { | 95 TestingPrefService::~TestingPrefService() { |
79 } | 96 } |
OLD | NEW |