Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / sync / protocol / proto_value_conversions.h
blob2a3c1ae1b8a4865dba99ed3fbd4488ed5e99abbb
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"
12 namespace base {
13 class DictionaryValue;
16 namespace sync_pb {
17 class AppListSpecifics;
18 class AppNotification;
19 class AppNotificationSettings;
20 class AppSettingSpecifics;
21 class AppSpecifics;
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;
31 class CollapsedInfo;
32 class DatatypeAssociationStats;
33 class DebugEventInfo;
34 class DebugInfo;
35 class DeviceInfoSpecifics;
36 class DeviceInformation;
37 class DictionarySpecifics;
38 class EncryptedData;
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;
49 class Media;
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;
60 class SessionHeader;
61 class SessionSpecifics;
62 class SessionTab;
63 class SessionWindow;
64 class SimpleCollapsedLayout;
65 class SyncCycleCompletedEventInfo;
66 class SyncEntity;
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;
76 class TabNavigation;
77 class Target;
78 class ThemeSpecifics;
79 class TimeRangeDirective;
80 class TypedUrlSpecifics;
81 } // namespace sync_pb
83 // Utility functions to convert sync protocol buffers to dictionaries.
84 // Each protocol field is mapped to a key of the same name. Repeated
85 // fields are mapped to array values and sub-messages are mapped to
86 // sub-dictionary values.
88 // TODO(akalin): Add has_* information.
90 // TODO(akalin): Improve enum support.
92 namespace syncer {
94 // Ownership of all returned DictionaryValues are transferred to the
95 // caller.
97 // TODO(akalin): Perhaps extend this to decrypt?
98 SYNC_EXPORT_PRIVATE base::DictionaryValue* EncryptedDataToValue(
99 const sync_pb::EncryptedData& encrypted_data);
101 // Sub-protocol of AppListSpecifics.
102 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppListSpecificsToValue(
103 const sync_pb::AppListSpecifics& proto);
105 // Sub-protocol of AppSpecifics.
106 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSettingsToValue(
107 const sync_pb::AppNotificationSettings& app_notification_settings);
109 // Sub-protocols of SessionSpecifics.
111 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionHeaderToValue(
112 const sync_pb::SessionHeader& session_header);
114 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionTabToValue(
115 const sync_pb::SessionTab& session_tab);
117 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionWindowToValue(
118 const sync_pb::SessionWindow& session_window);
120 SYNC_EXPORT_PRIVATE base::DictionaryValue* TabNavigationToValue(
121 const sync_pb::TabNavigation& tab_navigation);
123 SYNC_EXPORT_PRIVATE base::DictionaryValue* NavigationRedirectToValue(
124 const sync_pb::NavigationRedirect& navigation_redirect);
126 // Sub-protocol of PasswordSpecifics.
128 SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsDataToValue(
129 const sync_pb::PasswordSpecificsData& password_specifics_data);
131 // Sub-protocol of NigoriSpecifics.
133 base::DictionaryValue* DeviceInformationToValue(
134 const sync_pb::DeviceInformation& device_information);
136 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
138 base::DictionaryValue* GlobalIdDirectiveToValue(
139 const sync_pb::GlobalIdDirective& global_id_directive);
141 base::DictionaryValue* TimeRangeDirectiveToValue(
142 const sync_pb::TimeRangeDirective& time_range_directive);
144 // Sub-protocol of Experiments.
146 base::DictionaryValue* KeystoreEncryptionToValue(
147 const sync_pb::KeystoreEncryptionFlagsSpecifics& proto);
149 // Sub protocols of SyncedNotifications.
151 base::DictionaryValue* SimpleCollapsedLayoutToValue(
152 const sync_pb::SimpleCollapsedLayout& proto);
154 base::DictionaryValue* CollapsedInfoToValue(
155 const sync_pb::CollapsedInfo& proto);
157 base::DictionaryValue* RenderInfoToValue(
158 const sync_pb::SyncedNotificationRenderInfo& proto);
160 base::DictionaryValue* CoalescedNotificationToValue(
161 const sync_pb::CoalescedSyncedNotification& proto);
163 base::DictionaryValue* SyncedNotificationActionToValue(
164 const sync_pb::SyncedNotificationAction& action);
166 base::DictionaryValue* SyncedNotificationDestinationToValue(
167 const sync_pb::SyncedNotificationDestination& destination);
169 base::DictionaryValue* SyncedNotificationToValue(
170 const sync_pb::SyncedNotification& notification);
172 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionSpecificsToValue(
173 const sync_pb::SessionSpecifics& session_specifics);
175 SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationImageToValue(
176 const sync_pb::SyncedNotificationImage& image);
178 SYNC_EXPORT_PRIVATE base::DictionaryValue*
179 SyncedNotificationProfileImageToValue(
180 const sync_pb::SyncedNotificationProfileImage& image);
182 SYNC_EXPORT_PRIVATE base::DictionaryValue* TargetToValue(
183 const sync_pb::Target& target);
185 // Main *SpecificsToValue functions.
187 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppNotificationToValue(
188 const sync_pb::AppNotification& app_notification_specifics);
190 base::DictionaryValue* AppSettingSpecificsToValue(
191 const sync_pb::AppSettingSpecifics& app_setting_specifics);
193 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSpecificsToValue(
194 const sync_pb::AppSpecifics& app_specifics);
196 SYNC_EXPORT_PRIVATE base::DictionaryValue* ArticleSpecificsToValue(
197 const sync_pb::ArticleSpecifics& article_specifics);
199 SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillSpecificsToValue(
200 const sync_pb::AutofillSpecifics& autofill_specifics);
202 SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillProfileSpecificsToValue(
203 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
205 SYNC_EXPORT_PRIVATE base::DictionaryValue* BookmarkSpecificsToValue(
206 const sync_pb::BookmarkSpecifics& bookmark_specifics);
208 SYNC_EXPORT_PRIVATE base::DictionaryValue* DeviceInfoSpecificsToValue(
209 const sync_pb::DeviceInfoSpecifics& device_info_specifics);
211 SYNC_EXPORT_PRIVATE base::DictionaryValue* DictionarySpecificsToValue(
212 const sync_pb::DictionarySpecifics& dictionary_specifics);
214 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExperimentsSpecificsToValue(
215 const sync_pb::ExperimentsSpecifics& proto);
217 SYNC_EXPORT_PRIVATE base::DictionaryValue* PriorityPreferenceSpecificsToValue(
218 const sync_pb::PriorityPreferenceSpecifics& proto);
220 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSettingSpecificsToValue(
221 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics);
223 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSpecificsToValue(
224 const sync_pb::ExtensionSpecifics& extension_specifics);
226 SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconImageSpecificsToValue(
227 const sync_pb::FaviconImageSpecifics& favicon_image_specifics);
229 SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconTrackingSpecificsToValue(
230 const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics);
232 SYNC_EXPORT base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
233 const sync_pb::HistoryDeleteDirectiveSpecifics&
234 history_delete_directive_specifics);
236 SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSettingSpecificsToValue(
237 const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics);
239 SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSpecificsToValue(
240 const sync_pb::ManagedUserSpecifics& managed_user_specifics);
242 SYNC_EXPORT_PRIVATE base::DictionaryValue*
243 ManagedUserSharedSettingSpecificsToValue(
244 const sync_pb::ManagedUserSharedSettingSpecifics&
245 managed_user_shared_setting_specifics);
247 SYNC_EXPORT_PRIVATE base::DictionaryValue* MediaToValue(
248 const sync_pb::Media& media);
250 SYNC_EXPORT_PRIVATE base::DictionaryValue* NigoriSpecificsToValue(
251 const sync_pb::NigoriSpecifics& nigori_specifics);
253 SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsToValue(
254 const sync_pb::PasswordSpecifics& password_specifics);
256 SYNC_EXPORT_PRIVATE base::DictionaryValue* PreferenceSpecificsToValue(
257 const sync_pb::PreferenceSpecifics& password_specifics);
259 SYNC_EXPORT_PRIVATE base::DictionaryValue*
260 SyncedNotificationAppInfoSpecificsToValue(
261 const sync_pb::SyncedNotificationAppInfoSpecifics&
262 synced_notification_specifics);
264 SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationSpecificsToValue(
265 const sync_pb::SyncedNotificationSpecifics&
266 synced_notification_specifics);
268 SYNC_EXPORT_PRIVATE base::DictionaryValue* SearchEngineSpecificsToValue(
269 const sync_pb::SearchEngineSpecifics& search_engine_specifics);
271 SYNC_EXPORT_PRIVATE base::DictionaryValue* ThemeSpecificsToValue(
272 const sync_pb::ThemeSpecifics& theme_specifics);
274 SYNC_EXPORT_PRIVATE base::DictionaryValue* TypedUrlSpecificsToValue(
275 const sync_pb::TypedUrlSpecifics& typed_url_specifics);
277 // Any present extensions are mapped to sub-dictionary values with the
278 // key equal to the extension name.
279 SYNC_EXPORT_PRIVATE base::DictionaryValue* EntitySpecificsToValue(
280 const sync_pb::EntitySpecifics& specifics);
282 SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncEntityToValue(
283 const sync_pb::SyncEntity& entity,
284 bool include_specifics);
286 SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerMessageToValue(
287 const sync_pb::ClientToServerMessage& proto,
288 bool include_specifics);
290 SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerResponseToValue(
291 const sync_pb::ClientToServerResponse& proto,
292 bool include_specifics);
294 base::DictionaryValue* DatatypeAssociationStatsToValue(
295 const sync_pb::DatatypeAssociationStats& proto);
297 base::DictionaryValue* DebugEventInfoToValue(
298 const sync_pb::DebugEventInfo& proto);
300 base::DictionaryValue* DebugInfoToValue(
301 const sync_pb::DebugInfo& proto);
303 base::DictionaryValue* SyncCycleCompletedEventInfoToValue(
304 const sync_pb::SyncCycleCompletedEventInfo& proto);
306 base::DictionaryValue* ClientConfigParamsToValue(
307 const sync_pb::ClientConfigParams& proto);
309 SYNC_EXPORT_PRIVATE base::DictionaryValue* AttachmentIdProtoToValue(
310 const sync_pb::AttachmentIdProto& proto);
312 } // namespace syncer
314 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_