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 AppListSpecifics
;
18 class AppNotification
;
19 class AppNotificationSettings
;
20 class AppSettingSpecifics
;
22 class ArticleSpecifics
;
23 class AttachmentIdProto
;
24 class AutofillProfileSpecifics
;
25 class AutofillSpecifics
;
26 class BookmarkSpecifics
;
27 class ClientConfigParams
;
28 class ClientToServerMessage
;
29 class ClientToServerResponse
;
30 class CoalescedSyncedNotification
;
32 class DatatypeAssociationStats
;
35 class DeviceInfoSpecifics
;
36 class DeviceInformation
;
37 class DictionarySpecifics
;
39 class EntitySpecifics
;
40 class EverythingDirective
;
41 class ExperimentsSpecifics
;
42 class ExtensionSettingSpecifics
;
43 class ExtensionSpecifics
;
44 class FaviconImageSpecifics
;
45 class FaviconTrackingSpecifics
;
46 class GlobalIdDirective
;
47 class HistoryDeleteDirectiveSpecifics
;
48 class KeystoreEncryptionFlagsSpecifics
;
50 class ManagedUserSettingSpecifics
;
51 class ManagedUserSharedSettingSpecifics
;
52 class ManagedUserSpecifics
;
53 class NavigationRedirect
;
54 class NigoriSpecifics
;
55 class PasswordSpecifics
;
56 class PasswordSpecificsData
;
57 class PreferenceSpecifics
;
58 class PriorityPreferenceSpecifics
;
59 class SearchEngineSpecifics
;
61 class SessionSpecifics
;
64 class SimpleCollapsedLayout
;
65 class SyncCycleCompletedEventInfo
;
67 class SyncedNotification
;
68 class SyncedNotificationAction
;
69 class SyncedNotificationAppInfo
;
70 class SyncedNotificationAppInfoSpecifics
;
71 class SyncedNotificationDestination
;
72 class SyncedNotificationImage
;
73 class SyncedNotificationProfileImage
;
74 class SyncedNotificationRenderInfo
;
75 class SyncedNotificationSpecifics
;
79 class TimeRangeDirective
;
80 class TypedUrlSpecifics
;
81 class WifiCredentialSpecifics
;
82 } // namespace sync_pb
84 // Utility functions to convert sync protocol buffers to dictionaries.
85 // Each protocol field is mapped to a key of the same name. Repeated
86 // fields are mapped to array values and sub-messages are mapped to
87 // sub-dictionary values.
89 // TODO(akalin): Add has_* information.
91 // TODO(akalin): Improve enum support.
95 // Ownership of all returned DictionaryValues are transferred to the
98 // TODO(akalin): Perhaps extend this to decrypt?
99 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EncryptedDataToValue(
100 const sync_pb::EncryptedData
& encrypted_data
);
102 // Sub-protocol of AppListSpecifics.
103 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppListSpecificsToValue(
104 const sync_pb::AppListSpecifics
& proto
);
106 // Sub-protocol of AppSpecifics.
107 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSettingsToValue(
108 const sync_pb::AppNotificationSettings
& app_notification_settings
);
110 // Sub-protocols of SessionSpecifics.
112 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionHeaderToValue(
113 const sync_pb::SessionHeader
& session_header
);
115 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionTabToValue(
116 const sync_pb::SessionTab
& session_tab
);
118 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionWindowToValue(
119 const sync_pb::SessionWindow
& session_window
);
121 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TabNavigationToValue(
122 const sync_pb::TabNavigation
& tab_navigation
);
124 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* NavigationRedirectToValue(
125 const sync_pb::NavigationRedirect
& navigation_redirect
);
127 // Sub-protocol of PasswordSpecifics.
129 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsDataToValue(
130 const sync_pb::PasswordSpecificsData
& password_specifics_data
);
132 // Sub-protocol of NigoriSpecifics.
134 base::DictionaryValue
* DeviceInformationToValue(
135 const sync_pb::DeviceInformation
& device_information
);
137 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
139 base::DictionaryValue
* GlobalIdDirectiveToValue(
140 const sync_pb::GlobalIdDirective
& global_id_directive
);
142 base::DictionaryValue
* TimeRangeDirectiveToValue(
143 const sync_pb::TimeRangeDirective
& time_range_directive
);
145 // Sub-protocol of Experiments.
147 base::DictionaryValue
* KeystoreEncryptionToValue(
148 const sync_pb::KeystoreEncryptionFlagsSpecifics
& proto
);
150 // Sub protocols of SyncedNotifications.
152 base::DictionaryValue
* SimpleCollapsedLayoutToValue(
153 const sync_pb::SimpleCollapsedLayout
& proto
);
155 base::DictionaryValue
* CollapsedInfoToValue(
156 const sync_pb::CollapsedInfo
& proto
);
158 base::DictionaryValue
* RenderInfoToValue(
159 const sync_pb::SyncedNotificationRenderInfo
& proto
);
161 base::DictionaryValue
* CoalescedNotificationToValue(
162 const sync_pb::CoalescedSyncedNotification
& proto
);
164 base::DictionaryValue
* SyncedNotificationActionToValue(
165 const sync_pb::SyncedNotificationAction
& action
);
167 base::DictionaryValue
* SyncedNotificationDestinationToValue(
168 const sync_pb::SyncedNotificationDestination
& destination
);
170 base::DictionaryValue
* SyncedNotificationToValue(
171 const sync_pb::SyncedNotification
& notification
);
173 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionSpecificsToValue(
174 const sync_pb::SessionSpecifics
& session_specifics
);
176 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncedNotificationImageToValue(
177 const sync_pb::SyncedNotificationImage
& image
);
179 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
180 SyncedNotificationProfileImageToValue(
181 const sync_pb::SyncedNotificationProfileImage
& image
);
183 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TargetToValue(
184 const sync_pb::Target
& target
);
186 // Main *SpecificsToValue functions.
188 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppNotificationToValue(
189 const sync_pb::AppNotification
& app_notification_specifics
);
191 base::DictionaryValue
* AppSettingSpecificsToValue(
192 const sync_pb::AppSettingSpecifics
& app_setting_specifics
);
194 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSpecificsToValue(
195 const sync_pb::AppSpecifics
& app_specifics
);
197 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ArticleSpecificsToValue(
198 const sync_pb::ArticleSpecifics
& article_specifics
);
200 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillSpecificsToValue(
201 const sync_pb::AutofillSpecifics
& autofill_specifics
);
203 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillProfileSpecificsToValue(
204 const sync_pb::AutofillProfileSpecifics
& autofill_profile_specifics
);
206 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* BookmarkSpecificsToValue(
207 const sync_pb::BookmarkSpecifics
& bookmark_specifics
);
209 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DeviceInfoSpecificsToValue(
210 const sync_pb::DeviceInfoSpecifics
& device_info_specifics
);
212 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DictionarySpecificsToValue(
213 const sync_pb::DictionarySpecifics
& dictionary_specifics
);
215 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExperimentsSpecificsToValue(
216 const sync_pb::ExperimentsSpecifics
& proto
);
218 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PriorityPreferenceSpecificsToValue(
219 const sync_pb::PriorityPreferenceSpecifics
& proto
);
221 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSettingSpecificsToValue(
222 const sync_pb::ExtensionSettingSpecifics
& extension_setting_specifics
);
224 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSpecificsToValue(
225 const sync_pb::ExtensionSpecifics
& extension_specifics
);
227 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconImageSpecificsToValue(
228 const sync_pb::FaviconImageSpecifics
& favicon_image_specifics
);
230 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconTrackingSpecificsToValue(
231 const sync_pb::FaviconTrackingSpecifics
& favicon_tracking_specifics
);
233 SYNC_EXPORT
base::DictionaryValue
* HistoryDeleteDirectiveSpecificsToValue(
234 const sync_pb::HistoryDeleteDirectiveSpecifics
&
235 history_delete_directive_specifics
);
237 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSettingSpecificsToValue(
238 const sync_pb::ManagedUserSettingSpecifics
& managed_user_setting_specifics
);
240 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSpecificsToValue(
241 const sync_pb::ManagedUserSpecifics
& managed_user_specifics
);
243 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
244 ManagedUserSharedSettingSpecificsToValue(
245 const sync_pb::ManagedUserSharedSettingSpecifics
&
246 managed_user_shared_setting_specifics
);
248 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* MediaToValue(
249 const sync_pb::Media
& media
);
251 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* NigoriSpecificsToValue(
252 const sync_pb::NigoriSpecifics
& nigori_specifics
);
254 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsToValue(
255 const sync_pb::PasswordSpecifics
& password_specifics
);
257 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PreferenceSpecificsToValue(
258 const sync_pb::PreferenceSpecifics
& password_specifics
);
260 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
261 SyncedNotificationAppInfoSpecificsToValue(
262 const sync_pb::SyncedNotificationAppInfoSpecifics
&
263 synced_notification_specifics
);
265 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncedNotificationSpecificsToValue(
266 const sync_pb::SyncedNotificationSpecifics
&
267 synced_notification_specifics
);
269 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SearchEngineSpecificsToValue(
270 const sync_pb::SearchEngineSpecifics
& search_engine_specifics
);
272 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ThemeSpecificsToValue(
273 const sync_pb::ThemeSpecifics
& theme_specifics
);
275 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TypedUrlSpecificsToValue(
276 const sync_pb::TypedUrlSpecifics
& typed_url_specifics
);
278 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* WifiCredentialSpecificsToValue(
279 const sync_pb::WifiCredentialSpecifics
& wifi_credential_specifics
);
281 // Any present extensions are mapped to sub-dictionary values with the
282 // key equal to the extension name.
283 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EntitySpecificsToValue(
284 const sync_pb::EntitySpecifics
& specifics
);
286 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncEntityToValue(
287 const sync_pb::SyncEntity
& entity
,
288 bool include_specifics
);
290 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerMessageToValue(
291 const sync_pb::ClientToServerMessage
& proto
,
292 bool include_specifics
);
294 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerResponseToValue(
295 const sync_pb::ClientToServerResponse
& proto
,
296 bool include_specifics
);
298 base::DictionaryValue
* DatatypeAssociationStatsToValue(
299 const sync_pb::DatatypeAssociationStats
& proto
);
301 base::DictionaryValue
* DebugEventInfoToValue(
302 const sync_pb::DebugEventInfo
& proto
);
304 base::DictionaryValue
* DebugInfoToValue(
305 const sync_pb::DebugInfo
& proto
);
307 base::DictionaryValue
* SyncCycleCompletedEventInfoToValue(
308 const sync_pb::SyncCycleCompletedEventInfo
& proto
);
310 base::DictionaryValue
* ClientConfigParamsToValue(
311 const sync_pb::ClientConfigParams
& proto
);
313 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AttachmentIdProtoToValue(
314 const sync_pb::AttachmentIdProto
& proto
);
316 } // namespace syncer
318 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_