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" |
11 #include "base/mac/bundle_locations.h" | 11 #include "base/mac/bundle_locations.h" |
12 #include "base/mac/mac_util.h" | 12 #include "base/mac/mac_util.h" |
13 #import "base/memory/scoped_nsobject.h" | 13 #import "base/memory/scoped_nsobject.h" |
14 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" // IDC_* | 15 #include "chrome/app/chrome_command_ids.h" // IDC_* |
16 #include "chrome/browser/bookmarks/bookmark_editor.h" | 16 #include "chrome/browser/bookmarks/bookmark_editor.h" |
17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/instant/instant_controller.h" | 18 #include "chrome/browser/instant/instant_controller.h" |
19 #include "chrome/browser/managed_mode.h" | 19 #include "chrome/browser/managed_mode.h" |
20 #include "chrome/browser/profiles/avatar_menu_model.h" | 20 #include "chrome/browser/profiles/avatar_menu_model.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/profiles/profile_info_cache.h" | 22 #include "chrome/browser/profiles/profile_info_cache.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 24 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/sync/sync_ui_util_mac.h" | 25 #include "chrome/browser/sync/sync_ui_util_mac.h" |
26 #include "chrome/browser/themes/theme_service.h" | 26 #include "chrome/browser/themes/theme_service.h" |
27 #include "chrome/browser/themes/theme_service_factory.h" | 27 #include "chrome/browser/themes/theme_service_factory.h" |
28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
| 29 #include "chrome/browser/ui/browser_command_controller.h" |
| 30 #include "chrome/browser/ui/browser_commands.h" |
29 #include "chrome/browser/ui/browser_list.h" | 31 #include "chrome/browser/ui/browser_list.h" |
30 #include "chrome/browser/ui/browser_window_state.h" | 32 #include "chrome/browser/ui/browser_window_state.h" |
31 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 33 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
32 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 34 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
33 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 35 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
34 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 36 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
35 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 37 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
36 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 38 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
37 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 39 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
38 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" | 40 #import "chrome/browser/ui/cocoa/chrome_to_mobile_bubble_controller.h" |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // registering for the appropriate tab notifications from the back-end and | 315 // registering for the appropriate tab notifications from the back-end and |
314 // managing the creation of new tabs. | 316 // managing the creation of new tabs. |
315 [self createTabStripController]; | 317 [self createTabStripController]; |
316 | 318 |
317 // Create a controller for the toolbar, giving it the toolbar model object | 319 // Create a controller for the toolbar, giving it the toolbar model object |
318 // and the toolbar view from the nib. The controller will handle | 320 // and the toolbar view from the nib. The controller will handle |
319 // registering for the appropriate command state changes from the back-end. | 321 // registering for the appropriate command state changes from the back-end. |
320 // Adds the toolbar to the content area. | 322 // Adds the toolbar to the content area. |
321 toolbarController_.reset([[ToolbarController alloc] | 323 toolbarController_.reset([[ToolbarController alloc] |
322 initWithModel:browser->toolbar_model() | 324 initWithModel:browser->toolbar_model() |
323 commands:browser->command_updater() | 325 commands:browser->command_controller()->comm
and_updater() |
324 profile:browser->profile() | 326 profile:browser->profile() |
325 browser:browser | 327 browser:browser |
326 resizeDelegate:self]); | 328 resizeDelegate:self]); |
327 [toolbarController_ setHasToolbar:[self hasToolbar] | 329 [toolbarController_ setHasToolbar:[self hasToolbar] |
328 hasLocationBar:[self hasLocationBar]]; | 330 hasLocationBar:[self hasLocationBar]]; |
329 [[[self window] contentView] addSubview:[toolbarController_ view]]; | 331 [[[self window] contentView] addSubview:[toolbarController_ view]]; |
330 | 332 |
331 // Create a sub-controller for the bookmark bar. | 333 // Create a sub-controller for the bookmark bar. |
332 bookmarkBarController_.reset( | 334 bookmarkBarController_.reset( |
333 [[BookmarkBarController alloc] | 335 [[BookmarkBarController alloc] |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1008 // NOTE: we might have to handle state for app-wide menu items, | 1010 // NOTE: we might have to handle state for app-wide menu items, |
1009 // although we could cheat and directly ask the app controller if our | 1011 // although we could cheat and directly ask the app controller if our |
1010 // command_updater doesn't support the command. This may or may not be an issue, | 1012 // command_updater doesn't support the command. This may or may not be an issue, |
1011 // too early to tell. | 1013 // too early to tell. |
1012 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { | 1014 - (BOOL)validateUserInterfaceItem:(id<NSValidatedUserInterfaceItem>)item { |
1013 SEL action = [item action]; | 1015 SEL action = [item action]; |
1014 BOOL enable = NO; | 1016 BOOL enable = NO; |
1015 if (action == @selector(commandDispatch:) || | 1017 if (action == @selector(commandDispatch:) || |
1016 action == @selector(commandDispatchUsingKeyModifiers:)) { | 1018 action == @selector(commandDispatchUsingKeyModifiers:)) { |
1017 NSInteger tag = [item tag]; | 1019 NSInteger tag = [item tag]; |
1018 if (browser_->command_updater()->SupportsCommand(tag)) { | 1020 if (chrome::SupportsCommand(browser_.get(), tag)) { |
1019 // Generate return value (enabled state) | 1021 // Generate return value (enabled state) |
1020 enable = browser_->command_updater()->IsCommandEnabled(tag); | 1022 enable = chrome::IsCommandEnabled(browser_.get(), tag); |
1021 switch (tag) { | 1023 switch (tag) { |
1022 case IDC_CLOSE_TAB: | 1024 case IDC_CLOSE_TAB: |
1023 // Disable "close tab" if the receiving window is not tabbed. | 1025 // Disable "close tab" if the receiving window is not tabbed. |
1024 // We simply check whether the item has a keyboard shortcut set here; | 1026 // We simply check whether the item has a keyboard shortcut set here; |
1025 // app_controller_mac.mm actually determines whether the item should | 1027 // app_controller_mac.mm actually determines whether the item should |
1026 // be enabled. | 1028 // be enabled. |
1027 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) | 1029 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) |
1028 enable &= !![[static_cast<NSMenuItem*>(item) keyEquivalent] length]; | 1030 enable &= !![[static_cast<NSMenuItem*>(item) keyEquivalent] length]; |
1029 break; | 1031 break; |
1030 case IDC_FULLSCREEN: { | 1032 case IDC_FULLSCREEN: { |
(...skipping 25 matching lines...) Expand all Loading... |
1056 enable &= original_profile->IsSyncAccessible(); | 1058 enable &= original_profile->IsSyncAccessible(); |
1057 sync_ui_util::UpdateSyncItem(item, enable, original_profile); | 1059 sync_ui_util::UpdateSyncItem(item, enable, original_profile); |
1058 break; | 1060 break; |
1059 } | 1061 } |
1060 default: | 1062 default: |
1061 // Special handling for the contents of the Text Encoding submenu. On | 1063 // Special handling for the contents of the Text Encoding submenu. On |
1062 // Mac OS, instead of enabling/disabling the top-level menu item, we | 1064 // Mac OS, instead of enabling/disabling the top-level menu item, we |
1063 // enable/disable the submenu's contents (per Apple's HIG). | 1065 // enable/disable the submenu's contents (per Apple's HIG). |
1064 EncodingMenuController encoding_controller; | 1066 EncodingMenuController encoding_controller; |
1065 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) { | 1067 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) { |
1066 enable &= browser_->command_updater()->IsCommandEnabled( | 1068 enable &= chrome::IsCommandEnabled(browser_.get(), |
1067 IDC_ENCODING_MENU) ? YES : NO; | 1069 IDC_ENCODING_MENU) ? YES : NO; |
1068 } | 1070 } |
1069 } | 1071 } |
1070 | 1072 |
1071 // If the item is toggleable, find its toggle state and | 1073 // If the item is toggleable, find its toggle state and |
1072 // try to update it. This is a little awkward, but the alternative is | 1074 // try to update it. This is a little awkward, but the alternative is |
1073 // to check after a commandDispatch, which seems worse. | 1075 // to check after a commandDispatch, which seems worse. |
1074 [self updateToggleStateWithTag:tag forItem:item]; | 1076 [self updateToggleStateWithTag:tag forItem:item]; |
1075 } | 1077 } |
1076 } | 1078 } |
1077 return enable; | 1079 return enable; |
1078 } | 1080 } |
1079 | 1081 |
1080 // Called when the user picks a menu or toolbar item when this window is key. | 1082 // Called when the user picks a menu or toolbar item when this window is key. |
1081 // Calls through to the browser object to execute the command. This assumes that | 1083 // Calls through to the browser object to execute the command. This assumes that |
1082 // the command is supported and doesn't check, otherwise it would have been | 1084 // the command is supported and doesn't check, otherwise it would have been |
1083 // disabled in the UI in validateUserInterfaceItem:. | 1085 // disabled in the UI in validateUserInterfaceItem:. |
1084 - (void)commandDispatch:(id)sender { | 1086 - (void)commandDispatch:(id)sender { |
1085 DCHECK(sender); | 1087 DCHECK(sender); |
1086 // Identify the actual BWC to which the command should be dispatched. It might | 1088 // Identify the actual BWC to which the command should be dispatched. It might |
1087 // belong to a background window, yet this controller gets it because it is | 1089 // belong to a background window, yet this controller gets it because it is |
1088 // the foreground window's controller and thus in the responder chain. Some | 1090 // the foreground window's controller and thus in the responder chain. Some |
1089 // senders don't have this problem (for example, menus only operate on the | 1091 // senders don't have this problem (for example, menus only operate on the |
1090 // foreground window), so this is only an issue for senders that are part of | 1092 // foreground window), so this is only an issue for senders that are part of |
1091 // windows. | 1093 // windows. |
1092 BrowserWindowController* targetController = self; | 1094 BrowserWindowController* targetController = self; |
1093 if ([sender respondsToSelector:@selector(window)]) | 1095 if ([sender respondsToSelector:@selector(window)]) |
1094 targetController = [[sender window] windowController]; | 1096 targetController = [[sender window] windowController]; |
1095 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]); | 1097 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]); |
1096 DCHECK(targetController->browser_.get()); | 1098 DCHECK(targetController->browser_.get()); |
1097 targetController->browser_->ExecuteCommand([sender tag]); | 1099 chrome::ExecuteCommand(targetController->browser_.get(), [sender tag]); |
1098 } | 1100 } |
1099 | 1101 |
1100 // Same as |-commandDispatch:|, but executes commands using a disposition | 1102 // Same as |-commandDispatch:|, but executes commands using a disposition |
1101 // determined by the key flags. If the window is in the background and the | 1103 // determined by the key flags. If the window is in the background and the |
1102 // command key is down, ignore the command key, but process any other modifiers. | 1104 // command key is down, ignore the command key, but process any other modifiers. |
1103 - (void)commandDispatchUsingKeyModifiers:(id)sender { | 1105 - (void)commandDispatchUsingKeyModifiers:(id)sender { |
1104 DCHECK(sender); | 1106 DCHECK(sender); |
1105 | 1107 |
1106 if (![sender isEnabled]) { | 1108 if (![sender isEnabled]) { |
1107 // This code is reachable e.g. if the user mashes the back button, queuing | 1109 // This code is reachable e.g. if the user mashes the back button, queuing |
(...skipping 29 matching lines...) Expand all Loading... |
1137 case IDC_RELOAD: | 1139 case IDC_RELOAD: |
1138 case IDC_RELOAD_IGNORING_CACHE: | 1140 case IDC_RELOAD_IGNORING_CACHE: |
1139 if (disposition == CURRENT_TAB) { | 1141 if (disposition == CURRENT_TAB) { |
1140 // Forcibly reset the location bar, since otherwise it won't discard any | 1142 // Forcibly reset the location bar, since otherwise it won't discard any |
1141 // ongoing user edits, since it doesn't realize this is a user-initiated | 1143 // ongoing user edits, since it doesn't realize this is a user-initiated |
1142 // action. | 1144 // action. |
1143 [targetController locationBarBridge]->Revert(); | 1145 [targetController locationBarBridge]->Revert(); |
1144 } | 1146 } |
1145 } | 1147 } |
1146 DCHECK(targetController->browser_.get()); | 1148 DCHECK(targetController->browser_.get()); |
1147 targetController->browser_->ExecuteCommandWithDisposition(command, | 1149 chrome::ExecuteCommandWithDisposition(targetController->browser_.get(), |
1148 disposition); | 1150 command, disposition); |
1149 } | 1151 } |
1150 | 1152 |
1151 // Called when another part of the internal codebase needs to execute a | 1153 // Called when another part of the internal codebase needs to execute a |
1152 // command. | 1154 // command. |
1153 - (void)executeCommand:(int)command { | 1155 - (void)executeCommand:(int)command { |
1154 browser_->ExecuteCommandIfEnabled(command); | 1156 chrome::ExecuteCommand(browser_.get(), command); |
1155 } | 1157 } |
1156 | 1158 |
1157 // StatusBubble delegate method: tell the status bubble the frame it should | 1159 // StatusBubble delegate method: tell the status bubble the frame it should |
1158 // position itself in. | 1160 // position itself in. |
1159 - (NSRect)statusBubbleBaseFrame { | 1161 - (NSRect)statusBubbleBaseFrame { |
1160 NSView* view = [previewableContentsController_ view]; | 1162 NSView* view = [previewableContentsController_ view]; |
1161 return [view convertRect:[view bounds] toView:nil]; | 1163 return [view convertRect:[view bounds] toView:nil]; |
1162 } | 1164 } |
1163 | 1165 |
1164 - (GTMWindowSheetController*)sheetController { | 1166 - (GTMWindowSheetController*)sheetController { |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1697 // Map forwards and backwards to history; left is positive, right is negative. | 1699 // Map forwards and backwards to history; left is positive, right is negative. |
1698 unsigned int command = 0; | 1700 unsigned int command = 0; |
1699 if (deltaX > 0.5) { | 1701 if (deltaX > 0.5) { |
1700 command = IDC_BACK; | 1702 command = IDC_BACK; |
1701 } else if (deltaX < -0.5) { | 1703 } else if (deltaX < -0.5) { |
1702 command = IDC_FORWARD; | 1704 command = IDC_FORWARD; |
1703 } else if (deltaY > 0.5) { | 1705 } else if (deltaY > 0.5) { |
1704 // TODO(pinkerton): figure out page-up, http://crbug.com/16305 | 1706 // TODO(pinkerton): figure out page-up, http://crbug.com/16305 |
1705 } else if (deltaY < -0.5) { | 1707 } else if (deltaY < -0.5) { |
1706 // TODO(pinkerton): figure out page-down, http://crbug.com/16305 | 1708 // TODO(pinkerton): figure out page-down, http://crbug.com/16305 |
1707 browser_->ExecuteCommand(IDC_TABPOSE); | 1709 chrome::ExecuteCommand(browser_.get(), IDC_TABPOSE); |
1708 } | 1710 } |
1709 | 1711 |
1710 // Ensure the command is valid first (ExecuteCommand() won't do that) and | 1712 // Ensure the command is valid first (ExecuteCommand() won't do that) and |
1711 // then make it so. | 1713 // then make it so. |
1712 if (browser_->command_updater()->IsCommandEnabled(command)) | 1714 if (chrome::IsCommandEnabled(browser_.get(), command)) { |
1713 browser_->ExecuteCommandWithDisposition(command, | 1715 chrome::ExecuteCommandWithDisposition( |
| 1716 browser_.get(), |
| 1717 command, |
1714 event_utils::WindowOpenDispositionFromNSEvent(event)); | 1718 event_utils::WindowOpenDispositionFromNSEvent(event)); |
| 1719 } |
1715 } | 1720 } |
1716 | 1721 |
1717 // Documented in 10.6+, but present starting in 10.5. Called repeatedly during | 1722 // Documented in 10.6+, but present starting in 10.5. Called repeatedly during |
1718 // a pinch gesture, with incremental change values. | 1723 // a pinch gesture, with incremental change values. |
1719 - (void)magnifyWithEvent:(NSEvent*)event { | 1724 - (void)magnifyWithEvent:(NSEvent*)event { |
1720 // The deltaZ difference necessary to trigger a zoom action. Derived from | 1725 // The deltaZ difference necessary to trigger a zoom action. Derived from |
1721 // experimentation to find a value that feels reasonable. | 1726 // experimentation to find a value that feels reasonable. |
1722 const float kZoomStepValue = 300; | 1727 const float kZoomStepValue = 300; |
1723 | 1728 |
1724 // Find the (absolute) thresholds on either side of the current zoom factor, | 1729 // Find the (absolute) thresholds on either side of the current zoom factor, |
1725 // then convert those to actual numbers to trigger a zoom in or out. | 1730 // then convert those to actual numbers to trigger a zoom in or out. |
1726 // This logic deliberately makes the range around the starting zoom value for | 1731 // This logic deliberately makes the range around the starting zoom value for |
1727 // the gesture twice as large as the other ranges (i.e., the notches are at | 1732 // the gesture twice as large as the other ranges (i.e., the notches are at |
1728 // ..., -3*step, -2*step, -step, step, 2*step, 3*step, ... but not at 0) | 1733 // ..., -3*step, -2*step, -step, step, 2*step, 3*step, ... but not at 0) |
1729 // so that it's easier to get back to your starting point than it is to | 1734 // so that it's easier to get back to your starting point than it is to |
1730 // overshoot. | 1735 // overshoot. |
1731 float nextStep = (abs(currentZoomStepDelta_) + 1) * kZoomStepValue; | 1736 float nextStep = (abs(currentZoomStepDelta_) + 1) * kZoomStepValue; |
1732 float backStep = abs(currentZoomStepDelta_) * kZoomStepValue; | 1737 float backStep = abs(currentZoomStepDelta_) * kZoomStepValue; |
1733 float zoomInThreshold = (currentZoomStepDelta_ >= 0) ? nextStep : -backStep; | 1738 float zoomInThreshold = (currentZoomStepDelta_ >= 0) ? nextStep : -backStep; |
1734 float zoomOutThreshold = (currentZoomStepDelta_ <= 0) ? -nextStep : backStep; | 1739 float zoomOutThreshold = (currentZoomStepDelta_ <= 0) ? -nextStep : backStep; |
1735 | 1740 |
1736 unsigned int command = 0; | 1741 unsigned int command = 0; |
1737 totalMagnifyGestureAmount_ += [event deltaZ]; | 1742 totalMagnifyGestureAmount_ += [event deltaZ]; |
1738 if (totalMagnifyGestureAmount_ > zoomInThreshold) { | 1743 if (totalMagnifyGestureAmount_ > zoomInThreshold) { |
1739 command = IDC_ZOOM_PLUS; | 1744 command = IDC_ZOOM_PLUS; |
1740 } else if (totalMagnifyGestureAmount_ < zoomOutThreshold) { | 1745 } else if (totalMagnifyGestureAmount_ < zoomOutThreshold) { |
1741 command = IDC_ZOOM_MINUS; | 1746 command = IDC_ZOOM_MINUS; |
1742 } | 1747 } |
1743 | 1748 |
1744 if (command && browser_->command_updater()->IsCommandEnabled(command)) { | 1749 if (command && chrome::IsCommandEnabled(browser_.get(), command)) { |
1745 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1; | 1750 currentZoomStepDelta_ += (command == IDC_ZOOM_PLUS) ? 1 : -1; |
1746 browser_->ExecuteCommandWithDisposition(command, | 1751 chrome::ExecuteCommandWithDisposition( |
| 1752 browser_.get(), |
| 1753 command, |
1747 event_utils::WindowOpenDispositionFromNSEvent(event)); | 1754 event_utils::WindowOpenDispositionFromNSEvent(event)); |
1748 } | 1755 } |
1749 } | 1756 } |
1750 | 1757 |
1751 // Delegate method called when window is resized. | 1758 // Delegate method called when window is resized. |
1752 - (void)windowDidResize:(NSNotification*)notification { | 1759 - (void)windowDidResize:(NSNotification*)notification { |
1753 [self saveWindowPositionIfNeeded]; | 1760 [self saveWindowPositionIfNeeded]; |
1754 | 1761 |
1755 // Resize (and possibly move) the status bubble. Note that we may get called | 1762 // Resize (and possibly move) the status bubble. Note that we may get called |
1756 // when the status bubble does not exist. | 1763 // when the status bubble does not exist. |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1935 [sheet orderOut:self]; | 1942 [sheet orderOut:self]; |
1936 } | 1943 } |
1937 | 1944 |
1938 @end // @implementation BrowserWindowController | 1945 @end // @implementation BrowserWindowController |
1939 | 1946 |
1940 | 1947 |
1941 @implementation BrowserWindowController(Fullscreen) | 1948 @implementation BrowserWindowController(Fullscreen) |
1942 | 1949 |
1943 - (void)handleLionToggleFullscreen { | 1950 - (void)handleLionToggleFullscreen { |
1944 DCHECK(base::mac::IsOSLionOrLater()); | 1951 DCHECK(base::mac::IsOSLionOrLater()); |
1945 browser_->ExecuteCommand(IDC_FULLSCREEN); | 1952 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); |
1946 } | 1953 } |
1947 | 1954 |
1948 // On Lion, this method is called by either the Lion fullscreen button or the | 1955 // On Lion, this method is called by either the Lion fullscreen button or the |
1949 // "Enter Full Screen" menu item. On Snow Leopard, this function is never | 1956 // "Enter Full Screen" menu item. On Snow Leopard, this function is never |
1950 // called by the UI directly, but it provides the implementation for | 1957 // called by the UI directly, but it provides the implementation for |
1951 // |-setPresentationMode:|. | 1958 // |-setPresentationMode:|. |
1952 - (void)setFullscreen:(BOOL)fullscreen | 1959 - (void)setFullscreen:(BOOL)fullscreen |
1953 url:(const GURL&)url | 1960 url:(const GURL&)url |
1954 bubbleType:(FullscreenExitBubbleType)bubbleType { | 1961 bubbleType:(FullscreenExitBubbleType)bubbleType { |
1955 if (fullscreen == [self isFullscreen]) | 1962 if (fullscreen == [self isFullscreen]) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 - (BOOL)isFullscreen { | 1997 - (BOOL)isFullscreen { |
1991 return (fullscreenWindow_.get() != nil) || | 1998 return (fullscreenWindow_.get() != nil) || |
1992 ([[self window] styleMask] & NSFullScreenWindowMask) || | 1999 ([[self window] styleMask] & NSFullScreenWindowMask) || |
1993 enteringFullscreen_; | 2000 enteringFullscreen_; |
1994 } | 2001 } |
1995 | 2002 |
1996 - (void)togglePresentationModeForLionOrLater:(id)sender { | 2003 - (void)togglePresentationModeForLionOrLater:(id)sender { |
1997 // Called only by the presentation mode toggle button. | 2004 // Called only by the presentation mode toggle button. |
1998 DCHECK(base::mac::IsOSLionOrLater()); | 2005 DCHECK(base::mac::IsOSLionOrLater()); |
1999 enteredPresentationModeFromFullscreen_ = YES; | 2006 enteredPresentationModeFromFullscreen_ = YES; |
2000 browser_->ExecuteCommand(IDC_PRESENTATION_MODE); | 2007 chrome::ExecuteCommand(browser_.get(), IDC_PRESENTATION_MODE); |
2001 } | 2008 } |
2002 | 2009 |
2003 // On Lion, this function is called by either the presentation mode toggle | 2010 // On Lion, this function is called by either the presentation mode toggle |
2004 // button or the "Enter Presentation Mode" menu item. In the latter case, this | 2011 // button or the "Enter Presentation Mode" menu item. In the latter case, this |
2005 // function also triggers the Lion machinery to enter fullscreen mode as well as | 2012 // function also triggers the Lion machinery to enter fullscreen mode as well as |
2006 // set presentation mode. On Snow Leopard, this function is called by the | 2013 // set presentation mode. On Snow Leopard, this function is called by the |
2007 // "Enter Presentation Mode" menu item, and triggering presentation mode always | 2014 // "Enter Presentation Mode" menu item, and triggering presentation mode always |
2008 // moves the user into fullscreen mode. | 2015 // moves the user into fullscreen mode. |
2009 - (void)setPresentationMode:(BOOL)presentationMode | 2016 - (void)setPresentationMode:(BOOL)presentationMode |
2010 url:(const GURL&)url | 2017 url:(const GURL&)url |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2210 | 2217 |
2211 - (BOOL)supportsBookmarkBar { | 2218 - (BOOL)supportsBookmarkBar { |
2212 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2219 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2213 } | 2220 } |
2214 | 2221 |
2215 - (BOOL)isTabbedWindow { | 2222 - (BOOL)isTabbedWindow { |
2216 return browser_->is_type_tabbed(); | 2223 return browser_->is_type_tabbed(); |
2217 } | 2224 } |
2218 | 2225 |
2219 @end // @implementation BrowserWindowController(WindowType) | 2226 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |