Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / download / download_shelf_controller.h
blobc264571b6f8b94217f042a1f89b43164b281ed6a
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/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h"
9 #import "chrome/browser/ui/cocoa/view_resizer.h"
10 #include "ui/base/cocoa/tracking_area.h"
12 @class AnimatableView;
13 class Browser;
14 @class BrowserWindowController;
15 @class DownloadItemController;
16 class DownloadShelf;
17 @class DownloadShelfView;
18 @class HyperlinkButtonCell;
19 @class HoverButton;
21 namespace content {
22 class DownloadItem;
23 class PageNavigator;
26 // A controller class that manages the download shelf for one window. It is
27 // responsible for the behavior of the shelf itself (showing/hiding, handling
28 // the link, layout) as well as for managing the download items it contains.
30 // All the files in cocoa/downloads_* are related as follows:
32 // download_shelf_mac bridges calls from chromium's c++ world to the objc
33 // download_shelf_controller for the shelf (this file). The shelf's background
34 // is drawn by download_shelf_view. Every item in a shelf is controlled by a
35 // download_item_controller.
37 // download_item_mac bridges calls from chromium's c++ world to the objc
38 // download_item_controller, which is responsible for managing a single item
39 // on the shelf. The item controller loads its UI from a xib file, where the
40 // UI of an item itself is represented by a button that is drawn by
41 // download_item_cell.
43 @interface DownloadShelfController : NSViewController<NSTextViewDelegate> {
44 @private
45 IBOutlet HoverButton* hoverCloseButton_;
47 // YES if the download shelf is intended to be displayed. The shelf animates
48 // out when it is closing. During this time, barIsVisible_ is NO although the
49 // shelf is still visible on screen.
50 BOOL barIsVisible_;
52 // YES if the containing browser window is fullscreen.
53 BOOL isFullscreen_;
55 // YES if the shelf should be closed when the mouse leaves the shelf.
56 BOOL shouldCloseOnMouseExit_;
58 // YES if the mouse is currently over the download shelf.
59 BOOL isMouseInsideView_;
61 scoped_ptr<DownloadShelf> bridge_;
63 // Height of the shelf when it's fully visible.
64 CGFloat maxShelfHeight_;
66 // Current height of the shelf. Changes while the shelf is animating in or
67 // out.
68 CGFloat currentShelfHeight_;
70 // Used to autoclose the shelf when the mouse is moved off it.
71 ui::ScopedCrTrackingArea trackingArea_;
73 // The download items we have added to our shelf.
74 base::scoped_nsobject<NSMutableArray> downloadItemControllers_;
76 // The container that contains (and clamps) all the download items.
77 IBOutlet NSView* itemContainerView_;
79 // Delegate that handles resizing our view.
80 id<ViewResizer> resizeDelegate_;
82 // Used for loading pages.
83 content::PageNavigator* navigator_;
86 - (id)initWithBrowser:(Browser*)browser
87 resizeDelegate:(id<ViewResizer>)resizeDelegate;
89 // Run when the user clicks the 'Show All' button.
90 - (IBAction)showDownloadsTab:(id)sender;
92 // Run when the user clicks the close button on the right side of the shelf.
93 - (IBAction)handleClose:(id)sender;
95 // Shows or hides the download shelf based on the value of |show|.
96 // |isUserAction| should be YES if the operation is being triggered based on a
97 // user action (currently only relevant when hiding the shelf).
98 // Note: This is intended to be invoked from DownloadShelfMac. If invoked
99 // directly, the shelf visibility state maintained by DownloadShelf and the
100 // owning Browser will not be updated.
101 - (void)showDownloadShelf:(BOOL)show
102 isUserAction:(BOOL)isUserAction;
104 // Returns our view cast as an AnimatableView.
105 - (AnimatableView*)animatableView;
107 - (DownloadShelf*)bridge;
108 - (BOOL)isVisible;
110 // Add a new download item to the leftmost position of the download shelf. The
111 // item should not have been already added to this shelf.
112 - (void)addDownloadItem:(content::DownloadItem*)downloadItem;
114 // Similar to addDownloadItem above, but adds a DownloadItemController.
115 - (void)add:(DownloadItemController*)download;
117 // Remove a download, possibly via clearing browser data.
118 - (void)remove:(DownloadItemController*)download;
120 // Called by individual item controllers when their downloads are opened.
121 - (void)downloadWasOpened:(DownloadItemController*)download;
123 // Notification that the download shelf is going to be destroyed and should
124 // release the downloads.
125 - (void)exiting;
127 // Return the height of the download shelf.
128 - (float)height;
130 // Re-layouts all download items based on their current state.
131 - (void)layoutItems;
133 @end