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

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

Issue 12018007: Refactor BrowserWindow fullscreen and presentation on Mac to be consistent with other platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge TOT Created 7 years, 10 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 | Annotate | Revision Log
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"
(...skipping 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 2000
2001 - (void)handleLionToggleFullscreen { 2001 - (void)handleLionToggleFullscreen {
2002 DCHECK(base::mac::IsOSLionOrLater()); 2002 DCHECK(base::mac::IsOSLionOrLater());
2003 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN); 2003 chrome::ExecuteCommand(browser_.get(), IDC_FULLSCREEN);
2004 } 2004 }
2005 2005
2006 // On Lion, this method is called by either the Lion fullscreen button or the 2006 // On Lion, this method is called by either the Lion fullscreen button or the
2007 // "Enter Full Screen" menu item. On Snow Leopard, this function is never 2007 // "Enter Full Screen" menu item. On Snow Leopard, this function is never
2008 // called by the UI directly, but it provides the implementation for 2008 // called by the UI directly, but it provides the implementation for
2009 // |-setPresentationMode:|. 2009 // |-setPresentationMode:|.
2010 - (void)setFullscreen:(BOOL)fullscreen 2010 - (void)setFullscreen:(BOOL)fullscreen {
2011 url:(const GURL&)url
2012 bubbleType:(FullscreenExitBubbleType)bubbleType {
2013 if (fullscreen == [self isFullscreen]) 2011 if (fullscreen == [self isFullscreen])
2014 return; 2012 return;
2015 2013
2016 if (!chrome::IsCommandEnabled(browser_.get(), IDC_FULLSCREEN)) 2014 if (!chrome::IsCommandEnabled(browser_.get(), IDC_FULLSCREEN))
2017 return; 2015 return;
2018 2016
2019 if (base::mac::IsOSLionOrLater()) { 2017 if (base::mac::IsOSLionOrLater()) {
2020 enteredPresentationModeFromFullscreen_ = YES; 2018 enteredPresentationModeFromFullscreen_ = YES;
2021 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) 2019 if ([[self window] isKindOfClass:[FramedBrowserWindow class]])
2022 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; 2020 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen];
2023 } else { 2021 } else {
2024 if (fullscreen) 2022 if (fullscreen)
2025 [self enterFullscreenForSnowLeopard]; 2023 [self enterFullscreenForSnowLeopard];
2026 else 2024 else
2027 [self exitFullscreenForSnowLeopard]; 2025 [self exitFullscreenForSnowLeopard];
2028 } 2026 }
2029 } 2027 }
2030 2028
2031 - (void)enterFullscreenForURL:(const GURL&)url 2029 - (void)enterFullscreen {
2032 bubbleType:(FullscreenExitBubbleType)bubbleType { 2030 [self setFullscreen:YES];
2033 [self setFullscreen:YES url:url bubbleType:bubbleType];
2034 } 2031 }
2035 2032
2036 - (void)exitFullscreen { 2033 - (void)exitFullscreen {
2037 // url: and bubbleType: are ignored when leaving fullscreen. 2034 [self setFullscreen:NO];
2038 [self setFullscreen:NO url:GURL() bubbleType:FEB_TYPE_NONE];
2039 } 2035 }
2040 2036
2041 - (void)updateFullscreenExitBubbleURL:(const GURL&)url 2037 - (void)updateFullscreenExitBubbleURL:(const GURL&)url
2042 bubbleType:(FullscreenExitBubbleType)bubbleType { 2038 bubbleType:(FullscreenExitBubbleType)bubbleType {
2043 fullscreenUrl_ = url; 2039 fullscreenUrl_ = url;
2044 fullscreenBubbleType_ = bubbleType; 2040 fullscreenBubbleType_ = bubbleType;
2045 [self showFullscreenExitBubbleIfNecessary]; 2041 [self showFullscreenExitBubbleIfNecessary];
2046 } 2042 }
2047 2043
2048 - (BOOL)isFullscreen { 2044 - (BOOL)isFullscreen {
2049 return (fullscreenWindow_.get() != nil) || 2045 return (fullscreenWindow_.get() != nil) ||
2050 ([[self window] styleMask] & NSFullScreenWindowMask) || 2046 ([[self window] styleMask] & NSFullScreenWindowMask) ||
2051 enteringFullscreen_; 2047 enteringFullscreen_;
2052 } 2048 }
2053 2049
2054 // On Lion, this function is called by either the presentation mode toggle 2050 // On Lion, this function is called by either the presentation mode toggle
2055 // button or the "Enter Presentation Mode" menu item. In the latter case, this 2051 // button or the "Enter Presentation Mode" menu item. In the latter case, this
2056 // function also triggers the Lion machinery to enter fullscreen mode as well as 2052 // function also triggers the Lion machinery to enter fullscreen mode as well as
2057 // set presentation mode. On Snow Leopard, this function is called by the 2053 // set presentation mode. On Snow Leopard, this function is called by the
2058 // "Enter Presentation Mode" menu item, and triggering presentation mode always 2054 // "Enter Presentation Mode" menu item, and triggering presentation mode always
2059 // moves the user into fullscreen mode. 2055 // moves the user into fullscreen mode.
2060 - (void)setPresentationMode:(BOOL)presentationMode 2056 - (void)setPresentationMode:(BOOL)presentationMode
2061 url:(const GURL&)url 2057 url:(const GURL&)url
2062 bubbleType:(FullscreenExitBubbleType)bubbleType { 2058 bubbleType:(FullscreenExitBubbleType)bubbleType {
2063 fullscreenUrl_ = url; 2059 fullscreenUrl_ = url;
2064 fullscreenBubbleType_ = bubbleType; 2060 fullscreenBubbleType_ = bubbleType;
2065 2061
2066 // Presentation mode on Snow Leopard maps directly to fullscreen mode. 2062 // Presentation mode on Snow Leopard maps directly to fullscreen mode.
2067 if (base::mac::IsOSSnowLeopard()) { 2063 if (base::mac::IsOSSnowLeopard()) {
2068 [self setFullscreen:presentationMode url:url bubbleType:bubbleType]; 2064 [self setFullscreen:presentationMode];
2069 return; 2065 return;
2070 } 2066 }
2071 2067
2072 if (presentationMode) { 2068 if (presentationMode) {
2073 BOOL fullscreen = [self isFullscreen]; 2069 BOOL fullscreen = [self isFullscreen];
2074 enteredPresentationModeFromFullscreen_ = fullscreen; 2070 enteredPresentationModeFromFullscreen_ = fullscreen;
2075 enteringPresentationMode_ = YES; 2071 enteringPresentationMode_ = YES;
2076 2072
2077 if (fullscreen) { 2073 if (fullscreen) {
2078 // If already in fullscreen mode, just toggle the presentation mode 2074 // If already in fullscreen mode, just toggle the presentation mode
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2244 2240
2245 - (BOOL)supportsBookmarkBar { 2241 - (BOOL)supportsBookmarkBar {
2246 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2242 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2247 } 2243 }
2248 2244
2249 - (BOOL)isTabbedWindow { 2245 - (BOOL)isTabbedWindow {
2250 return browser_->is_type_tabbed(); 2246 return browser_->is_type_tabbed();
2251 } 2247 }
2252 2248
2253 @end // @implementation BrowserWindowController(WindowType) 2249 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698