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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 #endif 1219 #endif
1220 } 1220 }
1221 1221
1222 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) { 1222 void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) {
1223 // Clear the opener if it has been closed. 1223 // Clear the opener if it has been closed.
1224 if (web_contents == opener_) { 1224 if (web_contents == opener_) {
1225 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, 1225 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
1226 Source<WebContents>(opener_)); 1226 Source<WebContents>(opener_));
1227 opener_ = NULL; 1227 opener_ = NULL;
1228 } 1228 }
1229 // Clear a pending contents that has been closed before being shown.
1230 for (PendingContents::iterator iter = pending_contents_.begin();
1231 iter != pending_contents_.end();
1232 ++iter) {
1233 if (iter->second != web_contents)
1234 continue;
1235 pending_contents_.erase(iter);
1236 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
1237 Source<WebContents>(web_contents));
1238 return;
1239 }
1240 NOTREACHED();
Charlie Reis 2013/03/07 18:20:00 Why is this here? It's failing in all the tests,
jochen (gone - plz use gerrit) 2013/03/07 19:45:10 Ah, because I forgot to add a return in the if() b
1229 } 1241 }
1230 1242
1231 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { 1243 void WebContentsImpl::AddObserver(WebContentsObserver* observer) {
1232 observers_.AddObserver(observer); 1244 observers_.AddObserver(observer);
1233 } 1245 }
1234 1246
1235 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { 1247 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) {
1236 observers_.RemoveObserver(observer); 1248 observers_.RemoveObserver(observer);
1237 } 1249 }
1238 1250
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 WebContentsViewPort* new_view = new_contents->view_.get(); 1412 WebContentsViewPort* new_view = new_contents->view_.get();
1401 1413
1402 // TODO(brettw): It seems bogus that we have to call this function on the 1414 // TODO(brettw): It seems bogus that we have to call this function on the
1403 // newly created object and give it one of its own member variables. 1415 // newly created object and give it one of its own member variables.
1404 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); 1416 new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
1405 1417
1406 // Save the created window associated with the route so we can show it 1418 // Save the created window associated with the route so we can show it
1407 // later. 1419 // later.
1408 DCHECK_NE(MSG_ROUTING_NONE, route_id); 1420 DCHECK_NE(MSG_ROUTING_NONE, route_id);
1409 pending_contents_[route_id] = new_contents; 1421 pending_contents_[route_id] = new_contents;
1422 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
1423 Source<WebContents>(new_contents));
1410 } 1424 }
1411 1425
1412 if (delegate_) { 1426 if (delegate_) {
1413 delegate_->WebContentsCreated( 1427 delegate_->WebContentsCreated(
1414 this, params.opener_frame_id, params.target_url, new_contents); 1428 this, params.opener_frame_id, params.target_url, new_contents);
1415 } 1429 }
1416 1430
1417 if (params.opener_suppressed) { 1431 if (params.opener_suppressed) {
1418 // When the opener is suppressed, the original renderer cannot access the 1432 // When the opener is suppressed, the original renderer cannot access the
1419 // new window. As a result, we need to show and navigate the window here. 1433 // new window. As a result, we need to show and navigate the window here.
(...skipping 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after
3501 } 3515 }
3502 3516
3503 BrowserPluginGuestManager* 3517 BrowserPluginGuestManager*
3504 WebContentsImpl::GetBrowserPluginGuestManager() const { 3518 WebContentsImpl::GetBrowserPluginGuestManager() const {
3505 return static_cast<BrowserPluginGuestManager*>( 3519 return static_cast<BrowserPluginGuestManager*>(
3506 GetBrowserContext()->GetUserData( 3520 GetBrowserContext()->GetUserData(
3507 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3521 browser_plugin::kBrowserPluginGuestManagerKeyName));
3508 } 3522 }
3509 3523
3510 } // namespace content 3524 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698