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

Unified Diff: ui/message_center/views/notification_view.cc

Issue 381953002: New avatar button: Consolidate text elision between Mac and Win/Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits2 Created 6 years, 5 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/views/notification_view.cc
diff --git a/ui/message_center/views/notification_view.cc b/ui/message_center/views/notification_view.cc
index be77657f6e0dc522854ebeffeaff888419488b41..363cefa008a1c6929d11796db1ba92498fad74b8 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -528,12 +528,13 @@ void NotificationView::CreateOrUpdateTitleView(
int title_character_limit =
kNotificationWidth * kMaxTitleLines / kMinPixelsPerTitleCharacter;
+ base::string16 title = gfx::TruncateString(notification.title(),
+ title_character_limit,
+ gfx::WORD_BREAK);
if (!title_view_) {
int padding = kTitleLineHeight - font_list.GetHeight();
- title_view_ = new BoundedLabel(
- gfx::TruncateString(notification.title(), title_character_limit),
- font_list);
+ title_view_ = new BoundedLabel(title, font_list);
title_view_->SetLineHeight(kTitleLineHeight);
title_view_->SetLineLimit(kMaxTitleLines);
title_view_->SetColors(message_center::kRegularTextColor,
@@ -541,8 +542,7 @@ void NotificationView::CreateOrUpdateTitleView(
title_view_->SetBorder(MakeTextBorder(padding, 3, 0));
top_view_->AddChildView(title_view_);
} else {
- title_view_->SetText(
- gfx::TruncateString(notification.title(), title_character_limit));
+ title_view_->SetText(title);
}
}
@@ -559,18 +559,19 @@ void NotificationView::CreateOrUpdateMessageView(
DCHECK(top_view_ != NULL);
+ base::string16 text = gfx::TruncateString(notification.message(),
+ kMessageCharacterLimit,
+ gfx::WORD_BREAK);
if (!message_view_) {
int padding = kMessageLineHeight - views::Label().font_list().GetHeight();
- message_view_ = new BoundedLabel(
- gfx::TruncateString(notification.message(), kMessageCharacterLimit));
+ message_view_ = new BoundedLabel(text);
message_view_->SetLineHeight(kMessageLineHeight);
message_view_->SetColors(message_center::kRegularTextColor,
kDimTextBackgroundColor);
message_view_->SetBorder(MakeTextBorder(padding, 4, 0));
top_view_->AddChildView(message_view_);
} else {
- message_view_->SetText(
- gfx::TruncateString(notification.message(), kMessageCharacterLimit));
+ message_view_->SetText(text);
}
message_view_->SetVisible(!notification.items().size());
@@ -589,10 +590,12 @@ void NotificationView::CreateOrUpdateContextMessageView(
DCHECK(top_view_ != NULL);
+ base::string16 text = gfx::TruncateString(notification.context_message(),
+ kContextMessageCharacterLimit,
+ gfx::WORD_BREAK);
if (!context_message_view_) {
int padding = kMessageLineHeight - views::Label().font_list().GetHeight();
- context_message_view_ = new BoundedLabel(gfx::TruncateString(
- notification.context_message(), kContextMessageCharacterLimit));
+ context_message_view_ = new BoundedLabel(text);
context_message_view_->SetLineLimit(
message_center::kContextMessageLineLimit);
context_message_view_->SetLineHeight(kMessageLineHeight);
@@ -601,8 +604,7 @@ void NotificationView::CreateOrUpdateContextMessageView(
context_message_view_->SetBorder(MakeTextBorder(padding, 4, 0));
top_view_->AddChildView(context_message_view_);
} else {
- context_message_view_->SetText(gfx::TruncateString(
- notification.context_message(), kContextMessageCharacterLimit));
+ context_message_view_->SetText(text);
}
}

Powered by Google App Engine
This is Rietveld 408576698