| OLD | NEW |
| 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 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 date_time_chooser_.reset(new DateTimeChooserAndroid()); | 1218 date_time_chooser_.reset(new DateTimeChooserAndroid()); |
| 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 return; |
| 1228 } | 1229 } |
| 1230 // Clear a pending contents that has been closed before being shown. |
| 1231 for (PendingContents::iterator iter = pending_contents_.begin(); |
| 1232 iter != pending_contents_.end(); |
| 1233 ++iter) { |
| 1234 if (iter->second != web_contents) |
| 1235 continue; |
| 1236 pending_contents_.erase(iter); |
| 1237 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1238 Source<WebContents>(web_contents)); |
| 1239 return; |
| 1240 } |
| 1241 NOTREACHED(); |
| 1229 } | 1242 } |
| 1230 | 1243 |
| 1231 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { | 1244 void WebContentsImpl::AddObserver(WebContentsObserver* observer) { |
| 1232 observers_.AddObserver(observer); | 1245 observers_.AddObserver(observer); |
| 1233 } | 1246 } |
| 1234 | 1247 |
| 1235 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { | 1248 void WebContentsImpl::RemoveObserver(WebContentsObserver* observer) { |
| 1236 observers_.RemoveObserver(observer); | 1249 observers_.RemoveObserver(observer); |
| 1237 } | 1250 } |
| 1238 | 1251 |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1400 WebContentsViewPort* new_view = new_contents->view_.get(); | 1413 WebContentsViewPort* new_view = new_contents->view_.get(); |
| 1401 | 1414 |
| 1402 // TODO(brettw): It seems bogus that we have to call this function on the | 1415 // 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. | 1416 // newly created object and give it one of its own member variables. |
| 1404 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1417 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
| 1405 | 1418 |
| 1406 // Save the created window associated with the route so we can show it | 1419 // Save the created window associated with the route so we can show it |
| 1407 // later. | 1420 // later. |
| 1408 DCHECK_NE(MSG_ROUTING_NONE, route_id); | 1421 DCHECK_NE(MSG_ROUTING_NONE, route_id); |
| 1409 pending_contents_[route_id] = new_contents; | 1422 pending_contents_[route_id] = new_contents; |
| 1423 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1424 Source<WebContents>(new_contents)); |
| 1410 } | 1425 } |
| 1411 | 1426 |
| 1412 if (delegate_) { | 1427 if (delegate_) { |
| 1413 delegate_->WebContentsCreated( | 1428 delegate_->WebContentsCreated( |
| 1414 this, params.opener_frame_id, params.target_url, new_contents); | 1429 this, params.opener_frame_id, params.target_url, new_contents); |
| 1415 } | 1430 } |
| 1416 | 1431 |
| 1417 if (params.opener_suppressed) { | 1432 if (params.opener_suppressed) { |
| 1418 // When the opener is suppressed, the original renderer cannot access the | 1433 // 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. | 1434 // new window. As a result, we need to show and navigate the window here. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 PendingContents::iterator iter = pending_contents_.find(route_id); | 1548 PendingContents::iterator iter = pending_contents_.find(route_id); |
| 1534 | 1549 |
| 1535 // Certain systems can block the creation of new windows. If we didn't succeed | 1550 // Certain systems can block the creation of new windows. If we didn't succeed |
| 1536 // in creating one, just return NULL. | 1551 // in creating one, just return NULL. |
| 1537 if (iter == pending_contents_.end()) { | 1552 if (iter == pending_contents_.end()) { |
| 1538 return NULL; | 1553 return NULL; |
| 1539 } | 1554 } |
| 1540 | 1555 |
| 1541 WebContentsImpl* new_contents = iter->second; | 1556 WebContentsImpl* new_contents = iter->second; |
| 1542 pending_contents_.erase(route_id); | 1557 pending_contents_.erase(route_id); |
| 1558 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1559 Source<WebContents>(new_contents)); |
| 1543 | 1560 |
| 1544 if (!new_contents->GetRenderProcessHost()->HasConnection() || | 1561 if (!new_contents->GetRenderProcessHost()->HasConnection() || |
| 1545 !new_contents->GetRenderViewHost()->GetView()) | 1562 !new_contents->GetRenderViewHost()->GetView()) |
| 1546 return NULL; | 1563 return NULL; |
| 1547 | 1564 |
| 1548 // TODO(brettw): It seems bogus to reach into here and initialize the host. | 1565 // TODO(brettw): It seems bogus to reach into here and initialize the host. |
| 1549 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); | 1566 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); |
| 1550 return new_contents; | 1567 return new_contents; |
| 1551 } | 1568 } |
| 1552 | 1569 |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3501 } | 3518 } |
| 3502 | 3519 |
| 3503 BrowserPluginGuestManager* | 3520 BrowserPluginGuestManager* |
| 3504 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3521 WebContentsImpl::GetBrowserPluginGuestManager() const { |
| 3505 return static_cast<BrowserPluginGuestManager*>( | 3522 return static_cast<BrowserPluginGuestManager*>( |
| 3506 GetBrowserContext()->GetUserData( | 3523 GetBrowserContext()->GetUserData( |
| 3507 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3524 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
| 3508 } | 3525 } |
| 3509 | 3526 |
| 3510 } // namespace content | 3527 } // namespace content |
| OLD | NEW |