Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 306003002: Move guest lifetime management to chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed content_browsertests crash Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/browser_plugin/browser_plugin_guest.cc
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc
index 6c290b7058c80856d21a0bd74408744e43ce4eaf..4e673e14855f192df1e25aec2cf01abf4e4290f9 100644
--- a/content/browser/browser_plugin/browser_plugin_guest.cc
+++ b/content/browser/browser_plugin/browser_plugin_guest.cc
@@ -43,10 +43,6 @@ namespace content {
// static
BrowserPluginHostFactory* BrowserPluginGuest::factory_ = NULL;
-namespace {
-
-} // namespace
-
class BrowserPluginGuest::EmbedderWebContentsObserver
: public WebContentsObserver {
public:
@@ -58,11 +54,7 @@ class BrowserPluginGuest::EmbedderWebContentsObserver
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 @@ BrowserPluginGuest::BrowserPluginGuest(
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 @@ bool BrowserPluginGuest::LockMouse(bool allowed) {
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 @@ BrowserPluginGuest* BrowserPluginGuest::Create(
delegate->RegisterDestructionCallback(
base::Bind(&BrowserPluginGuest::WillDestroy,
base::Unretained(guest)));
- guest->SetDelegate(delegate);
+ guest->set_delegate(delegate);
}
return guest;
}
@@ -407,11 +394,6 @@ void BrowserPluginGuest::EndSystemDrag() {
guest_rvh->DragSourceSystemDragEnded();
}
-void BrowserPluginGuest::SetDelegate(BrowserPluginGuestDelegate* delegate) {
- DCHECK(!delegate_);
- delegate_.reset(delegate);
-}
-
void BrowserPluginGuest::SendQueuedMessages() {
if (!attached())
return;

Powered by Google App Engine
This is Rietveld 408576698