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

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: Address nits 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..99a6f2aea1b48479c028db6373ee7fcea73e4346 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"
@@ -304,6 +312,28 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
if (!image_bitmap_.IsEmpty())
rich_notification_data.image = image_bitmap_;
+ if (!app_icon_bitmap_.IsEmpty()) {
+ // 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)));
+ rich_notification_data.small_image = small_image;
+ }
+
// Set the ContextMessage inside the rich notification data for the
// annotation.
rich_notification_data.context_message = annotation;
@@ -326,7 +356,6 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
replace_key,
rich_notification_data,
delegate.get());
-
// In case the notification is not supposed to be toasted, pretend that it
// has already been shown.
ui_notification.set_shown_as_popup(!toast_state_);

Powered by Google App Engine
This is Rietveld 408576698