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/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "sync/protocol/app_setting_specifics.pb.h" | 9 #include "sync/protocol/app_setting_specifics.pb.h" |
10 #include "sync/protocol/extension_setting_specifics.pb.h" | 10 #include "sync/protocol/extension_setting_specifics.pb.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 const std::string& extension_id, | 34 const std::string& extension_id, |
35 const std::string& key, | 35 const std::string& key, |
36 const Value& value, | 36 const Value& value, |
37 sync_pb::AppSettingSpecifics* specifics) { | 37 sync_pb::AppSettingSpecifics* specifics) { |
38 PopulateExtensionSettingSpecifics( | 38 PopulateExtensionSettingSpecifics( |
39 extension_id, key, value, specifics->mutable_extension_setting()); | 39 extension_id, key, value, specifics->mutable_extension_setting()); |
40 } | 40 } |
41 | 41 |
42 } // namespace | 42 } // namespace |
43 | 43 |
44 SyncData CreateData( | 44 csync::SyncData CreateData( |
45 const std::string& extension_id, | 45 const std::string& extension_id, |
46 const std::string& key, | 46 const std::string& key, |
47 const Value& value, | 47 const Value& value, |
48 syncable::ModelType type) { | 48 syncable::ModelType type) { |
49 sync_pb::EntitySpecifics specifics; | 49 sync_pb::EntitySpecifics specifics; |
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.mutable_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.mutable_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 csync::SyncData::CreateLocalData( |
| 72 extension_id + "/" + key, key, specifics); |
72 } | 73 } |
73 | 74 |
74 SyncChange CreateAdd( | 75 csync::SyncChange CreateAdd( |
75 const std::string& extension_id, | 76 const std::string& extension_id, |
76 const std::string& key, | 77 const std::string& key, |
77 const Value& value, | 78 const Value& value, |
78 syncable::ModelType type) { | 79 syncable::ModelType type) { |
79 return SyncChange( | 80 return csync::SyncChange( |
80 SyncChange::ACTION_ADD, CreateData(extension_id, key, value, type)); | 81 csync::SyncChange::ACTION_ADD, |
| 82 CreateData(extension_id, key, value, type)); |
81 } | 83 } |
82 | 84 |
83 SyncChange CreateUpdate( | 85 csync::SyncChange CreateUpdate( |
84 const std::string& extension_id, | 86 const std::string& extension_id, |
85 const std::string& key, | 87 const std::string& key, |
86 const Value& value, | 88 const Value& value, |
87 syncable::ModelType type) { | 89 syncable::ModelType type) { |
88 return SyncChange( | 90 return csync::SyncChange( |
89 SyncChange::ACTION_UPDATE, CreateData(extension_id, key, value, type)); | 91 csync::SyncChange::ACTION_UPDATE, |
| 92 CreateData(extension_id, key, value, type)); |
90 } | 93 } |
91 | 94 |
92 SyncChange CreateDelete( | 95 csync::SyncChange CreateDelete( |
93 const std::string& extension_id, | 96 const std::string& extension_id, |
94 const std::string& key, | 97 const std::string& key, |
95 syncable::ModelType type) { | 98 syncable::ModelType type) { |
96 DictionaryValue no_value; | 99 DictionaryValue no_value; |
97 return SyncChange( | 100 return csync::SyncChange( |
98 SyncChange::ACTION_DELETE, CreateData(extension_id, key, no_value, type)); | 101 csync::SyncChange::ACTION_DELETE, |
| 102 CreateData(extension_id, key, no_value, type)); |
99 } | 103 } |
100 | 104 |
101 } // namespace settings_sync_util | 105 } // namespace settings_sync_util |
102 | 106 |
103 } // namespace extensions | 107 } // namespace extensions |
OLD | NEW |