OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <numeric> | 8 #include <numeric> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 1115 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
1116 SEL action = [item action]; | 1116 SEL action = [item action]; |
1117 BOOL enable = NO; | 1117 BOOL enable = NO; |
1118 if (action == @selector(commandDispatch:) || | 1118 if (action == @selector(commandDispatch:) || |
1119 action == @selector(commandDispatchUsingKeyModifiers:)) { | 1119 action == @selector(commandDispatchUsingKeyModifiers:)) { |
1120 NSInteger tag = [item tag]; | 1120 NSInteger tag = [item tag]; |
1121 if (chrome::SupportsCommand(browser_.get(), tag)) { | 1121 if (chrome::SupportsCommand(browser_.get(), tag)) { |
1122 // Generate return value (enabled state) | 1122 // Generate return value (enabled state) |
1123 enable = chrome::IsCommandEnabled(browser_.get(), tag); | 1123 enable = chrome::IsCommandEnabled(browser_.get(), tag); |
1124 switch (tag) { | 1124 switch (tag) { |
| 1125 case IDC_SHOW_AS_TAB: |
| 1126 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { |
| 1127 bool shouldHide = browser_->is_type_tabbed(); |
| 1128 [menuItem setHidden:shouldHide]; |
| 1129 } |
| 1130 break; |
| 1131 case IDC_NEW_TAB: |
| 1132 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { |
| 1133 bool shouldHide = !browser_->is_type_tabbed(); |
| 1134 [menuItem setHidden:shouldHide]; |
| 1135 } |
| 1136 break; |
1125 case IDC_CLOSE_TAB: | 1137 case IDC_CLOSE_TAB: |
1126 // Disable "close tab" if the receiving window is not tabbed. | 1138 // Disable "close tab" if the receiving window is not tabbed. |
1127 // We simply check whether the item has a keyboard shortcut set here; | 1139 // We simply check whether the item has a keyboard shortcut set here; |
1128 // app_controller_mac.mm actually determines whether the item should | 1140 // app_controller_mac.mm actually determines whether the item should |
1129 // be enabled. | 1141 // be enabled. |
1130 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) | 1142 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) |
1131 enable &= !![[menuItem keyEquivalent] length]; | 1143 enable &= !![[menuItem keyEquivalent] length]; |
1132 break; | 1144 break; |
1133 case IDC_FULLSCREEN: { | 1145 case IDC_FULLSCREEN: { |
1134 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { | 1146 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) { |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 | 2284 |
2273 - (BOOL)supportsBookmarkBar { | 2285 - (BOOL)supportsBookmarkBar { |
2274 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2286 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2275 } | 2287 } |
2276 | 2288 |
2277 - (BOOL)isTabbedWindow { | 2289 - (BOOL)isTabbedWindow { |
2278 return browser_->is_type_tabbed(); | 2290 return browser_->is_type_tabbed(); |
2279 } | 2291 } |
2280 | 2292 |
2281 @end // @implementation BrowserWindowController(WindowType) | 2293 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |