Check USB device path access when prompting users to select a device.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / extensions / browser_actions_controller.h
blobaf71cd3dce2dd8442a4d30015e2c925fee469360
1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #import "base/mac/scoped_nsobject.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/gfx/geometry/size.h"
14 class Browser;
15 @class BrowserActionButton;
16 @class BrowserActionsContainerView;
17 @class MenuButton;
18 class ToolbarActionsBar;
19 class ToolbarActionsBarDelegate;
21 namespace content {
22 class WebContents;
25 // Sent when the visibility of the Browser Actions changes.
26 extern NSString* const kBrowserActionVisibilityChangedNotification;
28 // Handles state and provides an interface for controlling the Browser Actions
29 // container within the Toolbar.
30 @interface BrowserActionsController : NSObject<NSMenuDelegate> {
31 @private
32 // Reference to the current browser. Weak.
33 Browser* browser_;
35 // The view from Toolbar.xib we'll be rendering our browser actions in. Weak.
36 BrowserActionsContainerView* containerView_;
38 // Array of toolbar action buttons in the correct order for them to be
39 // displayed (includes both hidden and visible buttons).
40 base::scoped_nsobject<NSMutableArray> buttons_;
42 // The delegate for the ToolbarActionsBar.
43 scoped_ptr<ToolbarActionsBarDelegate> toolbarActionsBarBridge_;
45 // The controlling ToolbarActionsBar.
46 scoped_ptr<ToolbarActionsBar> toolbarActionsBar_;
48 // True if we should supppress the chevron (we do this during drag
49 // animations).
50 BOOL suppressChevron_;
52 // True if this is the overflow container for toolbar actions.
53 BOOL isOverflow_;
55 // The currently running chevron animation (fade in/out).
56 base::scoped_nsobject<NSViewAnimation> chevronAnimation_;
58 // The chevron button used when Browser Actions are hidden.
59 base::scoped_nsobject<MenuButton> chevronMenuButton_;
61 // The Browser Actions overflow menu.
62 base::scoped_nsobject<NSMenu> overflowMenu_;
65 @property(readonly, nonatomic) BrowserActionsContainerView* containerView;
66 @property(readonly, nonatomic) Browser* browser;
67 @property(readonly, nonatomic) BOOL isOverflow;
69 // Initializes the controller given the current browser and container view that
70 // will hold the browser action buttons. If |mainController| is nil, the created
71 // BrowserActionsController will be the main controller; otherwise (if this is
72 // for the overflow menu), |mainController| should be controller of the main bar
73 // for the |browser|.
74 - (id)initWithBrowser:(Browser*)browser
75 containerView:(BrowserActionsContainerView*)container
76 mainController:(BrowserActionsController*)mainController;
78 // Update the display of all buttons.
79 - (void)update;
81 // Returns the current number of browser action buttons within the container,
82 // whether or not they are displayed.
83 - (NSUInteger)buttonCount;
85 // Returns the current number of browser action buttons displayed in the
86 // container.
87 - (NSUInteger)visibleButtonCount;
89 // Returns the preferred size for the container.
90 - (gfx::Size)preferredSize;
92 // Returns where the popup arrow should point to for the action with the given
93 // |id|. If passed an id with no corresponding button, returns NSZeroPoint.
94 - (NSPoint)popupPointForId:(const std::string&)id;
96 // Returns whether the chevron button is currently hidden or in the process of
97 // being hidden (fading out). Will return NO if it is not hidden or is in the
98 // process of fading in.
99 - (BOOL)chevronIsHidden;
101 // Returns the currently-active web contents.
102 - (content::WebContents*)currentWebContents;
104 // Returns the BrowserActionButton in the main browser actions container (as
105 // opposed to the overflow) for the action of the given id.
106 - (BrowserActionButton*)mainButtonForId:(const std::string&)id;
108 @end // @interface BrowserActionsController
110 @interface BrowserActionsController(TestingAPI)
111 - (BrowserActionButton*)buttonWithIndex:(NSUInteger)index;
112 - (ToolbarActionsBar*)toolbarActionsBar;
113 + (BrowserActionsController*)fromToolbarActionsBarDelegate:
114 (ToolbarActionsBarDelegate*)delegate;
115 @end
117 #endif // CHROME_BROWSER_UI_COCOA_EXTENSIONS_BROWSER_ACTIONS_CONTROLLER_H_