blob: afcb1c57b0a4629bb36e07ca42c39aadf7b3274d [file] [log] [blame]
[email protected]9a8c4022011-01-25 14:25:331// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]74379bc52010-07-21 13:54:082// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "chrome/test/testing_pref_service.h"
6
[email protected]f2d1f612010-12-09 15:10:177#include "chrome/browser/policy/configuration_policy_pref_store.h"
[email protected]ce1850e92010-10-15 08:40:588#include "chrome/browser/prefs/command_line_pref_store.h"
[email protected]9a8c4022011-01-25 14:25:339#include "chrome/browser/prefs/default_pref_store.h"
[email protected]acd78969c2010-12-08 09:49:1110#include "chrome/browser/prefs/pref_notifier.h"
[email protected]37858e52010-08-26 00:22:0211#include "chrome/browser/prefs/pref_value_store.h"
[email protected]f2d1f612010-12-09 15:10:1712#include "chrome/browser/prefs/testing_pref_store.h"
[email protected]fa26b3d52010-08-06 08:51:5013
[email protected]9a8c4022011-01-25 14:25:3314TestingPrefServiceBase::TestingPrefServiceBase(
15 TestingPrefStore* managed_platform_prefs,
16 TestingPrefStore* device_management_prefs,
17 TestingPrefStore* user_prefs)
18 : PrefService(managed_platform_prefs,
19 device_management_prefs,
20 NULL,
21 NULL,
22 user_prefs,
23 NULL,
24 new DefaultPrefStore()),
25 managed_platform_prefs_(managed_platform_prefs),
26 device_management_prefs_(device_management_prefs),
27 user_prefs_(user_prefs) {
[email protected]ce1850e92010-10-15 08:40:5828}
29
[email protected]9a8c4022011-01-25 14:25:3330TestingPrefServiceBase::~TestingPrefServiceBase() {
31}
32
33const Value* TestingPrefServiceBase::GetManagedPref(const char* path) const {
[email protected]be1c6e922010-11-17 12:49:1734 return GetPref(managed_platform_prefs_, path);
[email protected]74379bc52010-07-21 13:54:0835}
36
[email protected]9a8c4022011-01-25 14:25:3337void TestingPrefServiceBase::SetManagedPref(const char* path, Value* value) {
[email protected]be1c6e922010-11-17 12:49:1738 SetPref(managed_platform_prefs_, path, value);
[email protected]74379bc52010-07-21 13:54:0839}
40
[email protected]9a8c4022011-01-25 14:25:3341void TestingPrefServiceBase::RemoveManagedPref(const char* path) {
[email protected]be1c6e922010-11-17 12:49:1742 RemovePref(managed_platform_prefs_, path);
[email protected]74379bc52010-07-21 13:54:0843}
44
[email protected]9a8c4022011-01-25 14:25:3345const Value* TestingPrefServiceBase::GetUserPref(const char* path) const {
[email protected]74379bc52010-07-21 13:54:0846 return GetPref(user_prefs_, path);
47}
48
[email protected]9a8c4022011-01-25 14:25:3349void TestingPrefServiceBase::SetUserPref(const char* path, Value* value) {
[email protected]74379bc52010-07-21 13:54:0850 SetPref(user_prefs_, path, value);
51}
52
[email protected]9a8c4022011-01-25 14:25:3353void TestingPrefServiceBase::RemoveUserPref(const char* path) {
[email protected]74379bc52010-07-21 13:54:0854 RemovePref(user_prefs_, path);
55}
56
[email protected]9a8c4022011-01-25 14:25:3357const Value* TestingPrefServiceBase::GetPref(TestingPrefStore* pref_store,
58 const char* path) const {
[email protected]f2d1f612010-12-09 15:10:1759 Value* res;
60 return pref_store->GetValue(path, &res) == PrefStore::READ_OK ? res : NULL;
[email protected]74379bc52010-07-21 13:54:0861}
62
[email protected]9a8c4022011-01-25 14:25:3363void TestingPrefServiceBase::SetPref(TestingPrefStore* pref_store,
64 const char* path,
65 Value* value) {
[email protected]f2d1f612010-12-09 15:10:1766 pref_store->SetValue(path, value);
[email protected]74379bc52010-07-21 13:54:0867}
68
[email protected]9a8c4022011-01-25 14:25:3369void TestingPrefServiceBase::RemovePref(TestingPrefStore* pref_store,
70 const char* path) {
[email protected]f2d1f612010-12-09 15:10:1771 pref_store->RemoveValue(path);
[email protected]74379bc52010-07-21 13:54:0872}
[email protected]9a8c4022011-01-25 14:25:3373
74TestingPrefService::TestingPrefService()
75 : TestingPrefServiceBase(new TestingPrefStore(),
76 new TestingPrefStore(),
77 new TestingPrefStore()) {
78}
79
80TestingPrefService::~TestingPrefService() {
81}