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");
- }
+ CommonWebContentsDelegate::EnterFullscreenModeForTab(source, origin);
+ 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;
+ CommonWebContentsDelegate::ExitFullscreenModeForTab(source);
+ Emit("leave-html-full-screen");
}
void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) {
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;
CommonWebContentsDelegate::CommonWebContentsDelegate(bool is_guest)
: is_guest_(is_guest),
- owner_window_(nullptr) {
+ owner_window_(nullptr),
+ html_fullscreen_(false),
+ native_fullscreen_(false) {
}
CommonWebContentsDelegate::~CommonWebContentsDelegate() {
web_contents_.reset();
}
+content::WebContents* CommonWebContentsDelegate::GetWebContents() const {
+ if (!web_contents_)
+ return nullptr;
+ return web_contents_->GetWebContents();
+}
+
+content::WebContents*
+CommonWebContentsDelegate::GetDevToolsWebContents() const {
+ if (!web_contents_)
+ return nullptr;
+ return web_contents_->GetDevToolsWebContents();
+}
+
void CommonWebContentsDelegate::RequestToLockMouse(
content::WebContents* web_contents,
bool user_gesture,
web_dialog_helper_->EnumerateDirectory(guest, request_id, path);
}
-content::WebContents* CommonWebContentsDelegate::GetWebContents() const {
- if (!web_contents_)
- return nullptr;
- return web_contents_->GetWebContents();
+void CommonWebContentsDelegate::EnterFullscreenModeForTab(
+ content::WebContents* source, const GURL& origin) {
+ if (!owner_window_)
+ return;
+ SetHtmlApiFullscreen(true);
+ owner_window_->NotifyWindowEnterHtmlFullScreen();
+ source->GetRenderViewHost()->WasResized();
}
-content::WebContents*
-CommonWebContentsDelegate::GetDevToolsWebContents() const {
- if (!web_contents_)
- return nullptr;
- return web_contents_->GetDevToolsWebContents();
+void CommonWebContentsDelegate::ExitFullscreenModeForTab(
+ content::WebContents* source) {
+ if (!owner_window_)
+ return;
+ SetHtmlApiFullscreen(false);
+ owner_window_->NotifyWindowLeaveHtmlFullScreen();
+ source->GetRenderViewHost()->WasResized();
+}
+
+bool CommonWebContentsDelegate::IsFullscreenForTabOrPending(
+ const content::WebContents* source) const {
+ return html_fullscreen_;
}
void CommonWebContentsDelegate::DevToolsSaveToFile(
nullptr);
}
+void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) {
+ // Window is already in fullscreen mode, save the state.
+ if (enter_fullscreen && owner_window_->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;
+ }
+
+ owner_window_->SetFullScreen(enter_fullscreen);
+ html_fullscreen_ = enter_fullscreen;
+ native_fullscreen_ = false;
+}
+
} // namespace atom
void EnumerateDirectory(content::WebContents* web_contents,
int request_id,
const base::FilePath& path) override;
+ void EnterFullscreenModeForTab(content::WebContents* source,
+ const GURL& origin) override;
+ void ExitFullscreenModeForTab(content::WebContents* source) override;
+ bool IsFullscreenForTabOrPending(
+ const content::WebContents* source) const override;
// brightray::InspectableWebContentsDelegate:
void DevToolsSaveToFile(const std::string& url,
void DevToolsRemoveFileSystem(const std::string& file_system_path) override;
private:
+ // Set fullscreen mode triggered by html api.
+ void SetHtmlApiFullscreen(bool enter_fullscreen);
+
// Whether this is guest WebContents or NativeWindow.
const bool is_guest_;
// The window that this WebContents belongs to.
NativeWindow* owner_window_;
+ // Whether window is fullscreened by HTML5 api.
+ bool html_fullscreen_;
+
+ // Whether window is fullscreened by window api.
+ bool native_fullscreen_;
+
scoped_ptr<WebDialogHelper> web_dialog_helper_;
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
is_closed_(false),
node_integration_(true),
has_dialog_attached_(false),
- html_fullscreen_(false),
- native_fullscreen_(false),
zoom_factor_(1.0),
weak_factory_(this) {
printing::PrintViewManagerBasic::CreateForWebContents(web_contents);
}
}
-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;
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
}
-void NativeWindow::EnterFullscreenModeForTab(content::WebContents* source,
- const GURL& origin) {
- SetHtmlApiFullscreen(true);
-}
-
-void NativeWindow::ExitFullscreenModeForTab(content::WebContents* source) {
- SetHtmlApiFullscreen(false);
-}
-
-bool NativeWindow::IsFullscreenForTabOrPending(
- const content::WebContents* source) const {
- return is_html_api_fullscreen();
-}
-
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.
void AppendExtraCommandLineSwitches(base::CommandLine* command_line);
void OverrideWebkitPrefs(content::WebPreferences* prefs);
- // Set fullscreen mode triggered by html api.
- void SetHtmlApiFullscreen(bool enter_fullscreen);
-
// Public API used by platform-dependent delegates and observers to send UI
// related notifications.
void NotifyWindowClosed();
bool has_frame() const { return has_frame_; }
- bool is_html_api_fullscreen() const { return html_fullscreen_; }
-
void set_has_dialog_attached(bool has_dialog_attached) {
has_dialog_attached_ = has_dialog_attached;
}
void CloseContents(content::WebContents* source) 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;
// There is a dialog that has been attached to window.
bool has_dialog_attached_;
- // Whether window is fullscreened by HTML5 api.
- bool html_fullscreen_;
-
- // Whether window is fullscreened by window api.
- 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.
base::CancelableClosure window_unresposive_closure_;