OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/json/json_writer.h" | 6 #include "base/json/json_writer.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/api/storage/settings_frontend.h" | 10 #include "chrome/browser/extensions/api/storage/settings_frontend.h" |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 void FinalReplyWhenSatisfied( | 109 void FinalReplyWhenSatisfied( |
110 Namespace settings_namespace, | 110 Namespace settings_namespace, |
111 const std::string& normal_action, | 111 const std::string& normal_action, |
112 const std::string& incognito_action) { | 112 const std::string& incognito_action) { |
113 MaybeLoadAndReplyWhenSatisfied( | 113 MaybeLoadAndReplyWhenSatisfied( |
114 settings_namespace, normal_action, incognito_action, NULL, true); | 114 settings_namespace, normal_action, incognito_action, NULL, true); |
115 } | 115 } |
116 | 116 |
| 117 syncer::SyncableService* GetSyncableService() { |
| 118 return settings_sync_util::GetSyncableService(browser()->profile(), |
| 119 kModelType); |
| 120 } |
| 121 |
117 void InitSync(syncer::SyncChangeProcessor* sync_processor) { | 122 void InitSync(syncer::SyncChangeProcessor* sync_processor) { |
118 base::MessageLoop::current()->RunUntilIdle(); | 123 base::MessageLoop::current()->RunUntilIdle(); |
119 SettingsFrontend* frontend = SettingsFrontend::Get(browser()->profile()); | 124 InitSyncWithSyncableService(sync_processor, GetSyncableService()); |
120 InitSyncWithSyncableService(sync_processor, | |
121 frontend->GetBackendForSync(kModelType)); | |
122 } | 125 } |
123 | 126 |
124 void SendChanges(const syncer::SyncChangeList& change_list) { | 127 void SendChanges(const syncer::SyncChangeList& change_list) { |
125 base::MessageLoop::current()->RunUntilIdle(); | 128 base::MessageLoop::current()->RunUntilIdle(); |
126 SettingsFrontend* frontend = SettingsFrontend::Get(browser()->profile()); | 129 SendChangesToSyncableService(change_list, GetSyncableService()); |
127 SendChangesToSyncableService(change_list, | |
128 frontend->GetBackendForSync(kModelType)); | |
129 } | 130 } |
130 | 131 |
131 #if defined(ENABLE_CONFIGURATION_POLICY) | 132 #if defined(ENABLE_CONFIGURATION_POLICY) |
132 void SetPolicies(const base::DictionaryValue& policies) { | 133 void SetPolicies(const base::DictionaryValue& policies) { |
133 scoped_ptr<policy::PolicyBundle> bundle(new policy::PolicyBundle()); | 134 scoped_ptr<policy::PolicyBundle> bundle(new policy::PolicyBundle()); |
134 policy::PolicyMap& policy_map = bundle->Get(policy::PolicyNamespace( | 135 policy::PolicyMap& policy_map = bundle->Get(policy::PolicyNamespace( |
135 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)); | 136 policy::POLICY_DOMAIN_EXTENSIONS, kManagedStorageExtensionId)); |
136 policy_map.LoadFrom( | 137 policy_map.LoadFrom( |
137 &policies, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER); | 138 &policies, policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER); |
138 policy_provider_.UpdatePolicy(bundle.Pass()); | 139 policy_provider_.UpdatePolicy(bundle.Pass()); |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // ENABLE_CONFIGURATION_POLICY is not defined. | 572 // ENABLE_CONFIGURATION_POLICY is not defined. |
572 SettingsFrontend* frontend = SettingsFrontend::Get(browser()->profile()); | 573 SettingsFrontend* frontend = SettingsFrontend::Get(browser()->profile()); |
573 frontend->DisableStorageForTesting(MANAGED); | 574 frontend->DisableStorageForTesting(MANAGED); |
574 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); | 575 EXPECT_FALSE(frontend->IsStorageEnabled(MANAGED)); |
575 // Now run the extension. | 576 // Now run the extension. |
576 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) | 577 ASSERT_TRUE(RunExtensionTest("settings/managed_storage_disabled")) |
577 << message_; | 578 << message_; |
578 } | 579 } |
579 | 580 |
580 } // namespace extensions | 581 } // namespace extensions |
OLD | NEW |