[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / download / download_item_controller.h
blob78010b6be04b3c4056ba92fcfbb2039ce396ba65
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #import <Cocoa/Cocoa.h>
7 #include "base/memory/scoped_ptr.h"
8 #include "base/time/time.h"
10 @class ChromeUILocalizer;
11 @class DownloadItemCell;
12 @class DownloadItemButton;
13 class DownloadItemMac;
14 class DownloadItemModel;
15 class DownloadShelfContextMenuMac;
16 @class DownloadShelfController;
17 @class GTMWidthBasedTweaker;
19 namespace content {
20 class DownloadItem;
21 class PageNavigator;
24 namespace gfx {
25 class FontList;
28 namespace ui {
29 class MenuModel;
32 // A controller class that manages one download item.
34 @interface DownloadItemController : NSViewController {
35 @private
36 IBOutlet DownloadItemButton* progressView_;
37 IBOutlet DownloadItemCell* cell_;
39 // This is shown instead of progressView_ for dangerous downloads.
40 IBOutlet NSView* dangerousDownloadView_;
41 IBOutlet NSTextField* dangerousDownloadLabel_;
42 IBOutlet NSButton* dangerousDownloadConfirmButton_;
44 // Needed to find out how much the tweakers changed sizes to update the other
45 // views.
46 IBOutlet GTMWidthBasedTweaker* dangerousButtonTweaker_;
47 IBOutlet GTMWidthBasedTweaker* maliciousButtonTweaker_;
49 // Because the confirm text and button for dangerous downloads are determined
50 // at runtime, an outlet to the localizer is needed to construct the layout
51 // tweaker in awakeFromNib in order to adjust the UI after all strings are
52 // determined.
53 IBOutlet ChromeUILocalizer* localizer_;
55 IBOutlet NSImageView* image_;
57 scoped_ptr<DownloadItemMac> bridge_;
58 scoped_ptr<DownloadShelfContextMenuMac> menuBridge_;
60 // Weak pointer to the shelf that owns us.
61 DownloadShelfController* shelf_;
63 // The time at which this view was created.
64 base::Time creationTime_;
66 // Default font list to use for text metrics.
67 scoped_ptr<gfx::FontList> font_list_;
69 // The state of this item.
70 enum DownoadItemState {
71 kNormal,
72 kDangerous
73 } state_;
76 // Initialize controller for |downloadItem|.
77 - (id)initWithDownload:(content::DownloadItem*)downloadItem
78 shelf:(DownloadShelfController*)shelf
79 navigator:(content::PageNavigator*)navigator;
81 // Updates the UI and menu state from |downloadModel|.
82 - (void)setStateFromDownload:(DownloadItemModel*)downloadModel;
84 // Remove ourself from the download UI.
85 - (void)remove;
87 // Update item's visibility depending on if the item is still completely
88 // contained in its parent.
89 - (void)updateVisibility:(id)sender;
91 // Called after a download is opened.
92 - (void)downloadWasOpened;
94 // Asynchronous icon loading callback.
95 - (void)setIcon:(NSImage*)icon;
97 // Download item button clicked
98 - (IBAction)handleButtonClick:(id)sender;
100 // Returns the size this item wants to have.
101 - (NSSize)preferredSize;
103 // Returns the DownloadItem model object belonging to this item.
104 - (content::DownloadItem*)download;
106 // Returns the MenuModel for the download item context menu. The returned
107 // MenuModel is owned by the DownloadItemController and will be valid until the
108 // DownloadItemController is destroyed.
109 - (ui::MenuModel*)contextMenuModel;
111 // Updates the tooltip with the download's path.
112 - (void)updateToolTip;
114 // Handling of dangerous downloads
115 - (void)clearDangerousMode;
116 - (BOOL)isDangerousMode;
117 - (IBAction)saveDownload:(id)sender;
118 - (IBAction)discardDownload:(id)sender;
119 - (IBAction)dismissMaliciousDownload:(id)sender;
120 - (IBAction)showContextMenu:(id)sender;
121 @end