Roll src/third_party/WebKit 4619053:6b63e20 (svn 201059:201060)
[chromium-blink-merge.git] / base / prefs / pref_service_factory.cc
blob8caf073e7bb1de01ca27e85cd8fd91292e281d22
1 // Copyright 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.
5 #include "base/prefs/pref_service_factory.h"
7 #include "base/bind.h"
8 #include "base/prefs/default_pref_store.h"
9 #include "base/prefs/json_pref_store.h"
10 #include "base/prefs/pref_filter.h"
11 #include "base/prefs/pref_notifier_impl.h"
12 #include "base/prefs/pref_service.h"
13 #include "base/prefs/pref_value_store.h"
14 #include "base/sequenced_task_runner.h"
16 namespace base {
18 namespace {
20 // Do-nothing default implementation.
21 void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error) {
24 } // namespace
26 PrefServiceFactory::PrefServiceFactory()
27 : managed_prefs_(NULL),
28 supervised_user_prefs_(NULL),
29 extension_prefs_(NULL),
30 command_line_prefs_(NULL),
31 user_prefs_(NULL),
32 recommended_prefs_(NULL),
33 read_error_callback_(base::Bind(&DoNothingHandleReadError)),
34 async_(false) {}
36 PrefServiceFactory::~PrefServiceFactory() {}
38 void PrefServiceFactory::SetUserPrefsFile(
39 const base::FilePath& prefs_file,
40 base::SequencedTaskRunner* task_runner) {
41 user_prefs_ = new JsonPrefStore(
42 prefs_file, task_runner, scoped_ptr<PrefFilter>());
45 scoped_ptr<PrefService> PrefServiceFactory::Create(
46 PrefRegistry* pref_registry) {
47 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
48 scoped_ptr<PrefService> pref_service(
49 new PrefService(pref_notifier,
50 new PrefValueStore(managed_prefs_.get(),
51 supervised_user_prefs_.get(),
52 extension_prefs_.get(),
53 command_line_prefs_.get(),
54 user_prefs_.get(),
55 recommended_prefs_.get(),
56 pref_registry->defaults().get(),
57 pref_notifier),
58 user_prefs_.get(),
59 pref_registry,
60 read_error_callback_,
61 async_));
62 return pref_service.Pass();
65 } // namespace base