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

Unified Diff: chrome/browser/ui/views/download/download_item_view.cc

Issue 10169025: Show download interrupt reason in a tooltip (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move logic to DownloadItemModel Created 8 years, 8 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 | « chrome/browser/ui/gtk/download/download_item_gtk.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/download/download_item_view.cc
diff --git a/chrome/browser/ui/views/download/download_item_view.cc b/chrome/browser/ui/views/download/download_item_view.cc
index 606ad69862f86829cacb51645cf418620ad3d8e5..e17fd28f09e09315f35ffc1ea172c87c86f66a3d 100644
--- a/chrome/browser/ui/views/download/download_item_view.cc
+++ b/chrome/browser/ui/views/download/download_item_view.cc
@@ -49,6 +49,7 @@ static const int kHorizontalTextPadding = 2; // Pixels
static const int kVerticalPadding = 3; // Pixels
static const int kVerticalTextSpacer = 2; // Pixels
static const int kVerticalTextPadding = 2; // Pixels
+static const int kTooltipMaxWidth = 800; // Pixels
// We add some padding before the left image so that the progress animation icon
// hides the corners of the left image.
@@ -184,9 +185,6 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
LoadIcon();
- // Initial tooltip value.
- tooltip_text_ = download_->GetFileNameToReportUser().LossyDisplayName();
-
font_ = rb.GetFont(ui::ResourceBundle::BaseFont);
box_height_ = std::max<int>(2 * kVerticalPadding + font_.GetHeight() +
kVerticalTextPadding + font_.GetHeight(),
@@ -204,6 +202,8 @@ DownloadItemView::DownloadItemView(DownloadItem* download,
UpdateDropDownButtonPosition();
+ tooltip_text_ = model_->GetTooltipText(font_, kTooltipMaxWidth);
+
if (model_->IsDangerous())
ShowWarningDialog();
@@ -254,20 +254,6 @@ void DownloadItemView::OnExtractIconComplete(IconManager::Handle handle,
void DownloadItemView::OnDownloadUpdated(DownloadItem* download) {
DCHECK(download == download_);
- string16 old_tip = tooltip_text_;
- content::DownloadInterruptReason reason = download_->GetLastReason();
-
- if ((download_->GetState() == DownloadItem::INTERRUPTED) &&
- (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED)) {
- // Use two lines: The file name, and the message.
- tooltip_text_ = download_->GetFileNameToReportUser().LossyDisplayName();
- tooltip_text_ += ASCIIToUTF16("\n");
- // The message is localized.
- tooltip_text_ += DownloadItemModel::InterruptReasonMessage(reason);
- } else {
- tooltip_text_ = download_->GetFileNameToReportUser().LossyDisplayName();
- }
-
if (IsShowingWarningDialog() && !model_->IsDangerous()) {
// We have been approved.
ClearWarningDialog();
@@ -319,8 +305,11 @@ void DownloadItemView::OnDownloadUpdated(DownloadItem* download) {
status_text_ = status_text;
}
- if (old_tip != tooltip_text_)
+ string16 new_tip = model_->GetTooltipText(font_, kTooltipMaxWidth);
+ if (new_tip != tooltip_text_) {
+ tooltip_text_ = new_tip;
TooltipTextChanged();
+ }
UpdateAccessibleName();
« no previous file with comments | « chrome/browser/ui/gtk/download/download_item_gtk.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698