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