| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "sync/protocol/favicon_tracking_specifics.pb.h" | 31 #include "sync/protocol/favicon_tracking_specifics.pb.h" |
| 32 #include "sync/protocol/history_delete_directive_specifics.pb.h" | 32 #include "sync/protocol/history_delete_directive_specifics.pb.h" |
| 33 #include "sync/protocol/nigori_specifics.pb.h" | 33 #include "sync/protocol/nigori_specifics.pb.h" |
| 34 #include "sync/protocol/password_specifics.pb.h" | 34 #include "sync/protocol/password_specifics.pb.h" |
| 35 #include "sync/protocol/preference_specifics.pb.h" | 35 #include "sync/protocol/preference_specifics.pb.h" |
| 36 #include "sync/protocol/priority_preference_specifics.pb.h" | 36 #include "sync/protocol/priority_preference_specifics.pb.h" |
| 37 #include "sync/protocol/proto_enum_conversions.h" | 37 #include "sync/protocol/proto_enum_conversions.h" |
| 38 #include "sync/protocol/search_engine_specifics.pb.h" | 38 #include "sync/protocol/search_engine_specifics.pb.h" |
| 39 #include "sync/protocol/session_specifics.pb.h" | 39 #include "sync/protocol/session_specifics.pb.h" |
| 40 #include "sync/protocol/sync.pb.h" | 40 #include "sync/protocol/sync.pb.h" |
| 41 #include "sync/protocol/synced_notification_app_info_specifics.pb.h" | |
| 42 #include "sync/protocol/synced_notification_specifics.pb.h" | |
| 43 #include "sync/protocol/theme_specifics.pb.h" | 41 #include "sync/protocol/theme_specifics.pb.h" |
| 44 #include "sync/protocol/typed_url_specifics.pb.h" | 42 #include "sync/protocol/typed_url_specifics.pb.h" |
| 45 #include "sync/protocol/unique_position.pb.h" | 43 #include "sync/protocol/unique_position.pb.h" |
| 46 #include "sync/util/time.h" | 44 #include "sync/util/time.h" |
| 47 | 45 |
| 48 namespace syncer { | 46 namespace syncer { |
| 49 | 47 |
| 50 namespace { | 48 namespace { |
| 51 | 49 |
| 52 // Basic Type -> Value functions. | 50 // Basic Type -> Value functions. |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 } | 257 } |
| 260 | 258 |
| 261 base::DictionaryValue* TimeRangeDirectiveToValue( | 259 base::DictionaryValue* TimeRangeDirectiveToValue( |
| 262 const sync_pb::TimeRangeDirective& proto) { | 260 const sync_pb::TimeRangeDirective& proto) { |
| 263 base::DictionaryValue* value = new base::DictionaryValue(); | 261 base::DictionaryValue* value = new base::DictionaryValue(); |
| 264 SET_INT64(start_time_usec); | 262 SET_INT64(start_time_usec); |
| 265 SET_INT64(end_time_usec); | 263 SET_INT64(end_time_usec); |
| 266 return value; | 264 return value; |
| 267 } | 265 } |
| 268 | 266 |
| 269 base::DictionaryValue* SyncedNotificationAppInfoToValue( | |
| 270 const sync_pb::SyncedNotificationAppInfo& proto) { | |
| 271 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 272 SET_STR_REP(app_id); | |
| 273 SET_STR(settings_display_name); | |
| 274 SET_STR(app_name); | |
| 275 SET_STR(settings_url); | |
| 276 SET_STR(info_url); | |
| 277 SET(icon, SyncedNotificationImageToValue); | |
| 278 // TODO(petewil): Add fields for the monochrome icon when it is available. | |
| 279 return value; | |
| 280 } | |
| 281 | |
| 282 base::DictionaryValue* SyncedNotificationImageToValue( | |
| 283 const sync_pb::SyncedNotificationImage& proto) { | |
| 284 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 285 SET_STR(url); | |
| 286 SET_STR(alt_text); | |
| 287 SET_INT32(preferred_width); | |
| 288 SET_INT32(preferred_height); | |
| 289 return value; | |
| 290 } | |
| 291 | |
| 292 base::DictionaryValue* SyncedNotificationProfileImageToValue( | |
| 293 const sync_pb::SyncedNotificationProfileImage& proto) { | |
| 294 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 295 SET_STR(image_url); | |
| 296 SET_STR(oid); | |
| 297 SET_STR(display_name); | |
| 298 return value; | |
| 299 } | |
| 300 | |
| 301 base::DictionaryValue* MediaToValue( | |
| 302 const sync_pb::Media& proto) { | |
| 303 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 304 SET(image, SyncedNotificationImageToValue); | |
| 305 return value; | |
| 306 } | |
| 307 | |
| 308 base::DictionaryValue* SyncedNotificationActionToValue( | |
| 309 const sync_pb::SyncedNotificationAction& proto) { | |
| 310 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 311 SET_STR(text); | |
| 312 SET(icon, SyncedNotificationImageToValue); | |
| 313 SET_STR(url); | |
| 314 SET_STR(request_data); | |
| 315 SET_STR(accessibility_label); | |
| 316 return value; | |
| 317 } | |
| 318 | |
| 319 base::DictionaryValue* SyncedNotificationDestiationToValue( | |
| 320 const sync_pb::SyncedNotificationDestination& proto) { | |
| 321 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 322 SET_STR(text); | |
| 323 SET(icon, SyncedNotificationImageToValue); | |
| 324 SET_STR(url); | |
| 325 SET_STR(accessibility_label); | |
| 326 return value; | |
| 327 } | |
| 328 | |
| 329 base::DictionaryValue* TargetToValue( | |
| 330 const sync_pb::Target& proto) { | |
| 331 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 332 SET(destination, SyncedNotificationDestiationToValue); | |
| 333 SET(action, SyncedNotificationActionToValue); | |
| 334 SET_STR(target_key); | |
| 335 return value; | |
| 336 } | |
| 337 | |
| 338 base::DictionaryValue* SimpleCollapsedLayoutToValue( | |
| 339 const sync_pb::SimpleCollapsedLayout& proto) { | |
| 340 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 341 SET(app_icon, SyncedNotificationImageToValue); | |
| 342 SET_REP(profile_image, SyncedNotificationProfileImageToValue); | |
| 343 SET_STR(heading); | |
| 344 SET_STR(description); | |
| 345 SET_STR(annotation); | |
| 346 SET_REP(media, MediaToValue); | |
| 347 return value; | |
| 348 } | |
| 349 | |
| 350 base::DictionaryValue* CollapsedInfoToValue( | |
| 351 const sync_pb::CollapsedInfo& proto) { | |
| 352 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 353 SET(simple_collapsed_layout, SimpleCollapsedLayoutToValue); | |
| 354 SET_INT64(creation_timestamp_usec); | |
| 355 SET(default_destination, SyncedNotificationDestiationToValue); | |
| 356 SET_REP(target, TargetToValue); | |
| 357 return value; | |
| 358 } | |
| 359 | |
| 360 base::DictionaryValue* SyncedNotificationToValue( | |
| 361 const sync_pb::SyncedNotification& proto) { | |
| 362 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 363 SET_STR(type); | |
| 364 SET_STR(external_id); | |
| 365 // TODO(petewil) Add SyncedNotificationCreator here if we ever need it. | |
| 366 return value; | |
| 367 } | |
| 368 | |
| 369 base::DictionaryValue* RenderInfoToValue( | |
| 370 const sync_pb::SyncedNotificationRenderInfo& proto) { | |
| 371 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 372 // TODO(petewil): Add the expanded info values once we start using them. | |
| 373 SET(collapsed_info, CollapsedInfoToValue); | |
| 374 return value; | |
| 375 } | |
| 376 | |
| 377 base::DictionaryValue* CoalescedNotificationToValue( | |
| 378 const sync_pb::CoalescedSyncedNotification& proto) { | |
| 379 base::DictionaryValue* value = new base::DictionaryValue(); | |
| 380 SET_STR(key); | |
| 381 SET_STR(app_id); | |
| 382 SET_REP(notification, SyncedNotificationToValue); | |
| 383 SET(render_info, RenderInfoToValue); | |
| 384 SET_INT32(read_state); | |
| 385 SET_INT64(creation_time_msec); | |
| 386 SET_INT32(priority); | |
| 387 return value; | |
| 388 } | |
| 389 | |
| 390 base::DictionaryValue* AppListSpecificsToValue( | 267 base::DictionaryValue* AppListSpecificsToValue( |
| 391 const sync_pb::AppListSpecifics& proto) { | 268 const sync_pb::AppListSpecifics& proto) { |
| 392 base::DictionaryValue* value = new base::DictionaryValue(); | 269 base::DictionaryValue* value = new base::DictionaryValue(); |
| 393 SET_STR(item_id); | 270 SET_STR(item_id); |
| 394 SET_ENUM(item_type, GetAppListItemTypeString); | 271 SET_ENUM(item_type, GetAppListItemTypeString); |
| 395 SET_STR(item_name); | 272 SET_STR(item_name); |
| 396 SET_STR(parent_id); | 273 SET_STR(parent_id); |
| 397 SET_STR(item_ordinal); | 274 SET_STR(item_ordinal); |
| 398 | 275 |
| 399 return value; | 276 return value; |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 base::DictionaryValue* PriorityPreferenceSpecificsToValue( | 578 base::DictionaryValue* PriorityPreferenceSpecificsToValue( |
| 702 const sync_pb::PriorityPreferenceSpecifics& specifics) { | 579 const sync_pb::PriorityPreferenceSpecifics& specifics) { |
| 703 base::DictionaryValue* value = new base::DictionaryValue(); | 580 base::DictionaryValue* value = new base::DictionaryValue(); |
| 704 SET_FIELD(preference, PreferenceSpecificsToValue); | 581 SET_FIELD(preference, PreferenceSpecificsToValue); |
| 705 return value; | 582 return value; |
| 706 } | 583 } |
| 707 | 584 |
| 708 base::DictionaryValue* SyncedNotificationAppInfoSpecificsToValue( | 585 base::DictionaryValue* SyncedNotificationAppInfoSpecificsToValue( |
| 709 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { | 586 const sync_pb::SyncedNotificationAppInfoSpecifics& proto) { |
| 710 base::DictionaryValue* value = new base::DictionaryValue(); | 587 base::DictionaryValue* value = new base::DictionaryValue(); |
| 711 SET_REP(synced_notification_app_info, SyncedNotificationAppInfoToValue); | |
| 712 return value; | 588 return value; |
| 713 } | 589 } |
| 714 | 590 |
| 715 base::DictionaryValue* SyncedNotificationSpecificsToValue( | 591 base::DictionaryValue* SyncedNotificationSpecificsToValue( |
| 716 const sync_pb::SyncedNotificationSpecifics& proto) { | 592 const sync_pb::SyncedNotificationSpecifics& proto) { |
| 717 // There is a lot of data, for now just use heading, description, key, and | |
| 718 // the read state. | |
| 719 // TODO(petewil): Eventually add more data here. | |
| 720 base::DictionaryValue* value = new base::DictionaryValue(); | 593 base::DictionaryValue* value = new base::DictionaryValue(); |
| 721 SET(coalesced_notification, CoalescedNotificationToValue); | |
| 722 return value; | 594 return value; |
| 723 } | 595 } |
| 724 | 596 |
| 725 base::DictionaryValue* SearchEngineSpecificsToValue( | 597 base::DictionaryValue* SearchEngineSpecificsToValue( |
| 726 const sync_pb::SearchEngineSpecifics& proto) { | 598 const sync_pb::SearchEngineSpecifics& proto) { |
| 727 base::DictionaryValue* value = new base::DictionaryValue(); | 599 base::DictionaryValue* value = new base::DictionaryValue(); |
| 728 SET_STR(short_name); | 600 SET_STR(short_name); |
| 729 SET_STR(keyword); | 601 SET_STR(keyword); |
| 730 SET_STR(favicon_url); | 602 SET_STR(favicon_url); |
| 731 SET_STR(url); | 603 SET_STR(url); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 #undef SET_BYTES | 1006 #undef SET_BYTES |
| 1135 #undef SET_INT32 | 1007 #undef SET_INT32 |
| 1136 #undef SET_INT64 | 1008 #undef SET_INT64 |
| 1137 #undef SET_INT64_REP | 1009 #undef SET_INT64_REP |
| 1138 #undef SET_STR | 1010 #undef SET_STR |
| 1139 #undef SET_STR_REP | 1011 #undef SET_STR_REP |
| 1140 | 1012 |
| 1141 #undef SET_FIELD | 1013 #undef SET_FIELD |
| 1142 | 1014 |
| 1143 } // namespace syncer | 1015 } // namespace syncer |
| OLD | NEW |