also emit html fullscreen notification on windows when its webview contents trigger it

This commit is contained in:
deepak1556 2015-05-21 10:39:31 +05:30
parent 0dcf061dc1
commit e8a02316ce
3 changed files with 38 additions and 27 deletions

View file

@ -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;
}

View file

@ -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();

View file

@ -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.