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

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

Issue 159060: Use a real download item.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: first round of review comments addressed Created 11 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_shelf_controller.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
===================================================================
--- chrome/browser/cocoa/download_item_controller.mm (revision 21145)
+++ chrome/browser/cocoa/download_item_controller.mm (working copy)
@@ -4,13 +4,14 @@
#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.
class DownloadShelfContextMenuMac : public DownloadShelfContextMenu {
@@ -59,32 +60,12 @@
// Set correct popup menu.
if (downloadModel->download()->state() == DownloadItem::COMPLETE)
- [popupButton_ setMenu:completeDownloadMenu_];
+ currentMenu_ = completeDownloadMenu_;
else
- [popupButton_ setMenu:activeDownloadMenu_];
+ currentMenu_ = 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;
- }
-
- // TODO(thakis): Set status_text as status label.
+ [progressView_ setMenu:currentMenu_]; // for context menu
+ [cell_ setStateFromDownload:downloadModel];
}
- (void)remove {
@@ -92,6 +73,22 @@
[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.
« no previous file with comments | « chrome/browser/cocoa/download_item_controller.h ('k') | chrome/browser/cocoa/download_shelf_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698