| Index: chrome/browser/notifications/message_center_notification_manager.cc
|
| diff --git a/chrome/browser/notifications/message_center_notification_manager.cc b/chrome/browser/notifications/message_center_notification_manager.cc
|
| index d2cc43f32347774ff8952ee70219432f3be48614..0bf2429de02ac469cee1271d47e3f040c8507be0 100644
|
| --- a/chrome/browser/notifications/message_center_notification_manager.cc
|
| +++ b/chrome/browser/notifications/message_center_notification_manager.cc
|
| @@ -27,8 +27,8 @@
|
|
|
| MessageCenterNotificationManager::MessageCenterNotificationManager(
|
| message_center::MessageCenter* message_center)
|
| - : message_center_(message_center),
|
| - settings_controller_(new MessageCenterSettingsController) {
|
| + : message_center_(message_center),
|
| + settings_controller_(new MessageCenterSettingsController) {
|
| message_center_->SetDelegate(this);
|
| message_center_->AddObserver(this);
|
|
|
| @@ -166,12 +166,15 @@ bool MessageCenterNotificationManager::UpdateNotification(
|
| ProfileNotification* new_notification =
|
| new ProfileNotification(profile, notification, message_center_);
|
| profile_notifications_[notification.notification_id()] = new_notification;
|
| +
|
| + // Now pass a copy to message center.
|
| + scoped_ptr<message_center::Notification> message_center_notification(
|
| + make_scoped_ptr(new message_center::Notification(notification)));
|
| + message_center_notification->set_extension_id(
|
| + new_notification->GetExtensionId());
|
| message_center_->UpdateNotification(old_id,
|
| - notification.notification_id(),
|
| - notification.title(),
|
| - notification.body(),
|
| - notification.optional_fields(),
|
| - notification.delegate());
|
| + message_center_notification.Pass());
|
| +
|
| new_notification->StartDownloads();
|
| return true;
|
| }
|
| @@ -291,28 +294,34 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloads(
|
| notification.notification_id()));
|
|
|
| // Notification image.
|
| - StartDownloadByKey(
|
| + StartDownloadWithImage(
|
| notification,
|
| - message_center::kImageUrlKey,
|
| + NULL,
|
| + notification.image_url(),
|
| message_center::kNotificationPreferredImageSize,
|
| base::Bind(&message_center::MessageCenter::SetNotificationImage,
|
| base::Unretained(message_center_),
|
| notification.notification_id()));
|
|
|
| // Notification button icons.
|
| - StartDownloadByKey(
|
| + StartDownloadWithImage(
|
| notification,
|
| - message_center::kButtonOneIconUrlKey,
|
| + NULL,
|
| + notification.button_one_icon_url(),
|
| message_center::kNotificationButtonIconSize,
|
| base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon,
|
| base::Unretained(message_center_),
|
| - notification.notification_id(), 0));
|
| - StartDownloadByKey(
|
| - notification, message_center::kButtonTwoIconUrlKey,
|
| + notification.notification_id(),
|
| + 0));
|
| + StartDownloadWithImage(
|
| + notification,
|
| + NULL,
|
| + notification.button_two_icon_url(),
|
| message_center::kNotificationButtonIconSize,
|
| base::Bind(&message_center::MessageCenter::SetNotificationButtonIcon,
|
| base::Unretained(message_center_),
|
| - notification.notification_id(), 1));
|
| + notification.notification_id(),
|
| + 1));
|
|
|
| // This should tell the observer we're done if everything was synchronous.
|
| PendingDownloadCompleted();
|
| @@ -359,19 +368,6 @@ void MessageCenterNotificationManager::ImageDownloads::StartDownloadWithImage(
|
| callback));
|
| }
|
|
|
| -void MessageCenterNotificationManager::ImageDownloads::StartDownloadByKey(
|
| - const Notification& notification,
|
| - const char* key,
|
| - int size,
|
| - const SetImageCallback& callback) {
|
| - const base::DictionaryValue* optional_fields = notification.optional_fields();
|
| - if (optional_fields && optional_fields->HasKey(key)) {
|
| - string16 url;
|
| - optional_fields->GetString(key, &url);
|
| - StartDownloadWithImage(notification, NULL, GURL(url), size, callback);
|
| - }
|
| -}
|
| -
|
| void MessageCenterNotificationManager::ImageDownloads::DownloadComplete(
|
| const SetImageCallback& callback,
|
| int download_id,
|
| @@ -455,14 +451,13 @@ void MessageCenterNotificationManager::AddProfileNotification(
|
| DCHECK(profile_notifications_.find(id) == profile_notifications_.end());
|
| profile_notifications_[id] = profile_notification;
|
|
|
| - message_center_->AddNotification(notification.type(),
|
| - notification.notification_id(),
|
| - notification.title(),
|
| - notification.body(),
|
| - notification.display_source(),
|
| - profile_notification->GetExtensionId(),
|
| - notification.optional_fields(),
|
| - notification.delegate());
|
| + // Create the copy for message center, and ensure the extension ID is correct.
|
| + scoped_ptr<message_center::Notification> message_center_notification(
|
| + new message_center::Notification(notification));
|
| + message_center_notification->set_extension_id(
|
| + profile_notification->GetExtensionId());
|
| + message_center_->AddNotification(message_center_notification.Pass());
|
| +
|
| profile_notification->StartDownloads();
|
| }
|
|
|
|
|