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