| 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 #include "chrome/test/testing_pref_service.h" | 5 #include "chrome/test/testing_pref_service.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_pref_store.h" |
| 7 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 8 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
| 8 #include "chrome/browser/prefs/command_line_pref_store.h" | 9 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 10 #include "chrome/browser/prefs/default_pref_store.h" |
| 9 #include "chrome/browser/prefs/pref_notifier.h" | 11 #include "chrome/browser/prefs/pref_notifier.h" |
| 10 #include "chrome/browser/prefs/pref_value_store.h" | 12 #include "chrome/browser/prefs/pref_value_store.h" |
| 11 #include "chrome/browser/prefs/testing_pref_store.h" | 13 #include "chrome/browser/prefs/testing_pref_store.h" |
| 12 | 14 |
| 13 // TODO(pamg): Instantiate no PrefStores by default. Allow callers to specify | 15 // TODO(pamg): Instantiate no PrefStores by default. Allow callers to specify |
| 14 // which they want, and expand usage of this class to more unit tests. | 16 // which they want, and expand usage of this class to more unit tests. |
| 17 |
| 18 TestingPrefServiceBase::TestingPrefServiceBase( |
| 19 TestingPrefStore* managed_platform_prefs, |
| 20 TestingPrefStore* device_management_prefs, |
| 21 ExtensionPrefStore* extension_prefs, |
| 22 TestingPrefStore* user_prefs) |
| 23 : PrefService(managed_platform_prefs, |
| 24 device_management_prefs, |
| 25 extension_prefs, |
| 26 NULL, |
| 27 user_prefs, |
| 28 NULL, |
| 29 new DefaultPrefStore(), |
| 30 NULL, |
| 31 true), |
| 32 managed_platform_prefs_(managed_platform_prefs), |
| 33 device_management_prefs_(device_management_prefs), |
| 34 extension_prefs_(extension_prefs), |
| 35 user_prefs_(user_prefs) { |
| 36 } |
| 37 |
| 38 TestingPrefServiceBase::~TestingPrefServiceBase() { |
| 39 } |
| 40 |
| 15 TestingPrefService::TestingPrefService() | 41 TestingPrefService::TestingPrefService() |
| 16 : PrefService( | 42 : TestingPrefServiceBase(new TestingPrefStore(), |
| 17 managed_platform_prefs_ = new TestingPrefStore(), | 43 new TestingPrefStore(), |
| 18 device_management_prefs_ = new TestingPrefStore(), | 44 new ExtensionPrefStore(), |
| 19 NULL, | 45 new TestingPrefStore()) { |
| 20 NULL, | 46 } |
| 21 user_prefs_ = new TestingPrefStore(), | 47 |
| 22 NULL, | 48 TestingPrefService::~TestingPrefService() { |
| 23 NULL) { | |
| 24 } | 49 } |
| 25 | 50 |
| 26 const Value* TestingPrefService::GetManagedPref(const char* path) const { | 51 const Value* TestingPrefService::GetManagedPref(const char* path) const { |
| 27 return GetPref(managed_platform_prefs_, path); | 52 return GetPref(managed_platform_prefs_, path); |
| 28 } | 53 } |
| 29 | 54 |
| 30 void TestingPrefService::SetManagedPref(const char* path, Value* value) { | 55 void TestingPrefService::SetManagedPref(const char* path, Value* value) { |
| 31 SetPref(managed_platform_prefs_, path, value); | 56 SetPref(managed_platform_prefs_, path, value); |
| 32 } | 57 } |
| 33 | 58 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 56 void TestingPrefService::SetPref(TestingPrefStore* pref_store, | 81 void TestingPrefService::SetPref(TestingPrefStore* pref_store, |
| 57 const char* path, | 82 const char* path, |
| 58 Value* value) { | 83 Value* value) { |
| 59 pref_store->SetValue(path, value); | 84 pref_store->SetValue(path, value); |
| 60 } | 85 } |
| 61 | 86 |
| 62 void TestingPrefService::RemovePref(TestingPrefStore* pref_store, | 87 void TestingPrefService::RemovePref(TestingPrefStore* pref_store, |
| 63 const char* path) { | 88 const char* path) { |
| 64 pref_store->RemoveValue(path); | 89 pref_store->RemoveValue(path); |
| 65 } | 90 } |
| 91 |
| 92 ExtensionPrefStore* TestingPrefService::GetExtensionPrefs() { |
| 93 return extension_prefs_.get(); |
| 94 } |
| OLD | NEW |