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

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

Issue 10800011: [Mac] Changes to the behavior of Lion+ fullscreen and presentation mode. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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 (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 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 // We simply check whether the item has a keyboard shortcut set here; 1032 // We simply check whether the item has a keyboard shortcut set here;
1033 // app_controller_mac.mm actually determines whether the item should 1033 // app_controller_mac.mm actually determines whether the item should
1034 // be enabled. 1034 // be enabled.
1035 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) 1035 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]])
1036 enable &= !![[static_cast<NSMenuItem*>(item) keyEquivalent] length]; 1036 enable &= !![[static_cast<NSMenuItem*>(item) keyEquivalent] length];
1037 break; 1037 break;
1038 case IDC_FULLSCREEN: { 1038 case IDC_FULLSCREEN: {
1039 enable &= [self supportsFullscreen]; 1039 enable &= [self supportsFullscreen];
1040 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { 1040 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) {
1041 NSString* menuTitle = l10n_util::GetNSString( 1041 NSString* menuTitle = l10n_util::GetNSString(
1042 [self isFullscreen] ? IDS_EXIT_FULLSCREEN_MAC : 1042 [self isFullscreen] && ![self inPresentationMode] ?
1043 IDS_ENTER_FULLSCREEN_MAC); 1043 IDS_EXIT_FULLSCREEN_MAC :
1044 IDS_ENTER_FULLSCREEN_MAC);
1044 [static_cast<NSMenuItem*>(item) setTitle:menuTitle]; 1045 [static_cast<NSMenuItem*>(item) setTitle:menuTitle];
1045 1046
1046 if (base::mac::IsOSSnowLeopardOrEarlier()) 1047 if (base::mac::IsOSSnowLeopardOrEarlier())
1047 [static_cast<NSMenuItem*>(item) setHidden:YES]; 1048 [static_cast<NSMenuItem*>(item) setHidden:YES];
1048 } 1049 }
1049 break; 1050 break;
1050 } 1051 }
1051 case IDC_PRESENTATION_MODE: { 1052 case IDC_PRESENTATION_MODE: {
1052 enable &= [self supportsFullscreen]; 1053 enable &= [self supportsFullscreen];
1053 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) { 1054 if ([static_cast<NSObject*>(item) isKindOfClass:[NSMenuItem class]]) {
(...skipping 967 matching lines...) Expand 10 before | Expand all | Expand 10 after
2021 2022
2022 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen 2023 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen
2023 // mode. 2024 // mode.
2024 if (base::mac::IsOSSnowLeopardOrEarlier()) { 2025 if (base::mac::IsOSSnowLeopardOrEarlier()) {
2025 [self setFullscreen:presentationMode url:url bubbleType:bubbleType]; 2026 [self setFullscreen:presentationMode url:url bubbleType:bubbleType];
2026 return; 2027 return;
2027 } 2028 }
2028 2029
2029 if (presentationMode) { 2030 if (presentationMode) {
2030 BOOL fullscreen = [self isFullscreen]; 2031 BOOL fullscreen = [self isFullscreen];
2031 BOOL fullscreen_for_tab =
2032 browser_->fullscreen_controller()->IsFullscreenForTabOrPending();
2033 if (!fullscreen_for_tab)
2034 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES];
2035 enteredPresentationModeFromFullscreen_ = fullscreen; 2032 enteredPresentationModeFromFullscreen_ = fullscreen;
2033 enteringPresentationMode_ = presentationMode;
rohitrao (ping after 24h) 2012/07/22 11:50:44 This seems a little silly inside an if (presentati
Robert Sesek 2012/07/23 17:57:53 Done.
2036 2034
2037 if (fullscreen) { 2035 if (fullscreen) {
2038 // If already in fullscreen mode, just toggle the presentation mode 2036 // If already in fullscreen mode, just toggle the presentation mode
2039 // setting. Go through an elaborate dance to force the overlay to show, 2037 // setting. Go through an elaborate dance to force the overlay to show,
2040 // then animate out once the mouse moves away. This helps draw attention 2038 // then animate out once the mouse moves away. This helps draw attention
2041 // to the fact that the UI is in an overlay. Focus the tab contents 2039 // to the fact that the UI is in an overlay. Focus the tab contents
2042 // because the omnibox is the most likely source of bar visibility locks, 2040 // because the omnibox is the most likely source of bar visibility locks,
2043 // and taking focus away from the omnibox releases its lock. 2041 // and taking focus away from the omnibox releases its lock.
2044 [self lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; 2042 [self lockBarVisibilityForOwner:self withAnimation:NO delay:NO];
2045 [self focusTabContents]; 2043 [self focusTabContents];
2046 [self setPresentationModeInternal:YES forceDropdown:YES]; 2044 [self setPresentationModeInternal:YES forceDropdown:YES];
2047 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; 2045 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES];
2048 // Since -windowDidEnterFullScreen: won't be called in the 2046 // Since -windowDidEnterFullScreen: won't be called in the
2049 // fullscreen --> presentation mode case, manually show the exit bubble. 2047 // fullscreen --> presentation mode case, manually show the exit bubble.
2050 [self showFullscreenExitBubbleIfNecessary]; 2048 [self showFullscreenExitBubbleIfNecessary];
2051 } else { 2049 } else {
2052 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. 2050 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery.
2053 // Presentation mode will automatically be enabled in 2051 // Presentation mode will automatically be enabled in
2054 // |-windowWillEnterFullScreen:|. 2052 // |-windowWillEnterFullScreen:|.
2055 NSWindow* window = [self window]; 2053 NSWindow* window = [self window];
2056 if ([window isKindOfClass:[FramedBrowserWindow class]]) 2054 if ([window isKindOfClass:[FramedBrowserWindow class]])
2057 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; 2055 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen];
2058 } 2056 }
2059 } else { 2057 } else {
2060 if (enteredPresentationModeFromFullscreen_) { 2058 // The user is currently in presentation mode and is now exiting it, which
2061 // The window is currently in fullscreen mode, but the user is choosing to 2059 // also exits fullscreen using the Lion machinery.
2062 // turn presentation mode off (choosing to always show the UI). Set the 2060 NSWindow* window = [self window];
2063 // preference to ensure that presentation mode will stay off for the next 2061 if ([window isKindOfClass:[FramedBrowserWindow class]])
2064 // window that goes fullscreen. 2062 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen];
2065 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO];
2066 [self setPresentationModeInternal:NO forceDropdown:NO];
2067 // Since -windowWillExitFullScreen: won't be called in the
2068 // presentation mode --> fullscreen case, manually hide the exit bubble.
2069 [self destroyFullscreenExitBubbleIfNecessary];
2070 } else {
2071 // The user entered presentation mode directly from non-fullscreen mode
2072 // using the "Enter Presentation Mode" menu item and is using that same
2073 // menu item to exit presentation mode. In this case, exit fullscreen
2074 // mode as well (using the Lion machinery).
2075 NSWindow* window = [self window];
2076 if ([window isKindOfClass:[FramedBrowserWindow class]])
2077 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen];
2078 }
2079 } 2063 }
2080 } 2064 }
2081 2065
2082 - (void)enterPresentationModeForURL:(const GURL&)url 2066 - (void)enterPresentationModeForURL:(const GURL&)url
2083 bubbleType:(FullscreenExitBubbleType)bubbleType { 2067 bubbleType:(FullscreenExitBubbleType)bubbleType {
2084 [self setPresentationMode:YES url:url bubbleType:bubbleType]; 2068 [self setPresentationMode:YES url:url bubbleType:bubbleType];
2085 } 2069 }
2086 2070
2087 - (void)exitPresentationMode { 2071 - (void)exitPresentationMode {
2088 // url: and bubbleType: are ignored when leaving presentation mode. 2072 // url: and bubbleType: are ignored when leaving presentation mode.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2218 2202
2219 - (BOOL)supportsBookmarkBar { 2203 - (BOOL)supportsBookmarkBar {
2220 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2204 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2221 } 2205 }
2222 2206
2223 - (BOOL)isTabbedWindow { 2207 - (BOOL)isTabbedWindow {
2224 return browser_->is_type_tabbed(); 2208 return browser_->is_type_tabbed();
2225 } 2209 }
2226 2210
2227 @end // @implementation BrowserWindowController(WindowType) 2211 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698