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

Unified Diff: chrome/browser/ui/gtk/download/download_item_gtk.cc

Issue 9968090: Added download error descriptions to tooltips for Mac & Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed GCC compile issue. Created 8 years, 9 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: chrome/browser/ui/gtk/download/download_item_gtk.cc
diff --git a/chrome/browser/ui/gtk/download/download_item_gtk.cc b/chrome/browser/ui/gtk/download/download_item_gtk.cc
index 92be0bb60486a668509acc632f2d1dd09b1f256f..72f58049cc2b826b179a00485a0d748f79d05676 100644
--- a/chrome/browser/ui/gtk/download/download_item_gtk.cc
+++ b/chrome/browser/ui/gtk/download/download_item_gtk.cc
@@ -58,6 +58,9 @@ const int kTextWidth = 140;
// We only cap the size of the tooltip so we don't crash.
const int kTooltipMaxWidth = 1000;
+// Used for wrapping the download error description, if necessary.
+const int kToolTipErrorMessageMaxHeight = kTooltipMaxWidth / 4;
+
// The minimum width we will ever draw the download item. Used as a lower bound
// during animation. This number comes from the width of the images used to
// make the download item.
@@ -335,6 +338,7 @@ void DownloadItemGtk::OnDownloadUpdated(DownloadItem* download) {
break;
case DownloadItem::INTERRUPTED:
StopDownloadProgress();
+ UpdateTooltip();
complete_animation_.Show();
break;
@@ -476,11 +480,35 @@ void DownloadItemGtk::LoadIcon() {
}
void DownloadItemGtk::UpdateTooltip() {
- string16 elided_filename = ui::ElideFilename(
- get_download()->GetFileNameToReportUser(),
- gfx::Font(), kTooltipMaxWidth);
- gtk_widget_set_tooltip_text(body_.get(),
- UTF16ToUTF8(elided_filename).c_str());
+ string16 tooltip_text = ui::ElideFilename(
+ get_download()->GetFileNameToReportUser(), gfx::Font(), kTooltipMaxWidth);
asanka 2012/04/04 17:27:04 Can we move the tooltip generation logic into the
ahendrickson 2012/04/04 17:49:32 The logic is different on Windows vs Posix.
+
+ if (get_download()->GetState() == content::DownloadItem::INTERRUPTED) {
+ content::DownloadInterruptReason reason = get_download()->GetLastReason();
+ DCHECK(reason != 0);
+
+ // Split up the error description string as necessary.
+ std::vector<string16> elidedMessages;
+ ui::ElideRectangleText(
+ DownloadItemModel::InterruptReasonMessage(reason),
+ gfx::Font(),
+ kTooltipMaxWidth,
+ kToolTipErrorMessageMaxHeight,
+ ui::IGNORE_LONG_WORDS,
+ &elidedMessages);
Nico 2012/04/04 17:50:06 Hm, maybe that should be on the downloads page ins
asanka 2012/04/05 19:08:34 This has changed in the latest patch set. Part of
+
+ string16 new_line = ASCIIToUTF16("\n");
+ tooltip_text += new_line;
+
+ for (size_t i = 0; i < elidedMessages.size(); ++i) {
+ tooltip_text += elidedMessages[i];
+ tooltip_text += new_line;
+ }
+
+ tooltip_text += download_model_->GetProgressText();
+ }
+
+ gtk_widget_set_tooltip_text(body_.get(), UTF16ToUTF8(tooltip_text).c_str());
}
void DownloadItemGtk::UpdateNameLabel() {

Powered by Google App Engine
This is Rietveld 408576698