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) {
// notification so that clients that pick up a pointer to |this| can NULL the
// pointer. See Bug 1230284.
notify_disconnection_ = true;
FOR_EACH_OBSERVER(WebContentsObserver, observers_,
RenderViewHostSwapped(old_render_view_host));
// TODO(avi): Remove. http://crbug.com/170921
NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_SWAPPED,
Source<WebContents>(this),
......@@ -2812,14 +2816,8 @@ void WebContentsImpl::NotifySwapped(RenderViewHost* old_render_view_host) {
RemoveBrowserPluginEmbedder();
}
void WebContentsImpl::NotifyConnected() {
notify_disconnection_ = true;
NotificationService::current()->Notify(
NOTIFICATION_WEB_CONTENTS_CONNECTED,
Source<WebContents>(this),
NotificationService::NoDetails());
}
// TODO(avi): Remove this entire function because this notification is already
// covered by two observer functions. http://crbug.com/170921
void WebContentsImpl::NotifyDisconnected() {
if (!notify_disconnection_)
return;
......@@ -2906,7 +2904,13 @@ void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) {
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();
SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0);
......
......@@ -745,7 +745,6 @@ class CONTENT_EXPORT WebContentsImpl
// Helper functions for sending notifications.
void NotifySwapped(RenderViewHost* old_render_view_host);
void NotifyConnected();
void NotifyDisconnected();
void NotifyNavigationEntryCommitted(const LoadCommittedDetails& load_details);
......
......@@ -112,6 +112,7 @@ enum NotificationType {
// the WebContents. A WEB_CONTENTS_DISCONNECTED notification is
// guaranteed before the source pointer becomes junk. No details are
// expected.
// DEPRECATED: Use WebContentsObserver::RenderViewReady()
NOTIFICATION_WEB_CONTENTS_CONNECTED,
// This notification is sent when a WebContents swaps its render view host
......@@ -120,11 +121,16 @@ enum NotificationType {
// NOTIFICATION_WEB_CONTENTS_DISCONNECTED notification is guaranteed before
// the source pointer becomes junk. Details are the RenderViewHost that
// has been replaced, or NULL if the old RVH was shut down.
// DEPRECATED: Use WebContentsObserver::RenderViewHostSwapped()
NOTIFICATION_WEB_CONTENTS_SWAPPED,
// This message is sent after a WebContents is disconnected from the
// renderer process. The source is a Source<WebContents> with a pointer to
// 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,
// This notification is sent after WebContents' title is updated. The source
......@@ -141,6 +147,7 @@ enum NotificationType {
// object holding a reference to a WebContents can listen to that
// notification to properly reset the reference. The source is a
// Source<WebContents>.
// DEPRECATED: Use WebContentsObserver::WebContentsDestroyed()
NOTIFICATION_WEB_CONTENTS_DESTROYED,
// A RenderViewHost was created for a WebContents. The source is the
......
......@@ -66,6 +66,12 @@ class CONTENT_EXPORT WebContentsObserver : public IPC::Listener,
// invoked.
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
// to use for the next navigation, but before the navigation starts.
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