File: download_shelf_controller.h

package info (click to toggle)
chromium-browser 41.0.2272.118-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 2,189,132 kB
  • sloc: cpp: 9,691,462; ansic: 3,341,451; python: 712,689; asm: 518,779; xml: 208,926; java: 169,820; sh: 119,353; perl: 68,907; makefile: 28,311; yacc: 13,305; objc: 11,385; tcl: 3,186; cs: 2,225; sql: 2,217; lex: 2,215; lisp: 1,349; pascal: 1,256; awk: 407; ruby: 155; sed: 53; php: 14; exp: 11
file content (133 lines) | stat: -rw-r--r-- 4,602 bytes parent folder | download | duplicates (2)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright (c) 2012 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/mac/scoped_nsobject.h"
#include "base/memory/scoped_ptr.h"
#import "chrome/browser/ui/cocoa/view_resizer.h"
#include "ui/base/cocoa/tracking_area.h"

@class AnimatableView;
class Browser;
@class BrowserWindowController;
@class DownloadItemController;
class DownloadShelf;
@class DownloadShelfView;
@class HyperlinkButtonCell;
@class HoverButton;

namespace content {
class DownloadItem;
class PageNavigator;
}

// A controller class that manages the download shelf for one window. It is
// responsible for the behavior of the shelf itself (showing/hiding, handling
// the link, layout) as well as for managing the download items it contains.
//
// All the files in cocoa/downloads_* are related as follows:
//
// download_shelf_mac bridges calls from chromium's c++ world to the objc
// download_shelf_controller for the shelf (this file). The shelf's background
// is drawn by download_shelf_view. Every item in a shelf is controlled by a
// download_item_controller.
//
// download_item_mac bridges calls from chromium's c++ world to the objc
// download_item_controller, which is responsible for managing a single item
// on the shelf. The item controller loads its UI from a xib file, where the
// UI of an item itself is represented by a button that is drawn by
// download_item_cell.

@interface DownloadShelfController : NSViewController<NSTextViewDelegate> {
 @private
  IBOutlet HoverButton* hoverCloseButton_;

  // YES if the download shelf is intended to be displayed. The shelf animates
  // out when it is closing. During this time, barIsVisible_ is NO although the
  // shelf is still visible on screen.
  BOOL barIsVisible_;

  // YES if the containing browser window is fullscreen.
  BOOL isFullscreen_;

  // YES if the shelf should be closed when the mouse leaves the shelf.
  BOOL shouldCloseOnMouseExit_;

  // YES if the mouse is currently over the download shelf.
  BOOL isMouseInsideView_;

  scoped_ptr<DownloadShelf> bridge_;

  // Height of the shelf when it's fully visible.
  CGFloat maxShelfHeight_;

  // Current height of the shelf. Changes while the shelf is animating in or
  // out.
  CGFloat currentShelfHeight_;

  // Used to autoclose the shelf when the mouse is moved off it.
  ui::ScopedCrTrackingArea trackingArea_;

  // The download items we have added to our shelf.
  base::scoped_nsobject<NSMutableArray> downloadItemControllers_;

  // The container that contains (and clamps) all the download items.
  IBOutlet NSView* itemContainerView_;

  // Delegate that handles resizing our view.
  id<ViewResizer> resizeDelegate_;

  // Used for loading pages.
  content::PageNavigator* navigator_;
};

- (id)initWithBrowser:(Browser*)browser
       resizeDelegate:(id<ViewResizer>)resizeDelegate;

// Run when the user clicks the 'Show All' button.
- (IBAction)showDownloadsTab:(id)sender;

// Run when the user clicks the close button on the right side of the shelf.
- (IBAction)handleClose:(id)sender;

// Shows or hides the download shelf based on the value of |show|.
// |isUserAction| should be YES if the operation is being triggered based on a
// user action (currently only relevant when hiding the shelf).
// Note: This is intended to be invoked from DownloadShelfMac. If invoked
// directly, the shelf visibility state maintained by DownloadShelf and the
// owning Browser will not be updated.
- (void)showDownloadShelf:(BOOL)show
             isUserAction:(BOOL)isUserAction;

// Returns our view cast as an AnimatableView.
- (AnimatableView*)animatableView;

- (DownloadShelf*)bridge;
- (BOOL)isVisible;

// Add a new download item to the leftmost position of the download shelf. The
// item should not have been already added to this shelf.
- (void)addDownloadItem:(content::DownloadItem*)downloadItem;

// Similar to addDownloadItem above, but adds a DownloadItemController.
- (void)add:(DownloadItemController*)download;

// Remove a download, possibly via clearing browser data.
- (void)remove:(DownloadItemController*)download;

// Called by individual item controllers when their downloads are opened.
- (void)downloadWasOpened:(DownloadItemController*)download;

// Notification that the download shelf is going to be destroyed and should
// release the downloads.
- (void)exiting;

// Return the height of the download shelf.
- (float)height;

// Re-layouts all download items based on their current state.
- (void)layoutItems;

@end