Commit da7a7189 authored by avi@chromium.org's avatar avi@chromium.org

Provide observer functions for NOTIFICATION_WEB_CONTENTS_CONNECTED,...

Provide observer functions for NOTIFICATION_WEB_CONTENTS_CONNECTED, NOTIFICATION_WEB_CONTENTS_SWAPPED, NOTIFICATION_WEB_CONTENTS_DISCONNECTED

BUG=170921
TEST=no functional change

Review URL: https://chromiumcodereview.appspot.com/23784005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221640 0039d316-1c4b-4281-b951-d872f2087c98
parent 4ac4befe
...@@ -2801,6 +2801,10 @@ void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { ...@@ -2801,6 +2801,10 @@ void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) {
// notification so that clients that pick up a pointer to |this| can NULL the // notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284. // pointer. See Bug 1230284.
notify_disconnection_ = true; notify_disconnection_ = true;
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
RenderViewHostSwapped(old_render_view_host));
// TODO(avi): Remove. http://crbug.com/170921
NotificationService::current()->Notify( NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_SWAPPED, NOTIFICATION_WEB_CONTENTS_SWAPPED,
Source<WebContents>(this), Source<WebContents>(this),
...@@ -2812,14 +2816,8 @@ void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) { ...@@ -2812,14 +2816,8 @@ void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) {
RemoveBrowserPluginEmbedder(); RemoveBrowserPluginEmbedder();
} }
void WebContentsImpl::NotifyConnected() { // TODO(avi): Remove this entire function because this notification is already
notify_disconnection_ = true; // covered by two observer functions. http://crbug.com/170921
NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_CONNECTED,
Source<WebContents>(this),
NotificationService::NoDetails());
}
void WebContentsImpl::NotifyDisconnected() { void WebContentsImpl::NotifyDisconnected() {
if (!notify_disconnection_) if (!notify_disconnection_)
return; return;
...@@ -2906,7 +2904,13 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { ...@@ -2906,7 +2904,13 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) {
return; return;
} }
NotifyConnected(); notify_disconnection_ = true;
// TODO(avi): Remove. http://crbug.com/170921
NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_CONNECTED,
Source<WebContents>(this),
NotificationService::NoDetails());
bool was_crashed = IsCrashed(); bool was_crashed = IsCrashed();
SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0);
......
...@@ -745,7 +745,6 @@ class CONTENT_EXPORT WebContentsImpl ...@@ -745,7 +745,6 @@ class CONTENT_EXPORT WebContentsImpl
// Helper functions for sending notifications. // Helper functions for sending notifications.
void NotifySwapped(RenderViewHost* old_render_view_host); void NotifySwapped(RenderViewHost* old_render_view_host);
void NotifyConnected();
void NotifyDisconnected(); void NotifyDisconnected();
void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details); void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details);
......
...@@ -112,6 +112,7 @@ enum NotificationType { ...@@ -112,6 +112,7 @@ enum NotificationType {
// the WebContents. A WEB_CONTENTS_DISCONNECTED notification is // the WebContents. A WEB_CONTENTS_DISCONNECTED notification is
// guaranteed before the source pointer becomes junk. No details are // guaranteed before the source pointer becomes junk. No details are
// expected. // expected.
// DEPRECATED: Use WebContentsObserver::RenderViewReady()
NOTIFICATION_WEB_CONTENTS_CONNECTED, NOTIFICATION_WEB_CONTENTS_CONNECTED,
// This notification is sent when a WebContents swaps its render view host // This notification is sent when a WebContents swaps its render view host
...@@ -120,11 +121,16 @@ enum NotificationType { ...@@ -120,11 +121,16 @@ enum NotificationType {
// NOTIFICATION_WEB_CONTENTS_DISCONNECTED notification is guaranteed before // NOTIFICATION_WEB_CONTENTS_DISCONNECTED notification is guaranteed before
// the source pointer becomes junk. Details are the RenderViewHost that // the source pointer becomes junk. Details are the RenderViewHost that
// has been replaced, or NULL if the old RVH was shut down. // has been replaced, or NULL if the old RVH was shut down.
// DEPRECATED: Use WebContentsObserver::RenderViewHostSwapped()
NOTIFICATION_WEB_CONTENTS_SWAPPED, NOTIFICATION_WEB_CONTENTS_SWAPPED,
// This message is sent after a WebContents is disconnected from the // This message is sent after a WebContents is disconnected from the
// renderer process. The source is a Source<WebContents> with a pointer to // renderer process. The source is a Source<WebContents> with a pointer to
// the WebContents (the pointer is usable). No details are expected. // the WebContents (the pointer is usable). No details are expected.
// DEPRECATED: This is fired in two situations: when the render process
// crashes, in which case use WebContentsObserver::RenderProcessGone, and when
// the WebContents is being torn down, in which case use
// WebContentsObserver::WebContentsDestroyed()
NOTIFICATION_WEB_CONTENTS_DISCONNECTED, NOTIFICATION_WEB_CONTENTS_DISCONNECTED,
// This notification is sent after WebContents' title is updated. The source // This notification is sent after WebContents' title is updated. The source
...@@ -141,6 +147,7 @@ enum NotificationType { ...@@ -141,6 +147,7 @@ enum NotificationType {
// object holding a reference to a WebContents can listen to that // object holding a reference to a WebContents can listen to that
// notification to properly reset the reference. The source is a // notification to properly reset the reference. The source is a
// Source<WebContents>. // Source<WebContents>.
// DEPRECATED: Use WebContentsObserver::WebContentsDestroyed()
NOTIFICATION_WEB_CONTENTS_DESTROYED, NOTIFICATION_WEB_CONTENTS_DESTROYED,
// A RenderViewHost was created for a WebContents. The source is the // A RenderViewHost was created for a WebContents. The source is the
......
...@@ -66,6 +66,12 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener, ...@@ -66,6 +66,12 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
// invoked. // invoked.
virtual void RenderProcessGone(base::TerminationStatus status) {} virtual void RenderProcessGone(base::TerminationStatus status) {}
// This method is invoked when a WebContents swaps its render view host with
// another one, possibly changing processes. The RenderViewHost that has
// been replaced is in |old_render_view_host|, which is NULL if the old RVH
// was shut down.
virtual void RenderViewHostSwapped(RenderViewHost* old_render_view_host) {}
// This method is invoked after the WebContents decided which RenderViewHost // This method is invoked after the WebContents decided which RenderViewHost
// to use for the next navigation, but before the navigation starts. // to use for the next navigation, but before the navigation starts.
virtual void AboutToNavigateRenderView( virtual void AboutToNavigateRenderView(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment