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

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: Add missing override 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 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) { 979 void RenderFrameHostManager::OnDidUpdateOrigin(const url::Origin& origin) {
980 for (const auto& pair : proxy_hosts_) { 980 for (const auto& pair : proxy_hosts_) {
981 pair.second->Send( 981 pair.second->Send(
982 new FrameMsg_DidUpdateOrigin(pair.second->GetRoutingID(), origin)); 982 new FrameMsg_DidUpdateOrigin(pair.second->GetRoutingID(), origin));
983 } 983 }
984 } 984 }
985 985
986 RenderFrameHostManager::SiteInstanceDescriptor::SiteInstanceDescriptor( 986 RenderFrameHostManager::SiteInstanceDescriptor::SiteInstanceDescriptor(
987 BrowserContext* browser_context, 987 BrowserContext* browser_context,
988 GURL dest_url, 988 GURL dest_url,
989 bool related_to_current) 989 SiteInstanceRelation relation_to_current)
990 : existing_site_instance(nullptr), 990 : existing_site_instance(nullptr), relation(relation_to_current) {
991 new_is_related_to_current(related_to_current) {
992 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url); 991 new_site_url = SiteInstance::GetSiteForURL(browser_context, dest_url);
993 } 992 }
994 993
995 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) { 994 void RenderFrameHostManager::RenderProcessGone(SiteInstanceImpl* instance) {
996 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false); 995 GetRenderFrameProxyHost(instance)->set_render_frame_proxy_created(false);
997 } 996 }
998 997
999 void RenderFrameHostManager::ActiveFrameCountIsZero( 998 void RenderFrameHostManager::ActiveFrameCountIsZero(
1000 SiteInstanceImpl* site_instance) { 999 SiteInstanceImpl* site_instance) {
1001 // |site_instance| no longer contains any active RenderFrameHosts, so we don't 1000 // |site_instance| no longer contains any active RenderFrameHosts, so we don't
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 SiteInstanceDescriptor new_instance_descriptor = 1165 SiteInstanceDescriptor new_instance_descriptor =
1167 SiteInstanceDescriptor(current_instance); 1166 SiteInstanceDescriptor(current_instance);
1168 if (ShouldTransitionCrossSite() || force_swap) { 1167 if (ShouldTransitionCrossSite() || force_swap) {
1169 new_instance_descriptor = DetermineSiteInstanceForURL( 1168 new_instance_descriptor = DetermineSiteInstanceForURL(
1170 dest_url, source_instance, current_instance, dest_instance, transition, 1169 dest_url, source_instance, current_instance, dest_instance, transition,
1171 dest_is_restore, dest_is_view_source_mode, force_swap); 1170 dest_is_restore, dest_is_view_source_mode, force_swap);
1172 } 1171 }
1173 1172
1174 SiteInstance* new_instance = 1173 SiteInstance* new_instance =
1175 ConvertToSiteInstance(new_instance_descriptor, candidate_instance); 1174 ConvertToSiteInstance(new_instance_descriptor, candidate_instance);
1176
1177 // If |force_swap| is true, we must use a different SiteInstance than the 1175 // If |force_swap| is true, we must use a different SiteInstance than the
1178 // current one. If we didn't, we would have two RenderFrameHosts in the same 1176 // current one. If we didn't, we would have two RenderFrameHosts in the same
1179 // SiteInstance and the same frame, resulting in page_id conflicts for their 1177 // SiteInstance and the same frame, resulting in page_id conflicts for their
1180 // NavigationEntries. 1178 // NavigationEntries.
1181 if (force_swap) 1179 if (force_swap)
1182 CHECK_NE(new_instance, current_instance); 1180 CHECK_NE(new_instance, current_instance);
1181
1182 // |new_instance| may be a newly allocated SiteInstance. It is important to
1183 // immediately give this new SiteInstance to a RenderViewHost (if it is
1184 // different than our current SiteInstance), so that it is ref counted.
1183 return new_instance; 1185 return new_instance;
1184 } 1186 }
1185 1187
1186 RenderFrameHostManager::SiteInstanceDescriptor 1188 RenderFrameHostManager::SiteInstanceDescriptor
1187 RenderFrameHostManager::DetermineSiteInstanceForURL( 1189 RenderFrameHostManager::DetermineSiteInstanceForURL(
1188 const GURL& dest_url, 1190 const GURL& dest_url,
1189 SiteInstance* source_instance, 1191 SiteInstance* source_instance,
1190 SiteInstance* current_instance, 1192 SiteInstance* current_instance,
1191 SiteInstance* dest_instance, 1193 SiteInstance* dest_instance,
1192 ui::PageTransition transition, 1194 ui::PageTransition transition,
(...skipping 12 matching lines...) Expand all
1205 if (force_browsing_instance_swap) { 1207 if (force_browsing_instance_swap) {
1206 CHECK(!dest_instance->IsRelatedSiteInstance( 1208 CHECK(!dest_instance->IsRelatedSiteInstance(
1207 render_frame_host_->GetSiteInstance())); 1209 render_frame_host_->GetSiteInstance()));
1208 } 1210 }
1209 return SiteInstanceDescriptor(dest_instance); 1211 return SiteInstanceDescriptor(dest_instance);
1210 } 1212 }
1211 1213
1212 // If a swap is required, we need to force the SiteInstance AND 1214 // If a swap is required, we need to force the SiteInstance AND
1213 // BrowsingInstance to be different ones, using CreateForURL. 1215 // BrowsingInstance to be different ones, using CreateForURL.
1214 if (force_browsing_instance_swap) 1216 if (force_browsing_instance_swap)
1215 return SiteInstanceDescriptor(browser_context, dest_url, false); 1217 return SiteInstanceDescriptor(browser_context, dest_url,
1218 SiteInstanceRelation::UNRELATED);
1216 1219
1217 // (UGLY) HEURISTIC, process-per-site only: 1220 // (UGLY) HEURISTIC, process-per-site only:
1218 // 1221 //
1219 // If this navigation is generated, then it probably corresponds to a search 1222 // If this navigation is generated, then it probably corresponds to a search
1220 // query. Given that search results typically lead to users navigating to 1223 // query. Given that search results typically lead to users navigating to
1221 // other sites, we don't really want to use the search engine hostname to 1224 // other sites, we don't really want to use the search engine hostname to
1222 // determine the site instance for this navigation. 1225 // determine the site instance for this navigation.
1223 // 1226 //
1224 // NOTE: This can be removed once we have a way to transition between 1227 // NOTE: This can be removed once we have a way to transition between
1225 // RenderViews in response to a link click. 1228 // RenderViews in response to a link click.
(...skipping 18 matching lines...) Expand all
1244 // 1247 //
1245 // Also, if the URL should use process-per-site mode and there is an 1248 // Also, if the URL should use process-per-site mode and there is an
1246 // existing process for the site, we should use it. We can call 1249 // existing process for the site, we should use it. We can call
1247 // GetRelatedSiteInstance() for this, which will eagerly set the site and 1250 // GetRelatedSiteInstance() for this, which will eagerly set the site and
1248 // thus use the correct process. 1251 // thus use the correct process.
1249 bool use_process_per_site = 1252 bool use_process_per_site =
1250 RenderProcessHost::ShouldUseProcessPerSite(browser_context, dest_url) && 1253 RenderProcessHost::ShouldUseProcessPerSite(browser_context, dest_url) &&
1251 RenderProcessHostImpl::GetProcessHostForSite(browser_context, dest_url); 1254 RenderProcessHostImpl::GetProcessHostForSite(browser_context, dest_url);
1252 if (current_instance_impl->HasRelatedSiteInstance(dest_url) || 1255 if (current_instance_impl->HasRelatedSiteInstance(dest_url) ||
1253 use_process_per_site) { 1256 use_process_per_site) {
1254 return SiteInstanceDescriptor(browser_context, dest_url, true); 1257 return SiteInstanceDescriptor(browser_context, dest_url,
1258 SiteInstanceRelation::RELATED);
1255 } 1259 }
1256 1260
1257 // For extensions, Web UI URLs (such as the new tab page), and apps we do 1261 // For extensions, Web UI URLs (such as the new tab page), and apps we do
1258 // not want to use the |current_instance_impl| if it has no site, since it 1262 // not want to use the |current_instance_impl| if it has no site, since it
1259 // will have a RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance 1263 // will have a RenderProcessHost of PRIV_NORMAL. Create a new SiteInstance
1260 // for this URL instead (with the correct process type). 1264 // for this URL instead (with the correct process type).
1261 if (current_instance_impl->HasWrongProcessForURL(dest_url)) 1265 if (current_instance_impl->HasWrongProcessForURL(dest_url))
1262 return SiteInstanceDescriptor(browser_context, dest_url, true); 1266 return SiteInstanceDescriptor(browser_context, dest_url,
1267 SiteInstanceRelation::RELATED);
1263 1268
1264 // View-source URLs must use a new SiteInstance and BrowsingInstance. 1269 // View-source URLs must use a new SiteInstance and BrowsingInstance.
1265 // TODO(nasko): This is the same condition as later in the function. This 1270 // TODO(nasko): This is the same condition as later in the function. This
1266 // should be taken into account when refactoring this method as part of 1271 // should be taken into account when refactoring this method as part of
1267 // http://crbug.com/123007. 1272 // http://crbug.com/123007.
1268 if (dest_is_view_source_mode) 1273 if (dest_is_view_source_mode)
1269 return SiteInstanceDescriptor(browser_context, dest_url, false); 1274 return SiteInstanceDescriptor(browser_context, dest_url,
1275 SiteInstanceRelation::UNRELATED);
1270 1276
1271 // If we are navigating from a blank SiteInstance to a WebUI, make sure we 1277 // If we are navigating from a blank SiteInstance to a WebUI, make sure we
1272 // create a new SiteInstance. 1278 // create a new SiteInstance.
1273 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( 1279 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL(
1274 browser_context, dest_url)) { 1280 browser_context, dest_url)) {
1275 return SiteInstanceDescriptor(browser_context, dest_url, false); 1281 return SiteInstanceDescriptor(browser_context, dest_url,
1282 SiteInstanceRelation::UNRELATED);
1276 } 1283 }
1277 1284
1278 // Normally the "site" on the SiteInstance is set lazily when the load 1285 // Normally the "site" on the SiteInstance is set lazily when the load
1279 // actually commits. This is to support better process sharing in case 1286 // actually commits. This is to support better process sharing in case
1280 // the site redirects to some other site: we want to use the destination 1287 // the site redirects to some other site: we want to use the destination
1281 // site in the site instance. 1288 // site in the site instance.
1282 // 1289 //
1283 // In the case of session restore, as it loads all the pages immediately 1290 // In the case of session restore, as it loads all the pages immediately
1284 // we need to set the site first, otherwise after a restore none of the 1291 // we need to set the site first, otherwise after a restore none of the
1285 // pages would share renderers in process-per-site. 1292 // pages would share renderers in process-per-site.
(...skipping 29 matching lines...) Expand all
1315 } 1322 }
1316 1323
1317 // View-source URLs must use a new SiteInstance and BrowsingInstance. 1324 // View-source URLs must use a new SiteInstance and BrowsingInstance.
1318 // We don't need a swap when going from view-source to a debug URL like 1325 // We don't need a swap when going from view-source to a debug URL like
1319 // chrome://crash, however. 1326 // chrome://crash, however.
1320 // TODO(creis): Refactor this method so this duplicated code isn't needed. 1327 // TODO(creis): Refactor this method so this duplicated code isn't needed.
1321 // See http://crbug.com/123007. 1328 // See http://crbug.com/123007.
1322 if (current_entry && 1329 if (current_entry &&
1323 current_entry->IsViewSourceMode() != dest_is_view_source_mode && 1330 current_entry->IsViewSourceMode() != dest_is_view_source_mode &&
1324 !IsRendererDebugURL(dest_url)) { 1331 !IsRendererDebugURL(dest_url)) {
1325 return SiteInstanceDescriptor(browser_context, dest_url, false); 1332 return SiteInstanceDescriptor(browser_context, dest_url,
1333 SiteInstanceRelation::UNRELATED);
1326 } 1334 }
1327 1335
1328 // Use the source SiteInstance in case of data URLs or about:blank pages, 1336 // Use the source SiteInstance in case of data URLs or about:blank pages,
1329 // because the content is then controlled and/or scriptable by the source 1337 // because the content is then controlled and/or scriptable by the source
1330 // SiteInstance. 1338 // SiteInstance.
1331 GURL about_blank(url::kAboutBlankURL); 1339 GURL about_blank(url::kAboutBlankURL);
1332 if (source_instance && 1340 if (source_instance &&
1333 (dest_url == about_blank || dest_url.scheme() == url::kDataScheme)) { 1341 (dest_url == about_blank || dest_url.scheme() == url::kDataScheme)) {
1334 return SiteInstanceDescriptor(source_instance); 1342 return SiteInstanceDescriptor(source_instance);
1335 } 1343 }
1336 1344
1337 // Use the current SiteInstance for same site navigations, as long as the 1345 // Use the current SiteInstance for same site navigations.
1338 // process type is correct. (The URL may have been installed as an app since 1346 if (IsCurrentlySameSite(render_frame_host_.get(), dest_url))
1339 // the last time we visited it.) 1347 return SiteInstanceDescriptor(render_frame_host_->GetSiteInstance());
1340 const GURL& current_url = GetCurrentURLForSiteInstance(current_instance_impl); 1348
1341 if (SiteInstance::IsSameWebSite(browser_context, current_url, dest_url) && 1349 if (SiteIsolationPolicy::IsTopDocumentIsolationEnabled()) {
1342 !current_instance_impl->HasWrongProcessForURL(dest_url)) { 1350 // TODO(nick): Looking at the main frame and openers is required for TDI
1343 return SiteInstanceDescriptor(current_instance_impl); 1351 // mode, but should be safe to enable unconditionally.
Charlie Reis 2016/03/25 19:47:12 I think I agree, but I also agree with guarding it
ncarter (slow) 2016/03/28 22:00:28 Acknowledged.
1352 if (!frame_tree_node_->IsMainFrame()) {
1353 RenderFrameHostImpl* main_frame =
1354 frame_tree_node_->frame_tree()->root()->current_frame_host();
1355 if (IsCurrentlySameSite(main_frame, dest_url))
1356 return SiteInstanceDescriptor(main_frame->GetSiteInstance());
1357 }
1358
1359 if (frame_tree_node_->opener()) {
1360 RenderFrameHostImpl* opener_frame =
1361 frame_tree_node_->opener()->current_frame_host();
1362 if (IsCurrentlySameSite(opener_frame, dest_url))
1363 return SiteInstanceDescriptor(opener_frame->GetSiteInstance());
1364 }
1365 }
1366
1367 if (!frame_tree_node_->IsMainFrame() &&
1368 SiteIsolationPolicy::IsTopDocumentIsolationEnabled() &&
1369 !SiteInstanceImpl::DoesSiteRequireDedicatedProcess(browser_context,
1370 dest_url)) {
1371 // This is a cross-site subframe of a non-isolated origin, so place this
1372 // frame in the default subframe site instance.
1373 return SiteInstanceDescriptor(
1374 browser_context, dest_url,
1375 SiteInstanceRelation::RELATED_DEFAULT_SUBFRAME);
Charlie Reis 2016/03/25 19:47:12 Yes, I think these changes make sense.
ncarter (slow) 2016/03/28 22:00:28 Acknowledged.
1344 } 1376 }
1345 1377
1346 // Start the new renderer in a new SiteInstance, but in the current 1378 // Start the new renderer in a new SiteInstance, but in the current
1347 // BrowsingInstance. It is important to immediately give this new 1379 // BrowsingInstance.
1348 // SiteInstance to a RenderViewHost (if it is different than our current 1380 return SiteInstanceDescriptor(browser_context, dest_url,
1349 // SiteInstance), so that it is ref counted. This will happen in 1381 SiteInstanceRelation::RELATED);
1350 // CreateRenderView.
1351 return SiteInstanceDescriptor(browser_context, dest_url, true);
1352 } 1382 }
1353 1383
1354 bool RenderFrameHostManager::IsRendererTransferNeededForNavigation( 1384 bool RenderFrameHostManager::IsRendererTransferNeededForNavigation(
1355 RenderFrameHostImpl* rfh, 1385 RenderFrameHostImpl* rfh,
1356 const GURL& dest_url) { 1386 const GURL& dest_url) {
1357 // A transfer is not needed if the current SiteInstance doesn't yet have a 1387 // 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. 1388 // site. This is the case for tests that use NavigateToURL.
1359 if (!rfh->GetSiteInstance()->HasSite()) 1389 if (!rfh->GetSiteInstance()->HasSite())
1360 return false; 1390 return false;
1361 1391
1362 // We do not currently swap processes for navigations in webview tag guests. 1392 // We do not currently swap processes for navigations in webview tag guests.
1363 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kGuestScheme)) 1393 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kGuestScheme))
1364 return false; 1394 return false;
1365 1395
1366 // Don't swap processes for extensions embedded in DevTools. See 1396 // Don't swap processes for extensions embedded in DevTools. See
1367 // https://crbug.com/564216. 1397 // https://crbug.com/564216.
1368 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kChromeDevToolsScheme)) { 1398 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kChromeDevToolsScheme)) {
1369 // TODO(nick): https://crbug.com/570483 Check to see if |dest_url| is a 1399 // TODO(nick): https://crbug.com/570483 Check to see if |dest_url| is a
1370 // devtools extension, and swap processes if not. 1400 // devtools extension, and swap processes if not.
1371 return false; 1401 return false;
1372 } 1402 }
1373 1403
1374 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext(); 1404 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext();
1375 GURL effective_url = SiteInstanceImpl::GetEffectiveURL(context, dest_url); 1405 GURL effective_url = SiteInstanceImpl::GetEffectiveURL(context, dest_url);
1376 1406
1377 // TODO(nasko, nick): These following --site-per-process checks are 1407 // TODO(nasko, nick): These following --site-per-process checks are
1378 // overly simplistic. Update them to match all the cases 1408 // overly simplistic. Update them to match all the cases
1379 // considered by DetermineSiteInstanceForURL. 1409 // considered by DetermineSiteInstanceForURL.
1380 if (SiteInstance::IsSameWebSite(rfh->GetSiteInstance()->GetBrowserContext(), 1410 if (IsCurrentlySameSite(rfh, dest_url)) {
1381 rfh->GetSiteInstance()->GetSiteURL(), 1411 // The same site, no transition needed for security purposes, and we must
1382 dest_url)) { 1412 // keep the same SiteInstance for correctness of synchronous scripting.
1383 return false; // The same site, no transition needed. 1413 return false;
1384 } 1414 }
1385 1415
1386 // The sites differ. If either one requires a dedicated process, 1416 // The sites differ. If either one requires a dedicated process,
1387 // then a transfer is needed. 1417 // then a transfer is needed.
1388 return rfh->GetSiteInstance()->RequiresDedicatedProcess() || 1418 if (rfh->GetSiteInstance()->RequiresDedicatedProcess() ||
1389 SiteInstanceImpl::DoesSiteRequireDedicatedProcess(context, 1419 SiteInstanceImpl::DoesSiteRequireDedicatedProcess(context,
1390 effective_url); 1420 effective_url)) {
1421 return true;
1422 }
1423
1424 bool subframe = !frame_tree_node_->IsMainFrame();
Charlie Reis 2016/03/25 19:47:12 nit: is_subframe (Does this help with clarity? W
ncarter (slow) 2016/03/28 22:00:28 I've inlined it -- this was an artifact of an earl
1425 if (SiteIsolationPolicy::IsTopDocumentIsolationEnabled() &&
1426 (subframe ||
1427 rfh->GetSiteInstance()->is_default_subframe_site_instance())) {
1428 // Always attempt a transfer in these cases.
1429 return true;
1430 }
1431
1432 return false;
1391 } 1433 }
1392 1434
1393 SiteInstance* RenderFrameHostManager::ConvertToSiteInstance( 1435 SiteInstance* RenderFrameHostManager::ConvertToSiteInstance(
1394 const SiteInstanceDescriptor& descriptor, 1436 const SiteInstanceDescriptor& descriptor,
1395 SiteInstance* candidate_instance) { 1437 SiteInstance* candidate_instance) {
1396 SiteInstance* current_instance = render_frame_host_->GetSiteInstance(); 1438 SiteInstanceImpl* current_instance = render_frame_host_->GetSiteInstance();
1397 1439
1398 // Note: If the |candidate_instance| matches the descriptor, it will already 1440 // Note: If the |candidate_instance| matches the descriptor, it will already
1399 // be set to |descriptor.existing_site_instance|. 1441 // be set to |descriptor.existing_site_instance|.
1400 if (descriptor.existing_site_instance) 1442 if (descriptor.existing_site_instance)
1401 return descriptor.existing_site_instance; 1443 return descriptor.existing_site_instance;
1402 1444
1403 // Note: If the |candidate_instance| matches the descriptor, 1445 // Note: If the |candidate_instance| matches the descriptor,
1404 // GetRelatedSiteInstance will return it. 1446 // GetRelatedSiteInstance will return it.
1405 if (descriptor.new_is_related_to_current) 1447 if (descriptor.relation == SiteInstanceRelation::RELATED)
1406 return current_instance->GetRelatedSiteInstance(descriptor.new_site_url); 1448 return current_instance->GetRelatedSiteInstance(descriptor.new_site_url);
1407 1449
1450 if (descriptor.relation == SiteInstanceRelation::RELATED_DEFAULT_SUBFRAME)
1451 return current_instance->GetDefaultSubframeSiteInstance();
1452
1408 // At this point we know an unrelated site instance must be returned. First 1453 // At this point we know an unrelated site instance must be returned. First
1409 // check if the candidate matches. 1454 // check if the candidate matches.
1410 if (candidate_instance && 1455 if (candidate_instance &&
1411 !current_instance->IsRelatedSiteInstance(candidate_instance) && 1456 !current_instance->IsRelatedSiteInstance(candidate_instance) &&
1412 candidate_instance->GetSiteURL() == descriptor.new_site_url) { 1457 candidate_instance->GetSiteURL() == descriptor.new_site_url) {
1413 return candidate_instance; 1458 return candidate_instance;
1414 } 1459 }
1415 1460
1416 // Otherwise return a newly created one. 1461 // Otherwise return a newly created one.
1417 return SiteInstance::CreateForURL( 1462 return SiteInstance::CreateForURL(
1418 delegate_->GetControllerForRenderManager().GetBrowserContext(), 1463 delegate_->GetControllerForRenderManager().GetBrowserContext(),
1419 descriptor.new_site_url); 1464 descriptor.new_site_url);
1420 } 1465 }
1421 1466
1422 const GURL& RenderFrameHostManager::GetCurrentURLForSiteInstance( 1467 bool RenderFrameHostManager::IsCurrentlySameSite(RenderFrameHostImpl* candidate,
1423 SiteInstance* current_instance) { 1468 const GURL& dest_url) {
1469 BrowserContext* browser_context =
1470 delegate_->GetControllerForRenderManager().GetBrowserContext();
1471
1472 // If the process type is incorrect, reject the candidate even if |dest_url|
1473 // is same-site. (The URL may have been installed as an app since
1474 // the last time we visited it.)
1475 if (candidate->GetSiteInstance()->HasWrongProcessForURL(dest_url))
1476 return false;
1477
1424 // Use the current RenderFrameHost's last successful URL if it has one. This 1478 // Use the current RenderFrameHost's last successful URL if it has one. This
1425 // excludes commits of net errors, since net errors do not currently swap 1479 // excludes commits of net errors, since net errors do not currently swap
1426 // processes for transfer navigations. Thus, we compare against the last 1480 // processes for transfer navigations. Thus, we compare against the last
1427 // successful commit when deciding whether to swap this time. 1481 // successful commit when deciding whether to swap this time. (Note: browser-
1428 // (Note: browser-initiated net errors do swap processes, but the frame's last 1482 // initiated net errors do swap processes, but the frame's last successful URL
1429 // successful URL will be empty in that case, causing us to fall back to the 1483 // will be empty in that case, causing us to fall back to the SiteInstance's
1430 // SiteInstance's URL below.) 1484 // URL below.)
1431 if (!render_frame_host_->last_successful_url().is_empty()) 1485 if (!candidate->last_successful_url().is_empty()) {
1432 return render_frame_host_->last_successful_url(); 1486 if (SiteInstance::IsSameWebSite(browser_context,
1487 candidate->last_successful_url(), dest_url))
1488 return true;
1433 1489
1434 // Fall back to the SiteInstance's Site URL if the FrameTreeNode doen't have a 1490 if (!candidate->GetLastCommittedOrigin().unique() &&
Charlie Reis 2016/03/25 19:47:12 This check takes a while to understand and depends
ncarter (slow) 2016/03/28 22:00:28 I've clarified the intent here with a comment. My
Charlie Reis 2016/03/29 17:17:12 Acknowledged.
1435 // current URL. 1491 SiteInstance::IsSameWebSite(
1436 return current_instance->GetSiteURL(); 1492 browser_context,
1493 GURL(candidate->GetLastCommittedOrigin().Serialize()), dest_url)) {
1494 return true;
Charlie Reis 2016/03/25 19:47:12 Maybe this overall block would be easier to read a
ncarter (slow) 2016/03/28 22:00:28 I've rearranged the code, hopefully it's better no
Charlie Reis 2016/03/29 17:17:12 Acknowledged.
1495 }
1496 } else {
1497 if (SiteInstance::IsSameWebSite(browser_context,
1498 candidate->GetSiteInstance()->GetSiteURL(),
1499 dest_url)) {
1500 return true;
1501 }
1502 }
1503 return false;
1437 } 1504 }
1438 1505
1439 void RenderFrameHostManager::CreatePendingRenderFrameHost( 1506 void RenderFrameHostManager::CreatePendingRenderFrameHost(
1440 SiteInstance* old_instance, 1507 SiteInstance* old_instance,
1441 SiteInstance* new_instance) { 1508 SiteInstance* new_instance) {
1442 int create_render_frame_flags = 0; 1509 int create_render_frame_flags = 0;
1443 if (delegate_->IsHidden()) 1510 if (delegate_->IsHidden())
1444 create_render_frame_flags |= CREATE_RF_HIDDEN; 1511 create_render_frame_flags |= CREATE_RF_HIDDEN;
1445 1512
1446 if (pending_render_frame_host_) 1513 if (pending_render_frame_host_)
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
2433 } else if (pending_render_frame_host_) { 2500 } else if (pending_render_frame_host_) {
2434 send_msg(pending_render_frame_host_.get(), 2501 send_msg(pending_render_frame_host_.get(),
2435 pending_render_frame_host_->GetRoutingID(), msg); 2502 pending_render_frame_host_->GetRoutingID(), msg);
2436 } 2503 }
2437 2504
2438 msg->set_routing_id(render_frame_host_->GetRoutingID()); 2505 msg->set_routing_id(render_frame_host_->GetRoutingID());
2439 render_frame_host_->Send(msg); 2506 render_frame_host_->Send(msg);
2440 } 2507 }
2441 2508
2442 } // namespace content 2509 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698