summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpetewil@chromium.org <petewil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 21:23:44 +0000
committerpetewil@chromium.org <petewil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-07 21:23:44 +0000
commit9c34c413c27316bf196bf3d430b99722ea21755a (patch)
tree1beb63f6da0d667fbaa687845aed62c1f3503ab3
parentabfd149a77db75e1be6543c70b77882dcbc300f4 (diff)
downloadchromium_src-9c34c413c27316bf196bf3d430b99722ea21755a.zip
chromium_src-9c34c413c27316bf196bf3d430b99722ea21755a.tar.gz
chromium_src-9c34c413c27316bf196bf3d430b99722ea21755a.tar.bz2
Synced Notifications - Send bitmaps to rich notifications
Now that a new interface is available on the notification object, use it to send the bitmaps we have fetched and decoded from the web to rich notifications. BUG=247538 Review URL: https://chromiumcodereview.appspot.com/15789016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@204932 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/notifications/sync_notifier/synced_notification.cc27
-rw-r--r--chrome/browser/notifications/sync_notifier/synced_notification.h2
-rw-r--r--chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc9
3 files changed, 19 insertions, 19 deletions
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification.cc b/chrome/browser/notifications/sync_notifier/synced_notification.cc
index deafcea..015eb1d 100644
--- a/chrome/browser/notifications/sync_notifier/synced_notification.cc
+++ b/chrome/browser/notifications/sync_notifier/synced_notification.cc
@@ -44,10 +44,10 @@ COMPILE_ASSERT(static_cast<sync_pb::CoalescedSyncedNotification_ReadState>(
local_enum_must_match_protobuf_enum);
SyncedNotification::SyncedNotification(const syncer::SyncData& sync_data)
- : notification_manager_(NULL),
- notifier_service_(NULL),
- profile_(NULL),
- active_fetcher_count_(0) {
+ : notification_manager_(NULL),
+ notifier_service_(NULL),
+ profile_(NULL),
+ active_fetcher_count_(0) {
Update(sync_data);
}
@@ -208,15 +208,21 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
rich_notification_data.priority = priority;
if (!button_one_title.empty()) {
message_center::ButtonInfo button_info(UTF8ToUTF16(button_one_title));
+ if (!button_one_bitmap_.IsEmpty())
+ button_info.icon = button_one_bitmap_;
rich_notification_data.buttons.push_back(button_info);
- // TODO(petewil): Add a button icon here.
}
if (!button_two_title.empty()) {
message_center::ButtonInfo button_info(UTF8ToUTF16(button_two_title));
+ if (!button_two_bitmap_.IsEmpty())
+ button_info.icon = button_two_bitmap_;
rich_notification_data.buttons.push_back(button_info);
- // TODO(petewil): Add a button icon here.
}
+ // Fill in the bitmap images.
+ if (!image_bitmap_.IsEmpty())
+ rich_notification_data.image = image_bitmap_;
+
// Fill the individual notification fields for a multiple notification.
if (notification_count > 1) {
for (int ii = 0; ii < notification_count; ++ii) {
@@ -227,14 +233,11 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
}
}
- // TODO(petewil): Add code here that sets the various notification images
- // that have been decoded. Also, don't use the notification tray icon once
- // this is enabled, that could cause user confusion.
Notification ui_notification(notification_type,
GetOriginUrl(),
heading,
text,
- gfx::Image(),
+ app_icon_bitmap_,
WebKit::WebTextDirectionDefault,
display_source,
replace_key,
@@ -262,8 +265,8 @@ void SyncedNotification::Show(NotificationUIManager* notification_manager,
return;
}
-// TODO(petewil): Consider the timestamp too once it gets added to the protobuf.
-// TODO: add more fields in here
+// TODO(petewil): Decide what we need for equals - is this enough, or should
+// we exhaustively compare every field in case the server refreshed the notif?
bool SyncedNotification::EqualsIgnoringReadState(
const SyncedNotification& other) const {
return (GetTitle() == other.GetTitle() &&
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification.h b/chrome/browser/notifications/sync_notifier/synced_notification.h
index 50868f8..70c15c2 100644
--- a/chrome/browser/notifications/sync_notifier/synced_notification.h
+++ b/chrome/browser/notifications/sync_notifier/synced_notification.h
@@ -121,7 +121,7 @@ class SyncedNotification : public NotificationBitmapFetcherDelegate {
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, AddBitmapToFetchQueueTest);
FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, OnFetchCompleteTest);
- FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapsTest);
+ FRIEND_TEST_ALL_PREFIXES(SyncedNotificationTest, QueueBitmapFetchJobsTest);
DISALLOW_COPY_AND_ASSIGN(SyncedNotification);
};
diff --git a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc
index 7e78ff0..3dc4fa6 100644
--- a/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc
+++ b/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc
@@ -150,7 +150,7 @@ class StubNotificationUIManager : public NotificationUIManager {
class SyncedNotificationTest : public testing::Test {
public:
SyncedNotificationTest()
- : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
+ : ui_thread_(content::BrowserThread::UI, &message_loop_) {}
virtual ~SyncedNotificationTest() {}
// Methods from testing::Test.
@@ -635,7 +635,6 @@ TEST_F(SyncedNotificationTest, AddBitmapToFetchQueueTest) {
}
TEST_F(SyncedNotificationTest, OnFetchCompleteTest) {
-
if (!UseRichNotifications())
return;
@@ -655,8 +654,7 @@ TEST_F(SyncedNotificationTest, OnFetchCompleteTest) {
// Put a real bitmap into "bitmap". 2x2 bitmap of green 32 bit pixels.
bitmap.setConfig(SkBitmap::kARGB_8888_Config, 2, 2);
bitmap.allocPixels();
- SkColor c = SK_ColorGREEN;
- bitmap.eraseColor(c);
+ bitmap.eraseColor(SK_ColorGREEN);
notification1_->OnFetchComplete(GURL(kIconUrl1), &bitmap);
EXPECT_EQ(1, notification1_->active_fetcher_count_);
@@ -679,8 +677,7 @@ TEST_F(SyncedNotificationTest, OnFetchCompleteTest) {
// image, notification1_->GetAppIconBitmap()));
}
-TEST_F(SyncedNotificationTest, QueueBitmapsTest) {
-
+TEST_F(SyncedNotificationTest, QueueBitmapFetchJobsTest) {
if (!UseRichNotifications())
return;