| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" | 5 #import "chrome/browser/ui/cocoa/wrench_menu/wrench_menu_controller.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #import "chrome/browser/app_controller_mac.h" | 13 #import "chrome/browser/app_controller_mac.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_window.h" | 16 #include "chrome/browser/ui/browser_window.h" |
| 17 #import "chrome/browser/ui/cocoa/accelerators_cocoa.h" | 17 #import "chrome/browser/ui/cocoa/accelerators_cocoa.h" |
| 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_bridge.h" |
| 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" | 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu_cocoa_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 20 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 21 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" |
| 21 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" | 22 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" |
| 22 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" | 23 #import "chrome/browser/ui/cocoa/encoding_menu_controller_delegate_mac.h" |
| 23 #import "chrome/browser/ui/cocoa/l10n_util.h" | 24 #import "chrome/browser/ui/cocoa/l10n_util.h" |
| 24 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 25 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 25 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_root_view.h" | 26 #import "chrome/browser/ui/cocoa/wrench_menu/menu_tracked_root_view.h" |
| 26 #import "chrome/browser/ui/cocoa/wrench_menu/recent_tabs_menu_model_delegate.h" | 27 #import "chrome/browser/ui/cocoa/wrench_menu/recent_tabs_menu_model_delegate.h" |
| 27 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" | 28 #include "chrome/browser/ui/toolbar/recent_tabs_sub_menu_model.h" |
| 28 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 29 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
| 29 #include "chrome/grit/generated_resources.h" | 30 #include "chrome/grit/generated_resources.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 // Handle the special-cased menu items. | 131 // Handle the special-cased menu items. |
| 131 base::scoped_nsobject<NSMenuItem> customItem( | 132 base::scoped_nsobject<NSMenuItem> customItem( |
| 132 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); | 133 [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]); |
| 133 MenuTrackedRootView* view = nil; | 134 MenuTrackedRootView* view = nil; |
| 134 switch (command_id) { | 135 switch (command_id) { |
| 135 case IDC_EXTENSIONS_OVERFLOW_MENU: { | 136 case IDC_EXTENSIONS_OVERFLOW_MENU: { |
| 136 view = [buttonViewController_ toolbarActionsOverflowItem]; | 137 view = [buttonViewController_ toolbarActionsOverflowItem]; |
| 137 BrowserActionsContainerView* containerView = | 138 BrowserActionsContainerView* containerView = |
| 138 [buttonViewController_ overflowActionsContainerView]; | 139 [buttonViewController_ overflowActionsContainerView]; |
| 139 | 140 |
| 141 // The overflow browser actions container can't function properly without |
| 142 // a main counterpart, so if the browser window hasn't initialized, abort. |
| 143 // (This is fine because we re-populate the wrench menu each time before |
| 144 // we show it.) |
| 145 if (!browser_->window()) |
| 146 break; |
| 147 |
| 148 BrowserActionsController* mainController = |
| 149 [[[BrowserWindowController browserWindowControllerForWindow:browser_-> |
| 150 window()->GetNativeWindow()] toolbarController] |
| 151 browserActionsController]; |
| 140 browserActionsController_.reset( | 152 browserActionsController_.reset( |
| 141 [[BrowserActionsController alloc] | 153 [[BrowserActionsController alloc] |
| 142 initWithBrowser:browser_ | 154 initWithBrowser:browser_ |
| 143 containerView:containerView | 155 containerView:containerView |
| 144 isOverflow:YES]); | 156 mainController:mainController]); |
| 145 | 157 |
| 146 // Set the origins and preferred size for the container. | 158 // Set the origins and preferred size for the container. |
| 147 gfx::Size preferredSize = [browserActionsController_ preferredSize]; | 159 gfx::Size preferredSize = [browserActionsController_ preferredSize]; |
| 148 NSSize preferredNSSize = NSMakeSize(preferredSize.width(), | 160 NSSize preferredNSSize = NSMakeSize(preferredSize.width(), |
| 149 preferredSize.height()); | 161 preferredSize.height()); |
| 150 // View hierarchy is as follows (from parent > child): | 162 // View hierarchy is as follows (from parent > child): |
| 151 // |view| > |anonymous view| > containerView. We have to set the origin | 163 // |view| > |anonymous view| > containerView. We have to set the origin |
| 152 // and size of each for it display properly. | 164 // and size of each for it display properly. |
| 153 [view setFrameSize:preferredNSSize]; | 165 [view setFrameSize:preferredNSSize]; |
| 154 [view setFrameOrigin:NSMakePoint(0, 0)]; | 166 [view setFrameOrigin:NSMakePoint(0, 0)]; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 controller_ = controller; | 450 controller_ = controller; |
| 439 } | 451 } |
| 440 return self; | 452 return self; |
| 441 } | 453 } |
| 442 | 454 |
| 443 - (IBAction)dispatchWrenchMenuCommand:(id)sender { | 455 - (IBAction)dispatchWrenchMenuCommand:(id)sender { |
| 444 [controller_ dispatchWrenchMenuCommand:sender]; | 456 [controller_ dispatchWrenchMenuCommand:sender]; |
| 445 } | 457 } |
| 446 | 458 |
| 447 @end // @implementation WrenchMenuButtonViewController | 459 @end // @implementation WrenchMenuButtonViewController |
| OLD | NEW |