| 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 "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/app_setting_specifics.pb.h" | 9 #include "chrome/browser/sync/protocol/app_setting_specifics.pb.h" |
| 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" | 10 #include "chrome/browser/sync/protocol/extension_setting_specifics.pb.h" |
| 11 #include "chrome/browser/sync/protocol/sync.pb.h" |
| 11 | 12 |
| 12 namespace extensions { | 13 namespace extensions { |
| 13 | 14 |
| 14 namespace settings_sync_util { | 15 namespace settings_sync_util { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 void PopulateExtensionSettingSpecifics( | 19 void PopulateExtensionSettingSpecifics( |
| 19 const std::string& extension_id, | 20 const std::string& extension_id, |
| 20 const std::string& key, | 21 const std::string& key, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 39 } | 40 } |
| 40 | 41 |
| 41 } // namespace | 42 } // namespace |
| 42 | 43 |
| 43 SyncData CreateData( | 44 SyncData CreateData( |
| 44 const std::string& extension_id, | 45 const std::string& extension_id, |
| 45 const std::string& key, | 46 const std::string& key, |
| 46 const Value& value, | 47 const Value& value, |
| 47 syncable::ModelType type) { | 48 syncable::ModelType type) { |
| 48 sync_pb::EntitySpecifics specifics; | 49 sync_pb::EntitySpecifics specifics; |
| 49 | |
| 50 switch (type) { | 50 switch (type) { |
| 51 case syncable::EXTENSION_SETTINGS: | 51 case syncable::EXTENSION_SETTINGS: |
| 52 PopulateExtensionSettingSpecifics( | 52 PopulateExtensionSettingSpecifics( |
| 53 extension_id, | 53 extension_id, |
| 54 key, | 54 key, |
| 55 value, | 55 value, |
| 56 specifics.MutableExtension(sync_pb::extension_setting)); | 56 specifics.mutable_extension_setting()); |
| 57 break; | 57 break; |
| 58 | 58 |
| 59 case syncable::APP_SETTINGS: | 59 case syncable::APP_SETTINGS: |
| 60 PopulateAppSettingSpecifics( | 60 PopulateAppSettingSpecifics( |
| 61 extension_id, | 61 extension_id, |
| 62 key, | 62 key, |
| 63 value, | 63 value, |
| 64 specifics.MutableExtension(sync_pb::app_setting)); | 64 specifics.mutable_app_setting()); |
| 65 break; | 65 break; |
| 66 | 66 |
| 67 default: | 67 default: |
| 68 NOTREACHED(); | 68 NOTREACHED(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics); | 71 return SyncData::CreateLocalData(extension_id + "/" + key, key, specifics); |
| 72 } | 72 } |
| 73 | 73 |
| 74 SyncChange CreateAdd( | 74 SyncChange CreateAdd( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 94 const std::string& key, | 94 const std::string& key, |
| 95 syncable::ModelType type) { | 95 syncable::ModelType type) { |
| 96 DictionaryValue no_value; | 96 DictionaryValue no_value; |
| 97 return SyncChange( | 97 return SyncChange( |
| 98 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value, type)); | 98 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value, type)); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace settings_sync_util | 101 } // namespace settings_sync_util |
| 102 | 102 |
| 103 } // namespace extensions | 103 } // namespace extensions |
| OLD | NEW |