Copy Smart Lock user preferences to local state so we can access them on the sign...
[chromium-blink-merge.git] / sync / protocol / proto_value_conversions.h
blob960ee456ea0dc66bdc57d6bd482ac38cc5adf25b
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 CollapsedInfo;
31 class DatatypeAssociationStats;
32 class DebugEventInfo;
33 class DebugInfo;
34 class DeviceInfoSpecifics;
35 class DeviceInformation;
36 class DictionarySpecifics;
37 class EncryptedData;
38 class EntitySpecifics;
39 class EverythingDirective;
40 class ExperimentsSpecifics;
41 class ExtensionSettingSpecifics;
42 class ExtensionSpecifics;
43 class FaviconImageSpecifics;
44 class FaviconTrackingSpecifics;
45 class GlobalIdDirective;
46 class HistoryDeleteDirectiveSpecifics;
47 class KeystoreEncryptionFlagsSpecifics;
48 class Media;
49 class ManagedUserSettingSpecifics;
50 class ManagedUserSharedSettingSpecifics;
51 class ManagedUserSpecifics;
52 class ManagedUserWhitelistSpecifics;
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 SyncedNotificationAppInfoSpecifics;
68 class SyncedNotificationSpecifics;
69 class TabNavigation;
70 class Target;
71 class ThemeSpecifics;
72 class TimeRangeDirective;
73 class TypedUrlSpecifics;
74 class WifiCredentialSpecifics;
75 } // namespace sync_pb
77 // Utility functions to convert sync protocol buffers to dictionaries.
78 // Each protocol field is mapped to a key of the same name. Repeated
79 // fields are mapped to array values and sub-messages are mapped to
80 // sub-dictionary values.
82 // TODO(akalin): Add has_* information.
84 // TODO(akalin): Improve enum support.
86 namespace syncer {
88 // Ownership of all returned DictionaryValues are transferred to the
89 // caller.
91 // TODO(akalin): Perhaps extend this to decrypt?
92 SYNC_EXPORT_PRIVATE base::DictionaryValue* EncryptedDataToValue(
93 const sync_pb::EncryptedData& encrypted_data);
95 // Sub-protocol of AppListSpecifics.
96 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppListSpecificsToValue(
97 const sync_pb::AppListSpecifics& proto);
99 // Sub-protocol of AppSpecifics.
100 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSettingsToValue(
101 const sync_pb::AppNotificationSettings& app_notification_settings);
103 // Sub-protocols of SessionSpecifics.
105 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionHeaderToValue(
106 const sync_pb::SessionHeader& session_header);
108 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionTabToValue(
109 const sync_pb::SessionTab& session_tab);
111 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionWindowToValue(
112 const sync_pb::SessionWindow& session_window);
114 SYNC_EXPORT_PRIVATE base::DictionaryValue* TabNavigationToValue(
115 const sync_pb::TabNavigation& tab_navigation);
117 SYNC_EXPORT_PRIVATE base::DictionaryValue* NavigationRedirectToValue(
118 const sync_pb::NavigationRedirect& navigation_redirect);
120 // Sub-protocol of PasswordSpecifics.
122 SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsDataToValue(
123 const sync_pb::PasswordSpecificsData& password_specifics_data);
125 // Sub-protocol of NigoriSpecifics.
127 base::DictionaryValue* DeviceInformationToValue(
128 const sync_pb::DeviceInformation& device_information);
130 // Sub-protocol of HistoryDeleteDirectiveSpecifics.
132 base::DictionaryValue* GlobalIdDirectiveToValue(
133 const sync_pb::GlobalIdDirective& global_id_directive);
135 base::DictionaryValue* TimeRangeDirectiveToValue(
136 const sync_pb::TimeRangeDirective& time_range_directive);
138 // Sub-protocol of Experiments.
140 base::DictionaryValue* KeystoreEncryptionToValue(
141 const sync_pb::KeystoreEncryptionFlagsSpecifics& proto);
143 SYNC_EXPORT_PRIVATE base::DictionaryValue* SessionSpecificsToValue(
144 const sync_pb::SessionSpecifics& session_specifics);
146 // Main *SpecificsToValue functions.
148 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppNotificationToValue(
149 const sync_pb::AppNotification& app_notification_specifics);
151 base::DictionaryValue* AppSettingSpecificsToValue(
152 const sync_pb::AppSettingSpecifics& app_setting_specifics);
154 SYNC_EXPORT_PRIVATE base::DictionaryValue* AppSpecificsToValue(
155 const sync_pb::AppSpecifics& app_specifics);
157 SYNC_EXPORT_PRIVATE base::DictionaryValue* ArticleSpecificsToValue(
158 const sync_pb::ArticleSpecifics& article_specifics);
160 SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillSpecificsToValue(
161 const sync_pb::AutofillSpecifics& autofill_specifics);
163 SYNC_EXPORT_PRIVATE base::DictionaryValue* AutofillProfileSpecificsToValue(
164 const sync_pb::AutofillProfileSpecifics& autofill_profile_specifics);
166 SYNC_EXPORT_PRIVATE base::DictionaryValue* BookmarkSpecificsToValue(
167 const sync_pb::BookmarkSpecifics& bookmark_specifics);
169 SYNC_EXPORT_PRIVATE base::DictionaryValue* DeviceInfoSpecificsToValue(
170 const sync_pb::DeviceInfoSpecifics& device_info_specifics);
172 SYNC_EXPORT_PRIVATE base::DictionaryValue* DictionarySpecificsToValue(
173 const sync_pb::DictionarySpecifics& dictionary_specifics);
175 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExperimentsSpecificsToValue(
176 const sync_pb::ExperimentsSpecifics& proto);
178 SYNC_EXPORT_PRIVATE base::DictionaryValue* PriorityPreferenceSpecificsToValue(
179 const sync_pb::PriorityPreferenceSpecifics& proto);
181 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSettingSpecificsToValue(
182 const sync_pb::ExtensionSettingSpecifics& extension_setting_specifics);
184 SYNC_EXPORT_PRIVATE base::DictionaryValue* ExtensionSpecificsToValue(
185 const sync_pb::ExtensionSpecifics& extension_specifics);
187 SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconImageSpecificsToValue(
188 const sync_pb::FaviconImageSpecifics& favicon_image_specifics);
190 SYNC_EXPORT_PRIVATE base::DictionaryValue* FaviconTrackingSpecificsToValue(
191 const sync_pb::FaviconTrackingSpecifics& favicon_tracking_specifics);
193 SYNC_EXPORT base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue(
194 const sync_pb::HistoryDeleteDirectiveSpecifics&
195 history_delete_directive_specifics);
197 SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSettingSpecificsToValue(
198 const sync_pb::ManagedUserSettingSpecifics& managed_user_setting_specifics);
200 SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserSpecificsToValue(
201 const sync_pb::ManagedUserSpecifics& managed_user_specifics);
203 SYNC_EXPORT_PRIVATE base::DictionaryValue*
204 ManagedUserSharedSettingSpecificsToValue(
205 const sync_pb::ManagedUserSharedSettingSpecifics&
206 managed_user_shared_setting_specifics);
208 SYNC_EXPORT_PRIVATE base::DictionaryValue* ManagedUserWhitelistSpecificsToValue(
209 const sync_pb::ManagedUserWhitelistSpecifics&
210 managed_user_whitelist_specifics);
212 SYNC_EXPORT_PRIVATE base::DictionaryValue* MediaToValue(
213 const sync_pb::Media& media);
215 SYNC_EXPORT_PRIVATE base::DictionaryValue* NigoriSpecificsToValue(
216 const sync_pb::NigoriSpecifics& nigori_specifics);
218 SYNC_EXPORT_PRIVATE base::DictionaryValue* PasswordSpecificsToValue(
219 const sync_pb::PasswordSpecifics& password_specifics);
221 SYNC_EXPORT_PRIVATE base::DictionaryValue* PreferenceSpecificsToValue(
222 const sync_pb::PreferenceSpecifics& password_specifics);
224 SYNC_EXPORT_PRIVATE base::DictionaryValue*
225 SyncedNotificationAppInfoSpecificsToValue(
226 const sync_pb::SyncedNotificationAppInfoSpecifics&
227 synced_notification_specifics);
229 SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncedNotificationSpecificsToValue(
230 const sync_pb::SyncedNotificationSpecifics&
231 synced_notification_specifics);
233 SYNC_EXPORT_PRIVATE base::DictionaryValue* SearchEngineSpecificsToValue(
234 const sync_pb::SearchEngineSpecifics& search_engine_specifics);
236 SYNC_EXPORT_PRIVATE base::DictionaryValue* ThemeSpecificsToValue(
237 const sync_pb::ThemeSpecifics& theme_specifics);
239 SYNC_EXPORT_PRIVATE base::DictionaryValue* TypedUrlSpecificsToValue(
240 const sync_pb::TypedUrlSpecifics& typed_url_specifics);
242 SYNC_EXPORT_PRIVATE base::DictionaryValue* WifiCredentialSpecificsToValue(
243 const sync_pb::WifiCredentialSpecifics& wifi_credential_specifics);
245 // Any present extensions are mapped to sub-dictionary values with the
246 // key equal to the extension name.
247 SYNC_EXPORT_PRIVATE base::DictionaryValue* EntitySpecificsToValue(
248 const sync_pb::EntitySpecifics& specifics);
250 SYNC_EXPORT_PRIVATE base::DictionaryValue* SyncEntityToValue(
251 const sync_pb::SyncEntity& entity,
252 bool include_specifics);
254 SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerMessageToValue(
255 const sync_pb::ClientToServerMessage& proto,
256 bool include_specifics);
258 SYNC_EXPORT_PRIVATE base::DictionaryValue* ClientToServerResponseToValue(
259 const sync_pb::ClientToServerResponse& proto,
260 bool include_specifics);
262 base::DictionaryValue* DatatypeAssociationStatsToValue(
263 const sync_pb::DatatypeAssociationStats& proto);
265 base::DictionaryValue* DebugEventInfoToValue(
266 const sync_pb::DebugEventInfo& proto);
268 base::DictionaryValue* DebugInfoToValue(
269 const sync_pb::DebugInfo& proto);
271 base::DictionaryValue* SyncCycleCompletedEventInfoToValue(
272 const sync_pb::SyncCycleCompletedEventInfo& proto);
274 base::DictionaryValue* ClientConfigParamsToValue(
275 const sync_pb::ClientConfigParams& proto);
277 SYNC_EXPORT_PRIVATE base::DictionaryValue* AttachmentIdProtoToValue(
278 const sync_pb::AttachmentIdProto& proto);
280 } // namespace syncer
282 #endif // SYNC_PROTOCOL_PROTO_VALUE_CONVERSIONS_H_