check if window is html or forced fullscreen

This commit is contained in:
deepak1556 2015-05-19 14:06:19 +05:30
parent f2d91bc53c
commit 0dcf061dc1
6 changed files with 35 additions and 4 deletions

View file

@ -221,6 +221,7 @@ void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
if (window) {
window->SetHtmlApiFullscreen(true);
source->GetRenderViewHost()->WasResized();
Emit("enter-html-full-screen");
}
}
@ -229,6 +230,7 @@ void WebContents::ExitFullscreenModeForTab(content::WebContents* source) {
if (window) {
window->SetHtmlApiFullscreen(false);
source->GetRenderViewHost()->WasResized();
Emit("leave-html-full-screen");
}
}

View file

@ -20,6 +20,8 @@ supportedWebViewEvents = [
'destroyed'
'page-title-set'
'page-favicon-updated'
'enter-html-full-screen'
'leave-html-full-screen'
]
nextInstanceId = 0

View file

@ -99,7 +99,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
is_closed_(false),
node_integration_(true),
has_dialog_attached_(false),
fullscreen_(false),
html_fullscreen_(false),
zoom_factor_(1.0),
weak_factory_(this),
inspectable_web_contents_(
@ -806,8 +806,22 @@ void NativeWindow::ScheduleUnresponsiveEvent(int 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);
fullscreen_ = enter_fullscreen;
html_fullscreen_ = enter_fullscreen;
forced_fullscreen_ = false;
}
void NativeWindow::NotifyWindowUnresponsive() {

View file

@ -220,7 +220,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
bool has_frame() const { return has_frame_; }
bool IsHtmlApiFullscreen() const { return fullscreen_; }
bool IsHtmlApiFullscreen() const { return html_fullscreen_; }
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
@ -349,7 +349,10 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
bool has_dialog_attached_;
// Whether window is fullscreened by HTML5 api.
bool fullscreen_;
bool html_fullscreen_;
// Whether window is fullscreened by window api.
bool forced_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.

View file

@ -22,6 +22,8 @@ WEB_VIEW_EVENTS =
'destroyed': []
'page-title-set': ['title', 'explicitSet']
'page-favicon-updated': ['favicons']
'enter-html-full-screen': []
'leave-html-full-screen': []
dispatchEvent = (webView, event, args...) ->
throw new Error("Unkown event #{event}") unless WEB_VIEW_EVENTS[event]?

View file

@ -361,6 +361,14 @@ url.
Fired when page receives favicon urls.
### enter-html-full-screen
Fired when page enters fullscreen triggered by html api.
### leave-html-full-screen
Fired when page leaves fullscreen triggered by html api.
### console-message
* `level` Integer