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