| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // cross-site navigations. This is skipped if a transfer is already required | 193 // cross-site navigations. This is skipped if a transfer is already required |
| 194 // or for WebUI processes for now, since pages like the NTP host multiple | 194 // or for WebUI processes for now, since pages like the NTP host multiple |
| 195 // cross-site WebUI iframes. | 195 // cross-site WebUI iframes. |
| 196 if (!should_transfer && | 196 if (!should_transfer && |
| 197 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && | 197 CommandLine::ForCurrentProcess()->HasSwitch(switches::kSitePerProcess) && |
| 198 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 198 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 199 info->GetChildID())) { | 199 info->GetChildID())) { |
| 200 return DeferForNavigationPolicyCheck(info, response, defer); | 200 return DeferForNavigationPolicyCheck(info, response, defer); |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool swap_needed = should_transfer || | 203 bool swap_needed = |
| 204 CrossSiteRequestManager::GetInstance()-> | 204 should_transfer || |
| 205 HasPendingCrossSiteRequest(info->GetChildID(), info->GetRouteID()); | 205 CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
| 206 info->GetChildID(), info->GetRenderFrameID()); |
| 206 | 207 |
| 207 // If this is a download, just pass the response through without doing a | 208 // If this is a download, just pass the response through without doing a |
| 208 // cross-site check. The renderer will see it is a download and abort the | 209 // cross-site check. The renderer will see it is a download and abort the |
| 209 // request. | 210 // request. |
| 210 // | 211 // |
| 211 // Similarly, HTTP 204 (No Content) responses leave us showing the previous | 212 // Similarly, HTTP 204 (No Content) responses leave us showing the previous |
| 212 // page. We should allow the navigation to finish without running the unload | 213 // page. We should allow the navigation to finish without running the unload |
| 213 // handler or swapping in the pending RenderFrameHost. | 214 // handler or swapping in the pending RenderFrameHost. |
| 214 // | 215 // |
| 215 // In both cases, any pending RenderFrameHost (if one was created for this | 216 // In both cases, any pending RenderFrameHost (if one was created for this |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 const std::string& security_info, | 286 const std::string& security_info, |
| 286 bool* defer) { | 287 bool* defer) { |
| 287 if (!in_cross_site_transition_) { | 288 if (!in_cross_site_transition_) { |
| 288 ResourceRequestInfoImpl* info = GetRequestInfo(); | 289 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 289 // If we've already completed the transition, or we're canceling the | 290 // If we've already completed the transition, or we're canceling the |
| 290 // request, or an error occurred with no cross-process navigation in | 291 // request, or an error occurred with no cross-process navigation in |
| 291 // progress, then we should just pass this through. | 292 // progress, then we should just pass this through. |
| 292 if (has_started_response_ || | 293 if (has_started_response_ || |
| 293 status.status() != net::URLRequestStatus::FAILED || | 294 status.status() != net::URLRequestStatus::FAILED || |
| 294 !CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( | 295 !CrossSiteRequestManager::GetInstance()->HasPendingCrossSiteRequest( |
| 295 info->GetChildID(), info->GetRouteID())) { | 296 info->GetChildID(), info->GetRenderFrameID())) { |
| 296 next_handler_->OnResponseCompleted(status, security_info, defer); | 297 next_handler_->OnResponseCompleted(status, security_info, defer); |
| 297 return; | 298 return; |
| 298 } | 299 } |
| 299 | 300 |
| 300 // An error occurred. We should wait now for the cross-process transition, | 301 // An error occurred. We should wait now for the cross-process transition, |
| 301 // so that the error message (e.g., 404) can be displayed to the user. | 302 // so that the error message (e.g., 404) can be displayed to the user. |
| 302 // Also continue with the logic below to remember that we completed | 303 // Also continue with the logic below to remember that we completed |
| 303 // during the cross-site transition. | 304 // during the cross-site transition. |
| 304 StartCrossSiteTransition(NULL, false); | 305 StartCrossSiteTransition(NULL, false); |
| 305 } | 306 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 controller()->Resume(); | 442 controller()->Resume(); |
| 442 } | 443 } |
| 443 } | 444 } |
| 444 | 445 |
| 445 void CrossSiteResourceHandler::OnDidDefer() { | 446 void CrossSiteResourceHandler::OnDidDefer() { |
| 446 did_defer_ = true; | 447 did_defer_ = true; |
| 447 request()->LogBlockedBy("CrossSiteResourceHandler"); | 448 request()->LogBlockedBy("CrossSiteResourceHandler"); |
| 448 } | 449 } |
| 449 | 450 |
| 450 } // namespace content | 451 } // namespace content |
| OLD | NEW |