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

Unified Diff: chrome/browser/notifications/message_center_notification_manager.h

Issue 14631005: Enable users of NotificationUIManager to specify binary images. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove fake image from synced notification, stop checking icon_url in unit test. Created 7 years, 7 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/message_center_notification_manager.h
diff --git a/chrome/browser/notifications/message_center_notification_manager.h b/chrome/browser/notifications/message_center_notification_manager.h
index 0d081898b526af62ece11548cf2ddb15cac7ad48..97ec91fb3346485bedf7b14fe53cf3bf5c7f2e45 100644
--- a/chrome/browser/notifications/message_center_notification_manager.h
+++ b/chrome/browser/notifications/message_center_notification_manager.h
@@ -68,21 +68,20 @@ class MessageCenterNotificationManager
class ImageDownloads
: public base::SupportsWeakPtr<ImageDownloads> {
public:
- ImageDownloads(
- message_center::MessageCenter* message_center,
- ImageDownloadsObserver* observer);
+ ImageDownloads(message_center::Notification* notification,
+ ImageDownloadsObserver* observer);
virtual ~ImageDownloads();
void StartDownloads(const Notification& notification);
- void StartDownloadWithImage(const Notification& notification,
- const gfx::Image* image,
- const GURL& url,
- int size,
- const SetImageCallback& callback);
- void StartDownloadByKey(const Notification& notification,
+ void StartDownloadByKey(content::RenderViewHost* host,
+ const base::DictionaryValue* optional_fields,
const char* key,
int size,
const SetImageCallback& callback);
+ void StartDownloadByURL(content::RenderViewHost* host,
+ const GURL& url,
+ int size,
+ const SetImageCallback& callback);
// FaviconHelper callback.
void DownloadComplete(const SetImageCallback& callback,
@@ -91,6 +90,11 @@ class MessageCenterNotificationManager
const GURL& image_url,
int requested_size,
const std::vector<SkBitmap>& bitmaps);
+
+ void SetIcon(const gfx::Image& icon);
+ void SetImage(const gfx::Image& image);
+ void SetButtonIcon(size_t button_number, const gfx::Image& image);
+
private:
// Used to keep track of the number of pending downloads. Once this
// reaches zero, we can tell the delegate that we don't need the
@@ -98,8 +102,9 @@ class MessageCenterNotificationManager
void AddPendingDownload();
void PendingDownloadCompleted();
- // Weak reference to global message center.
- message_center::MessageCenter* message_center_;
+ // Weak, lifetime is that of the ProfileNotification.
+ // Notification model that is being filled out with image data.
+ message_center::Notification* message_center_notification_;
// Count of downloads that remain.
size_t pending_downloads_;
@@ -124,9 +129,15 @@ class MessageCenterNotificationManager
// into a single class.
class ProfileNotification : public ImageDownloadsObserver {
public:
+ // Use for new notifications.
ProfileNotification(Profile* profile,
const Notification& notification,
message_center::MessageCenter* message_center);
+ // Use to update notifications.
+ ProfileNotification(Profile* profile,
+ const Notification& notification,
+ message_center::MessageCenter* message_center,
+ const std::string& updated_id);
virtual ~ProfileNotification();
void StartDownloads();
@@ -142,9 +153,20 @@ class MessageCenterNotificationManager
std::string GetExtensionId();
private:
+ // Initializes message center notification and starts downloads.
+ void Init();
// Weak, guaranteed not to be used after profile removal by parent class.
Profile* profile_;
Notification notification_;
+ // Weak, global lifetime.
+ message_center::MessageCenter* message_center_;
+ // Temporary data structure that holds the bits that have been downloaded
+ // until they can be passed to the message center.
+ scoped_ptr<message_center::Notification> message_center_notification_;
+ // Whether to update message center or to add to it.
+ bool update_;
+ // Which id to update.
+ std::string updated_id_;
// Track the downloads for this notification so the notification can be
// updated properly.
scoped_ptr<ImageDownloads> downloads_;

Powered by Google App Engine
This is Rietveld 408576698