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

Side by Side Diff: content/browser/frame_host/render_frame_host_manager.cc

Issue 1797363002: "Top Document Isolation" mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Two new browsertests. Created 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/render_frame_host_manager.h" 5 #include "content/browser/frame_host/render_frame_host_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 // we need to set the site first, otherwise after a restore none of the 1284 // we need to set the site first, otherwise after a restore none of the
1285 // pages would share renderers in process-per-site. 1285 // pages would share renderers in process-per-site.
1286 // 1286 //
1287 // The embedder can request some urls never to be assigned to SiteInstance 1287 // The embedder can request some urls never to be assigned to SiteInstance
1288 // through the ShouldAssignSiteForURL() content client method, so that 1288 // through the ShouldAssignSiteForURL() content client method, so that
1289 // renderers created for particular chrome urls (e.g. the chrome-native:// 1289 // renderers created for particular chrome urls (e.g. the chrome-native://
1290 // scheme) can be reused for subsequent navigations in the same WebContents. 1290 // scheme) can be reused for subsequent navigations in the same WebContents.
1291 // See http://crbug.com/386542. 1291 // See http://crbug.com/386542.
1292 if (dest_is_restore && 1292 if (dest_is_restore &&
1293 GetContentClient()->browser()->ShouldAssignSiteForURL(dest_url)) { 1293 GetContentClient()->browser()->ShouldAssignSiteForURL(dest_url)) {
1294 // TODO(nick): What needs to happen so that TDI works with session
1295 // restore?
1294 current_instance_impl->SetSite(dest_url); 1296 current_instance_impl->SetSite(dest_url);
1295 } 1297 }
1296 1298
1299 // TODO(nick): Hopefully this whole block is not relevant for TDI mode?
1297 return SiteInstanceDescriptor(current_instance_impl); 1300 return SiteInstanceDescriptor(current_instance_impl);
1298 } 1301 }
1299 1302
1300 // Otherwise, only create a new SiteInstance for a cross-process navigation. 1303 // Otherwise, only create a new SiteInstance for a cross-process navigation.
1301 1304
1302 // TODO(creis): Once we intercept links and script-based navigations, we 1305 // TODO(creis): Once we intercept links and script-based navigations, we
1303 // will be able to enforce that all entries in a SiteInstance actually have 1306 // will be able to enforce that all entries in a SiteInstance actually have
1304 // the same site, and it will be safe to compare the URL against the 1307 // the same site, and it will be safe to compare the URL against the
1305 // SiteInstance's site, as follows: 1308 // SiteInstance's site, as follows:
1306 // const GURL& current_url = current_instance_impl->site(); 1309 // const GURL& current_url = current_instance_impl->site();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1341 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && 1344 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) &&
1342 !current_instance_impl->HasWrongProcessForURL(dest_url)) { 1345 !current_instance_impl->HasWrongProcessForURL(dest_url)) {
1343 return SiteInstanceDescriptor(current_instance_impl); 1346 return SiteInstanceDescriptor(current_instance_impl);
1344 } 1347 }
1345 1348
1346 // Start the new renderer in a new SiteInstance, but in the current 1349 // Start the new renderer in a new SiteInstance, but in the current
1347 // BrowsingInstance. It is important to immediately give this new 1350 // BrowsingInstance. It is important to immediately give this new
1348 // SiteInstance to a RenderViewHost (if it is different than our current 1351 // SiteInstance to a RenderViewHost (if it is different than our current
1349 // SiteInstance), so that it is ref counted. This will happen in 1352 // SiteInstance), so that it is ref counted. This will happen in
1350 // CreateRenderView. 1353 // CreateRenderView.
1351 return SiteInstanceDescriptor(browser_context, dest_url, true); 1354 SiteInstanceDescriptor result(browser_context, dest_url, true);
1355
1356 if (!current_instance_impl->HasRelatedSiteInstance(dest_url) &&
1357 !frame_tree_node_->IsMainFrame() &&
1358 SiteIsolationPolicy::UseDedicatedProcessForTopDocument() &&
1359 !SiteInstanceImpl::DoesSiteRequireDedicatedProcess(browser_context,
1360 dest_url)) {
1361 result.is_for_third_party_subframes = true;
1362 }
1363
1364 return result;
1352 } 1365 }
1353 1366
1354 bool RenderFrameHostManager::IsRendererTransferNeededForNavigation( 1367 bool RenderFrameHostManager::IsRendererTransferNeededForNavigation(
1355 RenderFrameHostImpl* rfh, 1368 RenderFrameHostImpl* rfh,
1356 const GURL& dest_url) { 1369 const GURL& dest_url) {
1357 // A transfer is not needed if the current SiteInstance doesn't yet have a 1370 // A transfer is not needed if the current SiteInstance doesn't yet have a
1358 // site. This is the case for tests that use NavigateToURL. 1371 // site. This is the case for tests that use NavigateToURL.
1359 if (!rfh->GetSiteInstance()->HasSite()) 1372 if (!rfh->GetSiteInstance()->HasSite())
1360 return false; 1373 return false;
1361 1374
(...skipping 11 matching lines...) Expand all
1373 1386
1374 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext(); 1387 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext();
1375 GURL effective_url = SiteInstanceImpl::GetEffectiveURL(context, dest_url); 1388 GURL effective_url = SiteInstanceImpl::GetEffectiveURL(context, dest_url);
1376 1389
1377 // TODO(nasko, nick): These following --site-per-process checks are 1390 // TODO(nasko, nick): These following --site-per-process checks are
1378 // overly simplistic. Update them to match all the cases 1391 // overly simplistic. Update them to match all the cases
1379 // considered by DetermineSiteInstanceForURL. 1392 // considered by DetermineSiteInstanceForURL.
1380 if (SiteInstance::IsSameWebSite(rfh->GetSiteInstance()->GetBrowserContext(), 1393 if (SiteInstance::IsSameWebSite(rfh->GetSiteInstance()->GetBrowserContext(),
1381 rfh->GetSiteInstance()->GetSiteURL(), 1394 rfh->GetSiteInstance()->GetSiteURL(),
1382 dest_url)) { 1395 dest_url)) {
1383 return false; // The same site, no transition needed. 1396 // The same site, no transition needed for security purposes, and we must
1397 // keep the same SiteInstance for correctness of synchronous scripting.
1398 return false;
1384 } 1399 }
1385 1400
1386 // The sites differ. If either one requires a dedicated process, 1401 // The sites differ. If either one requires a dedicated process,
1387 // then a transfer is needed. 1402 // then a transfer is needed.
1388 return rfh->GetSiteInstance()->RequiresDedicatedProcess() || 1403 if (rfh->GetSiteInstance()->RequiresDedicatedProcess() ||
1389 SiteInstanceImpl::DoesSiteRequireDedicatedProcess(context, 1404 SiteInstanceImpl::DoesSiteRequireDedicatedProcess(context,
1390 effective_url); 1405 effective_url)) {
1406 return true;
1407 }
1408
1409 // If this site already exists in the browsing instance, we should transfer to
1410 // the existing process for that site.
1411 // TODO(nick):
1412 // - Should we only switch back if the existing site instance has the
1413 // dedicated bit set?
1414 if (rfh->GetSiteInstance()->HasRelatedSiteInstance(effective_url)) {
Charlie Reis 2016/03/18 21:15:13 Note: this affects --isolate-extensions as well.
1415 if (rfh->GetSiteInstance()->GetRelatedSiteInstance(effective_url) !=
1416 rfh->GetSiteInstance()) {
1417 return true;
1418 }
1419 }
1420 return false;
1391 } 1421 }
1392 1422
1393 SiteInstance* RenderFrameHostManager::ConvertToSiteInstance( 1423 SiteInstance* RenderFrameHostManager::ConvertToSiteInstance(
1394 const SiteInstanceDescriptor& descriptor, 1424 const SiteInstanceDescriptor& descriptor,
1395 SiteInstance* candidate_instance) { 1425 SiteInstance* candidate_instance) {
1396 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 1426 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
1397 1427
1398 // Note: If the |candidate_instance| matches the descriptor, it will already 1428 // Note: If the |candidate_instance| matches the descriptor, it will already
1399 // be set to |descriptor.existing_site_instance|. 1429 // be set to |descriptor.existing_site_instance|.
1400 if (descriptor.existing_site_instance) 1430 if (descriptor.existing_site_instance)
1401 return descriptor.existing_site_instance; 1431 return descriptor.existing_site_instance;
1402 1432
1403 // Note: If the |candidate_instance| matches the descriptor, 1433 // Note: If the |candidate_instance| matches the descriptor,
1404 // GetRelatedSiteInstance will return it. 1434 // GetRelatedSiteInstance will return it.
1405 if (descriptor.new_is_related_to_current) 1435 if (descriptor.new_is_related_to_current) {
1406 return current_instance->GetRelatedSiteInstance(descriptor.new_site_url); 1436 if (descriptor.is_for_third_party_subframes)
1437 return current_instance->GetRelatedSiteInstanceForThirdPartySubframes(
1438 descriptor.new_site_url);
1439 else
1440 return current_instance->GetRelatedSiteInstance(descriptor.new_site_url);
1441 }
1407 1442
1408 // At this point we know an unrelated site instance must be returned. First 1443 // At this point we know an unrelated site instance must be returned. First
1409 // check if the candidate matches. 1444 // check if the candidate matches.
1410 if (candidate_instance && 1445 if (candidate_instance &&
1411 !current_instance->IsRelatedSiteInstance(candidate_instance) && 1446 !current_instance->IsRelatedSiteInstance(candidate_instance) &&
1412 candidate_instance->GetSiteURL() == descriptor.new_site_url) { 1447 candidate_instance->GetSiteURL() == descriptor.new_site_url) {
1413 return candidate_instance; 1448 return candidate_instance;
1414 } 1449 }
1415 1450
1416 // Otherwise return a newly created one. 1451 // Otherwise return a newly created one.
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 } else if (pending_render_frame_host_) { 2468 } else if (pending_render_frame_host_) {
2434 send_msg(pending_render_frame_host_.get(), 2469 send_msg(pending_render_frame_host_.get(),
2435 pending_render_frame_host_->GetRoutingID(), msg); 2470 pending_render_frame_host_->GetRoutingID(), msg);
2436 } 2471 }
2437 2472
2438 msg->set_routing_id(render_frame_host_->GetRoutingID()); 2473 msg->set_routing_id(render_frame_host_->GetRoutingID());
2439 render_frame_host_->Send(msg); 2474 render_frame_host_->Send(msg);
2440 } 2475 }
2441 2476
2442 } // namespace content 2477 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698