Index: chrome/browser/notifications/platform_notification_service_impl.cc |
diff --git a/chrome/browser/notifications/platform_notification_service_impl.cc b/chrome/browser/notifications/platform_notification_service_impl.cc |
index 4edd70ba27455560e8dd8e587cb83eec00304c9f..0f42b71afdaeaddd74ae1153f65d1270d38ddd65 100644 |
--- a/chrome/browser/notifications/platform_notification_service_impl.cc |
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc |
@@ -5,6 +5,7 @@ |
#include "chrome/browser/notifications/platform_notification_service_impl.h" |
#include <utility> |
+#include <vector> |
#include "base/command_line.h" |
#include "base/metrics/histogram_macros.h" |
@@ -38,6 +39,7 @@ |
#include "content/public/browser/platform_notification_context.h" |
#include "content/public/browser/storage_partition.h" |
#include "content/public/browser/user_metrics.h" |
+#include "content/public/common/notification_resources.h" |
#include "content/public/common/platform_notification_data.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/resource/resource_bundle.h" |
@@ -338,8 +340,8 @@ PlatformNotificationServiceImpl::CheckPermissionOnIOThread( |
void PlatformNotificationServiceImpl::DisplayNotification( |
BrowserContext* browser_context, |
const GURL& origin, |
- const SkBitmap& icon, |
const content::PlatformNotificationData& notification_data, |
+ const content::NotificationResources& notification_resources, |
scoped_ptr<content::DesktopNotificationDelegate> delegate, |
base::Closure* cancel_callback) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
@@ -347,11 +349,12 @@ void PlatformNotificationServiceImpl::DisplayNotification( |
Profile* profile = Profile::FromBrowserContext(browser_context); |
DCHECK(profile); |
DCHECK_EQ(0u, notification_data.actions.size()); |
+ DCHECK_EQ(0u, notification_resources.action_icons.size()); |
NotificationObjectProxy* proxy = |
new NotificationObjectProxy(browser_context, std::move(delegate)); |
Notification notification = CreateNotificationFromData( |
- profile, origin, icon, notification_data, proxy); |
+ profile, origin, notification_data, notification_resources, proxy); |
GetNotificationUIManager()->Add(notification, profile); |
if (cancel_callback) |
@@ -368,8 +371,8 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
BrowserContext* browser_context, |
int64_t persistent_notification_id, |
const GURL& origin, |
- const SkBitmap& icon, |
- const content::PlatformNotificationData& notification_data) { |
+ const content::PlatformNotificationData& notification_data, |
+ const content::NotificationResources& notification_resources) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
Profile* profile = Profile::FromBrowserContext(browser_context); |
@@ -383,7 +386,7 @@ void PlatformNotificationServiceImpl::DisplayPersistentNotification( |
settings_button_index); |
Notification notification = CreateNotificationFromData( |
- profile, origin, icon, notification_data, delegate); |
+ profile, origin, notification_data, notification_resources, delegate); |
// TODO(peter): Remove this mapping when we have reliable id generation for |
// the message_center::Notification objects. |
@@ -461,16 +464,20 @@ bool PlatformNotificationServiceImpl::GetDisplayedPersistentNotifications( |
Notification PlatformNotificationServiceImpl::CreateNotificationFromData( |
Profile* profile, |
const GURL& origin, |
- const SkBitmap& icon, |
const content::PlatformNotificationData& notification_data, |
+ const content::NotificationResources& notification_resources, |
NotificationDelegate* delegate) const { |
+ DCHECK_EQ(notification_data.actions.size(), |
+ notification_resources.action_icons.size()); |
+ |
// TODO(peter): Icons for Web Notifications are currently always requested for |
// 1x scale, whereas the displays on which they can be displayed can have a |
// different pixel density. Be smarter about this when the API gets updated |
// with a way for developers to specify images of different resolutions. |
Notification notification( |
message_center::NOTIFICATION_TYPE_SIMPLE, notification_data.title, |
- notification_data.body, gfx::Image::CreateFrom1xBitmap(icon), |
+ notification_data.body, |
+ gfx::Image::CreateFrom1xBitmap(notification_resources.notification_icon), |
message_center::NotifierId(origin), base::UTF8ToUTF16(origin.host()), |
origin, notification_data.tag, message_center::RichNotificationData(), |
delegate); |
@@ -480,12 +487,14 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData( |
notification.set_vibration_pattern(notification_data.vibration_pattern); |
notification.set_silent(notification_data.silent); |
+ // Developer supplied action buttons. |
std::vector<message_center::ButtonInfo> buttons; |
- |
- // Developer supplied buttons. |
- for (const auto& action : notification_data.actions) |
- buttons.push_back(message_center::ButtonInfo(action.title)); |
- |
+ for (size_t i = 0; i < notification_data.actions.size(); i++) { |
+ message_center::ButtonInfo button(notification_data.actions[i].title); |
+ button.icon = |
+ gfx::Image::CreateFrom1xBitmap(notification_resources.action_icons[i]); |
+ buttons.push_back(button); |
+ } |
notification.set_buttons(buttons); |
// On desktop, notifications with require_interaction==true stay on-screen |