Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller.mm

Issue 1250403002: [Mac] Move UI item validation to UserInterfaceItemCommandHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@commandexecute
Patch Set: Properly release |commandHandler|. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/mac/bundle_locations.h" 11 #include "base/mac/bundle_locations.h"
12 #import "base/mac/foundation_util.h" 12 #import "base/mac/foundation_util.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/app/chrome_command_ids.h" // IDC_* 17 #include "chrome/app/chrome_command_ids.h" // IDC_*
18 #import "chrome/browser/app_controller_mac.h"
19 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 18 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
20 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h" 19 #include "chrome/browser/bookmarks/managed_bookmark_service_factory.h"
21 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/devtools/devtools_window.h" 21 #include "chrome/browser/devtools/devtools_window.h"
23 #include "chrome/browser/extensions/extension_commands_global_registry.h" 22 #include "chrome/browser/extensions/extension_commands_global_registry.h"
24 #include "chrome/browser/fullscreen.h" 23 #include "chrome/browser/fullscreen.h"
25 #include "chrome/browser/profiles/avatar_menu.h" 24 #include "chrome/browser/profiles/avatar_menu.h"
26 #include "chrome/browser/profiles/profile.h" 25 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_info_cache.h" 26 #include "chrome/browser/profiles/profile_info_cache.h"
28 #include "chrome/browser/profiles/profile_manager.h" 27 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/profiles/profiles_state.h" 28 #include "chrome/browser/profiles/profiles_state.h"
30 #include "chrome/browser/themes/theme_service.h" 29 #include "chrome/browser/themes/theme_service.h"
31 #include "chrome/browser/themes/theme_service_factory.h" 30 #include "chrome/browser/themes/theme_service_factory.h"
32 #include "chrome/browser/translate/chrome_translate_client.h" 31 #include "chrome/browser/translate/chrome_translate_client.h"
33 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" 32 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
34 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
35 #include "chrome/browser/ui/browser.h" 33 #include "chrome/browser/ui/browser.h"
36 #include "chrome/browser/ui/browser_command_controller.h" 34 #include "chrome/browser/ui/browser_command_controller.h"
37 #include "chrome/browser/ui/browser_commands.h" 35 #include "chrome/browser/ui/browser_commands.h"
38 #include "chrome/browser/ui/browser_dialogs.h" 36 #include "chrome/browser/ui/browser_dialogs.h"
39 #include "chrome/browser/ui/browser_instant_controller.h" 37 #include "chrome/browser/ui/browser_instant_controller.h"
40 #include "chrome/browser/ui/browser_list.h" 38 #include "chrome/browser/ui/browser_list.h"
41 #include "chrome/browser/ui/browser_window_state.h" 39 #include "chrome/browser/ui/browser_window_state.h"
42 #import "chrome/browser/ui/cocoa/background_gradient_view.h" 40 #import "chrome/browser/ui/cocoa/background_gradient_view.h"
43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 41 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
44 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h" 42 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bubble_observer_cocoa.h"
45 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h"
46 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" 44 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h"
45 #import "chrome/browser/ui/cocoa/browser_window_command_handler.h"
47 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 46 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
48 #import "chrome/browser/ui/cocoa/browser_window_layout.h" 47 #import "chrome/browser/ui/cocoa/browser_window_layout.h"
49 #import "chrome/browser/ui/cocoa/browser_window_utils.h" 48 #import "chrome/browser/ui/cocoa/browser_window_utils.h"
50 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" 49 #import "chrome/browser/ui/cocoa/dev_tools_controller.h"
51 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" 50 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h"
52 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h" 51 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa .h"
53 #import "chrome/browser/ui/cocoa/fast_resize_view.h" 52 #import "chrome/browser/ui/cocoa/fast_resize_view.h"
54 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" 53 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h"
55 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" 54 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h"
56 #import "chrome/browser/ui/cocoa/framed_browser_window.h" 55 #import "chrome/browser/ui/cocoa/framed_browser_window.h"
(...skipping 11 matching lines...) Expand all
68 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 67 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" 68 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h"
70 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" 69 #import "chrome/browser/ui/cocoa/tabs/tab_view.h"
71 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 70 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
72 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" 71 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h"
73 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" 72 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h"
74 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" 73 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
75 #include "chrome/browser/ui/location_bar/location_bar.h" 74 #include "chrome/browser/ui/location_bar/location_bar.h"
76 #include "chrome/browser/ui/tabs/tab_strip_model.h" 75 #include "chrome/browser/ui/tabs/tab_strip_model.h"
77 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" 76 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h"
78 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h"
79 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h" 77 #include "chrome/browser/ui/translate/translate_bubble_model_impl.h"
80 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 78 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
81 #include "chrome/browser/ui/window_sizer/window_sizer.h" 79 #include "chrome/browser/ui/window_sizer/window_sizer.h"
82 #include "chrome/common/chrome_switches.h" 80 #include "chrome/common/chrome_switches.h"
83 #include "chrome/common/extensions/command.h" 81 #include "chrome/common/extensions/command.h"
84 #include "chrome/common/url_constants.h" 82 #include "chrome/common/url_constants.h"
85 #include "chrome/grit/generated_resources.h" 83 #include "chrome/grit/generated_resources.h"
86 #include "chrome/grit/locale_settings.h" 84 #include "chrome/grit/locale_settings.h"
87 #include "components/bookmarks/browser/bookmark_model.h" 85 #include "components/bookmarks/browser/bookmark_model.h"
88 #include "components/bookmarks/managed/managed_bookmark_service.h" 86 #include "components/bookmarks/managed/managed_bookmark_service.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 219
222 // Private(TestingAPI) init routine with testing options. 220 // Private(TestingAPI) init routine with testing options.
223 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt { 221 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt {
224 bool hasTabStrip = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); 222 bool hasTabStrip = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
225 if ((self = [super initTabWindowControllerWithTabStrip:hasTabStrip])) { 223 if ((self = [super initTabWindowControllerWithTabStrip:hasTabStrip])) {
226 DCHECK(browser); 224 DCHECK(browser);
227 initializing_ = YES; 225 initializing_ = YES;
228 browser_.reset(browser); 226 browser_.reset(browser);
229 ownsBrowser_ = ownIt; 227 ownsBrowser_ = ownIt;
230 NSWindow* window = [self window]; 228 NSWindow* window = [self window];
229 // Make the window handle browser window commands.
230 [base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(window)
231 setCommandHandler:[[[BrowserWindowCommandHandler alloc] init]
232 autorelease]];
233
231 // Make the content view for the window have a layer. This will make all 234 // Make the content view for the window have a layer. This will make all
232 // sub-views have layers. This is necessary to ensure correct layer 235 // sub-views have layers. This is necessary to ensure correct layer
233 // ordering of all child views and their layers. 236 // ordering of all child views and their layers.
234 [[window contentView] setWantsLayer:YES]; 237 [[window contentView] setWantsLayer:YES];
235 windowShim_.reset(new BrowserWindowCocoa(browser, self)); 238 windowShim_.reset(new BrowserWindowCocoa(browser, self));
236 239
237 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups. 240 // Set different minimum sizes on tabbed windows vs non-tabbed, e.g. popups.
238 // This has to happen before -enforceMinWindowSize: is called further down. 241 // This has to happen before -enforceMinWindowSize: is called further down.
239 NSSize minSize = [self isTabbedWindow] ? 242 NSSize minSize = [self isTabbedWindow] ?
240 NSMakeSize(400, 272) : NSMakeSize(100, 122); 243 NSMakeSize(400, 272) : NSMakeSize(100, 122);
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 if (resizeRectDirty) { 1059 if (resizeRectDirty) {
1057 // Send new resize rect to foreground tab. 1060 // Send new resize rect to foreground tab.
1058 if (WebContents* contents = [self webContents]) { 1061 if (WebContents* contents = [self webContents]) {
1059 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) { 1062 if (content::RenderViewHost* rvh = contents->GetRenderViewHost()) {
1060 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect()); 1063 rvh->ResizeRectChanged(windowShim_->GetRootWindowResizerRect());
1061 } 1064 }
1062 } 1065 }
1063 } 1066 }
1064 } 1067 }
1065 1068
1066 // Update a toggle state for an NSMenuItem if modified.
1067 // Take care to ensure |item| looks like a NSMenuItem.
1068 // Called by validateUserInterfaceItem:.
1069 - (void)updateToggleStateWithTag:(NSInteger)tag forItem:(id)item {
1070 if (![item respondsToSelector:@selector(state)] ||
1071 ![item respondsToSelector:@selector(setState:)])
1072 return;
1073
1074 // On Windows this logic happens in bookmark_bar_view.cc. On the
1075 // Mac we're a lot more MVC happy so we've moved it into a
1076 // controller. To be clear, this simply updates the menu item; it
1077 // does not display the bookmark bar itself.
1078 if (tag == IDC_SHOW_BOOKMARK_BAR) {
1079 bool toggled = windowShim_->IsBookmarkBarVisible();
1080 NSInteger oldState = [(NSMenuItem*)item state];
1081 NSInteger newState = toggled ? NSOnState : NSOffState;
1082 if (oldState != newState)
1083 [item setState:newState];
1084 }
1085
1086 // Update the checked/Unchecked state of items in the encoding menu.
1087 // On Windows, this logic is part of |EncodingMenuModel| in
1088 // browser/ui/views/toolbar_view.h.
1089 EncodingMenuController encoding_controller;
1090 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
1091 DCHECK(browser_.get());
1092 Profile* profile = browser_->profile();
1093 DCHECK(profile);
1094 WebContents* current_tab =
1095 browser_->tab_strip_model()->GetActiveWebContents();
1096 if (!current_tab)
1097 return;
1098
1099 const std::string encoding = current_tab->GetEncoding();
1100
1101 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag);
1102 NSInteger oldState = [(NSMenuItem*)item state];
1103 NSInteger newState = toggled ? NSOnState : NSOffState;
1104 if (oldState != newState)
1105 [item setState:newState];
1106 }
1107 }
1108
1109 // Called to validate menu and toolbar items when this window is key. All the
1110 // items we care about have been set with the |-commandDispatch:| or
1111 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder
1112 // in IB. If it's not one of those, let it continue up the responder chain to be
1113 // handled elsewhere. We pull out the tag as the cross-platform constant to
1114 // differentiate and dispatch the various commands.
1115 // NOTE: we might have to handle state for app-wide menu items,
1116 // although we could cheat and directly ask the app controller if our
1117 // command_updater doesn't support the command. This may or may not be an issue,
1118 // too early to tell.
1119 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item {
1120 SEL action = [item action];
1121 BOOL enable = NO;
1122 if (action == @selector(commandDispatch:) ||
1123 action == @selector(commandDispatchUsingKeyModifiers:)) {
1124 NSInteger tag = [item tag];
1125 if (chrome::SupportsCommand(browser_.get(), tag)) {
1126 // Generate return value (enabled state)
1127 enable = chrome::IsCommandEnabled(browser_.get(), tag);
1128 switch (tag) {
1129 case IDC_CLOSE_TAB:
1130 // Disable "close tab" if the receiving window is not tabbed.
1131 // We simply check whether the item has a keyboard shortcut set here;
1132 // app_controller_mac.mm actually determines whether the item should
1133 // be enabled.
1134 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item))
1135 enable &= !![[menuItem keyEquivalent] length];
1136 break;
1137 case IDC_FULLSCREEN: {
1138 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
1139 if (chrome::mac::SupportsSystemFullscreen()) {
1140 [menuItem setTitle:[self titleForFullscreenMenuItem]];
1141 } else {
1142 [menuItem setHidden:YES];
1143 }
1144 }
1145 break;
1146 }
1147 case IDC_PRESENTATION_MODE: {
1148 if (NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item)) {
1149 [menuItem setTitle:[self titleForFullscreenMenuItem]];
1150
1151 if (chrome::mac::SupportsSystemFullscreen())
1152 [menuItem setAlternate:YES];
1153 }
1154 break;
1155 }
1156 case IDC_SHOW_SIGNIN: {
1157 Profile* original_profile =
1158 browser_->profile()->GetOriginalProfile();
1159 [AppController updateSigninItem:item
1160 shouldShow:enable
1161 currentProfile:original_profile];
1162 break;
1163 }
1164 case IDC_BOOKMARK_PAGE: {
1165 // Extensions have the ability to hide the bookmark page menu item.
1166 // This only affects the bookmark page menu item under the main menu.
1167 // The bookmark page menu item under the wrench menu has its
1168 // visibility controlled by WrenchMenuModel.
1169 bool shouldHide =
1170 chrome::ShouldRemoveBookmarkThisPageUI(browser_->profile());
1171 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
1172 [menuItem setHidden:shouldHide];
1173 break;
1174 }
1175 case IDC_BOOKMARK_ALL_TABS: {
1176 // Extensions have the ability to hide the bookmark all tabs menu
1177 // item. This only affects the bookmark page menu item under the main
1178 // menu. The bookmark page menu item under the wrench menu has its
1179 // visibility controlled by WrenchMenuModel.
1180 bool shouldHide =
1181 chrome::ShouldRemoveBookmarkOpenPagesUI(browser_->profile());
1182 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
1183 [menuItem setHidden:shouldHide];
1184 break;
1185 }
1186 default:
1187 // Special handling for the contents of the Text Encoding submenu. On
1188 // Mac OS, instead of enabling/disabling the top-level menu item, we
1189 // enable/disable the submenu's contents (per Apple's HIG).
1190 EncodingMenuController encoding_controller;
1191 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
1192 enable &= chrome::IsCommandEnabled(browser_.get(),
1193 IDC_ENCODING_MENU) ? YES : NO;
1194 }
1195 }
1196
1197 // If the item is toggleable, find its toggle state and
1198 // try to update it. This is a little awkward, but the alternative is
1199 // to check after a commandDispatch, which seems worse.
1200 [self updateToggleStateWithTag:tag forItem:item];
1201 }
1202 }
1203 return enable;
1204 }
1205
1206 // Called when the user picks a menu or toolbar item when this window is key.
1207 // Calls through to the browser object to execute the command. This assumes that
1208 // the command is supported and doesn't check, otherwise it would have been
1209 // disabled in the UI in validateUserInterfaceItem:.
1210 - (void)commandDispatch:(id)sender {
1211 DCHECK(sender);
1212 // Identify the actual BWC to which the command should be dispatched. It might
1213 // belong to a background window, yet this controller gets it because it is
1214 // the foreground window's controller and thus in the responder chain. Some
1215 // senders don't have this problem (for example, menus only operate on the
1216 // foreground window), so this is only an issue for senders that are part of
1217 // windows.
1218 BrowserWindowController* targetController = self;
1219 if ([sender respondsToSelector:@selector(window)])
1220 targetController = [[sender window] windowController];
1221 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]);
1222 DCHECK(targetController->browser_.get());
1223
1224 // When system fullscreen is available, it supercedes presentation mode.
1225 int tag = [sender tag];
1226 if (tag == IDC_PRESENTATION_MODE && chrome::mac::SupportsSystemFullscreen())
1227 tag = IDC_FULLSCREEN;
1228
1229 chrome::ExecuteCommand(targetController->browser_.get(), tag);
1230 }
1231
1232 // Same as |-commandDispatch:|, but executes commands using a disposition
1233 // determined by the key flags. If the window is in the background and the
1234 // command key is down, ignore the command key, but process any other modifiers.
1235 - (void)commandDispatchUsingKeyModifiers:(id)sender {
1236 DCHECK(sender);
1237
1238 if (![sender isEnabled]) {
1239 // This code is reachable e.g. if the user mashes the back button, queuing
1240 // up a bunch of events before the button's enabled state is updated:
1241 // http://crbug.com/63254
1242 return;
1243 }
1244
1245 // See comment above for why we do this.
1246 BrowserWindowController* targetController = self;
1247 if ([sender respondsToSelector:@selector(window)])
1248 targetController = [[sender window] windowController];
1249 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]);
1250 DCHECK(targetController->browser_.get());
1251
1252 NSInteger command = [sender tag];
1253 NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags];
1254 if ((command == IDC_RELOAD) &&
1255 (modifierFlags & (NSShiftKeyMask | NSControlKeyMask))) {
1256 command = IDC_RELOAD_IGNORING_CACHE;
1257 // Mask off Shift and Control so they don't affect the disposition below.
1258 modifierFlags &= ~(NSShiftKeyMask | NSControlKeyMask);
1259 }
1260 if (![[sender window] isMainWindow]) {
1261 // Remove the command key from the flags, it means "keep the window in
1262 // the background" in this case.
1263 modifierFlags &= ~NSCommandKeyMask;
1264 }
1265 chrome::ExecuteCommandWithDisposition(
1266 targetController->browser_.get(), command,
1267 ui::WindowOpenDispositionFromNSEventWithFlags(
1268 [NSApp currentEvent], modifierFlags));
1269 }
1270
1271 - (BOOL)handledByExtensionCommand:(NSEvent*)event 1069 - (BOOL)handledByExtensionCommand:(NSEvent*)event
1272 priority:(ui::AcceleratorManager::HandlerPriority)priority { 1070 priority:(ui::AcceleratorManager::HandlerPriority)priority {
1273 return extension_keybinding_registry_->ProcessKeyEvent( 1071 return extension_keybinding_registry_->ProcessKeyEvent(
1274 content::NativeWebKeyboardEvent(event), priority); 1072 content::NativeWebKeyboardEvent(event), priority);
1275 } 1073 }
1276 1074
1277 // StatusBubble delegate method: tell the status bubble the frame it should 1075 // StatusBubble delegate method: tell the status bubble the frame it should
1278 // position itself in. 1076 // position itself in.
1279 - (NSRect)statusBubbleBaseFrame { 1077 - (NSRect)statusBubbleBaseFrame {
1280 NSView* view = [overlayableContentsController_ view]; 1078 NSView* view = [overlayableContentsController_ view];
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 1898
2101 @end // @implementation BrowserWindowController 1899 @end // @implementation BrowserWindowController
2102 1900
2103 @implementation BrowserWindowController(Fullscreen) 1901 @implementation BrowserWindowController(Fullscreen)
2104 1902
2105 - (void)handleLionToggleFullscreen { 1903 - (void)handleLionToggleFullscreen {
2106 DCHECK(base::mac::IsOSLionOrLater()); 1904 DCHECK(base::mac::IsOSLionOrLater());
2107 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); 1905 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN);
2108 } 1906 }
2109 1907
2110 - (NSString*)titleForFullscreenMenuItem {
2111 if (!chrome::mac::SupportsSystemFullscreen()) {
2112 return l10n_util::GetNSString([self inPresentationMode]
2113 ? IDS_EXIT_PRESENTATION_MAC
2114 : IDS_ENTER_PRESENTATION_MAC);
2115 }
2116
2117 return l10n_util::GetNSString([self isInAppKitFullscreen]
2118 ? IDS_EXIT_FULLSCREEN_MAC
2119 : IDS_ENTER_FULLSCREEN_MAC);
2120 }
2121
2122 - (void)enterBrowserFullscreenWithToolbar:(BOOL)withToolbar { 1908 - (void)enterBrowserFullscreenWithToolbar:(BOOL)withToolbar {
2123 if (!chrome::mac::SupportsSystemFullscreen()) { 1909 if (!chrome::mac::SupportsSystemFullscreen()) {
2124 if (![self isInImmersiveFullscreen]) 1910 if (![self isInImmersiveFullscreen])
2125 [self enterImmersiveFullscreen]; 1911 [self enterImmersiveFullscreen];
2126 return; 1912 return;
2127 } 1913 }
2128 1914
2129 if ([self isInAppKitFullscreen]) { 1915 if ([self isInAppKitFullscreen]) {
2130 [self updateFullscreenWithToolbar:withToolbar]; 1916 [self updateFullscreenWithToolbar:withToolbar];
2131 } else { 1917 } else {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 2061
2276 - (BOOL)supportsBookmarkBar { 2062 - (BOOL)supportsBookmarkBar {
2277 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2063 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2278 } 2064 }
2279 2065
2280 - (BOOL)isTabbedWindow { 2066 - (BOOL)isTabbedWindow {
2281 return browser_->is_type_tabbed(); 2067 return browser_->is_type_tabbed();
2282 } 2068 }
2283 2069
2284 @end // @implementation BrowserWindowController(WindowType) 2070 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/chrome_event_processing_window.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698