diff options
author | dharcourt@chromium.org <dharcourt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-04 12:17:38 +0000 |
---|---|---|
committer | dharcourt@chromium.org <dharcourt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-04 12:17:38 +0000 |
commit | 7cbf1affeebde4cf27cc07bc811c41b0094cd0f4 (patch) | |
tree | f33338b359499c97868bc06c2495bf0b87c848dc /ui | |
parent | e7b183112403e43ddd53a1d18d37544e7dc65295 (diff) | |
download | chromium_src-7cbf1affeebde4cf27cc07bc811c41b0094cd0f4.zip chromium_src-7cbf1affeebde4cf27cc07bc811c41b0094cd0f4.tar.gz chromium_src-7cbf1affeebde4cf27cc07bc811c41b0094cd0f4.tar.bz2 |
Set a display limit of 8 on multiple-item notifications items.
This limit is defined in the notification product requirement document,
section "Inbox Format for Multiple Messages". The limit only affects
the number of items displayed (to avoid notifications growing too tall).
The back end still handles any number of items. The maximum number is
declared in the public message_center_constants.h file so future code
can use it, for example to output a warning or return an error if
callers to the chrome.experimental.notification API ask for a
notification with more than the maximum number of displayable items.
BUG=161101
Review URL: https://chromiumcodereview.appspot.com/11638035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@175132 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/message_center/message_center_constants.cc | 1 | ||||
-rw-r--r-- | ui/message_center/message_center_constants.h | 2 | ||||
-rw-r--r-- | ui/message_center/notification_view.cc | 9 |
3 files changed, 9 insertions, 3 deletions
diff --git a/ui/message_center/message_center_constants.cc b/ui/message_center/message_center_constants.cc index 97d6218..f495180 100644 --- a/ui/message_center/message_center_constants.cc +++ b/ui/message_center/message_center_constants.cc @@ -7,5 +7,6 @@ namespace message_center { const int kNotificationIconWidth = 80; +const size_t kNotificationMaxItems = 8; } // namespace message_center diff --git a/ui/message_center/message_center_constants.h b/ui/message_center/message_center_constants.h index b82650a..be0bdb4 100644 --- a/ui/message_center/message_center_constants.h +++ b/ui/message_center/message_center_constants.h @@ -5,11 +5,13 @@ #ifndef UI_MESSAGE_CENTER_MESSAGE_CENTER_CONSTANTS_H_ #define UI_MESSAGE_CENTER_MESSAGE_CENTER_CONSTANTS_H_ +#include "base/basictypes.h" #include "ui/message_center/message_center_export.h" namespace message_center { MESSAGE_CENTER_EXPORT extern const int kNotificationIconWidth; +extern const size_t kNotificationMaxItems; } // namespace message_center diff --git a/ui/message_center/notification_view.cc b/ui/message_center/notification_view.cc index 22d1fc4..76fc38c 100644 --- a/ui/message_center/notification_view.cc +++ b/ui/message_center/notification_view.cc @@ -139,7 +139,9 @@ void NotificationView::SetUpView() { icon->SetVerticalAlignment(views::ImageView::LEADING); icon->set_border(MakePadding(kIconTopPadding, kIconLeftPadding, kIconBottomPadding, kIconToTextPadding)); - layout->AddView(icon, 1, 2 + notification_.items.size()); + int displayed_item_count = + std::min(notification_.items.size(), kNotificationMaxItems); + layout->AddView(icon, 1, 2 + displayed_item_count); // First row: Title. This vertically spans the close button padding row and // the close button row. @@ -168,8 +170,9 @@ void NotificationView::SetUpView() { layout->AddView(close_button_); // One row for each notification item, including appropriate padding. - for (int i = 0, n = notification_.items.size(); i < n; ++i) { - int bottom_padding = (i < n - 1) ? 4 : (kTextBottomPadding - 2); + for (int i = 0; i < displayed_item_count; ++i) { + int bottom_padding = + (i < displayed_item_count - 1) ? 4 : (kTextBottomPadding - 2); layout->StartRow(0, 0); layout->SkipColumns(1); ItemView* item = new ItemView(notification_.items[i]); |