OLD | NEW |
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/loader/cross_site_resource_handler.h" | 5 #include "content/browser/loader/cross_site_resource_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // was already in progress. Note that a swap may no longer be needed if we | 120 // was already in progress. Note that a swap may no longer be needed if we |
121 // transferred back into the original process due to a redirect. | 121 // transferred back into the original process due to a redirect. |
122 bool should_transfer = | 122 bool should_transfer = |
123 GetContentClient()->browser()->ShouldSwapProcessesForRedirect( | 123 GetContentClient()->browser()->ShouldSwapProcessesForRedirect( |
124 info->GetContext(), request()->original_url(), request()->url()); | 124 info->GetContext(), request()->original_url(), request()->url()); |
125 | 125 |
126 // When the --site-per-process flag is passed, we transfer processes for | 126 // When the --site-per-process flag is passed, we transfer processes for |
127 // cross-site subframe navigations. | 127 // cross-site subframe navigations. |
128 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { | 128 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess)) { |
129 GURL referrer(request()->referrer()); | 129 GURL referrer(request()->referrer()); |
130 // We skip this for WebUI processes for now, since pages like the NTP host | 130 // We skip this for WebUI and NTP processes for now, since pages like |
131 // cross-site WebUI iframes but don't have referrers. | 131 // Settings and the NTP host cross-site WebUI iframes but don't have |
| 132 // referrers. (Note: the NTP is not WebUI anymore.) |
132 bool is_webui_process = ChildProcessSecurityPolicyImpl::GetInstance()-> | 133 bool is_webui_process = ChildProcessSecurityPolicyImpl::GetInstance()-> |
133 HasWebUIBindings(info->GetChildID()); | 134 HasWebUIBindings(info->GetChildID()) || |
| 135 request()->url().SchemeIs(chrome::kChromeUIScheme) || |
| 136 request()->url().SchemeIs("chrome-search"); |
134 | 137 |
135 // TODO(creis): This shouldn't rely on the referrer to determine the parent | 138 // TODO(creis): This shouldn't rely on the referrer to determine the parent |
136 // frame's URL. This also doesn't work for hosted apps, due to passing NULL | 139 // frame's URL. This also doesn't work for hosted apps, due to passing NULL |
137 // to IsSameWebSite. It should be possible to always send the navigation to | 140 // to IsSameWebSite. It should be possible to always send the navigation to |
138 // the UI thread to make a policy decision, which could let us eliminate the | 141 // the UI thread to make a policy decision, which could let us eliminate the |
139 // renderer-side check in RenderViewImpl::decidePolicyForNavigation as well. | 142 // renderer-side check in RenderViewImpl::decidePolicyForNavigation as well. |
140 if (info->GetResourceType() == ResourceType::SUB_FRAME && | 143 if (info->GetResourceType() == ResourceType::SUB_FRAME && |
141 !is_webui_process && | 144 !is_webui_process && |
142 !SiteInstance::IsSameWebSite(NULL, request()->url(), referrer)) { | 145 !SiteInstance::IsSameWebSite(NULL, request()->url(), referrer)) { |
| 146 LOG(INFO) << "CSRH: Transferring for a cross-process subframe: " << |
| 147 request()->url(); |
143 should_transfer = true; | 148 should_transfer = true; |
144 } | 149 } |
145 } | 150 } |
146 | 151 |
147 bool swap_needed = should_transfer || | 152 bool swap_needed = should_transfer || |
148 CrossSiteRequestManager::GetInstance()-> | 153 CrossSiteRequestManager::GetInstance()-> |
149 HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID()); | 154 HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID()); |
150 | 155 |
151 // If this is a download, just pass the response through without doing a | 156 // If this is a download, just pass the response through without doing a |
152 // cross-site check. The renderer will see it is a download and abort the | 157 // cross-site check. The renderer will see it is a download and abort the |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 312 } |
308 | 313 |
309 void CrossSiteResourceHandler::ResumeIfDeferred() { | 314 void CrossSiteResourceHandler::ResumeIfDeferred() { |
310 if (did_defer_) { | 315 if (did_defer_) { |
311 did_defer_ = false; | 316 did_defer_ = false; |
312 controller()->Resume(); | 317 controller()->Resume(); |
313 } | 318 } |
314 } | 319 } |
315 | 320 |
316 } // namespace content | 321 } // namespace content |
OLD | NEW |