diff options
author | yoshiki <yoshiki@chromium.org> | 2015-07-13 23:38:07 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-07-14 06:39:06 +0000 |
commit | 9fa4dbc009d5d6fefa9f170921ae9adbaa977369 (patch) | |
tree | 708c599e1967726d371269c58ef667d66590532f | |
parent | 8fd2ebec607959294e42d4b5b4ff720b7e50c730 (diff) | |
download | chromium_src-9fa4dbc009d5d6fefa9f170921ae9adbaa977369.zip chromium_src-9fa4dbc009d5d6fefa9f170921ae9adbaa977369.tar.gz chromium_src-9fa4dbc009d5d6fefa9f170921ae9adbaa977369.tar.bz2 |
[Download Notification] Truncate long filename in group notification
Truncate and add an ellipsis if the filename has more than 20 characters.
BUG=468558
TEST=none
Review URL: https://codereview.chromium.org/1184483006
Cr-Commit-Position: refs/heads/master@{#338647}
-rw-r--r-- | chrome/browser/download/notification/download_group_notification.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/chrome/browser/download/notification/download_group_notification.cc b/chrome/browser/download/notification/download_group_notification.cc index 8978020..2b578f5 100644 --- a/chrome/browser/download/notification/download_group_notification.cc +++ b/chrome/browser/download/notification/download_group_notification.cc @@ -19,12 +19,22 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/time_format.h" #include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/text_elider.h" +#include "ui/views/controls/label.h" namespace { const char kDownloadNotificationNotifierId[] = "chrome://downloads/notification/id-notifier"; +const size_t kMaxFilenameWidth = 160; // in px + +base::string16 TruncateFilename(const base::FilePath& filename) { + return gfx::ElideFilename(filename, + views::Label().font_list(), + kMaxFilenameWidth); +} + } // anonymous namespace DownloadGroupNotification::DownloadGroupNotification( @@ -168,10 +178,9 @@ void DownloadGroupNotification::UpdateNotificationData() { std::vector<message_center::NotificationItem> subitems; for (auto download : items_) { DownloadItemModel model(download); - // TODO(yoshiki): Truncate long filename. // TODO(yoshiki): Use emplace_back when C++11 becomes allowed. subitems.push_back(message_center::NotificationItem( - download->GetFileNameToReportUser().LossyDisplayName(), + TruncateFilename(download->GetFileNameToReportUser()), model.GetStatusText())); if (!download->IsDone()) |