| 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 27c8accae20cdf39092662575eb52221be7b4e5d..a86e5fa7e0227c4362bfcbf013e9957ecfd04974 100644
|
| --- a/ui/message_center/views/notification_view.cc
|
| +++ b/ui/message_center/views/notification_view.cc
|
| @@ -8,6 +8,7 @@
|
| #include "base/stl_util.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| +#include "components/url_formatter/elide_url.h"
|
| #include "third_party/skia/include/core/SkPaint.h"
|
| #include "third_party/skia/include/core/SkPath.h"
|
| #include "ui/base/cursor/cursor.h"
|
| @@ -41,6 +42,7 @@
|
| #include "ui/views/painter.h"
|
| #include "ui/views/view_targeter.h"
|
| #include "ui/views/widget/widget.h"
|
| +#include "url/gurl.h"
|
|
|
| namespace {
|
|
|
| @@ -285,11 +287,11 @@ views::View* NotificationView::TargetForRect(views::View* root,
|
| void NotificationView::CreateOrUpdateViews(const Notification& notification) {
|
| CreateOrUpdateTitleView(notification);
|
| CreateOrUpdateMessageView(notification);
|
| - CreateOrUpdateContextMessageView(notification);
|
| CreateOrUpdateProgressBarView(notification);
|
| CreateOrUpdateListItemViews(notification);
|
| CreateOrUpdateIconView(notification);
|
| CreateOrUpdateImageView(notification);
|
| + CreateOrUpdateContextMessageView(notification);
|
| CreateOrUpdateActionButtonViews(notification);
|
| }
|
|
|
| @@ -297,7 +299,8 @@ void NotificationView::SetAccessibleName(const Notification& notification) {
|
| std::vector<base::string16> accessible_lines;
|
| accessible_lines.push_back(notification.title());
|
| accessible_lines.push_back(notification.message());
|
| - accessible_lines.push_back(notification.context_message());
|
| + accessible_lines.push_back(
|
| + base::UTF8ToUTF16(notification.context_message().message));
|
| std::vector<NotificationItem> items = notification.items();
|
| for (size_t i = 0; i < items.size() && i < kNotificationMaximumItems; ++i) {
|
| accessible_lines.push_back(items[i].title + base::ASCIIToUTF16(" ") +
|
| @@ -553,9 +556,24 @@ void NotificationView::CreateOrUpdateMessageView(
|
| message_view_->SetVisible(!notification.items().size());
|
| }
|
|
|
| +base::string16 NotificationView::FormatContextMessage(
|
| + const ContextMessage& context) const {
|
| + if (context.is_origin) {
|
| + GURL url(context.message);
|
| + if (!url.is_valid())
|
| + return base::UTF8ToUTF16(url.possibly_invalid_spec());
|
| + return url_formatter::ElideHost(url, views::Label().font_list(),
|
| + kContextMessageViewWidth);
|
| + }
|
| +
|
| + return gfx::TruncateString(
|
| + base::UTF8ToUTF16(context.message),
|
| + kContextMessageCharacterLimit, gfx::WORD_BREAK);
|
| +}
|
| +
|
| void NotificationView::CreateOrUpdateContextMessageView(
|
| const Notification& notification) {
|
| - if (notification.context_message().empty()) {
|
| + if (notification.context_message().message.empty()) {
|
| if (context_message_view_) {
|
| // Deletion will also remove |context_message_view_| from its parent.
|
| delete context_message_view_;
|
| @@ -566,12 +584,11 @@ void NotificationView::CreateOrUpdateContextMessageView(
|
|
|
| DCHECK(top_view_ != NULL);
|
|
|
| - base::string16 text = gfx::TruncateString(notification.context_message(),
|
| - kContextMessageCharacterLimit,
|
| - gfx::WORD_BREAK);
|
| + base::string16 message = FormatContextMessage(notification.context_message());
|
| +
|
| if (!context_message_view_) {
|
| int padding = kMessageLineHeight - views::Label().font_list().GetHeight();
|
| - context_message_view_ = new BoundedLabel(text);
|
| + context_message_view_ = new BoundedLabel(message);
|
| context_message_view_->SetLineLimit(
|
| message_center::kContextMessageLineLimit);
|
| context_message_view_->SetLineHeight(kMessageLineHeight);
|
| @@ -580,7 +597,7 @@ void NotificationView::CreateOrUpdateContextMessageView(
|
| context_message_view_->SetBorder(MakeTextBorder(padding, 4, 0));
|
| top_view_->AddChildView(context_message_view_);
|
| } else {
|
| - context_message_view_->SetText(text);
|
| + context_message_view_->SetText(message);
|
| }
|
| }
|
|
|
|
|