[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / wrench_menu / wrench_menu_controller.h
blobedfa6ceb2ca4285f228e33f3c26e5b820eb01a55
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 #ifndef CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #include "base/memory/scoped_ptr.h"
11 #import "ui/base/cocoa/menu_controller.h"
13 class BookmarkMenuBridge;
14 class Browser;
15 @class MenuTrackedRootView;
16 class RecentTabsMenuModelDelegate;
17 @class ToolbarController;
18 @class WrenchMenuButtonViewController;
19 class WrenchMenuModel;
21 namespace wrench_menu_controller {
22 // The vertical offset of the wrench bubbles from the wrench menu button.
23 extern const CGFloat kWrenchBubblePointOffsetY;
26 namespace WrenchMenuControllerInternal {
27 class AcceleratorDelegate;
28 class ZoomLevelObserver;
29 } // namespace WrenchMenuControllerInternal
31 // The Wrench menu has a creative layout, with buttons in menu items. There is
32 // a cross-platform model for this special menu, but on the Mac it's easier to
33 // get spacing and alignment precisely right using a NIB. To do that, we
34 // subclass the generic MenuController implementation and special-case the two
35 // items that require specific layout and load them from the NIB.
37 // This object is owned by the ToolbarController and receives its NIB-based
38 // views using the shim view controller below.
39 @interface WrenchMenuController : MenuController<NSMenuDelegate> {
40 @private
41 // Used to provide accelerators for the menu.
42 scoped_ptr<WrenchMenuControllerInternal::AcceleratorDelegate>
43 acceleratorDelegate_;
45 // The model, rebuilt each time the |-menuNeedsUpdate:|.
46 scoped_ptr<WrenchMenuModel> wrenchMenuModel_;
48 // Used to update icons in the recent tabs menu. This must be declared after
49 // |wrenchMenuModel_| so that it gets deleted first.
50 scoped_ptr<RecentTabsMenuModelDelegate> recentTabsMenuModelDelegate_;
52 // A shim NSViewController that loads the buttons from the NIB because ObjC
53 // doesn't have multiple inheritance as this class is a MenuController.
54 base::scoped_nsobject<WrenchMenuButtonViewController> buttonViewController_;
56 // The browser for which this controller exists.
57 Browser* browser_; // weak
59 // Used to build the bookmark submenu.
60 scoped_ptr<BookmarkMenuBridge> bookmarkMenuBridge_;
62 // Observer for page zoom level change notifications.
63 scoped_ptr<WrenchMenuControllerInternal::ZoomLevelObserver> observer_;
66 // Designated initializer.
67 - (id)initWithBrowser:(Browser*)browser;
69 // Used to dispatch commands from the Wrench menu. The custom items within the
70 // menu cannot be hooked up directly to First Responder because the window in
71 // which the controls reside is not the BrowserWindowController, but a
72 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system.
73 - (IBAction)dispatchWrenchMenuCommand:(id)sender;
75 // Returns the weak reference to the WrenchMenuModel.
76 - (WrenchMenuModel*)wrenchMenuModel;
78 // Creates a RecentTabsMenuModelDelegate instance which will take care of
79 // updating the recent tabs submenu.
80 - (void)updateRecentTabsSubmenu;
82 @end
84 ////////////////////////////////////////////////////////////////////////////////
86 // Shim view controller that merely unpacks objects from a NIB.
87 @interface WrenchMenuButtonViewController : NSViewController {
88 @private
89 WrenchMenuController* controller_;
91 MenuTrackedRootView* editItem_;
92 NSButton* editCut_;
93 NSButton* editCopy_;
94 NSButton* editPaste_;
96 MenuTrackedRootView* zoomItem_;
97 NSButton* zoomPlus_;
98 NSButton* zoomDisplay_;
99 NSButton* zoomMinus_;
100 NSButton* zoomFullScreen_;
103 @property(assign, nonatomic) IBOutlet MenuTrackedRootView* editItem;
104 @property(assign, nonatomic) IBOutlet NSButton* editCut;
105 @property(assign, nonatomic) IBOutlet NSButton* editCopy;
106 @property(assign, nonatomic) IBOutlet NSButton* editPaste;
107 @property(assign, nonatomic) IBOutlet MenuTrackedRootView* zoomItem;
108 @property(assign, nonatomic) IBOutlet NSButton* zoomPlus;
109 @property(assign, nonatomic) IBOutlet NSButton* zoomDisplay;
110 @property(assign, nonatomic) IBOutlet NSButton* zoomMinus;
111 @property(assign, nonatomic) IBOutlet NSButton* zoomFullScreen;
113 - (id)initWithController:(WrenchMenuController*)controller;
114 - (IBAction)dispatchWrenchMenuCommand:(id)sender;
116 @end
118 #endif // CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_