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

Unified Diff: content/child/notifications/pending_notification.cc

Issue 1750083004: Add badge to web notifications. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: content/child/notifications/pending_notification.cc
diff --git a/content/child/notifications/pending_notification.cc b/content/child/notifications/pending_notification.cc
index cc6542e6eeb1f8666bcd03b8e10d862e074400e8..ea8801b9eb6e9148691800fcbfbef9766ab3562a 100644
--- a/content/child/notifications/pending_notification.cc
+++ b/content/child/notifications/pending_notification.cc
@@ -51,13 +51,16 @@ void PendingNotification::FetchResources(
size_t num_actions = notification_data.actions.size();
action_icons_.resize(num_actions);
- size_t num_closures = 1 /* notification icon */ + num_actions;
+ size_t num_closures = 2 /* notification icon and small icon */ + num_actions;
fetches_finished_barrier_closure_ =
base::BarrierClosure(num_closures, fetches_finished_callback);
FetchImageResource(notification_data.icon,
base::Bind(&PendingNotification::DidFetchNotificationIcon,
weak_factory_.GetWeakPtr()));
+ FetchImageResource(notification_data.smallIcon,
+ base::Bind(&PendingNotification::DidFetchSmallIcon,
+ weak_factory_.GetWeakPtr()));
for (size_t i = 0; i < num_actions; i++) {
FetchImageResource(notification_data.actions[i].icon,
base::Bind(&PendingNotification::DidFetchActionIcon,
@@ -68,6 +71,7 @@ void PendingNotification::FetchResources(
NotificationResources PendingNotification::GetResources() const {
NotificationResources resources;
resources.notification_icon = notification_icon_;
+ resources.small_icon = small_icon_;
resources.action_icons = action_icons_;
return resources;
}
@@ -102,6 +106,12 @@ void PendingNotification::DidFetchNotificationIcon(const SkBitmap& icon) {
fetches_finished_barrier_closure_.Run();
}
+void PendingNotification::DidFetchSmallIcon(const SkBitmap& icon) {
+ small_icon_ =
+ ScaleDownIfNeeded(icon, kPlatformNotificationMaxSmallIconSizePx);
+ fetches_finished_barrier_closure_.Run();
+}
+
void PendingNotification::DidFetchActionIcon(size_t action_index,
const SkBitmap& icon) {
DCHECK_LT(action_index, action_icons_.size());

Powered by Google App Engine
This is Rietveld 408576698