blob: dea77224f9d137a96eea37045563110b18066fd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import <Cocoa/Cocoa.h>
#include "base/scoped_ptr.h"
#include "base/time.h"
class BaseDownloadItemModel;
@class ChromeUILocalizer;
@class DownloadItemCell;
class DownloadItem;
@class DownloadItemButton;
class DownloadItemMac;
class DownloadShelfContextMenuMac;
@class DownloadShelfController;
@class GTMWidthBasedTweaker;
// A controller class that manages one download item.
@interface DownloadItemController : NSViewController {
@private
IBOutlet DownloadItemButton* progressView_;
IBOutlet DownloadItemCell* cell_;
IBOutlet NSMenu* activeDownloadMenu_;
IBOutlet NSMenu* completeDownloadMenu_;
// This is shown instead of progressView_ for dangerous downloads.
IBOutlet NSView* dangerousDownloadView_;
IBOutlet NSTextField* dangerousDownloadLabel_;
IBOutlet NSButton* dangerousDownloadConfirmButton_;
// Needed to find out how much the tweaker changed sizes to update the
// other views.
IBOutlet GTMWidthBasedTweaker* buttonTweaker_;
// Because the confirm text and button for dangerous downloads are determined
// at runtime, an outlet to the localizer is needed to construct the layout
// tweaker in awakeFromNib in order to adjust the UI after all strings are
// determined.
IBOutlet ChromeUILocalizer* localizer_;
IBOutlet NSImageView* image_;
scoped_ptr<DownloadItemMac> bridge_;
scoped_ptr<DownloadShelfContextMenuMac> menuBridge_;
// Weak pointer to the shelf that owns us.
DownloadShelfController* shelf_;
// The time at which this view was created.
base::Time creationTime_;
// The state of this item.
enum DownoadItemState {
kNormal,
kDangerous
} state_;
};
// Takes ownership of |downloadModel|.
- (id)initWithModel:(BaseDownloadItemModel*)downloadModel
shelf:(DownloadShelfController*)shelf;
// Updates the UI and menu state from |downloadModel|.
- (void)setStateFromDownload:(BaseDownloadItemModel*)downloadModel;
// Remove ourself from the download UI.
- (void)remove;
// Update item's visibility depending on if the item is still completely
// contained in its parent.
- (void)updateVisibility:(id)sender;
// Asynchronous icon loading callback.
- (void)setIcon:(NSImage*)icon;
// Download item button clicked
- (IBAction)handleButtonClick:(id)sender;
// Returns the size this item wants to have.
- (NSSize)preferredSize;
// Returns the DownloadItem model object belonging to this item.
- (DownloadItem*)download;
// Updates the tooltip with the download's path.
- (void)updateToolTip;
// Handling of dangerous downloads
- (void)clearDangerousMode;
- (BOOL)isDangerousMode;
- (IBAction)saveDownload:(id)sender;
- (IBAction)discardDownload:(id)sender;
// Context menu handlers.
- (IBAction)handleOpen:(id)sender;
- (IBAction)handleAlwaysOpen:(id)sender;
- (IBAction)handleReveal:(id)sender;
- (IBAction)handleCancel:(id)sender;
- (IBAction)handleTogglePause:(id)sender;
@end
|