From 20b4cae980cf45c336e235128aaac2032bf7953e Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 21 Apr 2015 19:05:36 +0530 Subject: [PATCH] window: supports HTML5 fullscreen api --- atom/browser/native_window.cc | 14 ++++++++++++++ atom/browser/native_window.h | 7 ++++++- atom/browser/native_window_mac.h | 2 +- atom/browser/native_window_mac.mm | 2 +- atom/browser/native_window_views.cc | 2 +- atom/browser/native_window_views.h | 2 +- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 0576fec0576..c2ed3b0fe79 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -685,6 +685,20 @@ void NativeWindow::RendererResponsive(content::WebContents* source) { FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive()); } +void NativeWindow::EnterFullscreenModeForTab(content::WebContents* source, + const GURL& origin) { + SetFullScreen(true); +} + +void NativeWindow::ExitFullscreenModeForTab(content::WebContents* source) { + SetFullScreen(false); +} + +bool NativeWindow::IsFullscreenForTabOrPending( + const content::WebContents* source) const { + return IsFullscreen(); +} + void NativeWindow::BeforeUnloadFired(const base::TimeTicks& proceed_time) { // Do nothing, we override this method just to avoid compilation error since // there are two virtual functions named BeforeUnloadFired. diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index b300fce3d7b..b1f1a384b8b 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -112,7 +112,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, virtual void Restore() = 0; virtual bool IsMinimized() = 0; virtual void SetFullScreen(bool fullscreen) = 0; - virtual bool IsFullscreen() = 0; + virtual bool IsFullscreen() const = 0; virtual void SetSize(const gfx::Size& size) = 0; virtual gfx::Size GetSize() = 0; virtual void SetContentSize(const gfx::Size& size) = 0; @@ -273,6 +273,11 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, const content::WebContents* source) const override; void RendererUnresponsive(content::WebContents* source) override; void RendererResponsive(content::WebContents* source) override; + void EnterFullscreenModeForTab(content::WebContents* source, + const GURL& origin) override; + void ExitFullscreenModeForTab(content::WebContents* source) override; + bool IsFullscreenForTabOrPending( + const content::WebContents* source) const override; // Implementations of content::WebContentsObserver. void RenderViewCreated(content::RenderViewHost* render_view_host) override; diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index d21b207841e..822594038a5 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -44,7 +44,7 @@ class NativeWindowMac : public NativeWindow { void Restore() override; bool IsMinimized() override; void SetFullScreen(bool fullscreen) override; - bool IsFullscreen() override; + bool IsFullscreen() const override; void SetSize(const gfx::Size& size) override; gfx::Size GetSize() override; void SetContentSize(const gfx::Size& size) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 668826624b4..ce4bc8775f4 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -476,7 +476,7 @@ void NativeWindowMac::SetFullScreen(bool fullscreen) { [window_ toggleFullScreen:nil]; } -bool NativeWindowMac::IsFullscreen() { +bool NativeWindowMac::IsFullscreen() const { return [window_ styleMask] & NSFullScreenWindowMask; } diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 9dc0709946d..1ef0a63680c 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -369,7 +369,7 @@ void NativeWindowViews::SetFullScreen(bool fullscreen) { #endif } -bool NativeWindowViews::IsFullscreen() { +bool NativeWindowViews::IsFullscreen() const { return window_->IsFullscreen(); } diff --git a/atom/browser/native_window_views.h b/atom/browser/native_window_views.h index 56d77afa268..6ec3f2aef43 100644 --- a/atom/browser/native_window_views.h +++ b/atom/browser/native_window_views.h @@ -49,7 +49,7 @@ class NativeWindowViews : public NativeWindow, void Restore() override; bool IsMinimized() override; void SetFullScreen(bool fullscreen) override; - bool IsFullscreen() override; + bool IsFullscreen() const override; void SetSize(const gfx::Size& size) override; gfx::Size GetSize() override; void SetContentSize(const gfx::Size& size) override;