1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/prefs/pref_service_factory.h"
#include "base/bind.h"
#include "base/sequenced_task_runner.h"
#include "components/prefs/default_pref_store.h"
#include "components/prefs/json_pref_store.h"
#include "components/prefs/pref_filter.h"
#include "components/prefs/pref_notifier_impl.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/pref_value_store.h"
namespace {
// Do-nothing default implementation.
void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error) {
}
} // namespace
PrefServiceFactory::PrefServiceFactory()
: managed_prefs_(NULL),
supervised_user_prefs_(NULL),
extension_prefs_(NULL),
command_line_prefs_(NULL),
user_prefs_(NULL),
recommended_prefs_(NULL),
read_error_callback_(base::Bind(&DoNothingHandleReadError)),
async_(false) {}
PrefServiceFactory::~PrefServiceFactory() {}
void PrefServiceFactory::SetUserPrefsFile(
const base::FilePath& prefs_file,
base::SequencedTaskRunner* task_runner) {
user_prefs_ = new JsonPrefStore(
prefs_file, task_runner, scoped_ptr<PrefFilter>());
}
scoped_ptr<PrefService> PrefServiceFactory::Create(
PrefRegistry* pref_registry) {
PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
scoped_ptr<PrefService> pref_service(
new PrefService(pref_notifier,
new PrefValueStore(managed_prefs_.get(),
supervised_user_prefs_.get(),
extension_prefs_.get(),
command_line_prefs_.get(),
user_prefs_.get(),
recommended_prefs_.get(),
pref_registry->defaults().get(),
pref_notifier),
user_prefs_.get(),
pref_registry,
read_error_callback_,
async_));
return pref_service;
}
|