diff options
author | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-16 20:30:54 +0000 |
---|---|---|
committer | rsleevi@chromium.org <rsleevi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-16 20:30:54 +0000 |
commit | 261e4fbd2962bf913dfa938386ec29090b53fcbd (patch) | |
tree | b14726f207217e4217919cd05dc9ecdbdee96de5 /ui | |
parent | c610fbf5402c3414dc76949a88c6118318d4ca3a (diff) | |
download | chromium_src-261e4fbd2962bf913dfa938386ec29090b53fcbd.zip chromium_src-261e4fbd2962bf913dfa938386ec29090b53fcbd.tar.gz chromium_src-261e4fbd2962bf913dfa938386ec29090b53fcbd.tar.bz2 |
Revert 173387 - Broke compile on clang bots
Added support for secondary icon to multi-item notification view
TBR=derat@chromium.org for c/b/ui/views/ash/balloon_view_ash.*
BUG=161101
Review URL: https://chromiumcodereview.appspot.com/11474003
TBR=dharcourt@chromium.org
Review URL: https://codereview.chromium.org/11593003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173388 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message_center/base_format_view.cc | 4 | ||||
-rw-r--r-- | ui/message_center/message_center.cc | 14 | ||||
-rw-r--r-- | ui/message_center/message_center.h | 20 | ||||
-rw-r--r-- | ui/message_center/message_simple_view.cc | 2 | ||||
-rw-r--r-- | ui/message_center/message_view_multiple.cc | 42 | ||||
-rw-r--r-- | ui/message_center/message_view_multiple.h | 2 | ||||
-rw-r--r-- | ui/message_center/notification_list.cc | 23 | ||||
-rw-r--r-- | ui/message_center/notification_list.h | 15 | ||||
-rw-r--r-- | ui/notifications/notification_types.cc | 12 |
9 files changed, 52 insertions, 82 deletions
diff --git a/ui/message_center/base_format_view.cc b/ui/message_center/base_format_view.cc index 7bce22c..aff72a1 100644 --- a/ui/message_center/base_format_view.cc +++ b/ui/message_center/base_format_view.cc @@ -46,13 +46,13 @@ void BaseFormatView::SetUpView() { views::ImageView* icon = new views::ImageView; icon->SetImageSize( gfx::Size(kBaseFormatPrimaryIconWidth, kBaseFormatPrimaryIconWidth)); - icon->SetImage(notification_.primary_icon); + icon->SetImage(notification_.image); views::ImageView* second_icon = new views::ImageView; second_icon->SetImageSize( gfx::Size(kBaseFormatSecondaryIconWidth, kBaseFormatSecondaryIconWidth)); // TODO: set up second image - second_icon->SetImage(notification_.primary_icon); + second_icon->SetImage(notification_.image); views::Label* title = new views::Label(notification_.title); title->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/ui/message_center/message_center.cc b/ui/message_center/message_center.cc index a5460ee..cb14bed 100644 --- a/ui/message_center/message_center.cc +++ b/ui/message_center/message_center.cc @@ -77,15 +77,11 @@ void MessageCenter::RemoveNotification(const std::string& id) { host_->MessageCenterChanged(false); } -void MessageCenter::SetNotificationPrimaryIcon(const std::string& id, - const gfx::ImageSkia& image) { - if (notification_list_->SetNotificationPrimaryIcon(id, image) && host_) - host_->MessageCenterChanged(true); -} - -void MessageCenter::SetNotificationSecondaryIcon(const std::string& id, - const gfx::ImageSkia& image) { - if (notification_list_->SetNotificationSecondaryIcon(id, image) && host_) +void MessageCenter::SetNotificationImage(const std::string& id, + const gfx::ImageSkia& image) { + if (!notification_list_->SetNotificationImage(id, image)) + return; + if (host_) host_->MessageCenterChanged(true); } diff --git a/ui/message_center/message_center.h b/ui/message_center/message_center.h index 6aa5f96..bde7767 100644 --- a/ui/message_center/message_center.h +++ b/ui/message_center/message_center.h @@ -89,12 +89,12 @@ class MESSAGE_CENTER_EXPORT MessageCenter : public NotificationList::Delegate { // Adds a new notification. |id| is a unique identifier, used to update or // remove notifications. |title| and |meesage| describe the notification text. - // Use SetNotificationPrimaryIcon and SetNotificationSecondaryIcon to set - // images. If |extension_id| is provided then 'Disable extension' will appear - // in a dropdown menu and the id will be used to disable notifications from - // the extension. Otherwise if |display_source| is provided, a menu item - // showing the source and allowing notifications from that source to be - // disabled will be shown. All actual disabling is handled by the Delegate. + // Use SetNotificationImage to set the icon image. If |extension_id| is + // provided then 'Disable extension' will appear in a dropdown menu and the + // id will be used to disable notifications from the extension. Otherwise if + // |display_source| is provided, a menu item showing the source and allowing + // notifications from that source to be disabled will be shown. All actual + // disabling is handled by the Delegate. void AddNotification(ui::notifications::NotificationType type, const std::string& id, const string16& title, @@ -114,11 +114,9 @@ class MESSAGE_CENTER_EXPORT MessageCenter : public NotificationList::Delegate { // Removes an existing notification. void RemoveNotification(const std::string& id); - void SetNotificationPrimaryIcon(const std::string& id, - const gfx::ImageSkia& image); - - void SetNotificationSecondaryIcon(const std::string& id, - const gfx::ImageSkia& image); + // Sets the notification image. + void SetNotificationImage(const std::string& id, + const gfx::ImageSkia& image); NotificationList* notification_list() { return notification_list_.get(); } diff --git a/ui/message_center/message_simple_view.cc b/ui/message_center/message_simple_view.cc index fb3e9e0..0ac9363 100644 --- a/ui/message_center/message_simple_view.cc +++ b/ui/message_center/message_simple_view.cc @@ -34,7 +34,7 @@ void MessageSimpleView::SetUpView() { views::ImageView* icon = new views::ImageView; icon->SetImageSize( gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); - icon->SetImage(notification_.primary_icon); + icon->SetImage(notification_.image); views::Label* title = new views::Label(notification_.title); title->SetHorizontalAlignment(gfx::ALIGN_LEFT); diff --git a/ui/message_center/message_view_multiple.cc b/ui/message_center/message_view_multiple.cc index c6cfc1f..65c3c2b 100644 --- a/ui/message_center/message_view_multiple.cc +++ b/ui/message_center/message_view_multiple.cc @@ -20,10 +20,9 @@ namespace { // Notification dimensions. -const int kNotificationPrimaryIconSize = 64; -const int kNotificationSecondaryIconSize = 15; +const int kNotificationIconSize = 64; const int kNotificationPadding1Width = 12; -const int kNotificationColumn1Width = kNotificationPrimaryIconSize; +const int kNotificationColumn1Width = kNotificationIconSize; const int kNotificationPadding2Width = 12; const int kNotificationPadding3Width = 12; const int kNotificationColumn3Width = 26; @@ -218,15 +217,14 @@ void MessageViewMultiple::SetUpView() { kNotificationPadding4Width + kNotificationColumn4Width); columns->AddPaddingColumn(0, kNotificationPadding5Width); - // First row: Primary icon. + // First row: Icon. layout->StartRow(0, 0); - views::ImageView* primary_icon = new views::ImageView; - primary_icon->SetImageSize(gfx::Size(kNotificationPrimaryIconSize, - kNotificationPrimaryIconSize)); - primary_icon->SetImage(notification_.primary_icon); - primary_icon->set_border(CreateTopBorder(kNotificationColumn1Top)); - primary_icon->SetVerticalAlignment(views::ImageView::LEADING); - layout->AddView(primary_icon, 1, 3 + 2 * notification_.items.size()); + views::ImageView* icon = new views::ImageView; + icon->SetImageSize(gfx::Size(kNotificationIconSize, kNotificationIconSize)); + icon->SetImage(notification_.image); + icon->set_border(CreateTopBorder(kNotificationColumn1Top)); + icon->SetVerticalAlignment(views::ImageView::LEADING); + layout->AddView(icon, 1, 3 + 2 * notification_.items.size()); // First row: Title. // TODO(dharcourt): Skip the title Label when there's no title text. @@ -259,7 +257,7 @@ void MessageViewMultiple::SetUpView() { DCHECK(close_button_); layout->AddView(close_button_); - // Rows for each notification item, including appropriate padding. + // Two rows for each notification item, including appropriate padding. layout->AddPaddingRow(0, 3); std::vector<NotificationList::NotificationItem>::const_iterator i; for (i = notification_.items.begin(); i != notification_.items.end(); ++i) { @@ -269,33 +267,23 @@ void MessageViewMultiple::SetUpView() { layout->SkipColumns(2); } - // Rows for horizontal separator line with appropriate padding. + // Two rows for padding and a horizontal separator line. layout->StartRowWithPadding(0, 0, 0, 6); layout->SkipColumns(1); layout->AddView(new BoxView(1000000, 1, kNotificationSeparatorColor), 4, 1); - // Last row: Summary message with padding. + // Two rows for padding and the summary message and small icon. // TODO(dharcourt): Skip the message Label when there's no message text. - layout->StartRowWithPadding(0, 0, 0, 5); + // TODO(dharcourt): Add a small icon to the right of the summary message. + layout->StartRowWithPadding(0, 0, 0, 6); layout->SkipColumns(2); views::Label* message = new views::Label(notification_.message); message->SetHorizontalAlignment(gfx::ALIGN_LEFT); message->SetMultiLine(true); message->SetEnabledColor(kNotificationMessageColor); message->SetBackgroundColor(kNotificationMessageBackgroundColor); - message->set_border(CreateTopBorder(1)); layout->AddView(message); - - // Last row: Secondary icon. - layout->SkipColumns(1); - views::ImageView* secondary_icon = new views::ImageView; - secondary_icon->SetImageSize(gfx::Size(kNotificationSecondaryIconSize, - kNotificationSecondaryIconSize)); - secondary_icon->SetImage(notification_.secondary_icon.isNull() ? - notification_.primary_icon : - notification_.secondary_icon); - secondary_icon->SetVerticalAlignment(views::ImageView::LEADING); - layout->AddView(secondary_icon); + layout->SkipColumns(2); // Final row with the bottom padding. layout->AddPaddingRow(0, kNotificationPaddingBottom); diff --git a/ui/message_center/message_view_multiple.h b/ui/message_center/message_view_multiple.h index 426ea8d..c553be5 100644 --- a/ui/message_center/message_view_multiple.h +++ b/ui/message_center/message_view_multiple.h @@ -10,7 +10,7 @@ namespace message_center { -// View that displays multiple-item notifications. +// An early version of the multiple message notification view. // // TODO(dharcourt): Rename MessageCenter and MessageView* to NotificationCenter // and NotificationView*? diff --git a/ui/message_center/notification_list.cc b/ui/message_center/notification_list.cc index fd90a84..3bd0302 100644 --- a/ui/message_center/notification_list.cc +++ b/ui/message_center/notification_list.cc @@ -89,6 +89,10 @@ void NotificationList::UnpackOptionalFields( optional_fields->GetString(ui::notifications::kTimestampKey, &time_string); base::Time::FromString(time_string.c_str(), ¬ification->timestamp); } + // TODO + // if (optional_fields->HasKey(ui::notifications::kSecondIconUrlKey)) + // optional_fields->GetString(ui::notifications::kSecondIconUrlKey, + // ¬ification->second_icon_url); if (optional_fields->HasKey(ui::notifications::kUnreadCountKey)) optional_fields->GetInteger(ui::notifications::kUnreadCountKey, ¬ification->unread_count); @@ -101,6 +105,9 @@ void NotificationList::UnpackOptionalFields( if (optional_fields->HasKey(ui::notifications::kExpandedMessageKey)) optional_fields->GetString(ui::notifications::kExpandedMessageKey, ¬ification->expanded_message); + if (optional_fields->HasKey(ui::notifications::kImageUrlKey)) + optional_fields->GetString(ui::notifications::kImageUrlKey, + ¬ification->image_url); if (optional_fields->HasKey(ui::notifications::kItemsKey)) { const ListValue* items; CHECK(optional_fields->GetList(ui::notifications::kItemsKey, &items)); @@ -181,22 +188,12 @@ void NotificationList::SendRemoveNotificationsByExtension( } } -bool NotificationList::SetNotificationPrimaryIcon(const std::string& id, - const gfx::ImageSkia& image) { +bool NotificationList::SetNotificationImage(const std::string& id, + const gfx::ImageSkia& image) { Notifications::iterator iter; if (!GetNotification(id, &iter)) return false; - iter->primary_icon = image; - return true; -} - -bool NotificationList::SetNotificationSecondaryIcon( - const std::string& id, - const gfx::ImageSkia& image) { - Notifications::iterator iter; - if (!GetNotification(id, &iter)) - return false; - iter->secondary_icon = image; + iter->image = image; return true; } diff --git a/ui/message_center/notification_list.h b/ui/message_center/notification_list.h index 575f9ce6..ccdd663 100644 --- a/ui/message_center/notification_list.h +++ b/ui/message_center/notification_list.h @@ -47,17 +47,16 @@ class MESSAGE_CENTER_EXPORT NotificationList { // Begin unpacked values from optional_fields int priority; base::Time timestamp; + gfx::ImageSkia second_image; int unread_count; string16 button_one_title; string16 button_two_title; string16 expanded_message; + string16 image_url; std::vector<NotificationItem> items; // End unpacked values - // Images fetched asynchronously - gfx::ImageSkia primary_icon; - gfx::ImageSkia secondary_icon; - + gfx::ImageSkia image; bool is_read; // True if this has been seen in the message center bool shown_as_popup; // True if this has been shown as a popup notification }; @@ -125,12 +124,8 @@ class MESSAGE_CENTER_EXPORT NotificationList { void SendRemoveNotificationsByExtension(const std::string& id); // Returns true if the notification exists and was updated. - bool SetNotificationPrimaryIcon(const std::string& id, - const gfx::ImageSkia& image); - - // Returns true if the notification exists and was updated. - bool SetNotificationSecondaryIcon(const std::string& id, - const gfx::ImageSkia& image); + bool SetNotificationImage(const std::string& id, + const gfx::ImageSkia& image); bool HasNotification(const std::string& id); diff --git a/ui/notifications/notification_types.cc b/ui/notifications/notification_types.cc index 1b720d6..80bcead 100644 --- a/ui/notifications/notification_types.cc +++ b/ui/notifications/notification_types.cc @@ -4,14 +4,6 @@ #include "ui/notifications/notification_types.h" -namespace { - -const char kSimpleType[] = "simple"; -const char kBaseFormatType[] = "base"; -const char kMultipleType[] = "multiple"; - -} // namespace - namespace ui { namespace notifications { @@ -31,6 +23,10 @@ const char kItemsKey[] = "items"; const char kItemTitleKey[] = "title"; const char kItemMessageKey[] = "message"; +const char kSimpleType[] = "simple"; +const char kBaseFormatType[] = "base"; +const char kMultipleType[] = "multiple"; + NotificationType StringToNotificationType(std::string& string_type) { if (string_type == kSimpleType) return NOTIFICATION_TYPE_SIMPLE; |