Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6481)

Unified Diff: chrome/browser/notifications/platform_notification_service_impl.cc

Issue 1681123002: Plumb Notification action icons through to the UI layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ActionIconResourceFetching
Patch Set: Rebase. Appease FindBugs some more. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 360840444c8aef59257ed9cbd9b0bffc65b70a6c..8be2e139396fbb5ebebf88befdb50ede765828e1 100644
--- a/chrome/browser/notifications/platform_notification_service_impl.cc
+++ b/chrome/browser/notifications/platform_notification_service_impl.cc
@@ -339,6 +339,7 @@ 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));
@@ -456,6 +457,9 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
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
@@ -474,12 +478,14 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
notification.set_timestamp(notification_data.timestamp);
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 =
Peter Beverloo 2016/02/10 12:29:37 Please add a reference to the TODO on line 463.
Michael van Ouwerkerk 2016/02/10 17:18:12 I've shortened that bit and added a bug reference.
+ 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

Powered by Google App Engine
This is Rietveld 408576698