Chromium Code Reviews| 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() { |