Move guest lifetime management to chrome
Now, GuestViewBase takes full responsibility for managing the lifetime of the guest WebContents. The only signal coming from content is that indicating that the BrowserPlugin has been destroyed.
BUG=364141, 330264
[email protected] for trivial browser_plugin_guest_delegate.h code deletion (w00t!)
Review URL: https://codereview.chromium.org/306003002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273759 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 1fbad983..aca15a0 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -43,10 +43,6 @@
// static
BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL;
-namespace {
-
-} // namespace
-
class BrowserPluginGuest::EmbedderWebContentsObserver
: public WebContentsObserver {
public:
@@ -58,11 +54,7 @@
virtual ~EmbedderWebContentsObserver() {
}
- // WebContentsObserver:
- virtual void WebContentsDestroyed() OVERRIDE {
- browser_plugin_guest_->EmbedderDestroyed();
- }
-
+ // WebContentsObserver implementation.
virtual void WasShown() OVERRIDE {
browser_plugin_guest_->EmbedderVisibilityChanged(true);
}
@@ -99,13 +91,15 @@
last_text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
last_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
last_can_compose_inline_(true),
+ delegate_(NULL),
weak_ptr_factory_(this) {
DCHECK(web_contents);
}
-void BrowserPluginGuest::WillDestroy(WebContents* web_contents) {
- DCHECK_EQ(web_contents, GetWebContents());
+void BrowserPluginGuest::WillDestroy() {
is_in_destruction_ = true;
+ embedder_web_contents_ = NULL;
+ delegate_ = NULL;
}
base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() {
@@ -119,13 +113,6 @@
return embedder_web_contents()->GotResponseToLockMouseRequest(allowed);
}
-void BrowserPluginGuest::EmbedderDestroyed() {
- embedder_web_contents_ = NULL;
- if (delegate_)
- delegate_->EmbedderDestroyed();
- Destroy();
-}
-
void BrowserPluginGuest::Destroy() {
if (!delegate_)
return;
@@ -301,7 +288,7 @@
delegate->RegisterDestructionCallback(
base::Bind(&BrowserPluginGuest::WillDestroy,
base::Unretained(guest)));
- guest->SetDelegate(delegate);
+ guest->set_delegate(delegate);
}
return guest;
}
@@ -407,11 +394,6 @@
guest_rvh->DragSourceSystemDragEnded();
}
-void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) {
- DCHECK(!delegate_);
- delegate_.reset(delegate);
-}
-
void BrowserPluginGuest::SendQueuedMessages() {
if (!attached())
return;