| 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 #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 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 | 968 |
| 969 - (BOOL)supportsFullscreen { | 969 - (BOOL)supportsFullscreen { |
| 970 // TODO(avi, thakis): GTMWindowSheetController has no api to move | 970 // TODO(avi, thakis): GTMWindowSheetController has no api to move |
| 971 // tabsheets between windows. Until then, we have to prevent having to | 971 // tabsheets between windows. Until then, we have to prevent having to |
| 972 // move a tabsheet between windows, e.g. no fullscreen toggling | 972 // move a tabsheet between windows, e.g. no fullscreen toggling |
| 973 NSArray* a = [[tabStripController_ sheetController] viewsWithAttachedSheets]; | 973 NSArray* a = [[tabStripController_ sheetController] viewsWithAttachedSheets]; |
| 974 return [a count] == 0; | 974 return [a count] == 0; |
| 975 } | 975 } |
| 976 | 976 |
| 977 // Called to validate menu and toolbar items when this window is key. All the | 977 // Called to validate menu and toolbar items when this window is key. All the |
| 978 // items we care about have been set with the |-commandDispatch:| or | 978 // items we care about have been set with the -performClose:, -commandDispatch: |
| 979 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder | 979 // or -commandDispatchUsingKeyModifiers: actions and a target of FirstResponder |
| 980 // in IB. If it's not one of those, let it continue up the responder chain to be | 980 // in IB. If it's not one of those, let it continue up the responder chain to be |
| 981 // handled elsewhere. We pull out the tag as the cross-platform constant to | 981 // handled elsewhere. We pull out the tag as the cross-platform constant to |
| 982 // differentiate and dispatch the various commands. | 982 // differentiate and dispatch the various commands. |
| 983 // NOTE: we might have to handle state for app-wide menu items, | 983 // NOTE: we might have to handle state for app-wide menu items, |
| 984 // although we could cheat and directly ask the app controller if our | 984 // although we could cheat and directly ask the app controller if our |
| 985 // command_updater doesn't support the command. This may or may not be an issue, | 985 // command_updater doesn't support the command. This may or may not be an issue, |
| 986 // too early to tell. | 986 // too early to tell. |
| 987 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 987 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
| 988 SEL action = [item action]; | 988 SEL action = [item action]; |
| 989 BOOL enable = NO; | 989 BOOL enable = NO; |
| 990 if (action == @selector(commandDispatch:) || | 990 if (action == @selector(performClose:) || |
| 991 action == @selector(commandDispatch:) || |
| 991 action == @selector(commandDispatchUsingKeyModifiers:)) { | 992 action == @selector(commandDispatchUsingKeyModifiers:)) { |
| 992 NSInteger tag = [item tag]; | 993 NSInteger tag = [item tag]; |
| 993 if (browser_->command_updater()->SupportsCommand(tag)) { | 994 if (browser_->command_updater()->SupportsCommand(tag)) { |
| 994 // Generate return value (enabled state) | 995 // Generate return value (enabled state) |
| 995 enable = browser_->command_updater()->IsCommandEnabled(tag); | 996 enable = browser_->command_updater()->IsCommandEnabled(tag); |
| 996 switch (tag) { | 997 switch (tag) { |
| 997 case IDC_CLOSE_TAB: | 998 case IDC_CLOSE_TAB: |
| 998 // Disable "close tab" if the receiving window is not tabbed. | 999 // Disable "close tab" if the receiving window is not tabbed. |
| 999 // We simply check whether the item has a keyboard shortcut set here; | 1000 // We simply check whether the item has a keyboard shortcut set here; |
| 1000 // app_controller_mac.mm actually determines whether the item should | 1001 // app_controller_mac.mm actually determines whether the item should |
| (...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2172 | 2173 |
| 2173 - (BOOL)supportsBookmarkBar { | 2174 - (BOOL)supportsBookmarkBar { |
| 2174 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2175 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2175 } | 2176 } |
| 2176 | 2177 |
| 2177 - (BOOL)isTabbedWindow { | 2178 - (BOOL)isTabbedWindow { |
| 2178 return browser_->is_type_tabbed(); | 2179 return browser_->is_type_tabbed(); |
| 2179 } | 2180 } |
| 2180 | 2181 |
| 2181 @end // @implementation BrowserWindowController(WindowType) | 2182 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |