1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Keep this file in sync with the .proto files in this directory.
7 #ifndef SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_
8 #define SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_
10 #include "sync/base/sync_export.h"
13 class DictionaryValue
;
17 class AppNotification
;
18 class AppNotificationSettings
;
19 class AppSettingSpecifics
;
21 class ArticleSpecifics
;
22 class AutofillProfileSpecifics
;
23 class AutofillSpecifics
;
24 class BookmarkSpecifics
;
25 class ClientConfigParams
;
26 class ClientToServerMessage
;
27 class ClientToServerResponse
;
28 class CoalescedSyncedNotification
;
30 class DatatypeAssociationStats
;
33 class DeviceInfoSpecifics
;
34 class DeviceInformation
;
35 class DictionarySpecifics
;
37 class EntitySpecifics
;
38 class EverythingDirective
;
39 class ExperimentsSpecifics
;
40 class ExtensionSettingSpecifics
;
41 class ExtensionSpecifics
;
42 class FaviconImageSpecifics
;
43 class FaviconTrackingSpecifics
;
44 class GlobalIdDirective
;
45 class HistoryDeleteDirectiveSpecifics
;
46 class KeystoreEncryptionFlagsSpecifics
;
48 class ManagedUserSettingSpecifics
;
49 class ManagedUserSpecifics
;
50 class NigoriSpecifics
;
51 class PasswordSpecifics
;
52 class PasswordSpecificsData
;
53 class PreferenceSpecifics
;
54 class PriorityPreferenceSpecifics
;
55 class SearchEngineSpecifics
;
57 class SessionSpecifics
;
60 class SimpleCollapsedLayout
;
61 class SyncCycleCompletedEventInfo
;
62 class SyncedNotification
;
63 class SyncedNotificationAction
;
64 class SyncedNotificationDestination
;
65 class SyncedNotificationImage
;
66 class SyncedNotificationProfileImage
;
67 class SyncedNotificationRenderInfo
;
68 class SyncedNotificationSpecifics
;
72 class TimeRangeDirective
;
73 class TypedUrlSpecifics
;
74 } // namespace sync_pb
76 // Utility functions to convert sync protocol buffers to dictionaries.
77 // Each protocol field is mapped to a key of the same name. Repeated
78 // fields are mapped to array values and sub-messages are mapped to
79 // sub-dictionary values.
81 // TODO(akalin): Add has_* information.
83 // TODO(akalin): Improve enum support.
87 // Ownership of all returned DictionaryValues are transferred to the
90 // TODO(akalin): Perhaps extend this to decrypt?
91 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EncryptedDataToValue(
92 const sync_pb::EncryptedData
& encrypted_data
);
94 // Sub-protocol of AppSpecifics.
95 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSettingsToValue(
96 const sync_pb::AppNotificationSettings
& app_notification_settings
);
98 // Sub-protocols of SessionSpecifics.
100 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionHeaderToValue(
101 const sync_pb::SessionHeader
& session_header
);
103 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionTabToValue(
104 const sync_pb::SessionTab
& session_tab
);
106 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionWindowToValue(
107 const sync_pb::SessionWindow
& session_window
);
109 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TabNavigationToValue(
110 const sync_pb::TabNavigation
& tab_navigation
);
112 // Sub-protocol of PasswordSpecifics.
114 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsDataToValue(
115 const sync_pb::PasswordSpecificsData
& password_specifics_data
);
117 // Sub-protocol of NigoriSpecifics.
119 base::DictionaryValue
* DeviceInformationToValue(
120 const sync_pb::DeviceInformation
& device_information
);
122 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
124 base::DictionaryValue
* GlobalIdDirectiveToValue(
125 const sync_pb::GlobalIdDirective
& global_id_directive
);
127 base::DictionaryValue
* TimeRangeDirectiveToValue(
128 const sync_pb::TimeRangeDirective
& time_range_directive
);
130 // Sub-protocol of Experiments.
132 base::DictionaryValue
* KeystoreEncryptionToValue(
133 const sync_pb::KeystoreEncryptionFlagsSpecifics
& proto
);
135 // Sub protocols of SyncedNotifications.
137 base::DictionaryValue
* SimpleCollapsedLayoutToValue(
138 const sync_pb::SimpleCollapsedLayout
& proto
);
140 base::DictionaryValue
* CollapsedInfoToValue(
141 const sync_pb::CollapsedInfo
& proto
);
143 base::DictionaryValue
* RenderInfoToValue(
144 const sync_pb::SyncedNotificationRenderInfo
& proto
);
146 base::DictionaryValue
* CoalescedNotificationToValue(
147 const sync_pb::CoalescedSyncedNotification
& proto
);
149 base::DictionaryValue
* SyncedNotificationActionToValue(
150 const sync_pb::SyncedNotificationAction
& action
);
152 base::DictionaryValue
* SyncedNotificationDestinationToValue(
153 const sync_pb::SyncedNotificationDestination
& destination
);
155 base::DictionaryValue
* SyncedNotificationToValue(
156 const sync_pb::SyncedNotification
& notification
);
158 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionSpecificsToValue(
159 const sync_pb::SessionSpecifics
& session_specifics
);
161 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncedNotificationImageToValue(
162 const sync_pb::SyncedNotificationImage
& image
);
164 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
165 SyncedNotificationProfileImageToValue(
166 const sync_pb::SyncedNotificationProfileImage
& image
);
168 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TargetToValue(
169 const sync_pb::Target
& target
);
171 // Main *SpecificsToValue functions.
173 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppNotificationToValue(
174 const sync_pb::AppNotification
& app_notification_specifics
);
176 base::DictionaryValue
* AppSettingSpecificsToValue(
177 const sync_pb::AppSettingSpecifics
& app_setting_specifics
);
179 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSpecificsToValue(
180 const sync_pb::AppSpecifics
& app_specifics
);
182 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ArticleSpecificsToValue(
183 const sync_pb::ArticleSpecifics
& article_specifics
);
185 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillSpecificsToValue(
186 const sync_pb::AutofillSpecifics
& autofill_specifics
);
188 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillProfileSpecificsToValue(
189 const sync_pb::AutofillProfileSpecifics
& autofill_profile_specifics
);
191 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* BookmarkSpecificsToValue(
192 const sync_pb::BookmarkSpecifics
& bookmark_specifics
);
194 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DeviceInfoSpecificsToValue(
195 const sync_pb::DeviceInfoSpecifics
& device_info_specifics
);
197 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DictionarySpecificsToValue(
198 const sync_pb::DictionarySpecifics
& dictionary_specifics
);
200 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExperimentsSpecificsToValue(
201 const sync_pb::ExperimentsSpecifics
& proto
);
203 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PriorityPreferenceSpecificsToValue(
204 const sync_pb::PriorityPreferenceSpecifics
& proto
);
206 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSettingSpecificsToValue(
207 const sync_pb::ExtensionSettingSpecifics
& extension_setting_specifics
);
209 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSpecificsToValue(
210 const sync_pb::ExtensionSpecifics
& extension_specifics
);
212 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconImageSpecificsToValue(
213 const sync_pb::FaviconImageSpecifics
& favicon_image_specifics
);
215 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconTrackingSpecificsToValue(
216 const sync_pb::FaviconTrackingSpecifics
& favicon_tracking_specifics
);
218 SYNC_EXPORT
base::DictionaryValue
* HistoryDeleteDirectiveSpecificsToValue(
219 const sync_pb::HistoryDeleteDirectiveSpecifics
&
220 history_delete_directive_specifics
);
222 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSettingSpecificsToValue(
223 const sync_pb::ManagedUserSettingSpecifics
& managed_user_setting_specifics
);
225 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSpecificsToValue(
226 const sync_pb::ManagedUserSpecifics
& managed_user_specifics
);
228 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* MediaToValue(
229 const sync_pb::Media
& media
);
231 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* NigoriSpecificsToValue(
232 const sync_pb::NigoriSpecifics
& nigori_specifics
);
234 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsToValue(
235 const sync_pb::PasswordSpecifics
& password_specifics
);
237 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PreferenceSpecificsToValue(
238 const sync_pb::PreferenceSpecifics
& password_specifics
);
240 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncedNotificationSpecificsToValue(
241 const sync_pb::SyncedNotificationSpecifics
&
242 synced_notification_specifics
);
244 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SearchEngineSpecificsToValue(
245 const sync_pb::SearchEngineSpecifics
& search_engine_specifics
);
247 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ThemeSpecificsToValue(
248 const sync_pb::ThemeSpecifics
& theme_specifics
);
250 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TypedUrlSpecificsToValue(
251 const sync_pb::TypedUrlSpecifics
& typed_url_specifics
);
253 // Any present extensions are mapped to sub-dictionary values with the
254 // key equal to the extension name.
255 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EntitySpecificsToValue(
256 const sync_pb::EntitySpecifics
& specifics
);
258 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerMessageToValue(
259 const sync_pb::ClientToServerMessage
& proto
,
260 bool include_specifics
);
262 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerResponseToValue(
263 const sync_pb::ClientToServerResponse
& proto
,
264 bool include_specifics
);
266 base::DictionaryValue
* DatatypeAssociationStatsToValue(
267 const sync_pb::DatatypeAssociationStats
& proto
);
269 base::DictionaryValue
* DebugEventInfoToValue(
270 const sync_pb::DebugEventInfo
& proto
);
272 base::DictionaryValue
* DebugInfoToValue(
273 const sync_pb::DebugInfo
& proto
);
275 base::DictionaryValue
* SyncCycleCompletedEventInfoToValue(
276 const sync_pb::SyncCycleCompletedEventInfo
& proto
);
278 base::DictionaryValue
* ClientConfigParamsToValue(
279 const sync_pb::ClientConfigParams
& proto
);
281 } // namespace syncer
283 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_