diff options
author | rockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-09 05:23:18 +0000 |
---|---|---|
committer | rockot@chromium.org <rockot@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-09 05:23:18 +0000 |
commit | 8687971edd01944739be1fd94044e91274a9b953 (patch) | |
tree | d9fc27c6d88b92d598295c73df59cd89d49fca71 /apps | |
parent | b4ab2425bf4b4439a20663e0563c3e0f0043277a (diff) | |
download | chromium_src-8687971edd01944739be1fd94044e91274a9b953.zip chromium_src-8687971edd01944739be1fd94044e91274a9b953.tar.gz chromium_src-8687971edd01944739be1fd94044e91274a9b953.tar.bz2 |
When native app window visibility changes due to either show/hide or minimize/un-minimize, the RWH will now be notified so that page visibility events fire in the renderer.
BUG=157300
TEST=Install window-state-sample (https://chrome.google.com/webstore/detail/window-state-sample/gjijpbgljcllmmhmbcdcaegdandpgpml). Hiding or minimizing the window will cause document.webkitHidden to be true. This can be observed by looking at its checkbox under the "last 10 seconds" readout area after restoring visibility.
Review URL: https://codereview.chromium.org/23473005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227677 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'apps')
-rw-r--r-- | apps/native_app_window.h | 3 | ||||
-rw-r--r-- | apps/shell_window.cc | 13 | ||||
-rw-r--r-- | apps/shell_window.h | 5 |
3 files changed, 19 insertions, 2 deletions
diff --git a/apps/native_app_window.h b/apps/native_app_window.h index b0a6b17..e5403ed 100644 --- a/apps/native_app_window.h +++ b/apps/native_app_window.h @@ -47,6 +47,9 @@ class NativeAppWindow : public ui::BaseWindow, // borders) and the content bounds, if any. virtual gfx::Insets GetFrameInsets() const = 0; + // Indicate whether or not the window is visible. + virtual bool IsVisible() const = 0; + // Hide or show this window as part of hiding or showing the app. // This may have different logic to Hide, Show, and ShowInactive as those are // called via the AppWindow javascript API. diff --git a/apps/shell_window.cc b/apps/shell_window.cc index 99c330c..691bff8 100644 --- a/apps/shell_window.cc +++ b/apps/shell_window.cc @@ -81,7 +81,8 @@ ShellWindow::ShellWindow(Profile* profile, delegate_(delegate), image_loader_ptr_factory_(this), fullscreen_for_window_api_(false), - fullscreen_for_tab_(false) { + fullscreen_for_tab_(false), + is_content_visible_(false) { } void ShellWindow::Init(const GURL& url, @@ -296,6 +297,16 @@ void ShellWindow::OnNativeWindowChanged() { SaveWindowPosition(); if (shell_window_contents_ && native_app_window_) shell_window_contents_->NativeWindowChanged(native_app_window_.get()); + + bool was_content_visible = is_content_visible_; + NativeAppWindow* window = GetBaseWindow(); + if (window) { + is_content_visible_ = window->IsVisible() && !window->IsMinimized(); + if (was_content_visible && !is_content_visible_) + shell_window_contents_->GetWebContents()->WasHidden(); + else if (!was_content_visible && is_content_visible_) + shell_window_contents_->GetWebContents()->WasShown(); + } } void ShellWindow::OnNativeWindowActivated() { diff --git a/apps/shell_window.h b/apps/shell_window.h index f93182a..3d42da7 100644 --- a/apps/shell_window.h +++ b/apps/shell_window.h @@ -219,7 +219,7 @@ class ShellWindow : public content::NotificationObserver, void OnNativeClose(); // Should be called by native implementations when the window size, position, - // or minimized/maximized state has changed. + // minimized/maximized, or visibility state has changed. void OnNativeWindowChanged(); // Should be called by native implementations when the window is activated. @@ -379,6 +379,9 @@ class ShellWindow : public content::NotificationObserver, // Fullscreen entered by HTML requestFullscreen. bool fullscreen_for_tab_; + // The window content is visible. + bool is_content_visible_; + DISALLOW_COPY_AND_ASSIGN(ShellWindow); }; |