From 556e84f53a03b651ed7abeabc7271e7fa0aa3860 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Jun 2013 18:15:03 +0800 Subject: [PATCH] Discard fullscreen support on OS X 10.6. --- browser/default_app/main.js | 4 +++ browser/native_window_mac.h | 4 --- browser/native_window_mac.mm | 68 ++++-------------------------------- 3 files changed, 11 insertions(+), 65 deletions(-) diff --git a/browser/default_app/main.js b/browser/default_app/main.js index ca7d753ec6e..7bef852e78f 100644 --- a/browser/default_app/main.js +++ b/browser/default_app/main.js @@ -111,6 +111,10 @@ delegate.browserMainParts.preMainMessageLoopRun = function() { accelerator: 'Command+R', click: function() { BrowserWindow.getFocusedWindow().reloadIgnoringCache(); } }, + { + label: 'Enter Fullscreen', + click: function() { BrowserWindow.getFocusedWindow().setFullscreen(true); } + }, { label: 'Toggle DevTools', accelerator: 'Alt+Command+I', diff --git a/browser/native_window_mac.h b/browser/native_window_mac.h index ea20ef92ee0..d2684735455 100644 --- a/browser/native_window_mac.h +++ b/browser/native_window_mac.h @@ -57,8 +57,6 @@ class NativeWindowMac : public NativeWindow { void NotifyWindowBlur() { NativeWindow::NotifyWindowBlur(); } protected: - void SetNonLionFullscreen(bool fullscreen); - // Implementations of content::WebContentsDelegate. virtual void HandleKeyboardEvent( content::WebContents*, @@ -70,9 +68,7 @@ class NativeWindowMac : public NativeWindow { NSWindow* window_; - bool is_fullscreen_; bool is_kiosk_; - NSRect restored_bounds_; NSInteger attention_request_id_; // identifier from requestUserAttention diff --git a/browser/native_window_mac.mm b/browser/native_window_mac.mm index f1436794eed..194b38b7d39 100644 --- a/browser/native_window_mac.mm +++ b/browser/native_window_mac.mm @@ -85,7 +85,6 @@ namespace atom { NativeWindowMac::NativeWindowMac(content::WebContents* web_contents, base::DictionaryValue* options) : NativeWindow(web_contents, options), - is_fullscreen_(false), is_kiosk_(false), attention_request_id_(0) { int width, height; @@ -187,72 +186,19 @@ void NativeWindowMac::Restore() { } void NativeWindowMac::SetFullscreen(bool fullscreen) { - if (fullscreen == is_fullscreen_) + if (fullscreen == IsFullscreen()) return; - if (base::mac::IsOSLionOrLater()) { - is_fullscreen_ = fullscreen; - [window() toggleFullScreen:nil]; + if (!base::mac::IsOSLionOrLater()) { + LOG(ERROR) << "Fullscreen mode is only supported above Lion"; return; } - DCHECK(base::mac::IsOSSnowLeopard()); - - SetNonLionFullscreen(fullscreen); + [window() toggleFullScreen:nil]; } bool NativeWindowMac::IsFullscreen() { - return is_fullscreen_; -} - -void NativeWindowMac::SetNonLionFullscreen(bool fullscreen) { - if (fullscreen == is_fullscreen_) - return; - - is_fullscreen_ = fullscreen; - - // Fade to black. - const CGDisplayReservationInterval kFadeDurationSeconds = 0.6; - bool did_fade_out = false; - CGDisplayFadeReservationToken token; - if (CGAcquireDisplayFadeReservation(kFadeDurationSeconds, &token) == - kCGErrorSuccess) { - did_fade_out = true; - CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendNormal, - kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, /*synchronous=*/true); - } - - // Since frameless windows insert the WebContentsView into the NSThemeFrame - // ([[window contentView] superview]), and since that NSThemeFrame is - // destroyed and recreated when we change the styleMask of the window, we - // need to remove the view from the window when we change the style, and - // add it back afterwards. - UninstallView(); - if (fullscreen) { - restored_bounds_ = [window() frame]; - [window() setStyleMask:NSBorderlessWindowMask]; - [window() setFrame:[window() - frameRectForContentRect:[[window() screen] frame]] - display:YES]; - base::mac::RequestFullScreen(base::mac::kFullScreenModeAutoHideAll); - } else { - base::mac::ReleaseFullScreen(base::mac::kFullScreenModeAutoHideAll); - NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | - NSMiniaturizableWindowMask | NSResizableWindowMask | - NSTexturedBackgroundWindowMask; - [window() setStyleMask:style_mask]; - [window() setFrame:restored_bounds_ display:YES]; - } - InstallView(); - - // Fade back in. - if (did_fade_out) { - CGDisplayFade(token, kFadeDurationSeconds / 2, kCGDisplayBlendSolidColor, - kCGDisplayBlendNormal, 0.0, 0.0, 0.0, /*synchronous=*/false); - CGReleaseDisplayFadeReservation(token); - } - - is_fullscreen_ = fullscreen; + return [window() styleMask] & NSFullScreenWindowMask; } void NativeWindowMac::SetSize(const gfx::Size& size) { @@ -362,11 +308,11 @@ void NativeWindowMac::SetKiosk(bool kiosk) { NSApplicationPresentationDisableHideApplication; [NSApp setPresentationOptions:options]; is_kiosk_ = true; - SetNonLionFullscreen(true); + SetFullscreen(true); } else { [NSApp setPresentationOptions:[NSApp currentSystemPresentationOptions]]; is_kiosk_ = false; - SetNonLionFullscreen(false); + SetFullscreen(false); } }