| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // cross-site check. The renderer will see it is a download and abort the | 84 // cross-site check. The renderer will see it is a download and abort the |
| 85 // request. | 85 // request. |
| 86 // | 86 // |
| 87 // Similarly, HTTP 204 (No Content) responses leave us showing the previous | 87 // Similarly, HTTP 204 (No Content) responses leave us showing the previous |
| 88 // page. We should allow the navigation to finish without running the unload | 88 // page. We should allow the navigation to finish without running the unload |
| 89 // handler or swapping in the pending RenderViewHost. | 89 // handler or swapping in the pending RenderViewHost. |
| 90 // | 90 // |
| 91 // In both cases, the pending RenderViewHost will stick around until the next | 91 // In both cases, the pending RenderViewHost will stick around until the next |
| 92 // cross-site navigation, since we are unable to tell when to destroy it. | 92 // cross-site navigation, since we are unable to tell when to destroy it. |
| 93 // See RenderViewHostManager::RendererAbortedProvisionalLoad. | 93 // See RenderViewHostManager::RendererAbortedProvisionalLoad. |
| 94 if (info->is_download() || | 94 if (info->is_download() || (response->head.headers.get() && |
| 95 (response->head.headers && | 95 response->head.headers->response_code() == 204)) { |
| 96 response->head.headers->response_code() == 204)) { | |
| 97 return next_handler_->OnResponseStarted(request_id, response, defer); | 96 return next_handler_->OnResponseStarted(request_id, response, defer); |
| 98 } | 97 } |
| 99 | 98 |
| 100 // Tell the renderer to run the onunload event handler. | 99 // Tell the renderer to run the onunload event handler. |
| 101 StartCrossSiteTransition(request_id, response); | 100 StartCrossSiteTransition(request_id, response); |
| 102 | 101 |
| 103 // Defer loading until after the onunload event handler has run. | 102 // Defer loading until after the onunload event handler has run. |
| 104 did_defer_ = *defer = true; | 103 did_defer_ = *defer = true; |
| 105 return true; | 104 return true; |
| 106 } | 105 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 209 } |
| 211 | 210 |
| 212 void CrossSiteResourceHandler::ResumeIfDeferred() { | 211 void CrossSiteResourceHandler::ResumeIfDeferred() { |
| 213 if (did_defer_) { | 212 if (did_defer_) { |
| 214 did_defer_ = false; | 213 did_defer_ = false; |
| 215 controller()->Resume(); | 214 controller()->Resume(); |
| 216 } | 215 } |
| 217 } | 216 } |
| 218 | 217 |
| 219 } // namespace content | 218 } // namespace content |
| OLD | NEW |