| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "base/time.h" |
| 8 | 9 |
| 9 class BaseDownloadItemModel; | 10 class BaseDownloadItemModel; |
| 10 @class DownloadItemCell; | 11 @class DownloadItemCell; |
| 11 class DownloadItemMac; | 12 class DownloadItemMac; |
| 12 class DownloadShelfContextMenuMac; | 13 class DownloadShelfContextMenuMac; |
| 13 @class DownloadShelfController; | 14 @class DownloadShelfController; |
| 14 | 15 |
| 15 // A controller class that manages one download item. | 16 // A controller class that manages one download item. |
| 16 | 17 |
| 17 @interface DownloadItemController : NSViewController { | 18 @interface DownloadItemController : NSViewController { |
| 18 @private | 19 @private |
| 19 IBOutlet NSButton* progressView_; | 20 IBOutlet NSButton* progressView_; |
| 20 IBOutlet DownloadItemCell* cell_; | 21 IBOutlet DownloadItemCell* cell_; |
| 21 | 22 |
| 22 IBOutlet NSMenu* activeDownloadMenu_; | 23 IBOutlet NSMenu* activeDownloadMenu_; |
| 23 IBOutlet NSMenu* completeDownloadMenu_; | 24 IBOutlet NSMenu* completeDownloadMenu_; |
| 24 | 25 |
| 25 NSMenu* currentMenu_; // points to one of the two menus above | 26 NSMenu* currentMenu_; // points to one of the two menus above |
| 26 | 27 |
| 28 // This is shown instead of progressView_ for dangerous downloads. |
| 29 IBOutlet NSView* dangerousDownloadView_; |
| 30 IBOutlet NSTextField* dangerousDownloadLabel_; |
| 31 |
| 27 scoped_ptr<DownloadItemMac> bridge_; | 32 scoped_ptr<DownloadItemMac> bridge_; |
| 28 scoped_ptr<DownloadShelfContextMenuMac> menuBridge_; | 33 scoped_ptr<DownloadShelfContextMenuMac> menuBridge_; |
| 29 | 34 |
| 30 // Weak pointer to the shelf that owns us. | 35 // Weak pointer to the shelf that owns us. |
| 31 DownloadShelfController* shelf_; | 36 DownloadShelfController* shelf_; |
| 37 |
| 38 // The time at which this view was created. |
| 39 base::Time creationTime_; |
| 40 |
| 41 // The state of this item. |
| 42 enum DownoadItemState { |
| 43 kNormal, |
| 44 kDangerous |
| 45 } state_; |
| 32 }; | 46 }; |
| 33 | 47 |
| 34 // Takes ownership of |downloadModel|. | 48 // Takes ownership of |downloadModel|. |
| 35 - (id)initWithFrame:(NSRect)frameRect | 49 - (id)initWithModel:(BaseDownloadItemModel*)downloadModel |
| 36 model:(BaseDownloadItemModel*)downloadModel | |
| 37 shelf:(DownloadShelfController*)shelf; | 50 shelf:(DownloadShelfController*)shelf; |
| 38 | 51 |
| 39 // Updates the UI and menu state from |downloadModel|. | 52 // Updates the UI and menu state from |downloadModel|. |
| 40 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel; | 53 - (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel; |
| 41 | 54 |
| 42 // Remove ourself from the download UI. | 55 // Remove ourself from the download UI. |
| 43 - (void)remove; | 56 - (void)remove; |
| 44 | 57 |
| 45 // Update item's visibility depending on if the item is still completely | 58 // Update item's visibility depending on if the item is still completely |
| 46 // contained in its parent. | 59 // contained in its parent. |
| 47 - (void)updateVisibility:(id)sender; | 60 - (void)updateVisibility:(id)sender; |
| 48 | 61 |
| 49 // Asynchronous icon loading callback. | 62 // Asynchronous icon loading callback. |
| 50 - (void)setIcon:(NSImage*)icon; | 63 - (void)setIcon:(NSImage*)icon; |
| 51 | 64 |
| 52 // Download item button clicked | 65 // Download item button clicked |
| 53 - (IBAction)handleButtonClick:(id)sender; | 66 - (IBAction)handleButtonClick:(id)sender; |
| 54 | 67 |
| 68 // Returns the size this item wants to have. |
| 69 - (NSSize)preferredSize; |
| 70 |
| 71 // Handling of dangerous downloads |
| 72 - (void)clearDangerousMode; |
| 73 - (BOOL)isDangerousMode; |
| 74 - (IBAction)saveDownload:(id)sender; |
| 75 - (IBAction)discardDownload:(id)sender; |
| 76 |
| 55 // Context menu handlers. | 77 // Context menu handlers. |
| 56 - (IBAction)handleOpen:(id)sender; | 78 - (IBAction)handleOpen:(id)sender; |
| 57 - (IBAction)handleAlwaysOpen:(id)sender; | 79 - (IBAction)handleAlwaysOpen:(id)sender; |
| 58 - (IBAction)handleReveal:(id)sender; | 80 - (IBAction)handleReveal:(id)sender; |
| 59 - (IBAction)handleRemove:(id)sender; | 81 - (IBAction)handleRemove:(id)sender; |
| 60 - (IBAction)handleCancel:(id)sender; | 82 - (IBAction)handleCancel:(id)sender; |
| 61 | 83 |
| 62 @end | 84 @end |
| 63 | 85 |
| OLD | NEW |