summaryrefslogtreecommitdiffstats
path: root/ui/message_center/views/notification_view.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/message_center/views/notification_view.cc')
-rw-r--r--ui/message_center/views/notification_view.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index 8be9e75..6f8f2ff 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -44,6 +44,9 @@ const int kButtonIconTopPadding = 11;
const int kButtonIconToTitlePadding = 16;
const int kButtonTitleTopPadding = 0;
+const size_t kTitleCharacterLimit = 100;
+const size_t kMessageCharacterLimit = 200;
+
// Notification colors. The text background colors below are used only to keep
// view::Label from modifying the text color and will not actually be drawn.
// See view::Label's SetEnabledColor() and SetBackgroundColor() for details.
@@ -359,7 +362,8 @@ NotificationView::NotificationView(const Notification& notification,
// Create the title view if appropriate.
title_view_ = NULL;
if (!notification.title().empty()) {
- title_view_ = new views::Label(notification.title());
+ title_view_ = new views::Label(
+ MaybeTruncateText( notification.title(), kTitleCharacterLimit));
title_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
if (is_expanded())
title_view_->SetMultiLine(true);
@@ -375,7 +379,8 @@ NotificationView::NotificationView(const Notification& notification,
// Create the message view if appropriate.
message_view_ = NULL;
if (!notification.message().empty()) {
- message_view_ = new views::Label(notification.message());
+ message_view_ = new views::Label(
+ MaybeTruncateText(notification.message(), kMessageCharacterLimit));
message_view_->SetVisible(!is_expanded() || !notification.items().size());
message_view_->set_collapse_when_hidden(true);
message_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
@@ -528,4 +533,14 @@ void NotificationView::ButtonPressed(views::Button* sender,
}
}
+string16 NotificationView::MaybeTruncateText(const string16& text,
+ size_t limit) {
+ // Currently just truncate the text by the total number of characters.
+ // TODO(mukai): add better assumption like number of lines.
+ if (!is_expanded())
+ return text;
+
+ return ui::TruncateString(text, limit);
+}
+
} // namespace message_center