diff options
author | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 22:05:37 +0000 |
---|---|---|
committer | fsamuel@chromium.org <fsamuel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 22:05:37 +0000 |
commit | 375fa1b1ee5cec55d607bb74a56771d90a9e3129 (patch) | |
tree | a65f9d99c5a82dc49af4b6cc1761dab29e772dc9 /content | |
parent | 666b38db9f4a9faf3226f1da095d1dc5d753260b (diff) | |
download | chromium_src-375fa1b1ee5cec55d607bb74a56771d90a9e3129.zip chromium_src-375fa1b1ee5cec55d607bb74a56771d90a9e3129.tar.gz chromium_src-375fa1b1ee5cec55d607bb74a56771d90a9e3129.tar.bz2 |
Browser Plugin: WebContnets should notify when it's restored
Renamed NOTIFICATION_WEB_CONTENTS_HIDDEN to NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED and
updated all appropriate places. We check for the detail false if we meant to check if the
WebContents is hidden. This matches the behavior of RenderWidget's
NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED.
Added a WasRestored method to WebContents public interface.
Call WasRestored from WebContents::ShowContents
BUG=128814
TEST=did not break existing autofill popup browser test
Review URL: https://chromiumcodereview.appspot.com/10411033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138372 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/web_contents/web_contents_impl.cc | 15 | ||||
-rw-r--r-- | content/browser/web_contents/web_contents_impl.h | 1 | ||||
-rw-r--r-- | content/public/browser/notification_types.h | 7 | ||||
-rw-r--r-- | content/public/browser/web_contents.h | 4 |
4 files changed, 21 insertions, 6 deletions
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 01f4fa0..316b488 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -47,6 +47,7 @@ #include "content/public/browser/load_notification_details.h" #include "content/public/browser/navigation_details.h" #include "content/public/browser/notification_service.h" +#include "content/public/browser/notification_details.h" #include "content/public/browser/resource_request_details.h" #include "content/public/browser/user_metrics.h" #include "content/public/browser/web_contents_delegate.h" @@ -906,10 +907,19 @@ void WebContentsImpl::WasHidden() { rwhv->WasHidden(); } + bool is_visible = false; content::NotificationService::current()->Notify( - content::NOTIFICATION_WEB_CONTENTS_HIDDEN, + content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, content::Source<WebContents>(this), - content::NotificationService::NoDetails()); + content::Details<bool>(&is_visible)); +} + +void WebContentsImpl::WasRestored() { + bool is_visible = true; + content::NotificationService::current()->Notify( + content::NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, + content::Source<WebContents>(this), + content::Details<bool>(&is_visible)); } void WebContentsImpl::ShowContents() { @@ -917,6 +927,7 @@ void WebContentsImpl::ShowContents() { RenderWidgetHostViewPort::FromRWHV(GetRenderWidgetHostView()); if (rwhv) rwhv->DidBecomeSelected(); + WasRestored(); } void WebContentsImpl::HideContents() { diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 89f5db8..5bbd409 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -187,6 +187,7 @@ class CONTENT_EXPORT WebContentsImpl virtual void DidBecomeSelected() OVERRIDE; virtual base::TimeTicks GetLastSelectedTime() const OVERRIDE; virtual void WasHidden() OVERRIDE; + virtual void WasRestored() OVERRIDE; virtual void ShowContents() OVERRIDE; virtual void HideContents() OVERRIDE; virtual bool NeedToFireBeforeUnload() OVERRIDE; diff --git a/content/public/browser/notification_types.h b/content/public/browser/notification_types.h index 0b7eb70..6d9c080 100644 --- a/content/public/browser/notification_types.h +++ b/content/public/browser/notification_types.h @@ -212,9 +212,10 @@ enum NotificationType { // is a std::pair<NavigationEntry*, bool> that contains more information. NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, - // This notification is sent when a WebContents is being hidden, e.g. due - // to switching away from this tab. The source is a Source<WebContents>. - NOTIFICATION_WEB_CONTENTS_HIDDEN, + // Indicates a WebContents has been hidden or restored. The source is + // a Source<WebContents>. The details is a bool set to true if the new + // state is visible. + NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, // This notification is sent when a WebContents is being destroyed. Any // object holding a reference to a WebContents can listen to that diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index c284b4f..b5a406e 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -201,9 +201,11 @@ class WebContents : public PageNavigator { virtual base::TimeTicks GetLastSelectedTime() const = 0; // Invoked when the WebContents becomes hidden. - // NOTE: If you override this, call the superclass version too! virtual void WasHidden() = 0; + // Invoked when the WebContents is restored. + virtual void WasRestored() = 0; + // TODO(brettw) document these. virtual void ShowContents() = 0; virtual void HideContents() = 0; |