| 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/legacy/supervised_user_shared_settings_
service.h" | 5 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_
service.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> |
| 9 | 10 |
| 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/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 13 #include "base/prefs/scoped_user_pref_update.h" | 14 #include "base/prefs/scoped_user_pref_update.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 16 #include "components/pref_registry/pref_registry_syncable.h" | 17 #include "components/pref_registry/pref_registry_syncable.h" |
| 17 #include "sync/api/sync_change.h" | 18 #include "sync/api/sync_change.h" |
| 18 #include "sync/api/sync_data.h" | 19 #include "sync/api/sync_data.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 188 |
| 188 void SupervisedUserSharedSettingsService::Shutdown() {} | 189 void SupervisedUserSharedSettingsService::Shutdown() {} |
| 189 | 190 |
| 190 syncer::SyncMergeResult | 191 syncer::SyncMergeResult |
| 191 SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( | 192 SupervisedUserSharedSettingsService::MergeDataAndStartSyncing( |
| 192 syncer::ModelType type, | 193 syncer::ModelType type, |
| 193 const syncer::SyncDataList& initial_sync_data, | 194 const syncer::SyncDataList& initial_sync_data, |
| 194 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, | 195 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, |
| 195 scoped_ptr<syncer::SyncErrorFactory> error_handler) { | 196 scoped_ptr<syncer::SyncErrorFactory> error_handler) { |
| 196 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type); | 197 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, type); |
| 197 sync_processor_ = sync_processor.Pass(); | 198 sync_processor_ = std::move(sync_processor); |
| 198 error_handler_ = error_handler.Pass(); | 199 error_handler_ = std::move(error_handler); |
| 199 | 200 |
| 200 // We keep a map from MU ID to the set of keys that we have seen in the | 201 // We keep a map from MU ID to the set of keys that we have seen in the |
| 201 // initial sync data. | 202 // initial sync data. |
| 202 std::map<std::string, std::set<std::string> > seen_keys; | 203 std::map<std::string, std::set<std::string> > seen_keys; |
| 203 | 204 |
| 204 // Iterate over all initial sync data, and update it locally. This means that | 205 // Iterate over all initial sync data, and update it locally. This means that |
| 205 // the value from the server always wins over a local value. | 206 // the value from the server always wins over a local value. |
| 206 for (const SyncData& sync_data : initial_sync_data) { | 207 for (const SyncData& sync_data : initial_sync_data) { |
| 207 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, sync_data.GetDataType()); | 208 DCHECK_EQ(SUPERVISED_USER_SHARED_SETTINGS, sync_data.GetDataType()); |
| 208 const ::sync_pb::ManagedUserSharedSettingSpecifics& | 209 const ::sync_pb::ManagedUserSharedSettingSpecifics& |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 NOTREACHED(); | 337 NOTREACHED(); |
| 337 break; | 338 break; |
| 338 } | 339 } |
| 339 } | 340 } |
| 340 callbacks_.Notify(su_id, key); | 341 callbacks_.Notify(su_id, key); |
| 341 } | 342 } |
| 342 | 343 |
| 343 SyncError error; | 344 SyncError error; |
| 344 return error; | 345 return error; |
| 345 } | 346 } |
| OLD | NEW |