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

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: Address peter's comments. 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 4ecaf1512297f9288e2a88288c9605152fe7dada..619bfd3317bfbed2a3e02892fee3e048f3df9cde 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,10 +457,11 @@ Notification PlatformNotificationServiceImpl::CreateNotificationFromData(
const content::PlatformNotificationData& notification_data,
const content::NotificationResources& notification_resources,
NotificationDelegate* delegate) const {
- // 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.
+ DCHECK_EQ(notification_data.actions.size(),
+ notification_resources.action_icons.size());
+
+ // TODO(peter): Handle different screen densities instead of always using the
+ // 1x bitmap - crbug.com/585815.
Notification notification(
message_center::NOTIFICATION_TYPE_SIMPLE, notification_data.title,
notification_data.body,
@@ -474,12 +476,16 @@ 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);
+ // TODO(peter): Handle different screen densities instead of always using
+ // the 1x bitmap - crbug.com/585815.
+ 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

Powered by Google App Engine
This is Rietveld 408576698