From: deepak1556 Date: Thu, 21 May 2015 05:09:31 +0000 (+0530) Subject: also emit html fullscreen notification on windows when its webview contents trigger it X-Git-Tag: v0.26.1~3^2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=e8a02316ce78b684b03f3363daf4c1f9ddd891fe;p=electron.git also emit html fullscreen notification on windows when its webview contents trigger it --- diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index f72a4c4d..734434af 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -220,6 +220,7 @@ void WebContents::EnterFullscreenModeForTab(content::WebContents* source, auto window = GetWindowFromGuest(source); if (window) { window->SetHtmlApiFullscreen(true); + window->NotifyWindowEnterHtmlFullScreen(); source->GetRenderViewHost()->WasResized(); Emit("enter-html-full-screen"); } @@ -229,6 +230,7 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) { auto window = GetWindowFromGuest(source); if (window) { window->SetHtmlApiFullscreen(false); + window->NotifyWindowLeaveHtmlFullScreen(); source->GetRenderViewHost()->WasResized(); Emit("leave-html-full-screen"); } @@ -238,7 +240,7 @@ bool WebContents::IsFullscreenForTabOrPending( const content::WebContents* source) const { auto window = GetWindowFromGuest(source); if (window) - return window->IsHtmlApiFullscreen(); + return window->is_html_api_fullscreen(); else return false; } diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 79ea407f..e937bbdf 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -100,6 +100,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, node_integration_(true), has_dialog_attached_(false), html_fullscreen_(false), + native_fullscreen_(false), zoom_factor_(1.0), weak_factory_(this), inspectable_web_contents_( @@ -477,6 +478,25 @@ void NativeWindow::OverrideWebkitPrefs(content::WebPreferences* prefs) { } } +void NativeWindow::SetHtmlApiFullscreen(bool enter_fullscreen) { + // Window is already in fullscreen mode, save the state. + if (enter_fullscreen && IsFullscreen()) { + native_fullscreen_ = true; + html_fullscreen_ = true; + return; + } + + // Exit html fullscreen state but not window's fullscreen mode. + if (!enter_fullscreen && native_fullscreen_) { + html_fullscreen_ = false; + return; + } + + SetFullScreen(enter_fullscreen); + html_fullscreen_ = enter_fullscreen; + native_fullscreen_ = false; +} + void NativeWindow::NotifyWindowClosed() { if (is_closed_) return; @@ -525,6 +545,16 @@ void NativeWindow::NotifyWindowLeaveFullScreen() { OnWindowLeaveFullScreen()); } +void NativeWindow::NotifyWindowEnterHtmlFullScreen() { + FOR_EACH_OBSERVER(NativeWindowObserver, observers_, + OnWindowEnterHtmlFullScreen()); +} + +void NativeWindow::NotifyWindowLeaveHtmlFullScreen() { + FOR_EACH_OBSERVER(NativeWindowObserver, observers_, + OnWindowLeaveHtmlFullScreen()); +} + bool NativeWindow::ShouldCreateWebContents( content::WebContents* web_contents, int route_id, @@ -700,19 +730,15 @@ void NativeWindow::RendererResponsive(content::WebContents* source) { void NativeWindow::EnterFullscreenModeForTab(content::WebContents* source, const GURL& origin) { SetHtmlApiFullscreen(true); - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowEnterHtmlFullScreen()); } void NativeWindow::ExitFullscreenModeForTab(content::WebContents* source) { SetHtmlApiFullscreen(false); - FOR_EACH_OBSERVER(NativeWindowObserver, observers_, - OnWindowLeaveHtmlFullScreen()); } bool NativeWindow::IsFullscreenForTabOrPending( const content::WebContents* source) const { - return IsHtmlApiFullscreen(); + return is_html_api_fullscreen(); } void NativeWindow::BeforeUnloadFired(const base::TimeTicks& proceed_time) { @@ -805,25 +831,6 @@ void NativeWindow::ScheduleUnresponsiveEvent(int ms) { base::TimeDelta::FromMilliseconds(ms)); } -void NativeWindow::SetHtmlApiFullscreen(bool enter_fullscreen) { - // Window is already in fullscreen mode, save the state. - if (enter_fullscreen && IsFullscreen()) { - forced_fullscreen_ = true; - html_fullscreen_ = true; - return; - } - - // Exit html fullscreen state but not window's fullscreen mode. - if (!enter_fullscreen && forced_fullscreen_) { - html_fullscreen_ = false; - return; - } - - SetFullScreen(enter_fullscreen); - html_fullscreen_ = enter_fullscreen; - forced_fullscreen_ = false; -} - void NativeWindow::NotifyWindowUnresponsive() { window_unresposive_closure_.Cancel(); diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index f23c27eb..b114ecf5 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -209,6 +209,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, void NotifyWindowRestore(); void NotifyWindowEnterFullScreen(); void NotifyWindowLeaveFullScreen(); + void NotifyWindowEnterHtmlFullScreen(); + void NotifyWindowLeaveHtmlFullScreen(); void AddObserver(NativeWindowObserver* obs) { observers_.AddObserver(obs); @@ -220,7 +222,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, bool has_frame() const { return has_frame_; } - bool IsHtmlApiFullscreen() const { return html_fullscreen_; } + bool is_html_api_fullscreen() const { return html_fullscreen_; } void set_has_dialog_attached(bool has_dialog_attached) { has_dialog_attached_ = has_dialog_attached; @@ -352,7 +354,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, bool html_fullscreen_; // Whether window is fullscreened by window api. - bool forced_fullscreen_; + bool native_fullscreen_; // Closure that would be called when window is unresponsive when closing, // it should be cancelled when we can prove that the window is responsive.