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 <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 1889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1900 | 1900 |
1901 - (void)handleLionToggleFullscreen { | 1901 - (void)handleLionToggleFullscreen { |
1902 DCHECK(base::mac::IsOSLionOrLater()); | 1902 DCHECK(base::mac::IsOSLionOrLater()); |
1903 browser_->ExecuteCommand(IDC_FULLSCREEN); | 1903 browser_->ExecuteCommand(IDC_FULLSCREEN); |
1904 } | 1904 } |
1905 | 1905 |
1906 // On Lion, this method is called by either the Lion fullscreen button or the | 1906 // On Lion, this method is called by either the Lion fullscreen button or the |
1907 // "Enter Full Screen" menu item. On Snow Leopard, this function is never | 1907 // "Enter Full Screen" menu item. On Snow Leopard, this function is never |
1908 // called by the UI directly, but it provides the implementation for | 1908 // called by the UI directly, but it provides the implementation for |
1909 // |-setPresentationMode:|. | 1909 // |-setPresentationMode:|. |
1910 - (void)setFullscreen:(BOOL)fullscreen { | 1910 - (void)setFullscreen:(BOOL)fullscreen |
| 1911 forURL:(const GURL&)url |
| 1912 showButtons:(BOOL)show_buttons { |
1911 if (fullscreen == [self isFullscreen]) | 1913 if (fullscreen == [self isFullscreen]) |
1912 return; | 1914 return; |
1913 | 1915 |
1914 if (![self supportsFullscreen]) | 1916 if (![self supportsFullscreen]) |
1915 return; | 1917 return; |
1916 | 1918 |
1917 if (base::mac::IsOSLionOrLater()) { | 1919 if (base::mac::IsOSLionOrLater()) { |
1918 enteredPresentationModeFromFullscreen_ = YES; | 1920 enteredPresentationModeFromFullscreen_ = YES; |
1919 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) | 1921 if ([[self window] isKindOfClass:[FramedBrowserWindow class]]) |
1920 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; | 1922 [static_cast<FramedBrowserWindow*>([self window]) toggleSystemFullScreen]; |
1921 } else { | 1923 } else { |
1922 if (fullscreen) | 1924 if (fullscreen) |
1923 [self enterFullscreenForSnowLeopardOrEarlier]; | 1925 [self enterFullscreenForSnowLeopardOrEarlier]; |
1924 else | 1926 else |
1925 [self exitFullscreenForSnowLeopardOrEarlier]; | 1927 [self exitFullscreenForSnowLeopardOrEarlier]; |
1926 } | 1928 } |
1927 | 1929 |
1928 if (fullscreen) { | 1930 if (fullscreen && !url.is_empty()) { |
1929 [self showFullscreenExitBubbleIfNecessary]; | 1931 [self showFullscreenExitBubbleIfNecessaryWithURL:url |
| 1932 showButtons:show_buttons]; |
1930 } else { | 1933 } else { |
1931 [self destroyFullscreenExitBubbleIfNecessary]; | 1934 [self destroyFullscreenExitBubbleIfNecessary]; |
1932 } | 1935 } |
1933 } | 1936 } |
1934 | 1937 |
1935 - (BOOL)isFullscreen { | 1938 - (BOOL)isFullscreen { |
1936 return (fullscreenWindow_.get() != nil) || | 1939 return (fullscreenWindow_.get() != nil) || |
1937 ([[self window] styleMask] & NSFullScreenWindowMask); | 1940 ([[self window] styleMask] & NSFullScreenWindowMask); |
1938 } | 1941 } |
1939 | 1942 |
1940 - (void)togglePresentationModeForLionOrLater:(id)sender { | 1943 - (void)togglePresentationModeForLionOrLater:(id)sender { |
1941 // Called only by the presentation mode toggle button. | 1944 // Called only by the presentation mode toggle button. |
1942 DCHECK(base::mac::IsOSLionOrLater()); | 1945 DCHECK(base::mac::IsOSLionOrLater()); |
1943 enteredPresentationModeFromFullscreen_ = YES; | 1946 enteredPresentationModeFromFullscreen_ = YES; |
1944 browser_->ExecuteCommand(IDC_PRESENTATION_MODE); | 1947 browser_->ExecuteCommand(IDC_PRESENTATION_MODE); |
1945 } | 1948 } |
1946 | 1949 |
1947 // On Lion, this function is called by either the presentation mode toggle | 1950 // On Lion, this function is called by either the presentation mode toggle |
1948 // button or the "Enter Presentation Mode" menu item. In the latter case, this | 1951 // button or the "Enter Presentation Mode" menu item. In the latter case, this |
1949 // function also triggers the Lion machinery to enter fullscreen mode as well as | 1952 // function also triggers the Lion machinery to enter fullscreen mode as well as |
1950 // set presentation mode. On Snow Leopard, this function is called by the | 1953 // set presentation mode. On Snow Leopard, this function is called by the |
1951 // "Enter Presentation Mode" menu item, and triggering presentation mode always | 1954 // "Enter Presentation Mode" menu item, and triggering presentation mode always |
1952 // moves the user into fullscreen mode. | 1955 // moves the user into fullscreen mode. |
1953 - (void)setPresentationMode:(BOOL)presentationMode { | 1956 - (void)setPresentationMode:(BOOL)presentationMode |
| 1957 url:(const GURL&)url |
| 1958 showButtons:(BOOL)show_buttons { |
1954 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen | 1959 // Presentation mode on Leopard and Snow Leopard maps directly to fullscreen |
1955 // mode. | 1960 // mode. |
1956 if (base::mac::IsOSSnowLeopardOrEarlier()) { | 1961 if (base::mac::IsOSSnowLeopardOrEarlier()) { |
1957 [self setFullscreen:presentationMode]; | 1962 [self setFullscreen:presentationMode forURL:url showButtons:show_buttons]; |
1958 return; | 1963 return; |
1959 } | 1964 } |
1960 | 1965 |
1961 if (presentationMode) { | 1966 if (presentationMode) { |
1962 BOOL fullscreen = [self isFullscreen]; | 1967 BOOL fullscreen = [self isFullscreen]; |
1963 BOOL fullscreen_for_tab = browser_->is_fullscreen_for_tab(); | 1968 BOOL fullscreen_for_tab = browser_->is_fullscreen_for_tab(); |
1964 if (!fullscreen_for_tab) | 1969 if (!fullscreen_for_tab) |
1965 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; | 1970 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; |
1966 enteredPresentationModeFromFullscreen_ = fullscreen; | 1971 enteredPresentationModeFromFullscreen_ = fullscreen; |
1967 | 1972 |
(...skipping 10 matching lines...) Expand all Loading... |
1978 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; | 1983 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; |
1979 } else { | 1984 } else { |
1980 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. | 1985 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. |
1981 // Presentation mode will automatically be enabled in | 1986 // Presentation mode will automatically be enabled in |
1982 // |-windowWillEnterFullScreen:|. | 1987 // |-windowWillEnterFullScreen:|. |
1983 NSWindow* window = [self window]; | 1988 NSWindow* window = [self window]; |
1984 if ([window isKindOfClass:[FramedBrowserWindow class]]) | 1989 if ([window isKindOfClass:[FramedBrowserWindow class]]) |
1985 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; | 1990 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; |
1986 } | 1991 } |
1987 | 1992 |
1988 [self showFullscreenExitBubbleIfNecessary]; | 1993 [self showFullscreenExitBubbleIfNecessaryWithURL:url |
| 1994 showButtons:show_buttons]; |
1989 } else { | 1995 } else { |
1990 if (enteredPresentationModeFromFullscreen_) { | 1996 if (enteredPresentationModeFromFullscreen_) { |
1991 // The window is currently in fullscreen mode, but the user is choosing to | 1997 // The window is currently in fullscreen mode, but the user is choosing to |
1992 // turn presentation mode off (choosing to always show the UI). Set the | 1998 // turn presentation mode off (choosing to always show the UI). Set the |
1993 // preference to ensure that presentation mode will stay off for the next | 1999 // preference to ensure that presentation mode will stay off for the next |
1994 // window that goes fullscreen. | 2000 // window that goes fullscreen. |
1995 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; | 2001 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; |
1996 [self setPresentationModeInternal:NO forceDropdown:NO]; | 2002 [self setPresentationModeInternal:NO forceDropdown:NO]; |
1997 } else { | 2003 } else { |
1998 // The user entered presentation mode directly from non-fullscreen mode | 2004 // The user entered presentation mode directly from non-fullscreen mode |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2137 | 2143 |
2138 - (BOOL)supportsBookmarkBar { | 2144 - (BOOL)supportsBookmarkBar { |
2139 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2145 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2140 } | 2146 } |
2141 | 2147 |
2142 - (BOOL)isTabbedWindow { | 2148 - (BOOL)isTabbedWindow { |
2143 return browser_->is_type_tabbed(); | 2149 return browser_->is_type_tabbed(); |
2144 } | 2150 } |
2145 | 2151 |
2146 @end // @implementation BrowserWindowController(WindowType) | 2152 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |