| 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/settings/settings_sync_util.h" | 5 #include "chrome/browser/extensions/settings/settings_sync_util.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" | 9 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
| 10 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 10 | 11 |
| 11 namespace extensions { | 12 namespace extensions { |
| 12 | 13 |
| 13 namespace settings_sync_util { | 14 namespace settings_sync_util { |
| 14 | 15 |
| 15 SyncData CreateData( | 16 SyncData CreateData( |
| 16 const std::string& extension_id, | 17 const std::string& extension_id, |
| 17 const std::string& key, | 18 const std::string& key, |
| 18 const Value& value) { | 19 const Value& value) { |
| 19 sync_pb::EntitySpecifics specifics; | 20 sync_pb::EntitySpecifics specifics; |
| 20 sync_pb::ExtensionSettingSpecifics* setting_specifics = | 21 sync_pb::ExtensionSettingSpecifics* setting_specifics = |
| 21 specifics.MutableExtension(sync_pb::extension_setting); | 22 specifics.mutable_extension_setting(); |
| 22 setting_specifics->set_extension_id(extension_id); | 23 setting_specifics->set_extension_id(extension_id); |
| 23 setting_specifics->set_key(key); | 24 setting_specifics->set_key(key); |
| 24 std::string value_as_json; | 25 std::string value_as_json; |
| 25 base::JSONWriter::Write(&value, false, &value_as_json); | 26 base::JSONWriter::Write(&value, false, &value_as_json); |
| 26 setting_specifics->set_value(value_as_json); | 27 setting_specifics->set_value(value_as_json); |
| 27 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics); | 28 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics); |
| 28 } | 29 } |
| 29 | 30 |
| 30 SyncChange CreateAdd( | 31 SyncChange CreateAdd( |
| 31 const std::string& extension_id, | 32 const std::string& extension_id, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 46 SyncChange CreateDelete( | 47 SyncChange CreateDelete( |
| 47 const std::string& extension_id, const std::string& key) { | 48 const std::string& extension_id, const std::string& key) { |
| 48 DictionaryValue no_value; | 49 DictionaryValue no_value; |
| 49 return SyncChange( | 50 return SyncChange( |
| 50 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value)); | 51 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value)); |
| 51 } | 52 } |
| 52 | 53 |
| 53 } // namespace settings_sync_util | 54 } // namespace settings_sync_util |
| 54 | 55 |
| 55 } // namespace extensions | 56 } // namespace extensions |
| OLD | NEW |