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

Unified Diff: chrome/browser/ui/cocoa/download/download_item_controller.mm

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/cocoa/download/download_item_controller.mm
diff --git a/chrome/browser/ui/cocoa/download/download_item_controller.mm b/chrome/browser/ui/cocoa/download/download_item_controller.mm
index faac76d7ef690268f108ad453d8df683d24d9334..22bf80c5f63d45b531e78a2135bda1606496093d 100644
--- a/chrome/browser/ui/cocoa/download/download_item_controller.mm
+++ b/chrome/browser/ui/cocoa/download/download_item_controller.mm
@@ -44,6 +44,7 @@ const int kTextWidth = 140; // Pixels
// The maximum width in pixels for the file name tooltip.
const int kToolTipMaxWidth = 900;
+const int kToolTipErrorMessageMaxHeight = kToolTipMaxWidth / 4;
// Helper to widen a view.
@@ -245,9 +246,35 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
}
- (void)updateToolTip {
- string16 elidedFilename = ui::ElideFilename(
+ string16 tooltip_text = ui::ElideFilename(
[self download]->GetFileNameToReportUser(), *font_, kToolTipMaxWidth);
- [progressView_ setToolTip:base::SysUTF16ToNSString(elidedFilename)];
+
+ if ([self download]->GetState() == content::DownloadItem::INTERRUPTED) {
+ content::DownloadInterruptReason reason = [self download]->GetLastReason();
+ DCHECK(reason != 0);
+
+ // Split up the error description string as necessary.
+ std::vector<string16> elidedMessages;
+ ui::ElideRectangleText(
+ DownloadItemModel::InterruptReasonMessage(reason),
+ *font_,
+ kToolTipMaxWidth,
+ kToolTipErrorMessageMaxHeight,
+ ui::IGNORE_LONG_WORDS,
+ &elidedMessages);
+
+ 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 += bridge_->download_model()->GetProgressText();
+ }
+
+ [progressView_ setToolTip:base::SysUTF16ToNSString(tooltip_text)];
}
- (void)clearDangerousMode {

Powered by Google App Engine
This is Rietveld 408576698