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 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2976 void WebContentsImpl::DidChangeLoadProgress(double progress) { | 2993 void WebContentsImpl::DidChangeLoadProgress(double progress) { |
2977 #if defined(OS_ANDROID) | 2994 #if defined(OS_ANDROID) |
2978 if (delegate_) | 2995 if (delegate_) |
2979 delegate_->LoadProgressChanged(this, progress); | 2996 delegate_->LoadProgressChanged(this, progress); |
2980 #endif | 2997 #endif |
2981 } | 2998 } |
2982 | 2999 |
2983 void WebContentsImpl::DidDisownOpener(RenderViewHost* rvh) { | 3000 void WebContentsImpl::DidDisownOpener(RenderViewHost* rvh) { |
2984 // Clear our opener so that future cross-process navigations don't have an | 3001 // Clear our opener so that future cross-process navigations don't have an |
2985 // opener assigned. | 3002 // opener assigned. |
| 3003 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 3004 Source<WebContents>(opener_)); |
2986 opener_ = NULL; | 3005 opener_ = NULL; |
2987 | 3006 |
2988 // Notify all swapped out RenderViewHosts for this tab. This is important | 3007 // Notify all swapped out RenderViewHosts for this tab. This is important |
2989 // in case we go back to them, or if another window in those processes tries | 3008 // in case we go back to them, or if another window in those processes tries |
2990 // to access window.opener. | 3009 // to access window.opener. |
2991 render_manager_.DidDisownOpener(rvh); | 3010 render_manager_.DidDisownOpener(rvh); |
2992 } | 3011 } |
2993 | 3012 |
2994 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { | 3013 void WebContentsImpl::DidUpdateFrameTree(RenderViewHost* rvh) { |
2995 render_manager_.DidUpdateFrameTree(rvh); | 3014 render_manager_.DidUpdateFrameTree(rvh); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3501 } | 3520 } |
3502 | 3521 |
3503 BrowserPluginGuestManager* | 3522 BrowserPluginGuestManager* |
3504 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3523 WebContentsImpl::GetBrowserPluginGuestManager() const { |
3505 return static_cast<BrowserPluginGuestManager*>( | 3524 return static_cast<BrowserPluginGuestManager*>( |
3506 GetBrowserContext()->GetUserData( | 3525 GetBrowserContext()->GetUserData( |
3507 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3526 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
3508 } | 3527 } |
3509 | 3528 |
3510 } // namespace content | 3529 } // namespace content |
OLD | NEW |