| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" | 12 #import "chrome/browser/ui/cocoa/has_weak_browser_pointer.h" |
| 13 #import "ui/base/cocoa/menu_controller.h" | 13 #import "ui/base/cocoa/menu_controller.h" |
| 14 | 14 |
| 15 class BookmarkMenuBridge; | 15 class BookmarkMenuBridge; |
| 16 class Browser; | 16 class Browser; |
| 17 @class BrowserActionsContainerView; | 17 @class BrowserActionsContainerView; |
| 18 @class BrowserActionsController; | 18 @class BrowserActionsController; |
| 19 @class MenuTrackedRootView; | 19 @class MenuTrackedRootView; |
| 20 class RecentTabsMenuModelDelegate; | 20 class RecentTabsMenuModelDelegate; |
| 21 @class ToolbarController; | 21 @class ToolbarController; |
| 22 @class WrenchMenuButtonViewController; | 22 @class WrenchMenuButtonViewController; |
| 23 class WrenchMenuModel; | 23 class AppMenuModel; |
| 24 | 24 |
| 25 namespace wrench_menu_controller { | 25 namespace wrench_menu_controller { |
| 26 // The vertical offset of the wrench bubbles from the wrench menu button. | 26 // The vertical offset of the wrench bubbles from the wrench menu button. |
| 27 extern const CGFloat kWrenchBubblePointOffsetY; | 27 extern const CGFloat kWrenchBubblePointOffsetY; |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace WrenchMenuControllerInternal { | 30 namespace WrenchMenuControllerInternal { |
| 31 class AcceleratorDelegate; | 31 class AcceleratorDelegate; |
| 32 class ToolbarActionsBarObserverHelper; | 32 class ToolbarActionsBarObserverHelper; |
| 33 class ZoomLevelObserver; | 33 class ZoomLevelObserver; |
| 34 } // namespace WrenchMenuControllerInternal | 34 } // namespace WrenchMenuControllerInternal |
| 35 | 35 |
| 36 // The Wrench menu has a creative layout, with buttons in menu items. There is | 36 // The Wrench menu has a creative layout, with buttons in menu items. There is |
| 37 // a cross-platform model for this special menu, but on the Mac it's easier to | 37 // a cross-platform model for this special menu, but on the Mac it's easier to |
| 38 // get spacing and alignment precisely right using a NIB. To do that, we | 38 // get spacing and alignment precisely right using a NIB. To do that, we |
| 39 // subclass the generic MenuController implementation and special-case the two | 39 // subclass the generic MenuController implementation and special-case the two |
| 40 // items that require specific layout and load them from the NIB. | 40 // items that require specific layout and load them from the NIB. |
| 41 // | 41 // |
| 42 // This object is owned by the ToolbarController and receives its NIB-based | 42 // This object is owned by the ToolbarController and receives its NIB-based |
| 43 // views using the shim view controller below. | 43 // views using the shim view controller below. |
| 44 @interface WrenchMenuController | 44 @interface WrenchMenuController |
| 45 : MenuController<NSMenuDelegate, HasWeakBrowserPointer> { | 45 : MenuController<NSMenuDelegate, HasWeakBrowserPointer> { |
| 46 @private | 46 @private |
| 47 // Used to provide accelerators for the menu. | 47 // Used to provide accelerators for the menu. |
| 48 scoped_ptr<WrenchMenuControllerInternal::AcceleratorDelegate> | 48 scoped_ptr<WrenchMenuControllerInternal::AcceleratorDelegate> |
| 49 acceleratorDelegate_; | 49 acceleratorDelegate_; |
| 50 | 50 |
| 51 // The model, rebuilt each time the |-menuNeedsUpdate:|. | 51 // The model, rebuilt each time the |-menuNeedsUpdate:|. |
| 52 scoped_ptr<WrenchMenuModel> wrenchMenuModel_; | 52 scoped_ptr<AppMenuModel> appMenuModel_; |
| 53 | 53 |
| 54 // Used to update icons in the recent tabs menu. This must be declared after | 54 // Used to update icons in the recent tabs menu. This must be declared after |
| 55 // |wrenchMenuModel_| so that it gets deleted first. | 55 // |appMenuModel_| so that it gets deleted first. |
| 56 scoped_ptr<RecentTabsMenuModelDelegate> recentTabsMenuModelDelegate_; | 56 scoped_ptr<RecentTabsMenuModelDelegate> recentTabsMenuModelDelegate_; |
| 57 | 57 |
| 58 // A shim NSViewController that loads the buttons from the NIB because ObjC | 58 // A shim NSViewController that loads the buttons from the NIB because ObjC |
| 59 // doesn't have multiple inheritance as this class is a MenuController. | 59 // doesn't have multiple inheritance as this class is a MenuController. |
| 60 base::scoped_nsobject<WrenchMenuButtonViewController> buttonViewController_; | 60 base::scoped_nsobject<WrenchMenuButtonViewController> buttonViewController_; |
| 61 | 61 |
| 62 // The browser for which this controller exists. | 62 // The browser for which this controller exists. |
| 63 Browser* browser_; // weak | 63 Browser* browser_; // weak |
| 64 | 64 |
| 65 // Used to build the bookmark submenu. | 65 // Used to build the bookmark submenu. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 84 | 84 |
| 85 // Designated initializer. | 85 // Designated initializer. |
| 86 - (id)initWithBrowser:(Browser*)browser; | 86 - (id)initWithBrowser:(Browser*)browser; |
| 87 | 87 |
| 88 // Used to dispatch commands from the Wrench menu. The custom items within the | 88 // Used to dispatch commands from the Wrench menu. The custom items within the |
| 89 // menu cannot be hooked up directly to First Responder because the window in | 89 // menu cannot be hooked up directly to First Responder because the window in |
| 90 // which the controls reside is not the BrowserWindowController, but a | 90 // which the controls reside is not the BrowserWindowController, but a |
| 91 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system. | 91 // NSCarbonMenuWindow; this screws up the typical |-commandDispatch:| system. |
| 92 - (IBAction)dispatchWrenchMenuCommand:(id)sender; | 92 - (IBAction)dispatchWrenchMenuCommand:(id)sender; |
| 93 | 93 |
| 94 // Returns the weak reference to the WrenchMenuModel. | 94 // Returns the weak reference to the AppMenuModel. |
| 95 - (WrenchMenuModel*)wrenchMenuModel; | 95 - (AppMenuModel*)appMenuModel; |
| 96 | 96 |
| 97 // Creates a RecentTabsMenuModelDelegate instance which will take care of | 97 // Creates a RecentTabsMenuModelDelegate instance which will take care of |
| 98 // updating the recent tabs submenu. | 98 // updating the recent tabs submenu. |
| 99 - (void)updateRecentTabsSubmenu; | 99 - (void)updateRecentTabsSubmenu; |
| 100 | 100 |
| 101 // Updates the browser actions section of the menu. | 101 // Updates the browser actions section of the menu. |
| 102 - (void)updateBrowserActionsSubmenu; | 102 - (void)updateBrowserActionsSubmenu; |
| 103 | 103 |
| 104 // Retuns the weak reference to the BrowserActionsController. | 104 // Retuns the weak reference to the BrowserActionsController. |
| 105 - (BrowserActionsController*)browserActionsController; | 105 - (BrowserActionsController*)browserActionsController; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 IBOutlet MenuTrackedRootView* toolbarActionsOverflowItem; | 141 IBOutlet MenuTrackedRootView* toolbarActionsOverflowItem; |
| 142 @property(assign, nonatomic) | 142 @property(assign, nonatomic) |
| 143 IBOutlet BrowserActionsContainerView* overflowActionsContainerView; | 143 IBOutlet BrowserActionsContainerView* overflowActionsContainerView; |
| 144 | 144 |
| 145 - (id)initWithController:(WrenchMenuController*)controller; | 145 - (id)initWithController:(WrenchMenuController*)controller; |
| 146 - (IBAction)dispatchWrenchMenuCommand:(id)sender; | 146 - (IBAction)dispatchWrenchMenuCommand:(id)sender; |
| 147 | 147 |
| 148 @end | 148 @end |
| 149 | 149 |
| 150 #endif // CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ | 150 #endif // CHROME_BROWSER_UI_COCOA_WRENCH_MENU_WRENCH_MENU_CONTROLLER_H_ |
| OLD | NEW |