| 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 response->head.headers->response_code() == 204)) { | 166 response->head.headers->response_code() == 204)) { |
| 167 return next_handler_->OnResponseStarted(request_id, response, defer); | 167 return next_handler_->OnResponseStarted(request_id, response, defer); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Now that we know a swap is needed and we have something to commit, we | 170 // Now that we know a swap is needed and we have something to commit, we |
| 171 // pause to let the UI thread run the unload handler of the previous page | 171 // pause to let the UI thread run the unload handler of the previous page |
| 172 // and set up a transfer if needed. | 172 // and set up a transfer if needed. |
| 173 StartCrossSiteTransition(request_id, response, should_transfer); | 173 StartCrossSiteTransition(request_id, response, should_transfer); |
| 174 | 174 |
| 175 // Defer loading until after the onunload event handler has run. | 175 // Defer loading until after the onunload event handler has run. |
| 176 did_defer_ = *defer = true; | 176 *defer = true; |
| 177 OnDidDefer(); |
| 177 return true; | 178 return true; |
| 178 } | 179 } |
| 179 | 180 |
| 180 bool CrossSiteResourceHandler::OnReadCompleted(int request_id, | 181 bool CrossSiteResourceHandler::OnReadCompleted(int request_id, |
| 181 int bytes_read, | 182 int bytes_read, |
| 182 bool* defer) { | 183 bool* defer) { |
| 183 CHECK(!in_cross_site_transition_); | 184 CHECK(!in_cross_site_transition_); |
| 184 return next_handler_->OnReadCompleted(request_id, bytes_read, defer); | 185 return next_handler_->OnReadCompleted(request_id, bytes_read, defer); |
| 185 } | 186 } |
| 186 | 187 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 210 StartCrossSiteTransition(request_id, NULL, false); | 211 StartCrossSiteTransition(request_id, NULL, false); |
| 211 } | 212 } |
| 212 | 213 |
| 213 // We have to buffer the call until after the transition completes. | 214 // We have to buffer the call until after the transition completes. |
| 214 completed_during_transition_ = true; | 215 completed_during_transition_ = true; |
| 215 completed_status_ = status; | 216 completed_status_ = status; |
| 216 completed_security_info_ = security_info; | 217 completed_security_info_ = security_info; |
| 217 | 218 |
| 218 // Defer to tell RDH not to notify the world or clean up the pending request. | 219 // Defer to tell RDH not to notify the world or clean up the pending request. |
| 219 // We will do so in ResumeResponse. | 220 // We will do so in ResumeResponse. |
| 220 did_defer_ = true; | |
| 221 *defer = true; | 221 *defer = true; |
| 222 OnDidDefer(); |
| 222 } | 223 } |
| 223 | 224 |
| 224 // We can now send the response to the new renderer, which will cause | 225 // We can now send the response to the new renderer, which will cause |
| 225 // WebContentsImpl to swap in the new renderer and destroy the old one. | 226 // WebContentsImpl to swap in the new renderer and destroy the old one. |
| 226 void CrossSiteResourceHandler::ResumeResponse() { | 227 void CrossSiteResourceHandler::ResumeResponse() { |
| 227 DCHECK(request()); | 228 DCHECK(request()); |
| 228 DCHECK(in_cross_site_transition_); | 229 DCHECK(in_cross_site_transition_); |
| 229 in_cross_site_transition_ = false; | 230 in_cross_site_transition_ = false; |
| 230 ResourceRequestInfoImpl* info = GetRequestInfo(); | 231 ResourceRequestInfoImpl* info = GetRequestInfo(); |
| 231 | 232 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 should_transfer, | 305 should_transfer, |
| 305 transfer_url_chain, | 306 transfer_url_chain, |
| 306 referrer, | 307 referrer, |
| 307 info->GetPageTransition(), | 308 info->GetPageTransition(), |
| 308 frame_id, | 309 frame_id, |
| 309 info->should_replace_current_entry()))); | 310 info->should_replace_current_entry()))); |
| 310 } | 311 } |
| 311 | 312 |
| 312 void CrossSiteResourceHandler::ResumeIfDeferred() { | 313 void CrossSiteResourceHandler::ResumeIfDeferred() { |
| 313 if (did_defer_) { | 314 if (did_defer_) { |
| 315 request()->LogUnblocked(); |
| 314 did_defer_ = false; | 316 did_defer_ = false; |
| 315 controller()->Resume(); | 317 controller()->Resume(); |
| 316 } | 318 } |
| 317 } | 319 } |
| 318 | 320 |
| 321 void CrossSiteResourceHandler::OnDidDefer() { |
| 322 did_defer_ = true; |
| 323 request()->LogBlockedBy("CrossSiteResourceHandler"); |
| 324 } |
| 325 |
| 319 } // namespace content | 326 } // namespace content |
| OLD | NEW |