testing_pref_service_syncable.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
1// Copyright (c) 2013 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/base/testing_pref_service_syncable.h"
6
7#include "base/bind.h"
8#include "base/prefs/pref_notifier_impl.h"
9#include "base/prefs/pref_value_store.h"
10#include "components/user_prefs/pref_registry_syncable.h"
11#include "testing/gtest/include/gtest/gtest.h"
12
13template <>
14TestingPrefServiceBase<PrefServiceSyncable, user_prefs::PrefRegistrySyncable>::
15    TestingPrefServiceBase(TestingPrefStore* managed_prefs,
16                           TestingPrefStore* user_prefs,
17                           TestingPrefStore* recommended_prefs,
18                           user_prefs::PrefRegistrySyncable* pref_registry,
19                           PrefNotifierImpl* pref_notifier)
20    : PrefServiceSyncable(
21          pref_notifier,
22          new PrefValueStore(managed_prefs,
23                             NULL,
24                             NULL,
25                             user_prefs,
26                             recommended_prefs,
27                             pref_registry->defaults(),
28                             pref_notifier),
29          user_prefs,
30          pref_registry,
31          base::Bind(&TestingPrefServiceBase<
32              PrefServiceSyncable,
33              user_prefs::PrefRegistrySyncable>::HandleReadError),
34          false),
35      managed_prefs_(managed_prefs),
36      user_prefs_(user_prefs),
37      recommended_prefs_(recommended_prefs) {}
38
39TestingPrefServiceSyncable::TestingPrefServiceSyncable()
40    : TestingPrefServiceBase<PrefServiceSyncable,
41                             user_prefs::PrefRegistrySyncable>(
42        new TestingPrefStore(),
43        new TestingPrefStore(),
44        new TestingPrefStore(),
45        new user_prefs::PrefRegistrySyncable(),
46        new PrefNotifierImpl()) {
47}
48
49TestingPrefServiceSyncable::TestingPrefServiceSyncable(
50    TestingPrefStore* managed_prefs,
51    TestingPrefStore* user_prefs,
52    TestingPrefStore* recommended_prefs,
53    user_prefs::PrefRegistrySyncable* pref_registry,
54    PrefNotifierImpl* pref_notifier)
55    : TestingPrefServiceBase<PrefServiceSyncable,
56                             user_prefs::PrefRegistrySyncable>(
57        managed_prefs,
58        user_prefs,
59        recommended_prefs,
60        pref_registry,
61        pref_notifier) {
62}
63
64TestingPrefServiceSyncable::~TestingPrefServiceSyncable() {
65}
66
67user_prefs::PrefRegistrySyncable* TestingPrefServiceSyncable::registry() {
68  return static_cast<user_prefs::PrefRegistrySyncable*>(
69      DeprecatedGetPrefRegistry());
70}
71