| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <Carbon/Carbon.h> | 7 #include <Carbon/Carbon.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <numeric> | 10 #include <numeric> |
| (...skipping 1930 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 if (fullscreen == [self isFullscreen]) | 1941 if (fullscreen == [self isFullscreen]) |
| 1942 return; | 1942 return; |
| 1943 | 1943 |
| 1944 if (![self supportsFullscreen]) | 1944 if (![self supportsFullscreen]) |
| 1945 return; | 1945 return; |
| 1946 | 1946 |
| 1947 if (base::mac::IsOSLionOrLater()) { | 1947 if (base::mac::IsOSLionOrLater()) { |
| 1948 enteredPresentationModeFromFullscreen_ = YES; | 1948 enteredPresentationModeFromFullscreen_ = YES; |
| 1949 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) | 1949 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) |
| 1950 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; | 1950 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; |
| 1951 return; | 1951 } else { |
| 1952 if (fullscreen) |
| 1953 [self enterFullscreenForSnowLeopardOrEarlier]; |
| 1954 else |
| 1955 [self exitFullscreenForSnowLeopardOrEarlier]; |
| 1952 } | 1956 } |
| 1953 | 1957 |
| 1954 if (fullscreen) | 1958 if (fullscreen) { |
| 1955 [self enterFullscreenForSnowLeopardOrEarlier]; | 1959 [self showFullscreenExitBubbleIfNecessary]; |
| 1956 else | 1960 } else { |
| 1957 [self exitFullscreenForSnowLeopardOrEarlier]; | 1961 [self destroyFullscreenExitBubbleIfNecessary]; |
| 1962 } |
| 1958 } | 1963 } |
| 1959 | 1964 |
| 1960 - (BOOL)isFullscreen { | 1965 - (BOOL)isFullscreen { |
| 1961 return (fullscreenWindow_.get() != nil) || | 1966 return (fullscreenWindow_.get() != nil) || |
| 1962 ([[self window] styleMask] & NSFullScreenWindowMask); | 1967 ([[self window] styleMask] & NSFullScreenWindowMask); |
| 1963 } | 1968 } |
| 1964 | 1969 |
| 1965 - (void)togglePresentationModeForLionOrLater:(id)sender { | 1970 - (void)togglePresentationModeForLionOrLater:(id)sender { |
| 1966 // Called only by the presentation mode toggle button. | 1971 // Called only by the presentation mode toggle button. |
| 1967 DCHECK(base::mac::IsOSLionOrLater()); | 1972 DCHECK(base::mac::IsOSLionOrLater()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1978 - (void)setPresentationMode:(BOOL)presentationMode { | 1983 - (void)setPresentationMode:(BOOL)presentationMode { |
| 1979 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen | 1984 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen |
| 1980 // mode. | 1985 // mode. |
| 1981 if (base::mac::IsOSSnowLeopardOrEarlier()) { | 1986 if (base::mac::IsOSSnowLeopardOrEarlier()) { |
| 1982 [self setFullscreen:presentationMode]; | 1987 [self setFullscreen:presentationMode]; |
| 1983 return; | 1988 return; |
| 1984 } | 1989 } |
| 1985 | 1990 |
| 1986 if (presentationMode) { | 1991 if (presentationMode) { |
| 1987 BOOL fullscreen = [self isFullscreen]; | 1992 BOOL fullscreen = [self isFullscreen]; |
| 1988 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; | 1993 BOOL fullscreen_for_tab = browser_->is_fullscreen_for_tab(); |
| 1994 if (!fullscreen_for_tab) |
| 1995 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; |
| 1989 enteredPresentationModeFromFullscreen_ = fullscreen; | 1996 enteredPresentationModeFromFullscreen_ = fullscreen; |
| 1990 | 1997 |
| 1991 if (fullscreen) { | 1998 if (fullscreen) { |
| 1992 // If already in fullscreen mode, just toggle the presentation mode | 1999 // If already in fullscreen mode, just toggle the presentation mode |
| 1993 // setting. Go through an elaborate dance to force the overlay to show, | 2000 // setting. Go through an elaborate dance to force the overlay to show, |
| 1994 // then animate out once the mouse moves away. This helps draw attention | 2001 // then animate out once the mouse moves away. This helps draw attention |
| 1995 // to the fact that the UI is in an overlay. Focus the tab contents | 2002 // to the fact that the UI is in an overlay. Focus the tab contents |
| 1996 // because the omnibox is the most likely source of bar visibility locks, | 2003 // because the omnibox is the most likely source of bar visibility locks, |
| 1997 // and taking focus away from the omnibox releases its lock. | 2004 // and taking focus away from the omnibox releases its lock. |
| 1998 [self lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; | 2005 [self lockBarVisibilityForOwner:self withAnimation:NO delay:NO]; |
| 1999 [self focusTabContents]; | 2006 [self focusTabContents]; |
| 2000 [self setPresentationModeInternal:YES forceDropdown:YES]; | 2007 [self setPresentationModeInternal:YES forceDropdown:YES]; |
| 2001 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; | 2008 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; |
| 2002 } else { | 2009 } else { |
| 2003 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. | 2010 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. |
| 2004 // Presentation mode will automatically be enabled in | 2011 // Presentation mode will automatically be enabled in |
| 2005 // |-windowWillEnterFullScreen:|. | 2012 // |-windowWillEnterFullScreen:|. |
| 2006 NSWindow* window = [self window]; | 2013 NSWindow* window = [self window]; |
| 2007 if ([window isKindOfClass:[FramedBrowserWindow class]]) | 2014 if ([window isKindOfClass:[FramedBrowserWindow class]]) |
| 2008 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; | 2015 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; |
| 2009 } | 2016 } |
| 2017 |
| 2018 [self showFullscreenExitBubbleIfNecessary]; |
| 2010 } else { | 2019 } else { |
| 2011 if (enteredPresentationModeFromFullscreen_) { | 2020 if (enteredPresentationModeFromFullscreen_) { |
| 2012 // The window is currently in fullscreen mode, but the user is choosing to | 2021 // The window is currently in fullscreen mode, but the user is choosing to |
| 2013 // turn presentation mode off (choosing to always show the UI). Set the | 2022 // turn presentation mode off (choosing to always show the UI). Set the |
| 2014 // preference to ensure that presentation mode will stay off for the next | 2023 // preference to ensure that presentation mode will stay off for the next |
| 2015 // window that goes fullscreen. | 2024 // window that goes fullscreen. |
| 2016 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; | 2025 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; |
| 2017 [self setPresentationModeInternal:NO forceDropdown:NO]; | 2026 [self setPresentationModeInternal:NO forceDropdown:NO]; |
| 2018 } else { | 2027 } else { |
| 2019 // The user entered presentation mode directly from non-fullscreen mode | 2028 // The user entered presentation mode directly from non-fullscreen mode |
| 2020 // using the "Enter Presentation Mode" menu item and is using that same | 2029 // using the "Enter Presentation Mode" menu item and is using that same |
| 2021 // menu item to exit presentation mode. In this case, exit fullscreen | 2030 // menu item to exit presentation mode. In this case, exit fullscreen |
| 2022 // mode as well (using the Lion machinery). | 2031 // mode as well (using the Lion machinery). |
| 2023 NSWindow* window = [self window]; | 2032 NSWindow* window = [self window]; |
| 2024 if ([window isKindOfClass:[FramedBrowserWindow class]]) | 2033 if ([window isKindOfClass:[FramedBrowserWindow class]]) |
| 2025 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; | 2034 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; |
| 2026 } | 2035 } |
| 2036 |
| 2037 [self destroyFullscreenExitBubbleIfNecessary]; |
| 2027 } | 2038 } |
| 2028 } | 2039 } |
| 2029 | 2040 |
| 2030 - (BOOL)inPresentationMode { | 2041 - (BOOL)inPresentationMode { |
| 2031 return presentationModeController_.get() && | 2042 return presentationModeController_.get() && |
| 2032 [presentationModeController_ inPresentationMode]; | 2043 [presentationModeController_ inPresentationMode]; |
| 2033 } | 2044 } |
| 2034 | 2045 |
| 2035 - (void)resizeFullscreenWindow { | 2046 - (void)resizeFullscreenWindow { |
| 2036 DCHECK([self isFullscreen]); | 2047 DCHECK([self isFullscreen]); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 | 2167 |
| 2157 - (BOOL)supportsBookmarkBar { | 2168 - (BOOL)supportsBookmarkBar { |
| 2158 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2169 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2159 } | 2170 } |
| 2160 | 2171 |
| 2161 - (BOOL)isTabbedWindow { | 2172 - (BOOL)isTabbedWindow { |
| 2162 return browser_->is_type_tabbed(); | 2173 return browser_->is_type_tabbed(); |
| 2163 } | 2174 } |
| 2164 | 2175 |
| 2165 @end // @implementation BrowserWindowController(WindowType) | 2176 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |