OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/sync_preferences/pref_service_syncable_factory.h" | 5 #include "components/sync_preferences/pref_service_syncable_factory.h" |
6 | 6 |
7 #include "base/trace_event/trace_event.h" | 7 #include "base/trace_event/trace_event.h" |
| 8 #include "build/build_config.h" |
8 #include "components/pref_registry/pref_registry_syncable.h" | 9 #include "components/pref_registry/pref_registry_syncable.h" |
9 #include "components/prefs/default_pref_store.h" | 10 #include "components/prefs/default_pref_store.h" |
10 #include "components/prefs/pref_notifier_impl.h" | 11 #include "components/prefs/pref_notifier_impl.h" |
11 #include "components/prefs/pref_value_store.h" | 12 #include "components/prefs/pref_value_store.h" |
12 #include "components/sync_preferences/pref_service_syncable.h" | 13 #include "components/sync_preferences/pref_service_syncable.h" |
13 | 14 |
14 #if defined(SYNC_PREFERENCES_USE_POLICY) | 15 #if !defined(OS_IOS) |
15 #include "components/policy/core/browser/browser_policy_connector.h" | 16 #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/browser/configuration_policy_pref_store.h" |
17 #include "components/policy/core/common/policy_service.h" // nogncheck | 18 #include "components/policy/core/common/policy_service.h" // nogncheck |
18 #include "components/policy/core/common/policy_types.h" // nogncheck | 19 #include "components/policy/core/common/policy_types.h" // nogncheck |
19 #endif | 20 #endif |
20 | 21 |
21 namespace sync_preferences { | 22 namespace sync_preferences { |
22 | 23 |
23 PrefServiceSyncableFactory::PrefServiceSyncableFactory() {} | 24 PrefServiceSyncableFactory::PrefServiceSyncableFactory() {} |
24 | 25 |
25 PrefServiceSyncableFactory::~PrefServiceSyncableFactory() {} | 26 PrefServiceSyncableFactory::~PrefServiceSyncableFactory() {} |
26 | 27 |
27 void PrefServiceSyncableFactory::SetManagedPolicies( | 28 void PrefServiceSyncableFactory::SetManagedPolicies( |
28 policy::PolicyService* service, | 29 policy::PolicyService* service, |
29 policy::BrowserPolicyConnector* connector) { | 30 policy::BrowserPolicyConnector* connector) { |
30 #if defined(SYNC_PREFERENCES_USE_POLICY) | 31 #if !defined(OS_IOS) |
31 set_managed_prefs(new policy::ConfigurationPolicyPrefStore( | 32 set_managed_prefs(new policy::ConfigurationPolicyPrefStore( |
32 service, connector->GetHandlerList(), policy::POLICY_LEVEL_MANDATORY)); | 33 service, connector->GetHandlerList(), policy::POLICY_LEVEL_MANDATORY)); |
33 #else | 34 #else |
34 NOTREACHED(); | 35 NOTREACHED(); |
35 #endif | 36 #endif |
36 } | 37 } |
37 | 38 |
38 void PrefServiceSyncableFactory::SetRecommendedPolicies( | 39 void PrefServiceSyncableFactory::SetRecommendedPolicies( |
39 policy::PolicyService* service, | 40 policy::PolicyService* service, |
40 policy::BrowserPolicyConnector* connector) { | 41 policy::BrowserPolicyConnector* connector) { |
41 #if defined(SYNC_PREFERENCES_USE_POLICY) | 42 #if !defined(OS_IOS) |
42 set_recommended_prefs(new policy::ConfigurationPolicyPrefStore( | 43 set_recommended_prefs(new policy::ConfigurationPolicyPrefStore( |
43 service, connector->GetHandlerList(), policy::POLICY_LEVEL_RECOMMENDED)); | 44 service, connector->GetHandlerList(), policy::POLICY_LEVEL_RECOMMENDED)); |
44 #else | 45 #else |
45 NOTREACHED(); | 46 NOTREACHED(); |
46 #endif | 47 #endif |
47 } | 48 } |
48 | 49 |
49 void PrefServiceSyncableFactory::SetPrefModelAssociatorClient( | 50 void PrefServiceSyncableFactory::SetPrefModelAssociatorClient( |
50 PrefModelAssociatorClient* pref_model_associator_client) { | 51 PrefModelAssociatorClient* pref_model_associator_client) { |
51 pref_model_associator_client_ = pref_model_associator_client; | 52 pref_model_associator_client_ = pref_model_associator_client; |
52 } | 53 } |
53 | 54 |
54 std::unique_ptr<PrefServiceSyncable> PrefServiceSyncableFactory::CreateSyncable( | 55 std::unique_ptr<PrefServiceSyncable> PrefServiceSyncableFactory::CreateSyncable( |
55 user_prefs::PrefRegistrySyncable* pref_registry) { | 56 user_prefs::PrefRegistrySyncable* pref_registry) { |
56 TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable"); | 57 TRACE_EVENT0("browser", "PrefServiceSyncableFactory::CreateSyncable"); |
57 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); | 58 PrefNotifierImpl* pref_notifier = new PrefNotifierImpl(); |
58 std::unique_ptr<PrefServiceSyncable> pref_service(new PrefServiceSyncable( | 59 std::unique_ptr<PrefServiceSyncable> pref_service(new PrefServiceSyncable( |
59 pref_notifier, | 60 pref_notifier, |
60 new PrefValueStore(managed_prefs_.get(), supervised_user_prefs_.get(), | 61 new PrefValueStore(managed_prefs_.get(), supervised_user_prefs_.get(), |
61 extension_prefs_.get(), command_line_prefs_.get(), | 62 extension_prefs_.get(), command_line_prefs_.get(), |
62 user_prefs_.get(), recommended_prefs_.get(), | 63 user_prefs_.get(), recommended_prefs_.get(), |
63 pref_registry->defaults().get(), pref_notifier), | 64 pref_registry->defaults().get(), pref_notifier), |
64 user_prefs_.get(), pref_registry, pref_model_associator_client_, | 65 user_prefs_.get(), pref_registry, pref_model_associator_client_, |
65 read_error_callback_, async_)); | 66 read_error_callback_, async_)); |
66 return pref_service; | 67 return pref_service; |
67 } | 68 } |
68 | 69 |
69 } // namespace sync_preferences | 70 } // namespace sync_preferences |
OLD | NEW |