summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/download_item_controller.mm
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/cocoa/download_item_controller.mm')
-rw-r--r--chrome/browser/cocoa/download_item_controller.mm49
1 files changed, 23 insertions, 26 deletions
diff --git a/chrome/browser/cocoa/download_item_controller.mm b/chrome/browser/cocoa/download_item_controller.mm
index aa0d8a5..f5d2836 100644
--- a/chrome/browser/cocoa/download_item_controller.mm
+++ b/chrome/browser/cocoa/download_item_controller.mm
@@ -4,12 +4,13 @@
#import "chrome/browser/cocoa/download_item_controller.h"
-#include "app/l10n_util.h"
#include "base/mac_util.h"
-#include "base/sys_string_conversions.h"
+#import "chrome/browser/cocoa/download_item_cell.h"
#include "chrome/browser/cocoa/download_item_mac.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/download/download_util.h"
+
// A class for the chromium-side part of the download shelf context menu.
@@ -59,32 +60,12 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
// Set correct popup menu.
if (downloadModel->download()->state() == DownloadItem::COMPLETE)
- [popupButton_ setMenu:completeDownloadMenu_];
+ currentMenu_ = completeDownloadMenu_;
else
- [popupButton_ setMenu:activeDownloadMenu_];
-
- // Set name and icon of download.
- FilePath downloadPath = downloadModel->download()->GetFileName();
-
- // TODO(thakis): use filename eliding like gtk/windows versions.
- NSString* titleString = base::SysWideToNSString(downloadPath.ToWStringHack());
- [[popupButton_ itemAtIndex:0] setTitle:titleString];
-
- // TODO(paulg): Use IconManager for loading icons on the file thread
- // (crbug.com/16226).
- NSString* extension = base::SysUTF8ToNSString(downloadPath.Extension());
- [[popupButton_ itemAtIndex:0] setImage:
- [[NSWorkspace sharedWorkspace] iconForFileType:extension]];
-
- // Set status text.
- std::wstring statusText = downloadModel->GetStatusText();
- // Remove the status text label.
- if (statusText.empty()) {
- // TODO(thakis): Once there is a status label, hide it here.
- return;
- }
+ currentMenu_ = activeDownloadMenu_;
- // TODO(thakis): Set status_text as status label.
+ [progressView_ setMenu:currentMenu_]; // for context menu
+ [cell_ setStateFromDownload:downloadModel];
}
- (void)remove {
@@ -92,6 +73,22 @@ class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
[shelf_ remove:self];
}
+- (IBAction)handleButtonClick:(id)sender {
+ if ([cell_ isButtonPartPressed]) {
+ DownloadItem* download = bridge_->download_model()->download();
+ if (download->state() == DownloadItem::IN_PROGRESS) {
+ download->set_open_when_complete(!download->open_when_complete());
+ } else if (download->state() == DownloadItem::COMPLETE) {
+ download_util::OpenDownload(download);
+ }
+ } else {
+ // TODO(thakis): Align menu nicely with left view edge
+ [NSMenu popUpContextMenu:currentMenu_
+ withEvent:[NSApp currentEvent]
+ forView:progressView_];
+ }
+}
+
// Sets the enabled and checked state of a particular menu item for this
// download. We translate the NSMenuItem selection to menu selections understood
// by the non platform specific download context menu.