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 "components/syncable_prefs/pref_service_syncable_factory.h"
7 #include "base/prefs/default_pref_store.h"
8 #include "base/prefs/pref_notifier_impl.h"
9 #include "base/prefs/pref_value_store.h"
10 #include "base/trace_event/trace_event.h"
11 #include "components/pref_registry/pref_registry_syncable.h"
12 #include "components/syncable_prefs/pref_service_syncable.h"
14 #if defined(ENABLE_CONFIGURATION_POLICY)
15 #include "components/policy/core/browser/browser_policy_connector.h"
16 #include "components/policy/core/browser/configuration_policy_pref_store.h"
17 #include "components/policy/core/common/policy_service.h"
18 #include "components/policy/core/common/policy_types.h"
21 namespace syncable_prefs
{
23 PrefServiceSyncableFactory::PrefServiceSyncableFactory() {
26 PrefServiceSyncableFactory::~PrefServiceSyncableFactory() {
29 #if defined(ENABLE_CONFIGURATION_POLICY)
30 void PrefServiceSyncableFactory::SetManagedPolicies(
31 policy::PolicyService
* service
,
32 policy::BrowserPolicyConnector
* connector
) {
33 set_managed_prefs(new policy::ConfigurationPolicyPrefStore(
34 service
, connector
->GetHandlerList(), policy::POLICY_LEVEL_MANDATORY
));
37 void PrefServiceSyncableFactory::SetRecommendedPolicies(
38 policy::PolicyService
* service
,
39 policy::BrowserPolicyConnector
* connector
) {
40 set_recommended_prefs(new policy::ConfigurationPolicyPrefStore(
41 service
, connector
->GetHandlerList(), policy::POLICY_LEVEL_RECOMMENDED
));
45 void PrefServiceSyncableFactory::SetPrefModelAssociatorClient(
46 PrefModelAssociatorClient
* pref_model_associator_client
) {
47 pref_model_associator_client_
= pref_model_associator_client
;
50 scoped_ptr
<PrefServiceSyncable
> PrefServiceSyncableFactory::CreateSyncable(
51 user_prefs::PrefRegistrySyncable
* pref_registry
) {
52 TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable");
53 PrefNotifierImpl
* pref_notifier
= new PrefNotifierImpl();
54 scoped_ptr
<PrefServiceSyncable
> pref_service(
55 new PrefServiceSyncable(
57 new PrefValueStore(managed_prefs_
.get(),
58 supervised_user_prefs_
.get(),
59 extension_prefs_
.get(),
60 command_line_prefs_
.get(),
62 recommended_prefs_
.get(),
63 pref_registry
->defaults().get(),
67 pref_model_associator_client_
,
70 return pref_service
.Pass();
73 } // namespace syncable_prefs