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 AutofillWalletSpecifics
;
27 class BookmarkSpecifics
;
28 class ClientConfigParams
;
29 class ClientToServerMessage
;
30 class ClientToServerResponse
;
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 ManagedUserWhitelistSpecifics
;
54 class NavigationRedirect
;
55 class NigoriSpecifics
;
56 class PasswordSpecifics
;
57 class PasswordSpecificsData
;
58 class PreferenceSpecifics
;
59 class PriorityPreferenceSpecifics
;
60 class SearchEngineSpecifics
;
62 class SessionSpecifics
;
65 class SimpleCollapsedLayout
;
66 class SyncCycleCompletedEventInfo
;
68 class SyncedNotificationAppInfoSpecifics
;
69 class SyncedNotificationSpecifics
;
73 class TimeRangeDirective
;
74 class TypedUrlSpecifics
;
75 class WalletMaskedCreditCard
;
76 class WalletPostalAddress
;
77 class WifiCredentialSpecifics
;
78 } // namespace sync_pb
80 // Utility functions to convert sync protocol buffers to dictionaries.
81 // Each protocol field is mapped to a key of the same name. Repeated
82 // fields are mapped to array values and sub-messages are mapped to
83 // sub-dictionary values.
85 // TODO(akalin): Add has_* information.
87 // TODO(akalin): Improve enum support.
91 // Ownership of all returned DictionaryValues are transferred to the
94 // TODO(akalin): Perhaps extend this to decrypt?
95 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EncryptedDataToValue(
96 const sync_pb::EncryptedData
& encrypted_data
);
98 // Sub-protocol of AppListSpecifics.
99 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppListSpecificsToValue(
100 const sync_pb::AppListSpecifics
& proto
);
102 // Sub-protocol of AppSpecifics.
103 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSettingsToValue(
104 const sync_pb::AppNotificationSettings
& app_notification_settings
);
106 // Sub-protocols of SessionSpecifics.
108 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionHeaderToValue(
109 const sync_pb::SessionHeader
& session_header
);
111 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionTabToValue(
112 const sync_pb::SessionTab
& session_tab
);
114 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionWindowToValue(
115 const sync_pb::SessionWindow
& session_window
);
117 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TabNavigationToValue(
118 const sync_pb::TabNavigation
& tab_navigation
);
120 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* NavigationRedirectToValue(
121 const sync_pb::NavigationRedirect
& navigation_redirect
);
123 // Sub-protocol of PasswordSpecifics.
125 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsDataToValue(
126 const sync_pb::PasswordSpecificsData
& password_specifics_data
);
128 // Sub-protocol of NigoriSpecifics.
130 base::DictionaryValue
* DeviceInformationToValue(
131 const sync_pb::DeviceInformation
& device_information
);
133 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
135 base::DictionaryValue
* GlobalIdDirectiveToValue(
136 const sync_pb::GlobalIdDirective
& global_id_directive
);
138 base::DictionaryValue
* TimeRangeDirectiveToValue(
139 const sync_pb::TimeRangeDirective
& time_range_directive
);
141 // Sub-protocol of Experiments.
143 base::DictionaryValue
* KeystoreEncryptionToValue(
144 const sync_pb::KeystoreEncryptionFlagsSpecifics
& proto
);
146 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SessionSpecificsToValue(
147 const sync_pb::SessionSpecifics
& session_specifics
);
149 // Main *SpecificsToValue functions.
151 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppNotificationToValue(
152 const sync_pb::AppNotification
& app_notification_specifics
);
154 base::DictionaryValue
* AppSettingSpecificsToValue(
155 const sync_pb::AppSettingSpecifics
& app_setting_specifics
);
157 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AppSpecificsToValue(
158 const sync_pb::AppSpecifics
& app_specifics
);
160 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ArticleSpecificsToValue(
161 const sync_pb::ArticleSpecifics
& article_specifics
);
163 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillSpecificsToValue(
164 const sync_pb::AutofillSpecifics
& autofill_specifics
);
166 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillProfileSpecificsToValue(
167 const sync_pb::AutofillProfileSpecifics
& autofill_profile_specifics
);
169 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AutofillWalletSpecificsToValue(
170 const sync_pb::AutofillWalletSpecifics
& autofill_wallet_specifics
);
172 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* BookmarkSpecificsToValue(
173 const sync_pb::BookmarkSpecifics
& bookmark_specifics
);
175 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DeviceInfoSpecificsToValue(
176 const sync_pb::DeviceInfoSpecifics
& device_info_specifics
);
178 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* DictionarySpecificsToValue(
179 const sync_pb::DictionarySpecifics
& dictionary_specifics
);
181 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExperimentsSpecificsToValue(
182 const sync_pb::ExperimentsSpecifics
& proto
);
184 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PriorityPreferenceSpecificsToValue(
185 const sync_pb::PriorityPreferenceSpecifics
& proto
);
187 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSettingSpecificsToValue(
188 const sync_pb::ExtensionSettingSpecifics
& extension_setting_specifics
);
190 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ExtensionSpecificsToValue(
191 const sync_pb::ExtensionSpecifics
& extension_specifics
);
193 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconImageSpecificsToValue(
194 const sync_pb::FaviconImageSpecifics
& favicon_image_specifics
);
196 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* FaviconTrackingSpecificsToValue(
197 const sync_pb::FaviconTrackingSpecifics
& favicon_tracking_specifics
);
199 SYNC_EXPORT
base::DictionaryValue
* HistoryDeleteDirectiveSpecificsToValue(
200 const sync_pb::HistoryDeleteDirectiveSpecifics
&
201 history_delete_directive_specifics
);
203 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSettingSpecificsToValue(
204 const sync_pb::ManagedUserSettingSpecifics
& managed_user_setting_specifics
);
206 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserSpecificsToValue(
207 const sync_pb::ManagedUserSpecifics
& managed_user_specifics
);
209 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
210 ManagedUserSharedSettingSpecificsToValue(
211 const sync_pb::ManagedUserSharedSettingSpecifics
&
212 managed_user_shared_setting_specifics
);
214 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ManagedUserWhitelistSpecificsToValue(
215 const sync_pb::ManagedUserWhitelistSpecifics
&
216 managed_user_whitelist_specifics
);
218 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* MediaToValue(
219 const sync_pb::Media
& media
);
221 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* NigoriSpecificsToValue(
222 const sync_pb::NigoriSpecifics
& nigori_specifics
);
224 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PasswordSpecificsToValue(
225 const sync_pb::PasswordSpecifics
& password_specifics
);
227 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* PreferenceSpecificsToValue(
228 const sync_pb::PreferenceSpecifics
& password_specifics
);
230 SYNC_EXPORT_PRIVATE
base::DictionaryValue
*
231 SyncedNotificationAppInfoSpecificsToValue(
232 const sync_pb::SyncedNotificationAppInfoSpecifics
&
233 synced_notification_specifics
);
235 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncedNotificationSpecificsToValue(
236 const sync_pb::SyncedNotificationSpecifics
&
237 synced_notification_specifics
);
239 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SearchEngineSpecificsToValue(
240 const sync_pb::SearchEngineSpecifics
& search_engine_specifics
);
242 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ThemeSpecificsToValue(
243 const sync_pb::ThemeSpecifics
& theme_specifics
);
245 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* TypedUrlSpecificsToValue(
246 const sync_pb::TypedUrlSpecifics
& typed_url_specifics
);
248 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* WalletMaskedCreditCardToValue(
249 const sync_pb::WalletMaskedCreditCard
& wallet_masked_card
);
251 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* WalletPostalAddressToValue(
252 const sync_pb::WalletPostalAddress
& wallet_postal_address
);
254 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* WifiCredentialSpecificsToValue(
255 const sync_pb::WifiCredentialSpecifics
& wifi_credential_specifics
);
257 // Any present extensions are mapped to sub-dictionary values with the
258 // key equal to the extension name.
259 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* EntitySpecificsToValue(
260 const sync_pb::EntitySpecifics
& specifics
);
262 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* SyncEntityToValue(
263 const sync_pb::SyncEntity
& entity
,
264 bool include_specifics
);
266 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerMessageToValue(
267 const sync_pb::ClientToServerMessage
& proto
,
268 bool include_specifics
);
270 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* ClientToServerResponseToValue(
271 const sync_pb::ClientToServerResponse
& proto
,
272 bool include_specifics
);
274 base::DictionaryValue
* DatatypeAssociationStatsToValue(
275 const sync_pb::DatatypeAssociationStats
& proto
);
277 base::DictionaryValue
* DebugEventInfoToValue(
278 const sync_pb::DebugEventInfo
& proto
);
280 base::DictionaryValue
* DebugInfoToValue(
281 const sync_pb::DebugInfo
& proto
);
283 base::DictionaryValue
* SyncCycleCompletedEventInfoToValue(
284 const sync_pb::SyncCycleCompletedEventInfo
& proto
);
286 base::DictionaryValue
* ClientConfigParamsToValue(
287 const sync_pb::ClientConfigParams
& proto
);
289 SYNC_EXPORT_PRIVATE
base::DictionaryValue
* AttachmentIdProtoToValue(
290 const sync_pb::AttachmentIdProto
& proto
);
292 } // namespace syncer
294 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_