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 <utility> | 10 #include <utility> |
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1084 // doesn't usually swap (e.g., process-per-tab). Any time we return true, | 1084 // doesn't usually swap (e.g., process-per-tab). Any time we return true, |
1085 // the new_entry will be rendered in a new SiteInstance AND BrowsingInstance. | 1085 // the new_entry will be rendered in a new SiteInstance AND BrowsingInstance. |
1086 BrowserContext* browser_context = | 1086 BrowserContext* browser_context = |
1087 delegate_->GetControllerForRenderManager().GetBrowserContext(); | 1087 delegate_->GetControllerForRenderManager().GetBrowserContext(); |
1088 | 1088 |
1089 // Don't force a new BrowsingInstance for debug URLs that are handled in the | 1089 // Don't force a new BrowsingInstance for debug URLs that are handled in the |
1090 // renderer process, like javascript: or chrome://crash. | 1090 // renderer process, like javascript: or chrome://crash. |
1091 if (IsRendererDebugURL(new_effective_url)) | 1091 if (IsRendererDebugURL(new_effective_url)) |
1092 return false; | 1092 return false; |
1093 | 1093 |
1094 // Transitions across BrowserContexts should always require a | |
1095 // BrowsingInstance swap. For example, this can happen if an extension in a | |
1096 // normal profile opens an incognito window with a web URL using | |
1097 // chrome.windows.create(). | |
1098 // | |
1099 // TODO(alexmos): This check should've been enforced earlier in the | |
1100 // navigation, in chrome::Navigate(). Verify this, and then convert this to | |
1101 // a CHECK and remove the fallback. | |
1102 DCHECK_EQ(browser_context, | |
1103 render_frame_host_->GetSiteInstance()->GetBrowserContext()); | |
1104 if (browser_context != | |
1105 render_frame_host_->GetSiteInstance()->GetBrowserContext()) { | |
alexmos
2016/10/04 21:24:44
I was thinking of keeping this for now as a defens
| |
1106 return true; | |
1107 } | |
1108 | |
1094 // For security, we should transition between processes when one is a Web UI | 1109 // For security, we should transition between processes when one is a Web UI |
1095 // page and one isn't, or if the WebUI types differ. | 1110 // page and one isn't, or if the WebUI types differ. |
1096 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 1111 if (ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
1097 render_frame_host_->GetProcess()->GetID()) || | 1112 render_frame_host_->GetProcess()->GetID()) || |
1098 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( | 1113 WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL( |
1099 browser_context, current_effective_url)) { | 1114 browser_context, current_effective_url)) { |
1100 // If so, force a swap if destination is not an acceptable URL for Web UI. | 1115 // If so, force a swap if destination is not an acceptable URL for Web UI. |
1101 // Here, data URLs are never allowed. | 1116 // Here, data URLs are never allowed. |
1102 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 1117 if (!WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
1103 browser_context, new_effective_url)) { | 1118 browser_context, new_effective_url)) { |
1104 return true; | 1119 return true; |
1105 } | 1120 } |
1106 | 1121 |
1107 // Force swap if the current WebUI type differs from the one for the | 1122 // Force swap if the current WebUI type differs from the one for the |
1108 // destination. | 1123 // destination. |
1109 if (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 1124 if (WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
1110 browser_context, current_effective_url) != | 1125 browser_context, current_effective_url) != |
1111 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( | 1126 WebUIControllerFactoryRegistry::GetInstance()->GetWebUIType( |
1112 browser_context, new_effective_url)) { | 1127 browser_context, new_effective_url)) { |
1113 return true; | 1128 return true; |
1114 } | 1129 } |
1115 } else { | 1130 } else { |
1116 // Force a swap if it's a Web UI URL. | 1131 // Force a swap if it's a Web UI URL. |
1117 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIForURL( | 1132 if (WebUIControllerFactoryRegistry::GetInstance()->UseWebUIBindingsForURL( |
1118 browser_context, new_effective_url)) { | 1133 browser_context, new_effective_url)) { |
1119 return true; | 1134 return true; |
1120 } | 1135 } |
1121 } | 1136 } |
1122 | 1137 |
1123 // Check with the content client as well. Important to pass | 1138 // Check with the content client as well. Important to pass |
1124 // current_effective_url here, which uses the SiteInstance's site if there is | 1139 // current_effective_url here, which uses the SiteInstance's site if there is |
1125 // no current_entry. | 1140 // no current_entry. |
1126 if (GetContentClient()->browser()->ShouldSwapBrowsingInstancesForNavigation( | 1141 if (GetContentClient()->browser()->ShouldSwapBrowsingInstancesForNavigation( |
1127 render_frame_host_->GetSiteInstance(), | 1142 render_frame_host_->GetSiteInstance(), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1192 | 1207 |
1193 scoped_refptr<SiteInstance> new_instance = | 1208 scoped_refptr<SiteInstance> new_instance = |
1194 ConvertToSiteInstance(new_instance_descriptor, candidate_instance); | 1209 ConvertToSiteInstance(new_instance_descriptor, candidate_instance); |
1195 // If |force_swap| is true, we must use a different SiteInstance than the | 1210 // If |force_swap| is true, we must use a different SiteInstance than the |
1196 // current one. If we didn't, we would have two RenderFrameHosts in the same | 1211 // current one. If we didn't, we would have two RenderFrameHosts in the same |
1197 // SiteInstance and the same frame, resulting in page_id conflicts for their | 1212 // SiteInstance and the same frame, resulting in page_id conflicts for their |
1198 // NavigationEntries. | 1213 // NavigationEntries. |
1199 if (force_swap) | 1214 if (force_swap) |
1200 CHECK_NE(new_instance, current_instance); | 1215 CHECK_NE(new_instance, current_instance); |
1201 | 1216 |
1217 // Double-check that the new SiteInstance is associated with the right | |
1218 // BrowserContext. | |
1219 DCHECK_EQ(new_instance->GetBrowserContext(), browser_context); | |
alexmos
2016/10/04 21:24:44
This was getting hit in ExtensionTabsTest.DefaultT
| |
1220 | |
1202 return new_instance; | 1221 return new_instance; |
1203 } | 1222 } |
1204 | 1223 |
1205 RenderFrameHostManager::SiteInstanceDescriptor | 1224 RenderFrameHostManager::SiteInstanceDescriptor |
1206 RenderFrameHostManager::DetermineSiteInstanceForURL( | 1225 RenderFrameHostManager::DetermineSiteInstanceForURL( |
1207 const GURL& dest_url, | 1226 const GURL& dest_url, |
1208 SiteInstance* source_instance, | 1227 SiteInstance* source_instance, |
1209 SiteInstance* current_instance, | 1228 SiteInstance* current_instance, |
1210 SiteInstance* dest_instance, | 1229 SiteInstance* dest_instance, |
1211 ui::PageTransition transition, | 1230 ui::PageTransition transition, |
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2668 resolved_url)) { | 2687 resolved_url)) { |
2669 DCHECK(!dest_instance || | 2688 DCHECK(!dest_instance || |
2670 dest_instance == render_frame_host_->GetSiteInstance()); | 2689 dest_instance == render_frame_host_->GetSiteInstance()); |
2671 return false; | 2690 return false; |
2672 } | 2691 } |
2673 | 2692 |
2674 return true; | 2693 return true; |
2675 } | 2694 } |
2676 | 2695 |
2677 } // namespace content | 2696 } // namespace content |
OLD | NEW |