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

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: fix 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
« no previous file with comments | « ui/gfx/text_elider_unittest.cc ('k') | ui/views/corewm/tooltip_aura.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 ec22dec93cf9385e9bb6c2603ed0f54009929e77..e15d8b44e6b14d807e97beb5f5a0a496ccd1a903 100644
--- a/ui/message_center/views/notification_view.cc
+++ b/ui/message_center/views/notification_view.cc
@@ -535,12 +535,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,
@@ -548,8 +549,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);
}
}
@@ -566,18 +566,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());
@@ -596,10 +597,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);
@@ -608,8 +611,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);
}
}
« no previous file with comments | « ui/gfx/text_elider_unittest.cc ('k') | ui/views/corewm/tooltip_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698