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