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

Unified Diff: chrome/browser/notifications/sync_notifier/synced_notification.cc

Issue 149433005: Adds a small icon to notifications, and connects it to synced notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add testing. Created 6 years, 11 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/sync_notifier/synced_notification.cc
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification.cc b/chrome/browser/notifications/sync_notifier/synced_notification.cc
index 266d198431abdae7c89bcfee88c983c38795f25b..19b937ce3731f90653266eb70e128886d93206b6 100644
--- a/chrome/browser/notifications/sync_notifier/synced_notification.cc
+++ b/chrome/browser/notifications/sync_notifier/synced_notification.cc
@@ -6,6 +6,7 @@
#include "base/basictypes.h"
#include "base/strings/string_util.h"
+#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
@@ -15,9 +16,16 @@
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_delegate.h"
#include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
#include "content/public/browser/browser_thread.h"
+#include "skia/ext/image_operations.h"
#include "sync/protocol/sync.pb.h"
#include "sync/protocol/synced_notification_specifics.pb.h"
+#include "third_party/skia/include/core/SkPaint.h"
+#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image.h"
+#include "ui/gfx/size.h"
+#include "ui/gfx/skbitmap_operations.h"
+#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_util.h"
#include "ui/message_center/notification_types.h"
@@ -326,6 +334,27 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
replace_key,
rich_notification_data,
delegate.get());
+ if (!app_icon_bitmap_.IsEmpty()) {
Pete Williamson 2014/01/30 00:00:21 Nit: It would be nice to move this change to line
dewittj 2014/01/30 00:41:56 Done.
+ // Since we can't control the size of images we download, resize using a
+ // high quality filter down to the appropriate icon size.
+ // TODO(dewittj): Remove this when correct resources are sent via the
+ // protobuf.
+ SkBitmap new_app_icon =
+ skia::ImageOperations::Resize(app_icon_bitmap_.AsBitmap(),
+ skia::ImageOperations::RESIZE_BEST,
+ message_center::kSmallImageSize,
+ message_center::kSmallImageSize);
+
+ // The app icon should be in grayscale.
+ // TODO(dewittj): Remove this when correct resources are sent via the
+ // protobuf.
+ color_utils::HSL shift = {-1, 0, 0.6};
+ SkBitmap grayscale =
+ SkBitmapOperations::CreateHSLShiftedBitmap(new_app_icon, shift);
+ gfx::Image small_image =
+ gfx::Image(gfx::ImageSkia(gfx::ImageSkiaRep(grayscale, 1.0f)));
+ ui_notification.set_small_image(small_image);
+ }
// In case the notification is not supposed to be toasted, pretend that it
// has already been shown.

Powered by Google App Engine
This is Rietveld 408576698