Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / sync / protocol / proto_value_conversions.h
blob9ba456334ab6e2aa55eb63f6342d14ed2f5d02ce
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 "base/memory/scoped_ptr.h"
11 #include "sync/base/sync_export.h"
13 namespace base {
14 class DictionaryValue;
17 namespace sync_pb {
18 class AppListSpecifics;
19 class AppNotification;
20 class AppNotificationSettings;
21 class AppSettingSpecifics;
22 class AppSpecifics;
23 class ArticleSpecifics;
24 class AttachmentIdProto;
25 class AutofillProfileSpecifics;
26 class AutofillSpecifics;
27 class AutofillWalletSpecifics;
28 class BookmarkSpecifics;
29 class ClientConfigParams;
30 class ClientToServerMessage;
31 class ClientToServerResponse;
32 class CollapsedInfo;
33 class DatatypeAssociationStats;
34 class DebugEventInfo;
35 class DebugInfo;
36 class DeviceInfoSpecifics;
37 class DeviceInformation;
38 class DictionarySpecifics;
39 class EncryptedData;
40 class EntitySpecifics;
41 class EverythingDirective;
42 class ExperimentsSpecifics;
43 class ExtensionSettingSpecifics;
44 class ExtensionSpecifics;
45 class FaviconImageSpecifics;
46 class FaviconTrackingSpecifics;
47 class GlobalIdDirective;
48 class HistoryDeleteDirectiveSpecifics;
49 class KeystoreEncryptionFlagsSpecifics;
50 class LinkedAppIconInfo;
51 class ManagedUserSettingSpecifics;
52 class ManagedUserSharedSettingSpecifics;
53 class ManagedUserSpecifics;
54 class ManagedUserWhitelistSpecifics;
55 class Media;
56 class NavigationRedirect;
57 class NigoriSpecifics;
58 class PasswordSpecifics;
59 class PasswordSpecificsData;
60 class PreferenceSpecifics;
61 class PriorityPreferenceSpecifics;
62 class SearchEngineSpecifics;
63 class SessionHeader;
64 class SessionSpecifics;
65 class SessionTab;
66 class SessionWindow;
67 class SimpleCollapsedLayout;
68 class SyncCycleCompletedEventInfo;
69 class SyncEntity;
70 class SyncedNotificationAppInfoSpecifics;
71 class SyncedNotificationSpecifics;
72 class TabNavigation;
73 class Target;
74 class ThemeSpecifics;
75 class TimeRangeDirective;
76 class TypedUrlSpecifics;
77 class WalletMaskedCreditCard;
78 class WalletMetadataSpecifics;
79 class WalletPostalAddress;
80 class WifiCredentialSpecifics;
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 scoped_ptr<base::DictionaryValue> EncryptedDataToValue(
99 const sync_pb::EncryptedData& encrypted_data);
101 // Sub-protocol of AppListSpecifics.
102 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppListSpecificsToValue(
103 const sync_pb::AppListSpecifics& proto);
105 // Sub-protocols of AppSpecifics.
106 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppSettingsToValue(
107 const sync_pb::AppNotificationSettings& app_notification_settings);
109 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> LinkedAppIconInfoToValue(
110 const sync_pb::LinkedAppIconInfo& linked_app_icon_info);
112 // Sub-protocols of SessionSpecifics.
114 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionHeaderToValue(
115 const sync_pb::SessionHeader& session_header);
117 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionTabToValue(
118 const sync_pb::SessionTab& session_tab);
120 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionWindowToValue(
121 const sync_pb::SessionWindow& session_window);
123 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> TabNavigationToValue(
124 const sync_pb::TabNavigation& tab_navigation);
126 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> NavigationRedirectToValue(
127 const sync_pb::NavigationRedirect& navigation_redirect);
129 // Sub-protocol of PasswordSpecifics.
131 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
132 PasswordSpecificsDataToValue(
133 const sync_pb::PasswordSpecificsData& password_specifics_data);
135 // Sub-protocol of NigoriSpecifics.
137 scoped_ptr<base::DictionaryValue> DeviceInformationToValue(
138 const sync_pb::DeviceInformation& device_information);
140 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
142 scoped_ptr<base::DictionaryValue> GlobalIdDirectiveToValue(
143 const sync_pb::GlobalIdDirective& global_id_directive);
145 scoped_ptr<base::DictionaryValue> TimeRangeDirectiveToValue(
146 const sync_pb::TimeRangeDirective& time_range_directive);
148 // Sub-protocol of Experiments.
150 scoped_ptr<base::DictionaryValue> KeystoreEncryptionToValue(
151 const sync_pb::KeystoreEncryptionFlagsSpecifics& proto);
153 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SessionSpecificsToValue(
154 const sync_pb::SessionSpecifics& session_specifics);
156 // Main *SpecificsToValue functions.
158 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppNotificationToValue(
159 const sync_pb::AppNotification& app_notification_specifics);
161 scoped_ptr<base::DictionaryValue> AppSettingSpecificsToValue(
162 const sync_pb::AppSettingSpecifics& app_setting_specifics);
164 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AppSpecificsToValue(
165 const sync_pb::AppSpecifics& app_specifics);
167 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ArticleSpecificsToValue(
168 const sync_pb::ArticleSpecifics& article_specifics);
170 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AutofillSpecificsToValue(
171 const sync_pb::AutofillSpecifics& autofill_specifics);
173 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
174 AutofillProfileSpecificsToValue(
175 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
177 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
178 WalletMetadataSpecificsToValue(
179 const sync_pb::WalletMetadataSpecifics& wallet_metadata_specifics);
181 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
182 AutofillWalletSpecificsToValue(
183 const sync_pb::AutofillWalletSpecifics& autofill_wallet_specifics);
185 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> BookmarkSpecificsToValue(
186 const sync_pb::BookmarkSpecifics& bookmark_specifics);
188 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
189 DeviceInfoSpecificsToValue(
190 const sync_pb::DeviceInfoSpecifics& device_info_specifics);
192 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
193 DictionarySpecificsToValue(
194 const sync_pb::DictionarySpecifics& dictionary_specifics);
196 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
197 ExperimentsSpecificsToValue(const sync_pb::ExperimentsSpecifics& proto);
199 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
200 PriorityPreferenceSpecificsToValue(
201 const sync_pb::PriorityPreferenceSpecifics& proto);
203 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
204 ExtensionSettingSpecificsToValue(
205 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics);
207 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ExtensionSpecificsToValue(
208 const sync_pb::ExtensionSpecifics& extension_specifics);
210 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
211 FaviconImageSpecificsToValue(
212 const sync_pb::FaviconImageSpecifics& favicon_image_specifics);
214 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
215 FaviconTrackingSpecificsToValue(
216 const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics);
218 SYNC_EXPORT scoped_ptr<base::DictionaryValue>
219 HistoryDeleteDirectiveSpecificsToValue(
220 const sync_pb::HistoryDeleteDirectiveSpecifics&
221 history_delete_directive_specifics);
223 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
224 ManagedUserSettingSpecificsToValue(
225 const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics);
227 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
228 ManagedUserSpecificsToValue(
229 const sync_pb::ManagedUserSpecifics& managed_user_specifics);
231 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
232 ManagedUserSharedSettingSpecificsToValue(
233 const sync_pb::ManagedUserSharedSettingSpecifics&
234 managed_user_shared_setting_specifics);
236 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
237 ManagedUserWhitelistSpecificsToValue(
238 const sync_pb::ManagedUserWhitelistSpecifics&
239 managed_user_whitelist_specifics);
241 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> MediaToValue(
242 const sync_pb::Media& media);
244 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> NigoriSpecificsToValue(
245 const sync_pb::NigoriSpecifics& nigori_specifics);
247 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> PasswordSpecificsToValue(
248 const sync_pb::PasswordSpecifics& password_specifics);
250 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
251 PreferenceSpecificsToValue(
252 const sync_pb::PreferenceSpecifics& password_specifics);
254 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
255 SyncedNotificationAppInfoSpecificsToValue(
256 const sync_pb::SyncedNotificationAppInfoSpecifics&
257 synced_notification_specifics);
259 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
260 SyncedNotificationSpecificsToValue(
261 const sync_pb::SyncedNotificationSpecifics& synced_notification_specifics);
263 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
264 SearchEngineSpecificsToValue(
265 const sync_pb::SearchEngineSpecifics& search_engine_specifics);
267 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> ThemeSpecificsToValue(
268 const sync_pb::ThemeSpecifics& theme_specifics);
270 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> TypedUrlSpecificsToValue(
271 const sync_pb::TypedUrlSpecifics& typed_url_specifics);
273 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
274 WalletMaskedCreditCardToValue(
275 const sync_pb::WalletMaskedCreditCard& wallet_masked_card);
277 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
278 WalletPostalAddressToValue(
279 const sync_pb::WalletPostalAddress& wallet_postal_address);
281 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
282 WifiCredentialSpecificsToValue(
283 const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics);
285 // Any present extensions are mapped to sub-dictionary values with the
286 // key equal to the extension name.
287 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> EntitySpecificsToValue(
288 const sync_pb::EntitySpecifics& specifics);
290 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> SyncEntityToValue(
291 const sync_pb::SyncEntity& entity,
292 bool include_specifics);
294 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
295 ClientToServerMessageToValue(const sync_pb::ClientToServerMessage& proto,
296 bool include_specifics);
298 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue>
299 ClientToServerResponseToValue(const sync_pb::ClientToServerResponse& proto,
300 bool include_specifics);
302 scoped_ptr<base::DictionaryValue> DatatypeAssociationStatsToValue(
303 const sync_pb::DatatypeAssociationStats& proto);
305 scoped_ptr<base::DictionaryValue> DebugEventInfoToValue(
306 const sync_pb::DebugEventInfo& proto);
308 scoped_ptr<base::DictionaryValue> DebugInfoToValue(
309 const sync_pb::DebugInfo& proto);
311 scoped_ptr<base::DictionaryValue> SyncCycleCompletedEventInfoToValue(
312 const sync_pb::SyncCycleCompletedEventInfo& proto);
314 scoped_ptr<base::DictionaryValue> ClientConfigParamsToValue(
315 const sync_pb::ClientConfigParams& proto);
317 SYNC_EXPORT_PRIVATE scoped_ptr<base::DictionaryValue> AttachmentIdProtoToValue(
318 const sync_pb::AttachmentIdProto& proto);
320 } // namespace syncer
322 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_