OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/supervised_user/supervised_user_settings_service.h" | 5 #include "chrome/browser/supervised_user/supervised_user_settings_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/callback.h" | 10 #include "base/callback.h" |
10 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
11 #include "base/json/json_writer.h" | 12 #include "base/json/json_writer.h" |
12 #include "base/prefs/json_pref_store.h" | 13 #include "base/prefs/json_pref_store.h" |
13 #include "base/prefs/pref_filter.h" | 14 #include "base/prefs/pref_filter.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
16 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 17 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
17 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void SupervisedUserSettingsService::Shutdown() { | 183 void SupervisedUserSettingsService::Shutdown() { |
183 store_->RemoveObserver(this); | 184 store_->RemoveObserver(this); |
184 } | 185 } |
185 | 186 |
186 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( | 187 SyncMergeResult SupervisedUserSettingsService::MergeDataAndStartSyncing( |
187 ModelType type, | 188 ModelType type, |
188 const SyncDataList& initial_sync_data, | 189 const SyncDataList& initial_sync_data, |
189 scoped_ptr<SyncChangeProcessor> sync_processor, | 190 scoped_ptr<SyncChangeProcessor> sync_processor, |
190 scoped_ptr<SyncErrorFactory> error_handler) { | 191 scoped_ptr<SyncErrorFactory> error_handler) { |
191 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); | 192 DCHECK_EQ(SUPERVISED_USER_SETTINGS, type); |
192 sync_processor_ = sync_processor.Pass(); | 193 sync_processor_ = std::move(sync_processor); |
193 error_handler_ = error_handler.Pass(); | 194 error_handler_ = std::move(error_handler); |
194 | 195 |
195 // Clear all atomic and split settings, then recreate them from Sync data. | 196 // Clear all atomic and split settings, then recreate them from Sync data. |
196 Clear(); | 197 Clear(); |
197 for (const SyncData& sync_data : initial_sync_data) { | 198 for (const SyncData& sync_data : initial_sync_data) { |
198 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); | 199 DCHECK_EQ(SUPERVISED_USER_SETTINGS, sync_data.GetDataType()); |
199 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = | 200 const ::sync_pb::ManagedUserSettingSpecifics& supervised_user_setting = |
200 sync_data.GetSpecifics().managed_user_setting(); | 201 sync_data.GetSpecifics().managed_user_setting(); |
201 scoped_ptr<base::Value> value = | 202 scoped_ptr<base::Value> value = |
202 JSONReader::Read(supervised_user_setting.value()); | 203 JSONReader::Read(supervised_user_setting.value()); |
203 std::string name_suffix = supervised_user_setting.name(); | 204 std::string name_suffix = supervised_user_setting.name(); |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 400 |
400 base::DictionaryValue* split_settings = GetSplitSettings(); | 401 base::DictionaryValue* split_settings = GetSplitSettings(); |
401 for (base::DictionaryValue::Iterator it(*split_settings); !it.IsAtEnd(); | 402 for (base::DictionaryValue::Iterator it(*split_settings); !it.IsAtEnd(); |
402 it.Advance()) { | 403 it.Advance()) { |
403 if (!SettingShouldApplyToPrefs(it.key())) | 404 if (!SettingShouldApplyToPrefs(it.key())) |
404 continue; | 405 continue; |
405 | 406 |
406 settings->Set(it.key(), it.value().DeepCopy()); | 407 settings->Set(it.key(), it.value().DeepCopy()); |
407 } | 408 } |
408 | 409 |
409 return settings.Pass(); | 410 return settings; |
410 } | 411 } |
411 | 412 |
412 void SupervisedUserSettingsService::InformSubscribers() { | 413 void SupervisedUserSettingsService::InformSubscribers() { |
413 if (!IsReady()) | 414 if (!IsReady()) |
414 return; | 415 return; |
415 | 416 |
416 scoped_ptr<base::DictionaryValue> settings = GetSettings(); | 417 scoped_ptr<base::DictionaryValue> settings = GetSettings(); |
417 callback_list_.Notify(settings.get()); | 418 callback_list_.Notify(settings.get()); |
418 } | 419 } |
OLD | NEW |