| 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)ask_permission { |
| 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:ask_permission]; |
| 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)ask_permission { |
| 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 forURL:url askPermission:ask_permission
]; |
| 1954 return; | 1959 return; |
| 1955 } | 1960 } |
| 1956 | 1961 |
| 1957 if (presentationMode) { | 1962 if (presentationMode) { |
| 1958 BOOL fullscreen = [self isFullscreen]; | 1963 BOOL fullscreen = [self isFullscreen]; |
| 1959 BOOL fullscreen_for_tab = browser_->is_fullscreen_for_tab(); | 1964 BOOL fullscreen_for_tab = browser_->is_fullscreen_for_tab(); |
| 1960 if (!fullscreen_for_tab) | 1965 if (!fullscreen_for_tab) |
| 1961 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; | 1966 [self setShouldUsePresentationModeWhenEnteringFullscreen:YES]; |
| 1962 enteredPresentationModeFromFullscreen_ = fullscreen; | 1967 enteredPresentationModeFromFullscreen_ = fullscreen; |
| 1963 | 1968 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1974 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; | 1979 [self releaseBarVisibilityForOwner:self withAnimation:YES delay:YES]; |
| 1975 } else { | 1980 } else { |
| 1976 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. | 1981 // If not in fullscreen mode, trigger the Lion fullscreen mode machinery. |
| 1977 // Presentation mode will automatically be enabled in | 1982 // Presentation mode will automatically be enabled in |
| 1978 // |-windowWillEnterFullScreen:|. | 1983 // |-windowWillEnterFullScreen:|. |
| 1979 NSWindow* window = [self window]; | 1984 NSWindow* window = [self window]; |
| 1980 if ([window isKindOfClass:[FramedBrowserWindow class]]) | 1985 if ([window isKindOfClass:[FramedBrowserWindow class]]) |
| 1981 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; | 1986 [static_cast<FramedBrowserWindow*>(window) toggleSystemFullScreen]; |
| 1982 } | 1987 } |
| 1983 | 1988 |
| 1984 [self showFullscreenExitBubbleIfNecessary]; | 1989 [self showFullscreenExitBubbleIfNecessaryWithURL:url |
| 1990 askPermission:ask_permission]; |
| 1985 } else { | 1991 } else { |
| 1986 if (enteredPresentationModeFromFullscreen_) { | 1992 if (enteredPresentationModeFromFullscreen_) { |
| 1987 // The window is currently in fullscreen mode, but the user is choosing to | 1993 // 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 | 1994 // 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 | 1995 // preference to ensure that presentation mode will stay off for the next |
| 1990 // window that goes fullscreen. | 1996 // window that goes fullscreen. |
| 1991 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; | 1997 [self setShouldUsePresentationModeWhenEnteringFullscreen:NO]; |
| 1992 [self setPresentationModeInternal:NO forceDropdown:NO]; | 1998 [self setPresentationModeInternal:NO forceDropdown:NO]; |
| 1993 } else { | 1999 } else { |
| 1994 // The user entered presentation mode directly from non-fullscreen mode | 2000 // The user entered presentation mode directly from non-fullscreen mode |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2133 | 2139 |
| 2134 - (BOOL)supportsBookmarkBar { | 2140 - (BOOL)supportsBookmarkBar { |
| 2135 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2141 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2136 } | 2142 } |
| 2137 | 2143 |
| 2138 - (BOOL)isTabbedWindow { | 2144 - (BOOL)isTabbedWindow { |
| 2139 return browser_->is_type_tabbed(); | 2145 return browser_->is_type_tabbed(); |
| 2140 } | 2146 } |
| 2141 | 2147 |
| 2142 @end // @implementation BrowserWindowController(WindowType) | 2148 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |