| 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 #include "chrome/browser/extensions/app_notification_manager.h" | 5 #include "chrome/browser/extensions/app_notification_manager.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 specifics.mutable_app_notification(); | 556 specifics.mutable_app_notification(); |
| 557 notif_specifics->set_app_id(notification.extension_id()); | 557 notif_specifics->set_app_id(notification.extension_id()); |
| 558 notif_specifics->set_creation_timestamp_ms( | 558 notif_specifics->set_creation_timestamp_ms( |
| 559 notification.creation_time().ToInternalValue()); | 559 notification.creation_time().ToInternalValue()); |
| 560 notif_specifics->set_body_text(notification.body()); | 560 notif_specifics->set_body_text(notification.body()); |
| 561 notif_specifics->set_guid(notification.guid()); | 561 notif_specifics->set_guid(notification.guid()); |
| 562 notif_specifics->set_link_text(notification.link_text()); | 562 notif_specifics->set_link_text(notification.link_text()); |
| 563 notif_specifics->set_link_url(notification.link_url().spec()); | 563 notif_specifics->set_link_url(notification.link_url().spec()); |
| 564 notif_specifics->set_title(notification.title()); | 564 notif_specifics->set_title(notification.title()); |
| 565 return syncer::SyncData::CreateLocalData( | 565 return syncer::SyncData::CreateLocalData( |
| 566 notif_specifics->guid(), notif_specifics->app_id(), specifics); | 566 notif_specifics->guid(), notif_specifics->app_id(), specifics, false); |
| 567 } | 567 } |
| 568 | 568 |
| 569 // static | 569 // static |
| 570 AppNotification* AppNotificationManager::CreateNotificationFromSyncData( | 570 AppNotification* AppNotificationManager::CreateNotificationFromSyncData( |
| 571 const syncer::SyncData& sync_data) { | 571 const syncer::SyncData& sync_data) { |
| 572 sync_pb::AppNotification specifics = | 572 sync_pb::AppNotification specifics = |
| 573 sync_data.GetSpecifics().app_notification(); | 573 sync_data.GetSpecifics().app_notification(); |
| 574 | 574 |
| 575 // Check for mandatory fields. | 575 // Check for mandatory fields. |
| 576 if (!specifics.has_app_id() || !specifics.has_guid() || | 576 if (!specifics.has_app_id() || !specifics.has_guid() || |
| 577 !specifics.has_title() || !specifics.has_body_text() || | 577 !specifics.has_title() || !specifics.has_body_text() || |
| 578 !specifics.has_creation_timestamp_ms()) { | 578 !specifics.has_creation_timestamp_ms()) { |
| 579 return NULL; | 579 return NULL; |
| 580 } | 580 } |
| 581 | 581 |
| 582 AppNotification* notification = new AppNotification( | 582 AppNotification* notification = new AppNotification( |
| 583 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()), | 583 false, base::Time::FromInternalValue(specifics.creation_timestamp_ms()), |
| 584 specifics.guid(), specifics.app_id(), | 584 specifics.guid(), specifics.app_id(), |
| 585 specifics.title(), specifics.body_text()); | 585 specifics.title(), specifics.body_text()); |
| 586 if (specifics.has_link_text()) | 586 if (specifics.has_link_text()) |
| 587 notification->set_link_text(specifics.link_text()); | 587 notification->set_link_text(specifics.link_text()); |
| 588 if (specifics.has_link_url()) | 588 if (specifics.has_link_url()) |
| 589 notification->set_link_url(GURL(specifics.link_url())); | 589 notification->set_link_url(GURL(specifics.link_url())); |
| 590 return notification; | 590 return notification; |
| 591 } | 591 } |
| 592 | 592 |
| 593 } // namespace extensions | 593 } // namespace extensions |
| OLD | NEW |