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

Unified Diff: content/browser/web_contents/web_contents_impl.cc

Issue 12602003: When a pending contents is created but deleted before it is shown, remove it from the list of pendi… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 7 years, 9 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/web_contents/web_contents_impl.cc
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index f7bee53452acc678511175979851aa1a5d09b18d..6e7c16d17fe43021abbd168e52ef85c4f735708e 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -1225,7 +1225,20 @@ void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) {
registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
Source<WebContents>(opener_));
opener_ = NULL;
+ return;
}
+ // Clear a pending contents that has been closed before being shown.
+ for (PendingContents::iterator iter = pending_contents_.begin();
+ iter != pending_contents_.end();
+ ++iter) {
+ if (iter->second != web_contents)
+ continue;
+ pending_contents_.erase(iter);
+ registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ Source<WebContents>(web_contents));
+ return;
+ }
+ NOTREACHED();
}
void WebContentsImpl::AddObserver(WebContentsObserver* observer) {
@@ -1407,6 +1420,8 @@ void WebContentsImpl::CreateNewWindow(
// later.
DCHECK_NE(MSG_ROUTING_NONE, route_id);
pending_contents_[route_id] = new_contents;
+ registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ Source<WebContents>(new_contents));
}
if (delegate_) {
@@ -1540,6 +1555,8 @@ WebContentsImpl* WebContentsImpl::GetCreatedWindow(int route_id) {
WebContentsImpl* new_contents = iter->second;
pending_contents_.erase(route_id);
+ registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
+ Source<WebContents>(new_contents));
if (!new_contents->GetRenderProcessHost()->HasConnection() ||
!new_contents->GetRenderViewHost()->GetView())

Powered by Google App Engine
This is Rietveld 408576698