OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include "base/mac/objc_property_releaser.h" | |
11 #import "base/mac/scoped_nsobject.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" | |
14 #import "ui/base/cocoa/menu_controller.h" | |
15 | |
16 class BookmarkMenuBridge; | |
17 class Browser; | |
18 @class BrowserActionsContainerView; | |
19 @class BrowserActionsController; | |
20 @class MenuTrackedRootView; | |
21 class RecentTabsMenuModelDelegate; | |
22 @class ToolbarController; | |
23 @class WrenchMenuButtonViewController; | |
24 class AppMenuModel; | |
25 | |
26 namespace wrench_menu_controller { | |
27 // The vertical offset of the wrench bubbles from the wrench menu button. | |
28 extern const CGFloat kWrenchBubblePointOffsetY; | |
29 } | |
30 | |
31 namespace WrenchMenuControllerInternal { | |
32 class AcceleratorDelegate; | |
33 class ToolbarActionsBarObserverHelper; | |
34 class ZoomLevelObserver; | |
35 } // namespace WrenchMenuControllerInternal | |
36 | |
37 // The Wrench menu has a creative layout, with buttons in menu items. There is | |
38 // a cross-platform model for this special menu, but on the Mac it's easier to | |
39 // get spacing and alignment precisely right using a NIB. To do that, we | |
40 // subclass the generic MenuController implementation and special-case the two | |
41 // items that require specific layout and load them from the NIB. | |
42 // | |
43 // This object is owned by the ToolbarController and receives its NIB-based | |
44 // views using the shim view controller below. | |
45 @interface WrenchMenuController | |
46 : MenuController<NSMenuDelegate, HasWeakBrowserPointer> { | |
47 @private | |
48 // Used to provide accelerators for the menu. | |
49 scoped_ptr<WrenchMenuControllerInternal::AcceleratorDelegate> | |
50 acceleratorDelegate_; | |
51 | |
52 // The model, rebuilt each time the |-menuNeedsUpdate:|. | |
53 scoped_ptr<AppMenuModel> appMenuModel_; | |
54 | |
55 // Used to update icons in the recent tabs menu. This must be declared after | |
56 // |appMenuModel_| so that it gets deleted first. | |
57 scoped_ptr<RecentTabsMenuModelDelegate> recentTabsMenuModelDelegate_; | |
58 | |
59 // A shim NSViewController that loads the buttons from the NIB because ObjC | |
60 // doesn't have multiple inheritance as this class is a MenuController. | |
61 base::scoped_nsobject<WrenchMenuButtonViewController> buttonViewController_; | |
62 | |
63 // The browser for which this controller exists. | |
64 Browser* browser_; // weak | |
65 | |
66 // Used to build the bookmark submenu. | |
67 scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_; | |
68 | |
69 // Observer for page zoom level change notifications. | |
70 scoped_ptr<WrenchMenuControllerInternal::ZoomLevelObserver> | |
71 zoom_level_observer_; | |
72 | |
73 // Observer for the main window's ToolbarActionsBar changing size. | |
74 scoped_ptr<WrenchMenuControllerInternal::ToolbarActionsBarObserverHelper> | |
75 toolbar_actions_bar_observer_; | |
76 | |
77 // The controller for the toolbar actions overflow that is stored in the | |
78 // wrench menu. | |
79 // This will only be present if the extension action redesign switch is on. | |
80 base::scoped_nsobject<BrowserActionsController> browserActionsController_; | |
81 | |
82 // The menu item containing the browser actions overflow container. | |
83 NSMenuItem* browserActionsMenuItem_; | |
84 } | |
85 | |
86 // Designated initializer. | |
87 - (id)initWithBrowser:(Browser*)browser; | |
88 | |
89 // Used to dispatch commands from the Wrench menu. The custom items within the | |
90 // menu cannot be hooked up directly to First Responder because the window in | |
91 // which the controls reside is not the BrowserWindowController, but a | |
92 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system. | |
93 - (IBAction)dispatchWrenchMenuCommand:(id)sender; | |
94 | |
95 // Returns the weak reference to the AppMenuModel. | |
96 - (AppMenuModel*)appMenuModel; | |
97 | |
98 // Creates a RecentTabsMenuModelDelegate instance which will take care of | |
99 // updating the recent tabs submenu. | |
100 - (void)updateRecentTabsSubmenu; | |
101 | |
102 // Updates the browser actions section of the menu. | |
103 - (void)updateBrowserActionsSubmenu; | |
104 | |
105 // Retuns the weak reference to the BrowserActionsController. | |
106 - (BrowserActionsController*)browserActionsController; | |
107 | |
108 @end | |
109 | |
110 //////////////////////////////////////////////////////////////////////////////// | |
111 | |
112 // Shim view controller that merely unpacks objects from a NIB. | |
113 @interface WrenchMenuButtonViewController : NSViewController { | |
114 @private | |
115 WrenchMenuController* controller_; | |
116 | |
117 MenuTrackedRootView* editItem_; | |
118 NSButton* editCut_; | |
119 NSButton* editCopy_; | |
120 NSButton* editPaste_; | |
121 | |
122 MenuTrackedRootView* zoomItem_; | |
123 NSButton* zoomPlus_; | |
124 NSButton* zoomDisplay_; | |
125 NSButton* zoomMinus_; | |
126 NSButton* zoomFullScreen_; | |
127 | |
128 MenuTrackedRootView* toolbarActionsOverflowItem_; | |
129 BrowserActionsContainerView* overflowActionsContainerView_; | |
130 | |
131 base::mac::ObjCPropertyReleaser propertyReleaser_; | |
132 } | |
133 | |
134 @property(retain, nonatomic) IBOutlet MenuTrackedRootView* editItem; | |
135 @property(retain, nonatomic) IBOutlet NSButton* editCut; | |
136 @property(retain, nonatomic) IBOutlet NSButton* editCopy; | |
137 @property(retain, nonatomic) IBOutlet NSButton* editPaste; | |
138 @property(retain, nonatomic) IBOutlet MenuTrackedRootView* zoomItem; | |
139 @property(retain, nonatomic) IBOutlet NSButton* zoomPlus; | |
140 @property(retain, nonatomic) IBOutlet NSButton* zoomDisplay; | |
141 @property(retain, nonatomic) IBOutlet NSButton* zoomMinus; | |
142 @property(retain, nonatomic) IBOutlet NSButton* zoomFullScreen; | |
143 @property(retain, nonatomic) | |
144 IBOutlet MenuTrackedRootView* toolbarActionsOverflowItem; | |
145 @property(retain, nonatomic) | |
146 IBOutlet BrowserActionsContainerView* overflowActionsContainerView; | |
147 | |
148 - (id)initWithController:(WrenchMenuController*)controller; | |
149 - (IBAction)dispatchWrenchMenuCommand:(id)sender; | |
150 | |
151 @end | |
152 | |
153 #endif // CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | |
OLD | NEW |