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

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

Issue 2835036: Mac: Add tooltip to download item. (Closed)
Patch Set: nits Created 10 years, 5 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/cocoa/download_item_controller.h ('k') | chrome/browser/cocoa/download_item_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/download_item_controller.mm
diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm
index 02dcd66036c93163a98bbae8905b4c80d50e1f16..ccc27704e2703de89d4dc3a26e42561ec97f924b 100644
--- a/chrome/browser/cocoa/download_item_controller.mm
+++ b/chrome/browser/cocoa/download_item_controller.mm
@@ -36,6 +36,10 @@ const int kTextWidth = 140; // Pixels
// dangerous download message.
const int kFileNameMaxLength = 20;
+// The maximum width in pixels for the file name tooltip.
+const int kToolTipMaxWidth = 900;
+
+
// Helper to widen a view.
void WidenView(NSView* view, CGFloat widthChange) {
// If it is an NSBox, the autoresize of the contentView is the issue.
@@ -150,6 +154,7 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
[image_ setImage:alertIcon];
bridge_->LoadIcon();
+ [self updateToolTip];
}
- (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel {
@@ -254,6 +259,13 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
return bridge_->download_model()->download();
}
+- (void)updateToolTip {
+ std::wstring elidedFilename = gfx::ElideFilename(
+ [self download]->GetFileName(),
+ gfx::Font(), kToolTipMaxWidth);
+ [progressView_ setToolTip:base::SysWideToNSString(elidedFilename)];
+}
+
- (void)clearDangerousMode {
[self setState:kNormal];
// The state change hide the dangerouse download view and is now showing the
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.h ('k') | chrome/browser/cocoa/download_item_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698