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"
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"
14 #include "base/prefs/pref_value_store.h"
20 // Do-nothing default implementation.
21 void DoNothingHandleReadError(PersistentPrefStore::PrefReadError error
) {
26 PrefServiceFactory::PrefServiceFactory()
27 : managed_prefs_(NULL
),
28 supervised_user_prefs_(NULL
),
29 extension_prefs_(NULL
),
30 command_line_prefs_(NULL
),
32 recommended_prefs_(NULL
),
33 read_error_callback_(base::Bind(&DoNothingHandleReadError
)),
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(),
55 recommended_prefs_
.get(),
56 pref_registry
->defaults().get(),
62 return pref_service
.Pass();