Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <string> | 10 #include <string> |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 #include "content/browser/frame_host/render_frame_proxy_host.h" | 33 #include "content/browser/frame_host/render_frame_proxy_host.h" |
| 34 #include "content/browser/renderer_host/render_process_host_impl.h" | 34 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 35 #include "content/browser/renderer_host/render_view_host_factory.h" | 35 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 36 #include "content/browser/renderer_host/render_view_host_impl.h" | 36 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 37 #include "content/browser/site_instance_impl.h" | 37 #include "content/browser/site_instance_impl.h" |
| 38 #include "content/browser/webui/web_ui_controller_factory_registry.h" | 38 #include "content/browser/webui/web_ui_controller_factory_registry.h" |
| 39 #include "content/common/frame_messages.h" | 39 #include "content/common/frame_messages.h" |
| 40 #include "content/common/frame_owner_properties.h" | 40 #include "content/common/frame_owner_properties.h" |
| 41 #include "content/common/site_isolation_policy.h" | 41 #include "content/common/site_isolation_policy.h" |
| 42 #include "content/common/view_messages.h" | 42 #include "content/common/view_messages.h" |
| 43 #include "content/public/browser/child_process_security_policy.h" | |
| 43 #include "content/public/browser/content_browser_client.h" | 44 #include "content/public/browser/content_browser_client.h" |
| 44 #include "content/public/browser/render_process_host_observer.h" | 45 #include "content/public/browser/render_process_host_observer.h" |
| 45 #include "content/public/browser/render_widget_host_iterator.h" | 46 #include "content/public/browser/render_widget_host_iterator.h" |
| 46 #include "content/public/browser/render_widget_host_view.h" | 47 #include "content/public/browser/render_widget_host_view.h" |
| 47 #include "content/public/browser/user_metrics.h" | 48 #include "content/public/browser/user_metrics.h" |
| 48 #include "content/public/common/browser_side_navigation_policy.h" | 49 #include "content/public/common/browser_side_navigation_policy.h" |
| 49 #include "content/public/common/content_switches.h" | 50 #include "content/public/common/content_switches.h" |
| 50 #include "content/public/common/referrer.h" | 51 #include "content/public/common/referrer.h" |
| 51 #include "content/public/common/url_constants.h" | 52 #include "content/public/common/url_constants.h" |
| 52 | 53 |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1330 // chrome://settings, which currently has multiple "cross-site" subframes that | 1331 // chrome://settings, which currently has multiple "cross-site" subframes that |
| 1331 // don't need isolation. | 1332 // don't need isolation. |
| 1332 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | 1333 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 1333 !frame_tree_node_->IsMainFrame()) { | 1334 !frame_tree_node_->IsMainFrame()) { |
| 1334 SiteInstance* parent_site_instance = | 1335 SiteInstance* parent_site_instance = |
| 1335 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); | 1336 frame_tree_node_->parent()->current_frame_host()->GetSiteInstance(); |
| 1336 if (parent_site_instance->GetSiteURL().SchemeIs(kChromeUIScheme) && | 1337 if (parent_site_instance->GetSiteURL().SchemeIs(kChromeUIScheme) && |
| 1337 dest_url.SchemeIs(kChromeUIScheme)) { | 1338 dest_url.SchemeIs(kChromeUIScheme)) { |
| 1338 return SiteInstanceDescriptor(parent_site_instance); | 1339 return SiteInstanceDescriptor(parent_site_instance); |
| 1339 } | 1340 } |
| 1341 if (parent_site_instance->GetSiteURL().SchemeIs(kChromeDevToolsScheme)) { | |
|
ncarter (slow)
2017/03/09 23:28:49
I think using |frame_tree_node_->parent()| is prob
alexmos
2017/03/10 21:18:26
Yes, I think we chatted about using the root here
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Yeah, Alex pretty much covered it all. Even if a
| |
| 1342 url::Origin origin = url::Origin(dest_url); | |
| 1343 auto* policy = content::ChildProcessSecurityPolicy::GetInstance(); | |
|
ncarter (slow)
2017/03/09 23:28:49
content:: is unnecessary here; we're already in th
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done.
| |
| 1344 bool is_devtools_extension = | |
|
ncarter (slow)
2017/03/09 23:28:49
Technically using 'extension' in this variable nam
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done.
| |
| 1345 policy->HasSpecificPermissionForOrigin(frame_tree_node_->parent() | |
| 1346 ->current_frame_host() | |
| 1347 ->GetProcess() | |
|
ncarter (slow)
2017/03/09 23:28:49
Instead of calling GetProcess on current_frame_hos
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done.
| |
| 1348 ->GetID(), | |
| 1349 origin); | |
| 1350 if (dest_url.SchemeIs(kChromeDevToolsScheme) || is_devtools_extension) { | |
|
ncarter (slow)
2017/03/09 23:28:49
Since you've already computed |origin|, it's proba
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done, I think? I used |origin.scheme()==kChromeDe
| |
| 1351 return SiteInstanceDescriptor(parent_site_instance); | |
| 1352 } | |
| 1353 } | |
| 1340 } | 1354 } |
| 1341 | 1355 |
| 1342 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it | 1356 // If we haven't used our SiteInstance (and thus RVH) yet, then we can use it |
| 1343 // for this entry. We won't commit the SiteInstance to this site until the | 1357 // for this entry. We won't commit the SiteInstance to this site until the |
| 1344 // navigation commits (in DidNavigate), unless the navigation entry was | 1358 // navigation commits (in DidNavigate), unless the navigation entry was |
| 1345 // restored or it's a Web UI as described below. | 1359 // restored or it's a Web UI as described below. |
| 1346 if (!current_instance_impl->HasSite()) { | 1360 if (!current_instance_impl->HasSite()) { |
| 1347 // If we've already created a SiteInstance for our destination, we don't | 1361 // If we've already created a SiteInstance for our destination, we don't |
| 1348 // want to use this unused SiteInstance; use the existing one. (We don't | 1362 // want to use this unused SiteInstance; use the existing one. (We don't |
| 1349 // do this check if the current_instance has a site, because for now, we | 1363 // do this check if the current_instance has a site, because for now, we |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1500 const GURL& dest_url) { | 1514 const GURL& dest_url) { |
| 1501 // A transfer is not needed if the current SiteInstance doesn't yet have a | 1515 // A transfer is not needed if the current SiteInstance doesn't yet have a |
| 1502 // site. This is the case for tests that use NavigateToURL. | 1516 // site. This is the case for tests that use NavigateToURL. |
| 1503 if (!rfh->GetSiteInstance()->HasSite()) | 1517 if (!rfh->GetSiteInstance()->HasSite()) |
| 1504 return false; | 1518 return false; |
| 1505 | 1519 |
| 1506 // We do not currently swap processes for navigations in webview tag guests. | 1520 // We do not currently swap processes for navigations in webview tag guests. |
| 1507 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kGuestScheme)) | 1521 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kGuestScheme)) |
| 1508 return false; | 1522 return false; |
| 1509 | 1523 |
| 1510 // Don't swap processes for extensions embedded in DevTools. See | 1524 // Don't swap processes for devtools extensions embedded in DevTools, except |
| 1511 // https://crbug.com/564216. | 1525 // for external navigations in iframes. See https://crbug.com/564216. |
| 1512 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kChromeDevToolsScheme)) { | 1526 if (rfh->GetSiteInstance()->GetSiteURL().SchemeIs(kChromeDevToolsScheme)) { |
| 1513 // TODO(nick): https://crbug.com/570483 Check to see if |dest_url| is a | 1527 url::Origin origin = url::Origin(dest_url); |
| 1514 // devtools extension, and swap processes if not. | 1528 auto* policy = content::ChildProcessSecurityPolicy::GetInstance(); |
|
ncarter (slow)
2017/03/09 23:28:49
content:: is unnecessary here, we're already insid
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done.
| |
| 1515 return false; | 1529 bool is_devtools_extension = policy->HasSpecificPermissionForOrigin( |
| 1530 rfh->GetProcess()->GetID(), origin); | |
| 1531 return !(dest_url.SchemeIs(kChromeDevToolsScheme) || is_devtools_extension); | |
|
ncarter (slow)
2017/03/09 23:28:49
As above, checking the scheme on |origin| instead
davidsac (gone - try alexmos)
2017/03/11 01:51:47
Done, I think? I used |origin.scheme()==kChromeDe
| |
| 1516 } | 1532 } |
| 1517 | 1533 |
| 1518 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext(); | 1534 BrowserContext* context = rfh->GetSiteInstance()->GetBrowserContext(); |
| 1519 // TODO(nasko, nick): These following --site-per-process checks are | 1535 // TODO(nasko, nick): These following --site-per-process checks are |
| 1520 // overly simplistic. Update them to match all the cases | 1536 // overly simplistic. Update them to match all the cases |
| 1521 // considered by DetermineSiteInstanceForURL. | 1537 // considered by DetermineSiteInstanceForURL. |
| 1522 if (IsCurrentlySameSite(rfh, dest_url)) { | 1538 if (IsCurrentlySameSite(rfh, dest_url)) { |
| 1523 // The same site, no transition needed for security purposes, and we must | 1539 // The same site, no transition needed for security purposes, and we must |
| 1524 // keep the same SiteInstance for correctness of synchronous scripting. | 1540 // keep the same SiteInstance for correctness of synchronous scripting. |
| 1525 return false; | 1541 return false; |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2782 resolved_url)) { | 2798 resolved_url)) { |
| 2783 DCHECK(!dest_instance || | 2799 DCHECK(!dest_instance || |
| 2784 dest_instance == render_frame_host_->GetSiteInstance()); | 2800 dest_instance == render_frame_host_->GetSiteInstance()); |
| 2785 return false; | 2801 return false; |
| 2786 } | 2802 } |
| 2787 | 2803 |
| 2788 return true; | 2804 return true; |
| 2789 } | 2805 } |
| 2790 | 2806 |
| 2791 } // namespace content | 2807 } // namespace content |
| OLD | NEW |