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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 // For more info, see comment above class BrowserPluginGuest. | 1348 // For more info, see comment above class BrowserPluginGuest. |
1349 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); | 1349 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); |
1350 WebContentsImpl* new_contents_impl = | 1350 WebContentsImpl* new_contents_impl = |
1351 static_cast<WebContentsImpl*>(new_contents); | 1351 static_cast<WebContentsImpl*>(new_contents); |
1352 new_contents_impl->browser_plugin_guest_.reset( | 1352 new_contents_impl->browser_plugin_guest_.reset( |
1353 BrowserPluginGuest::Create(instance_id, new_contents_impl)); | 1353 BrowserPluginGuest::Create(instance_id, new_contents_impl)); |
1354 } | 1354 } |
1355 new_contents->Init(create_params); | 1355 new_contents->Init(create_params); |
1356 | 1356 |
1357 // Save the window for later if we're not suppressing the opener (since it | 1357 // Save the window for later if we're not suppressing the opener (since it |
1358 // will be shown immediately) and if it's not a guest (since we separately | 1358 // will be shown immediately) and if it's not a guest (since we separately |
Charlie Reis
2013/04/04 21:48:46
This comment looks stale now. For guests, we are
Fady Samuel
2013/04/04 22:35:15
We save the window until WebContentsImpl::ShowCrea
| |
1359 // track when to show guests). | 1359 // track when to show guests). |
1360 if (!params.opener_suppressed && !is_guest) { | 1360 if (!params.opener_suppressed) { |
1361 WebContentsViewPort* new_view = new_contents->view_.get(); | 1361 if (!is_guest) { |
1362 WebContentsViewPort* new_view = new_contents->view_.get(); | |
1362 | 1363 |
1363 // TODO(brettw): It seems bogus that we have to call this function on the | 1364 // TODO(brettw): It seems bogus that we have to call this function on the |
1364 // newly created object and give it one of its own member variables. | 1365 // newly created object and give it one of its own member variables. |
1365 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1366 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
1366 | 1367 } |
1367 // Save the created window associated with the route so we can show it | 1368 // Save the created window associated with the route so we can show it |
1368 // later. | 1369 // later. |
1369 DCHECK_NE(MSG_ROUTING_NONE, route_id); | 1370 DCHECK_NE(MSG_ROUTING_NONE, route_id); |
1370 pending_contents_[route_id] = new_contents; | 1371 pending_contents_[route_id] = new_contents; |
1371 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1372 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1372 Source<WebContents>(new_contents)); | 1373 Source<WebContents>(new_contents)); |
1373 } | 1374 } |
1374 | 1375 |
1375 if (delegate_) { | 1376 if (delegate_) { |
1376 delegate_->WebContentsCreated( | 1377 delegate_->WebContentsCreated( |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1500 // in creating one, just return NULL. | 1501 // in creating one, just return NULL. |
1501 if (iter == pending_contents_.end()) { | 1502 if (iter == pending_contents_.end()) { |
1502 return NULL; | 1503 return NULL; |
1503 } | 1504 } |
1504 | 1505 |
1505 WebContentsImpl* new_contents = iter->second; | 1506 WebContentsImpl* new_contents = iter->second; |
1506 pending_contents_.erase(route_id); | 1507 pending_contents_.erase(route_id); |
1507 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1508 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, |
1508 Source<WebContents>(new_contents)); | 1509 Source<WebContents>(new_contents)); |
1509 | 1510 |
1511 // Don't initialize the guest WebContents immediately. | |
1512 if (new_contents->GetRenderProcessHost()->IsGuest()) | |
Charlie Reis
2013/04/04 21:48:46
What if the process died and didn't have a connect
Fady Samuel
2013/04/04 22:35:15
If the process crashed then we'll do cleanup elsew
| |
1513 return new_contents; | |
1514 | |
1510 if (!new_contents->GetRenderProcessHost()->HasConnection() || | 1515 if (!new_contents->GetRenderProcessHost()->HasConnection() || |
1511 !new_contents->GetRenderViewHost()->GetView()) | 1516 !new_contents->GetRenderViewHost()->GetView()) |
1512 return NULL; | 1517 return NULL; |
1513 | 1518 |
1514 // TODO(brettw): It seems bogus to reach into here and initialize the host. | 1519 // TODO(brettw): It seems bogus to reach into here and initialize the host. |
1515 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); | 1520 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); |
1516 return new_contents; | 1521 return new_contents; |
1517 } | 1522 } |
1518 | 1523 |
1519 RenderWidgetHostView* WebContentsImpl::GetCreatedWidget(int route_id) { | 1524 RenderWidgetHostView* WebContentsImpl::GetCreatedWidget(int route_id) { |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3434 } | 3439 } |
3435 | 3440 |
3436 BrowserPluginGuestManager* | 3441 BrowserPluginGuestManager* |
3437 WebContentsImpl::GetBrowserPluginGuestManager() const { | 3442 WebContentsImpl::GetBrowserPluginGuestManager() const { |
3438 return static_cast<BrowserPluginGuestManager*>( | 3443 return static_cast<BrowserPluginGuestManager*>( |
3439 GetBrowserContext()->GetUserData( | 3444 GetBrowserContext()->GetUserData( |
3440 browser_plugin::kBrowserPluginGuestManagerKeyName)); | 3445 browser_plugin::kBrowserPluginGuestManagerKeyName)); |
3441 } | 3446 } |
3442 | 3447 |
3443 } // namespace content | 3448 } // namespace content |
OLD | NEW |