| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/cocoa/download_item_controller.h" | 5 #import "chrome/browser/cocoa/download_item_controller.h" |
| 6 | 6 |
| 7 #include "base/mac_util.h" | 7 #include "base/mac_util.h" |
| 8 #import "chrome/browser/cocoa/download_item_cell.h" | 8 #import "chrome/browser/cocoa/download_item_cell.h" |
| 9 #include "chrome/browser/cocoa/download_item_mac.h" | 9 #include "chrome/browser/cocoa/download_item_mac.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| 11 #include "chrome/browser/download/download_shelf.h" | 11 #include "chrome/browser/download/download_shelf.h" |
| 12 #include "chrome/browser/download/download_util.h" | 12 #include "chrome/browser/download/download_util.h" |
| 13 | 13 |
| 14 | 14 |
| 15 // A class for the chromium-side part of the download shelf context menu. | 15 // A class for the chromium-side part of the download shelf context menu. |
| 16 | 16 |
| 17 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { | 17 class DownloadShelfContextMenuMac : public DownloadShelfContextMenu { |
| 18 public: | 18 public: |
| 19 DownloadShelfContextMenuMac(BaseDownloadItemModel* model) | 19 DownloadShelfContextMenuMac(BaseDownloadItemModel* model) |
| 20 : DownloadShelfContextMenu(model) { } | 20 : DownloadShelfContextMenu(model) { } |
| 21 | 21 |
| 22 using DownloadShelfContextMenu::ExecuteItemCommand; | 22 using DownloadShelfContextMenu::ExecuteItemCommand; |
| 23 using DownloadShelfContextMenu::ItemIsChecked; | 23 using DownloadShelfContextMenu::ItemIsChecked; |
| 24 using DownloadShelfContextMenu::IsItemCommandEnabled; | 24 using DownloadShelfContextMenu::IsItemCommandEnabled; |
| 25 | 25 |
| 26 using DownloadShelfContextMenu::SHOW_IN_FOLDER; | 26 using DownloadShelfContextMenu::SHOW_IN_FOLDER; |
| 27 using DownloadShelfContextMenu::OPEN_WHEN_COMPLETE; | 27 using DownloadShelfContextMenu::OPEN_WHEN_COMPLETE; |
| 28 using DownloadShelfContextMenu::ALWAYS_OPEN_TYPE; | 28 using DownloadShelfContextMenu::ALWAYS_OPEN_TYPE; |
| 29 using DownloadShelfContextMenu::CANCEL; | 29 using DownloadShelfContextMenu::CANCEL; |
| 30 using DownloadShelfContextMenu::REMOVE_ITEM; |
| 30 }; | 31 }; |
| 31 | 32 |
| 32 | 33 |
| 33 // Implementation of DownloadItemController | 34 // Implementation of DownloadItemController |
| 34 | 35 |
| 35 @implementation DownloadItemController | 36 @implementation DownloadItemController |
| 36 | 37 |
| 37 - (id)initWithFrame:(NSRect)frameRect | 38 - (id)initWithFrame:(NSRect)frameRect |
| 38 model:(BaseDownloadItemModel*)downloadModel | 39 model:(BaseDownloadItemModel*)downloadModel |
| 39 shelf:(DownloadShelfController*)shelf { | 40 shelf:(DownloadShelfController*)shelf { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 - (BOOL)validateMenuItem:(NSMenuItem *)item { | 108 - (BOOL)validateMenuItem:(NSMenuItem *)item { |
| 108 SEL action = [item action]; | 109 SEL action = [item action]; |
| 109 | 110 |
| 110 int actionId = 0; | 111 int actionId = 0; |
| 111 if (action == @selector(handleOpen:)) { | 112 if (action == @selector(handleOpen:)) { |
| 112 actionId = DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE; | 113 actionId = DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE; |
| 113 } else if (action == @selector(handleAlwaysOpen:)) { | 114 } else if (action == @selector(handleAlwaysOpen:)) { |
| 114 actionId = DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE; | 115 actionId = DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE; |
| 115 } else if (action == @selector(handleReveal:)) { | 116 } else if (action == @selector(handleReveal:)) { |
| 116 actionId = DownloadShelfContextMenuMac::SHOW_IN_FOLDER; | 117 actionId = DownloadShelfContextMenuMac::SHOW_IN_FOLDER; |
| 118 } else if (action == @selector(handleRemove:)) { |
| 119 actionId = DownloadShelfContextMenuMac::REMOVE_ITEM; |
| 117 } else if (action == @selector(handleCancel:)) { | 120 } else if (action == @selector(handleCancel:)) { |
| 118 actionId = DownloadShelfContextMenuMac::CANCEL; | 121 actionId = DownloadShelfContextMenuMac::CANCEL; |
| 119 } else { | 122 } else { |
| 120 NOTREACHED(); | 123 NOTREACHED(); |
| 121 return YES; | 124 return YES; |
| 122 } | 125 } |
| 123 | 126 |
| 124 if (menuBridge_->ItemIsChecked(actionId)) | 127 if (menuBridge_->ItemIsChecked(actionId)) |
| 125 [item setState:NSOnState]; | 128 [item setState:NSOnState]; |
| 126 else | 129 else |
| 127 [item setState:NSOffState]; | 130 [item setState:NSOffState]; |
| 128 | 131 |
| 129 return menuBridge_->IsItemCommandEnabled(actionId) ? YES : NO; | 132 return menuBridge_->IsItemCommandEnabled(actionId) ? YES : NO; |
| 130 } | 133 } |
| 131 | 134 |
| 132 - (IBAction)handleOpen:(id)sender { | 135 - (IBAction)handleOpen:(id)sender { |
| 133 menuBridge_->ExecuteItemCommand( | 136 menuBridge_->ExecuteItemCommand( |
| 134 DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE); | 137 DownloadShelfContextMenuMac::OPEN_WHEN_COMPLETE); |
| 135 } | 138 } |
| 136 | 139 |
| 137 - (IBAction)handleAlwaysOpen:(id)sender { | 140 - (IBAction)handleAlwaysOpen:(id)sender { |
| 138 menuBridge_->ExecuteItemCommand( | 141 menuBridge_->ExecuteItemCommand( |
| 139 DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE); | 142 DownloadShelfContextMenuMac::ALWAYS_OPEN_TYPE); |
| 140 } | 143 } |
| 141 | 144 |
| 142 - (IBAction)handleReveal:(id)sender { | 145 - (IBAction)handleReveal:(id)sender { |
| 143 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::SHOW_IN_FOLDER); | 146 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::SHOW_IN_FOLDER); |
| 144 } | 147 } |
| 145 | 148 |
| 149 - (IBAction)handleRemove:(id)sender { |
| 150 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::REMOVE_ITEM); |
| 151 } |
| 152 |
| 146 - (IBAction)handleCancel:(id)sender { | 153 - (IBAction)handleCancel:(id)sender { |
| 147 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::CANCEL); | 154 menuBridge_->ExecuteItemCommand(DownloadShelfContextMenuMac::CANCEL); |
| 148 } | 155 } |
| 149 | 156 |
| 150 @end | 157 @end |
| OLD | NEW |