OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "components/syncable_prefs/pref_service_syncable_factory.h" | |
6 | |
7 #include "base/trace_event/trace_event.h" | |
8 #include "components/pref_registry/pref_registry_syncable.h" | |
9 #include "components/prefs/default_pref_store.h" | |
10 #include "components/prefs/pref_notifier_impl.h" | |
11 #include "components/prefs/pref_value_store.h" | |
12 #include "components/syncable_prefs/pref_service_syncable.h" | |
13 | |
14 #if defined(SYNCABLE_PREFS_USE_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" // nogncheck | |
18 #include "components/policy/core/common/policy_types.h" // nogncheck | |
19 #endif | |
20 | |
21 namespace syncable_prefs { | |
22 | |
23 PrefServiceSyncableFactory::PrefServiceSyncableFactory() { | |
24 } | |
25 | |
26 PrefServiceSyncableFactory::~PrefServiceSyncableFactory() { | |
27 } | |
28 | |
29 void PrefServiceSyncableFactory::SetManagedPolicies( | |
30 policy::PolicyService* service, | |
31 policy::BrowserPolicyConnector* connector) { | |
32 #if defined(SYNCABLE_PREFS_USE_POLICY) | |
33 set_managed_prefs(new policy::ConfigurationPolicyPrefStore( | |
34 service, connector->GetHandlerList(), policy::POLICY_LEVEL_MANDATORY)); | |
35 #else | |
36 NOTREACHED(); | |
37 #endif | |
38 } | |
39 | |
40 void PrefServiceSyncableFactory::SetRecommendedPolicies( | |
41 policy::PolicyService* service, | |
42 policy::BrowserPolicyConnector* connector) { | |
43 #if defined(SYNCABLE_PREFS_USE_POLICY) | |
44 set_recommended_prefs(new policy::ConfigurationPolicyPrefStore( | |
45 service, connector->GetHandlerList(), policy::POLICY_LEVEL_RECOMMENDED)); | |
46 #else | |
47 NOTREACHED(); | |
48 #endif | |
49 } | |
50 | |
51 void PrefServiceSyncableFactory::SetPrefModelAssociatorClient( | |
52 PrefModelAssociatorClient* pref_model_associator_client) { | |
53 pref_model_associator_client_ = pref_model_associator_client; | |
54 } | |
55 | |
56 std::unique_ptr<PrefServiceSyncable> PrefServiceSyncableFactory::CreateSyncable( | |
57 user_prefs::PrefRegistrySyncable* pref_registry) { | |
58 TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable"); | |
59 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | |
60 std::unique_ptr<PrefServiceSyncable> pref_service(new PrefServiceSyncable( | |
61 pref_notifier, | |
62 new PrefValueStore(managed_prefs_.get(), supervised_user_prefs_.get(), | |
63 extension_prefs_.get(), command_line_prefs_.get(), | |
64 user_prefs_.get(), recommended_prefs_.get(), | |
65 pref_registry->defaults().get(), pref_notifier), | |
66 user_prefs_.get(), pref_registry, pref_model_associator_client_, | |
67 read_error_callback_, async_)); | |
68 return pref_service; | |
69 } | |
70 | |
71 } // namespace syncable_prefs | |
OLD | NEW |