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

Unified Diff: ui/message_center/notification.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: ui/message_center/notification.h
diff --git a/ui/message_center/notification.h b/ui/message_center/notification.h
index 5f7ee12a4523e48ca4464f154fe476220176a1af..5e5cd70db5f2cb865666ade048589374a2b2c79f 100644
--- a/ui/message_center/notification.h
+++ b/ui/message_center/notification.h
@@ -32,16 +32,42 @@ struct MESSAGE_CENTER_EXPORT ButtonInfo {
ButtonInfo(const string16& title);
};
+class MESSAGE_CENTER_EXPORT RichNotificationData {
+ public:
+ RichNotificationData();
+ RichNotificationData(const RichNotificationData& other);
+ ~RichNotificationData();
+
+ int priority;
+ bool never_timeout;
+ base::Time timestamp;
+ string16 expanded_message;
+ gfx::Image icon;
Jun Mukai 2013/05/31 17:08:10 Almost all notifications have icons, especially we
dewittj 2013/05/31 22:13:56 Not sure what you mean. Do you mean take out icon
+ gfx::Image image;
+ std::vector<NotificationItem> items;
+ std::vector<ButtonInfo> buttons;
+};
+
class MESSAGE_CENTER_EXPORT Notification {
public:
Notification(NotificationType type,
const std::string& id,
const string16& title,
const string16& message,
+ const gfx::Image& icon,
const string16& display_source,
const std::string& extension_id,
const DictionaryValue* optional_fields, // May be NULL.
NotificationDelegate* delegate); // May be NULL.
+
+ Notification(NotificationType type,
+ const std::string& id,
+ const string16& title,
+ const string16& message,
+ const string16& display_source,
+ const std::string& extension_id,
+ const RichNotificationData& optional_fields,
+ NotificationDelegate* delegate);
virtual ~Notification();
// Copies the internal on-memory state from |base|, i.e. shown_as_popup,
@@ -56,22 +82,28 @@ class MESSAGE_CENTER_EXPORT Notification {
const std::string& extension_id() const { return extension_id_; }
// Begin unpacked values from optional_fields.
- int priority() const { return priority_; }
- base::Time timestamp() const { return timestamp_; }
- const string16& expanded_message() const { return expanded_message_; }
- const std::vector<NotificationItem>& items() const { return items_; }
+ int priority() const { return optional_fields_.priority; }
+ base::Time timestamp() const { return optional_fields_.timestamp; }
+ const string16& expanded_message() const {
+ return optional_fields_.expanded_message;
+ }
+ const std::vector<NotificationItem>& items() const {
+ return optional_fields_.items;
+ }
// End unpacked values.
// Images fetched asynchronously.
- const gfx::Image& icon() const { return icon_; }
- void set_icon(const gfx::Image& icon) { icon_ = icon; }
+ const gfx::Image& icon() const { return optional_fields_.icon; }
+ void set_icon(const gfx::Image& icon) { optional_fields_.icon = icon; }
- const gfx::Image& image() const { return image_; }
- void set_image(const gfx::Image& image) { image_ = image; }
+ const gfx::Image& image() const { return optional_fields_.image; }
+ void set_image(const gfx::Image& image) { optional_fields_.image = image; }
// Buttons, with icons fetched asynchronously.
- const std::vector<ButtonInfo>& buttons() const { return buttons_; }
- bool SetButtonIcon(size_t index, const gfx::Image& icon);
+ const std::vector<ButtonInfo>& buttons() const {
+ return optional_fields_.buttons;
+ }
+ void SetButtonIcon(size_t index, const gfx::Image& icon);
bool shown_as_popup() const { return shown_as_popup_; }
void set_shown_as_popup(bool shown_as_popup) {
@@ -90,8 +122,9 @@ class MESSAGE_CENTER_EXPORT Notification {
// The notification with lesser serial_number is considered 'older'.
unsigned serial_number() { return serial_number_; }
- bool never_timeout() const { return never_timeout_; }
+ bool never_timeout() const { return optional_fields_.never_timeout; }
NotificationDelegate* delegate() { return delegate_.get(); }
+ const RichNotificationData& optional_fields() { return optional_fields_; }
private:
// Unpacks the provided |optional_fields| and applies the values to override
@@ -104,18 +137,11 @@ class MESSAGE_CENTER_EXPORT Notification {
string16 message_;
string16 display_source_;
std::string extension_id_;
- int priority_;
- base::Time timestamp_;
unsigned serial_number_;
- string16 expanded_message_;
- std::vector<NotificationItem> items_;
- gfx::Image icon_;
- gfx::Image image_;
- std::vector<ButtonInfo> buttons_;
+ RichNotificationData optional_fields_;
bool shown_as_popup_; // True if this has been shown as a popup.
bool is_read_; // True if this has been seen in the message center.
bool is_expanded_; // True if this has been expanded in the message center.
- bool never_timeout_; // True if it doesn't timeout when it appears as a toast.
// A proxy object that allows access back to the JavaScript object that
// represents the notification, for firing events.

Powered by Google App Engine
This is Rietveld 408576698