| Index: chrome/test/testing_pref_service.cc
|
| diff --git a/chrome/test/testing_pref_service.cc b/chrome/test/testing_pref_service.cc
|
| index 66342bc471b83327431e8980b7614c972c1d15d2..5328214bf5122636be49034985b74dcfa2ffd411 100644
|
| --- a/chrome/test/testing_pref_service.cc
|
| +++ b/chrome/test/testing_pref_service.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "chrome/test/testing_pref_service.h"
|
|
|
| +#include "chrome/browser/extensions/extension_pref_store.h"
|
| #include "chrome/browser/policy/configuration_policy_pref_store.h"
|
| #include "chrome/browser/prefs/command_line_pref_store.h"
|
| #include "chrome/browser/prefs/pref_notifier.h"
|
| @@ -12,15 +13,38 @@
|
|
|
| // TODO(pamg): Instantiate no PrefStores by default. Allow callers to specify
|
| // which they want, and expand usage of this class to more unit tests.
|
| -TestingPrefService::TestingPrefService()
|
| - : PrefService(
|
| - managed_platform_prefs_ = new TestingPrefStore(),
|
| - device_management_prefs_ = new TestingPrefStore(),
|
| - NULL,
|
| - NULL,
|
| - user_prefs_ = new TestingPrefStore(),
|
| - NULL,
|
| - NULL) {
|
| +
|
| +// We assign to managed_platform_prefs_weak_ because managed_platform_prefs_
|
| +// and friends are not constructed yet, at the time PrefService is being
|
| +// constructed.
|
| +TestingPrefService::TestingPrefService(
|
| + scoped_refptr<TestingPrefStore> managed_platform_prefs,
|
| + scoped_refptr<TestingPrefStore> device_management_prefs,
|
| + scoped_refptr<ExtensionPrefStore> extension_prefs,
|
| + scoped_refptr<TestingPrefStore> user_prefs)
|
| + : PrefService(managed_platform_prefs,
|
| + device_management_prefs,
|
| + extension_prefs,
|
| + NULL,
|
| + user_prefs,
|
| + NULL,
|
| + NULL),
|
| + managed_platform_prefs_(managed_platform_prefs),
|
| + device_management_prefs_(device_management_prefs),
|
| + extension_prefs_(extension_prefs),
|
| + user_prefs_(user_prefs) {
|
| +}
|
| +
|
| +TestingPrefService::~TestingPrefService() {
|
| +}
|
| +
|
| +// static
|
| +TestingPrefService* TestingPrefService::CreateTestingPrefService() {
|
| + return new TestingPrefService(
|
| + new TestingPrefStore(),
|
| + new TestingPrefStore(),
|
| + new ExtensionPrefStore(),
|
| + new TestingPrefStore());
|
| }
|
|
|
| const Value* TestingPrefService::GetManagedPref(const char* path) const {
|
| @@ -47,19 +71,24 @@ void TestingPrefService::RemoveUserPref(const char* path) {
|
| RemovePref(user_prefs_, path);
|
| }
|
|
|
| -const Value* TestingPrefService::GetPref(TestingPrefStore* pref_store,
|
| - const char* path) const {
|
| +const Value* TestingPrefService::GetPref(
|
| + scoped_refptr<TestingPrefStore> pref_store,
|
| + const char* path) const {
|
| Value* res;
|
| return pref_store->GetValue(path, &res) == PrefStore::READ_OK ? res : NULL;
|
| }
|
|
|
| -void TestingPrefService::SetPref(TestingPrefStore* pref_store,
|
| +void TestingPrefService::SetPref(scoped_refptr<TestingPrefStore> pref_store,
|
| const char* path,
|
| Value* value) {
|
| pref_store->SetValue(path, value);
|
| }
|
|
|
| -void TestingPrefService::RemovePref(TestingPrefStore* pref_store,
|
| +void TestingPrefService::RemovePref(scoped_refptr<TestingPrefStore> pref_store,
|
| const char* path) {
|
| pref_store->RemoveValue(path);
|
| }
|
| +
|
| +scoped_refptr<ExtensionPrefStore> TestingPrefService::GetExtensionPrefs() {
|
| + return extension_prefs_;
|
| +}
|
|
|