Merge pull request #1616 from deepak1556/webview_fullscreen_patch

webContents: override fullscreen notification apis for webview
This commit is contained in:
Cheng Zhao 2015-05-21 15:03:48 +08:00
commit fd41f1e8bc
11 changed files with 114 additions and 3 deletions

View file

@ -215,6 +215,36 @@ void WebContents::HandleKeyboardEvent(
web_contents(), event);
}
void WebContents::EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) {
auto window = GetWindowFromGuest(source);
if (window) {
window->SetHtmlApiFullscreen(true);
window->NotifyWindowEnterHtmlFullScreen();
source->GetRenderViewHost()->WasResized();
Emit("enter-html-full-screen");
}
}
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");
}
}
bool WebContents::IsFullscreenForTabOrPending(
const content::WebContents* source) const {
auto window = GetWindowFromGuest(source);
if (window)
return window->is_html_api_fullscreen();
else
return false;
}
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
Emit("render-view-deleted",
render_view_host->GetProcess()->GetID(),

View file

@ -151,6 +151,11 @@ class WebContents : public mate::EventEmitter,
void HandleKeyboardEvent(
content::WebContents* source,
const content::NativeWebKeyboardEvent& event) override;
void EnterFullscreenModeForTab(content::WebContents* source,
const GURL& origin) override;
void ExitFullscreenModeForTab(content::WebContents* source) override;
bool IsFullscreenForTabOrPending(
const content::WebContents* source) const override;
// content::WebContentsObserver:
void RenderViewDeleted(content::RenderViewHost*) override;

View file

@ -132,6 +132,14 @@ void Window::OnWindowLeaveFullScreen() {
Emit("leave-full-screen");
}
void Window::OnWindowEnterHtmlFullScreen() {
Emit("enter-html-full-screen");
}
void Window::OnWindowLeaveHtmlFullScreen() {
Emit("leave-html-full-screen");
}
void Window::OnRendererUnresponsive() {
Emit("unresponsive");
}

View file

@ -66,6 +66,8 @@ class Window : public mate::EventEmitter,
void OnWindowRestore() override;
void OnWindowEnterFullScreen() override;
void OnWindowLeaveFullScreen() override;
void OnWindowEnterHtmlFullScreen() override;
void OnWindowLeaveHtmlFullScreen() override;
void OnRendererUnresponsive() override;
void OnRendererResponsive() override;
void OnDevToolsFocus() override;