OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Keep this file in sync with the .proto files in this directory. | 5 // Keep this file in sync with the .proto files in this directory. |
6 | 6 |
7 #include "sync/protocol/proto_value_conversions.h" | 7 #include "sync/protocol/proto_value_conversions.h" |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "sync/protocol/app_notification_specifics.pb.h" | 14 #include "sync/protocol/app_notification_specifics.pb.h" |
15 #include "sync/protocol/app_setting_specifics.pb.h" | 15 #include "sync/protocol/app_setting_specifics.pb.h" |
16 #include "sync/protocol/app_specifics.pb.h" | 16 #include "sync/protocol/app_specifics.pb.h" |
17 #include "sync/protocol/autofill_specifics.pb.h" | 17 #include "sync/protocol/autofill_specifics.pb.h" |
18 #include "sync/protocol/bookmark_specifics.pb.h" | 18 #include "sync/protocol/bookmark_specifics.pb.h" |
19 #include "sync/protocol/encryption.pb.h" | 19 #include "sync/protocol/encryption.pb.h" |
20 #include "sync/protocol/extension_setting_specifics.pb.h" | 20 #include "sync/protocol/extension_setting_specifics.pb.h" |
21 #include "sync/protocol/extension_specifics.pb.h" | 21 #include "sync/protocol/extension_specifics.pb.h" |
| 22 #include "sync/protocol/history_delete_directive_specifics.pb.h" |
22 #include "sync/protocol/nigori_specifics.pb.h" | 23 #include "sync/protocol/nigori_specifics.pb.h" |
23 #include "sync/protocol/password_specifics.pb.h" | 24 #include "sync/protocol/password_specifics.pb.h" |
24 #include "sync/protocol/preference_specifics.pb.h" | 25 #include "sync/protocol/preference_specifics.pb.h" |
25 #include "sync/protocol/proto_enum_conversions.h" | 26 #include "sync/protocol/proto_enum_conversions.h" |
26 #include "sync/protocol/search_engine_specifics.pb.h" | 27 #include "sync/protocol/search_engine_specifics.pb.h" |
27 #include "sync/protocol/session_specifics.pb.h" | 28 #include "sync/protocol/session_specifics.pb.h" |
28 #include "sync/protocol/sync.pb.h" | 29 #include "sync/protocol/sync.pb.h" |
29 #include "sync/protocol/theme_specifics.pb.h" | 30 #include "sync/protocol/theme_specifics.pb.h" |
30 #include "sync/protocol/typed_url_specifics.pb.h" | 31 #include "sync/protocol/typed_url_specifics.pb.h" |
31 | 32 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 const sync_pb::DeviceInfoSpecifics& proto) { | 196 const sync_pb::DeviceInfoSpecifics& proto) { |
196 DictionaryValue* value = new DictionaryValue(); | 197 DictionaryValue* value = new DictionaryValue(); |
197 SET_STR(cache_guid); | 198 SET_STR(cache_guid); |
198 SET_STR(client_name); | 199 SET_STR(client_name); |
199 SET_ENUM(device_type, GetDeviceTypeString); | 200 SET_ENUM(device_type, GetDeviceTypeString); |
200 SET_STR(sync_user_agent); | 201 SET_STR(sync_user_agent); |
201 SET_STR(chrome_version); | 202 SET_STR(chrome_version); |
202 return value; | 203 return value; |
203 } | 204 } |
204 | 205 |
| 206 base::DictionaryValue* GlobalIdDirectiveToValue( |
| 207 const sync_pb::GlobalIdDirective& proto) { |
| 208 DictionaryValue* value = new DictionaryValue(); |
| 209 SET_INT64_REP(global_id); |
| 210 return value; |
| 211 } |
| 212 |
| 213 base::DictionaryValue* TimeRangeDirectiveToValue( |
| 214 const sync_pb::TimeRangeDirective& proto) { |
| 215 DictionaryValue* value = new DictionaryValue(); |
| 216 SET_INT64(start_time_usec); |
| 217 SET_INT64(end_time_usec); |
| 218 return value; |
| 219 } |
| 220 |
| 221 base::DictionaryValue* EverythingDirectiveToValue( |
| 222 const sync_pb::EverythingDirective& proto) { |
| 223 DictionaryValue* value = new DictionaryValue(); |
| 224 SET_BOOL(delete_everything); |
| 225 return value; |
| 226 } |
| 227 |
205 DictionaryValue* AppNotificationToValue( | 228 DictionaryValue* AppNotificationToValue( |
206 const sync_pb::AppNotification& proto) { | 229 const sync_pb::AppNotification& proto) { |
207 DictionaryValue* value = new DictionaryValue(); | 230 DictionaryValue* value = new DictionaryValue(); |
208 SET_STR(guid); | 231 SET_STR(guid); |
209 SET_STR(app_id); | 232 SET_STR(app_id); |
210 SET_INT64(creation_timestamp_ms); | 233 SET_INT64(creation_timestamp_ms); |
211 SET_STR(title); | 234 SET_STR(title); |
212 SET_STR(body_text); | 235 SET_STR(body_text); |
213 SET_STR(link_url); | 236 SET_STR(link_url); |
214 SET_STR(link_text); | 237 SET_STR(link_text); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 DictionaryValue* value = new DictionaryValue(); | 313 DictionaryValue* value = new DictionaryValue(); |
291 SET_STR(id); | 314 SET_STR(id); |
292 SET_STR(version); | 315 SET_STR(version); |
293 SET_STR(update_url); | 316 SET_STR(update_url); |
294 SET_BOOL(enabled); | 317 SET_BOOL(enabled); |
295 SET_BOOL(incognito_enabled); | 318 SET_BOOL(incognito_enabled); |
296 SET_STR(name); | 319 SET_STR(name); |
297 return value; | 320 return value; |
298 } | 321 } |
299 | 322 |
| 323 base::DictionaryValue* HistoryDeleteDirectiveSpecificsToValue( |
| 324 const sync_pb::HistoryDeleteDirectiveSpecifics& proto) { |
| 325 DictionaryValue* value = new DictionaryValue(); |
| 326 SET(global_id_directive, GlobalIdDirectiveToValue); |
| 327 SET(time_range_directive, TimeRangeDirectiveToValue); |
| 328 SET(everything_directive, EverythingDirectiveToValue); |
| 329 return value; |
| 330 } |
| 331 |
300 DictionaryValue* NigoriSpecificsToValue( | 332 DictionaryValue* NigoriSpecificsToValue( |
301 const sync_pb::NigoriSpecifics& proto) { | 333 const sync_pb::NigoriSpecifics& proto) { |
302 DictionaryValue* value = new DictionaryValue(); | 334 DictionaryValue* value = new DictionaryValue(); |
303 SET(encryption_keybag, EncryptedDataToValue); | 335 SET(encryption_keybag, EncryptedDataToValue); |
304 SET_BOOL(keybag_is_frozen); | 336 SET_BOOL(keybag_is_frozen); |
305 SET_BOOL(encrypt_bookmarks); | 337 SET_BOOL(encrypt_bookmarks); |
306 SET_BOOL(encrypt_preferences); | 338 SET_BOOL(encrypt_preferences); |
307 SET_BOOL(encrypt_autofill_profile); | 339 SET_BOOL(encrypt_autofill_profile); |
308 SET_BOOL(encrypt_autofill); | 340 SET_BOOL(encrypt_autofill); |
309 SET_BOOL(encrypt_themes); | 341 SET_BOOL(encrypt_themes); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 DictionaryValue* value = new DictionaryValue(); | 429 DictionaryValue* value = new DictionaryValue(); |
398 SET_FIELD(app, AppSpecificsToValue); | 430 SET_FIELD(app, AppSpecificsToValue); |
399 SET_FIELD(app_notification, AppNotificationToValue); | 431 SET_FIELD(app_notification, AppNotificationToValue); |
400 SET_FIELD(app_setting, AppSettingSpecificsToValue); | 432 SET_FIELD(app_setting, AppSettingSpecificsToValue); |
401 SET_FIELD(autofill, AutofillSpecificsToValue); | 433 SET_FIELD(autofill, AutofillSpecificsToValue); |
402 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); | 434 SET_FIELD(autofill_profile, AutofillProfileSpecificsToValue); |
403 SET_FIELD(bookmark, BookmarkSpecificsToValue); | 435 SET_FIELD(bookmark, BookmarkSpecificsToValue); |
404 SET_FIELD(device_info, DeviceInfoSpecificsToValue); | 436 SET_FIELD(device_info, DeviceInfoSpecificsToValue); |
405 SET_FIELD(extension, ExtensionSpecificsToValue); | 437 SET_FIELD(extension, ExtensionSpecificsToValue); |
406 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); | 438 SET_FIELD(extension_setting, ExtensionSettingSpecificsToValue); |
| 439 SET_FIELD(history_delete_directive, HistoryDeleteDirectiveSpecificsToValue); |
407 SET_FIELD(nigori, NigoriSpecificsToValue); | 440 SET_FIELD(nigori, NigoriSpecificsToValue); |
408 SET_FIELD(password, PasswordSpecificsToValue); | 441 SET_FIELD(password, PasswordSpecificsToValue); |
409 SET_FIELD(preference, PreferenceSpecificsToValue); | 442 SET_FIELD(preference, PreferenceSpecificsToValue); |
410 SET_FIELD(search_engine, SearchEngineSpecificsToValue); | 443 SET_FIELD(search_engine, SearchEngineSpecificsToValue); |
411 SET_FIELD(session, SessionSpecificsToValue); | 444 SET_FIELD(session, SessionSpecificsToValue); |
412 SET_FIELD(theme, ThemeSpecificsToValue); | 445 SET_FIELD(theme, ThemeSpecificsToValue); |
413 SET_FIELD(typed_url, TypedUrlSpecificsToValue); | 446 SET_FIELD(typed_url, TypedUrlSpecificsToValue); |
414 return value; | 447 return value; |
415 } | 448 } |
416 | 449 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 #undef SET_BYTES | 631 #undef SET_BYTES |
599 #undef SET_INT32 | 632 #undef SET_INT32 |
600 #undef SET_INT64 | 633 #undef SET_INT64 |
601 #undef SET_INT64_REP | 634 #undef SET_INT64_REP |
602 #undef SET_STR | 635 #undef SET_STR |
603 #undef SET_STR_REP | 636 #undef SET_STR_REP |
604 | 637 |
605 #undef SET_FIELD | 638 #undef SET_FIELD |
606 | 639 |
607 } // namespace syncer | 640 } // namespace syncer |
OLD | NEW |