blob: 66342bc471b83327431e8980b7614c972c1d15d2 [file] [log] [blame]
[email protected]74379bc52010-07-21 13:54:081// 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
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]acd78969c2010-12-08 09:49:119#include "chrome/browser/prefs/pref_notifier.h"
[email protected]37858e52010-08-26 00:22:0210#include "chrome/browser/prefs/pref_value_store.h"
[email protected]f2d1f612010-12-09 15:10:1711#include "chrome/browser/prefs/testing_pref_store.h"
[email protected]fa26b3d52010-08-06 08:51:5012
13// 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.
[email protected]74379bc52010-07-21 13:54:0815TestingPrefService::TestingPrefService()
[email protected]acd78969c2010-12-08 09:49:1116 : PrefService(
17 managed_platform_prefs_ = new TestingPrefStore(),
18 device_management_prefs_ = new TestingPrefStore(),
19 NULL,
20 NULL,
21 user_prefs_ = new TestingPrefStore(),
22 NULL,
23 NULL) {
[email protected]ce1850e92010-10-15 08:40:5824}
25
[email protected]f2d1f612010-12-09 15:10:1726const Value* TestingPrefService::GetManagedPref(const char* path) const {
[email protected]be1c6e922010-11-17 12:49:1727 return GetPref(managed_platform_prefs_, path);
[email protected]74379bc52010-07-21 13:54:0828}
29
[email protected]57ecc4b2010-08-11 03:02:5130void TestingPrefService::SetManagedPref(const char* path, Value* value) {
[email protected]be1c6e922010-11-17 12:49:1731 SetPref(managed_platform_prefs_, path, value);
[email protected]74379bc52010-07-21 13:54:0832}
33
[email protected]57ecc4b2010-08-11 03:02:5134void TestingPrefService::RemoveManagedPref(const char* path) {
[email protected]be1c6e922010-11-17 12:49:1735 RemovePref(managed_platform_prefs_, path);
[email protected]74379bc52010-07-21 13:54:0836}
37
[email protected]f2d1f612010-12-09 15:10:1738const Value* TestingPrefService::GetUserPref(const char* path) const {
[email protected]74379bc52010-07-21 13:54:0839 return GetPref(user_prefs_, path);
40}
41
[email protected]57ecc4b2010-08-11 03:02:5142void TestingPrefService::SetUserPref(const char* path, Value* value) {
[email protected]74379bc52010-07-21 13:54:0843 SetPref(user_prefs_, path, value);
44}
45
[email protected]57ecc4b2010-08-11 03:02:5146void TestingPrefService::RemoveUserPref(const char* path) {
[email protected]74379bc52010-07-21 13:54:0847 RemovePref(user_prefs_, path);
48}
49
[email protected]f2d1f612010-12-09 15:10:1750const Value* TestingPrefService::GetPref(TestingPrefStore* pref_store,
51 const char* path) const {
52 Value* res;
53 return pref_store->GetValue(path, &res) == PrefStore::READ_OK ? res : NULL;
[email protected]74379bc52010-07-21 13:54:0854}
55
[email protected]f2d1f612010-12-09 15:10:1756void TestingPrefService::SetPref(TestingPrefStore* pref_store,
[email protected]57ecc4b2010-08-11 03:02:5157 const char* path,
[email protected]74379bc52010-07-21 13:54:0858 Value* value) {
[email protected]f2d1f612010-12-09 15:10:1759 pref_store->SetValue(path, value);
[email protected]74379bc52010-07-21 13:54:0860}
61
[email protected]f2d1f612010-12-09 15:10:1762void TestingPrefService::RemovePref(TestingPrefStore* pref_store,
[email protected]57ecc4b2010-08-11 03:02:5163 const char* path) {
[email protected]f2d1f612010-12-09 15:10:1764 pref_store->RemoveValue(path);
[email protected]74379bc52010-07-21 13:54:0865}