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

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 13649007: Browser Plugin: Simplify NewWindow code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 7 years, 8 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
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1337 matching lines...) Expand 10 before | Expand all | Expand 10 after
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).
1359 // track when to show guests). 1359 if (!params.opener_suppressed) {
1360 if (!params.opener_suppressed && !is_guest) { 1360 if (!is_guest) {
1361 WebContentsViewPort* new_view = new_contents->view_.get(); 1361 WebContentsViewPort* new_view = new_contents->view_.get();
1362 1362
1363 // TODO(brettw): It seems bogus that we have to call this function on the 1363 // 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. 1364 // newly created object and give it one of its own member variables.
1365 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); 1365 new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
1366 1366 }
1367 // Save the created window associated with the route so we can show it 1367 // Save the created window associated with the route so we can show it
1368 // later. 1368 // later.
1369 DCHECK_NE(MSG_ROUTING_NONE, route_id); 1369 DCHECK_NE(MSG_ROUTING_NONE, route_id);
1370 pending_contents_[route_id] = new_contents; 1370 pending_contents_[route_id] = new_contents;
1371 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, 1371 registrar_.Add(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
1372 Source<WebContents>(new_contents)); 1372 Source<WebContents>(new_contents));
1373 } 1373 }
1374 1374
1375 if (delegate_) { 1375 if (delegate_) {
1376 delegate_->WebContentsCreated( 1376 delegate_->WebContentsCreated(
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 // in creating one, just return NULL. 1500 // in creating one, just return NULL.
1501 if (iter == pending_contents_.end()) { 1501 if (iter == pending_contents_.end()) {
1502 return NULL; 1502 return NULL;
1503 } 1503 }
1504 1504
1505 WebContentsImpl* new_contents = iter->second; 1505 WebContentsImpl* new_contents = iter->second;
1506 pending_contents_.erase(route_id); 1506 pending_contents_.erase(route_id);
1507 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, 1507 registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
1508 Source<WebContents>(new_contents)); 1508 Source<WebContents>(new_contents));
1509 1509
1510 // Don't initialize the guest WebContents immediately.
1511 if (new_contents->GetRenderProcessHost()->IsGuest())
1512 return new_contents;
1513
1510 if (!new_contents->GetRenderProcessHost()->HasConnection() || 1514 if (!new_contents->GetRenderProcessHost()->HasConnection() ||
1511 !new_contents->GetRenderViewHost()->GetView()) 1515 !new_contents->GetRenderViewHost()->GetView())
1512 return NULL; 1516 return NULL;
1513 1517
1514 // TODO(brettw): It seems bogus to reach into here and initialize the host. 1518 // TODO(brettw): It seems bogus to reach into here and initialize the host.
1515 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init(); 1519 static_cast<RenderViewHostImpl*>(new_contents->GetRenderViewHost())->Init();
1516 return new_contents; 1520 return new_contents;
1517 } 1521 }
1518 1522
1519 RenderWidgetHostView* WebContentsImpl::GetCreatedWidget(int route_id) { 1523 RenderWidgetHostView* WebContentsImpl::GetCreatedWidget(int route_id) {
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
3434 } 3438 }
3435 3439
3436 BrowserPluginGuestManager* 3440 BrowserPluginGuestManager*
3437 WebContentsImpl::GetBrowserPluginGuestManager() const { 3441 WebContentsImpl::GetBrowserPluginGuestManager() const {
3438 return static_cast<BrowserPluginGuestManager*>( 3442 return static_cast<BrowserPluginGuestManager*>(
3439 GetBrowserContext()->GetUserData( 3443 GetBrowserContext()->GetUserData(
3440 browser_plugin::kBrowserPluginGuestManagerKeyName)); 3444 browser_plugin::kBrowserPluginGuestManagerKeyName));
3441 } 3445 }
3442 3446
3443 } // namespace content 3447 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698