| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/syncable_extension_settings_storage.h" | 5 #include "chrome/browser/extensions/syncable_extension_settings_storage.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/extensions/extension_settings_sync_util.h" | 8 #include "chrome/browser/extensions/extension_settings_sync_util.h" |
| 9 #include "chrome/browser/sync/api/sync_data.h" | 9 #include "chrome/browser/sync/api/sync_data.h" |
| 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 scoped_ptr<DictionaryValue> new_sync_state(sync_state.DeepCopy()); | 167 scoped_ptr<DictionaryValue> new_sync_state(sync_state.DeepCopy()); |
| 168 | 168 |
| 169 ExtensionSettingSyncDataList changes; | 169 ExtensionSettingSyncDataList changes; |
| 170 for (DictionaryValue::key_iterator it = settings.begin_keys(); | 170 for (DictionaryValue::key_iterator it = settings.begin_keys(); |
| 171 it != settings.end_keys(); ++it) { | 171 it != settings.end_keys(); ++it) { |
| 172 Value* orphaned_sync_value = NULL; | 172 Value* orphaned_sync_value = NULL; |
| 173 if (new_sync_state->RemoveWithoutPathExpansion(*it, &orphaned_sync_value)) { | 173 if (new_sync_state->RemoveWithoutPathExpansion(*it, &orphaned_sync_value)) { |
| 174 scoped_ptr<Value> sync_value(orphaned_sync_value); | 174 scoped_ptr<Value> sync_value(orphaned_sync_value); |
| 175 Value* local_value = NULL; | 175 Value* local_value = NULL; |
| 176 settings.GetWithoutPathExpansion(*it, &local_value); | 176 settings.GetWithoutPathExpansion(*it, &local_value); |
| 177 if (!sync_value->Equals(local_value)) { | 177 if (sync_value->Equals(local_value)) { |
| 178 // Sync and local values are the same, no changes to send. |
| 179 synced_keys_.insert(*it); |
| 180 } else { |
| 178 // Sync value is different, update local setting with new value. | 181 // Sync value is different, update local setting with new value. |
| 179 changes.push_back( | 182 changes.push_back( |
| 180 ExtensionSettingSyncData( | 183 ExtensionSettingSyncData( |
| 181 SyncChange::ACTION_UPDATE, | 184 SyncChange::ACTION_UPDATE, |
| 182 extension_id_, | 185 extension_id_, |
| 183 *it, | 186 *it, |
| 184 sync_value.release())); | 187 sync_value.release())); |
| 185 } | 188 } |
| 186 } else { | 189 } else { |
| 187 // Not synced, delete local setting. | 190 // Not synced, delete local setting. |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 if (result.HasError()) { | 432 if (result.HasError()) { |
| 430 return SyncError( | 433 return SyncError( |
| 431 FROM_HERE, | 434 FROM_HERE, |
| 432 std::string("Error pushing sync remove to local settings: ") + | 435 std::string("Error pushing sync remove to local settings: ") + |
| 433 result.GetError(), | 436 result.GetError(), |
| 434 syncable::EXTENSION_SETTINGS); | 437 syncable::EXTENSION_SETTINGS); |
| 435 } | 438 } |
| 436 changes->AppendChange(key, old_value, NULL); | 439 changes->AppendChange(key, old_value, NULL); |
| 437 return SyncError(); | 440 return SyncError(); |
| 438 } | 441 } |
| OLD | NEW |