Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/navigation_resource_throttle.h" | 5 #include "content/browser/loader/navigation_resource_throttle.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 const ResourceRequestInfoImpl* info = | 197 const ResourceRequestInfoImpl* info = |
| 198 ResourceRequestInfoImpl::ForRequest(request_); | 198 ResourceRequestInfoImpl::ForRequest(request_); |
| 199 if (!info) | 199 if (!info) |
| 200 return; | 200 return; |
| 201 | 201 |
| 202 int render_process_id, render_frame_id; | 202 int render_process_id, render_frame_id; |
| 203 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) | 203 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) |
| 204 return; | 204 return; |
| 205 | 205 |
| 206 bool is_external_protocol = | 206 bool is_external_protocol = |
| 207 !info->GetContext()->GetRequestContext()->job_factory()->IsHandledURL( | 207 request_->url().is_valid() && |
| 208 request_->url()); | 208 !info->GetContext() |
| 209 ->GetRequestContext() | |
| 210 ->job_factory() | |
| 211 ->IsHandledProtocol(request_->url().scheme()); | |
|
mmenke
2017/03/31 04:30:04
This duplication seems ugly, but with PlzNavigate,
asanka
2017/03/31 20:38:30
Acknowledged.
| |
| 209 UIChecksPerformedCallback callback = | 212 UIChecksPerformedCallback callback = |
| 210 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, | 213 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, |
| 211 weak_ptr_factory_.GetWeakPtr()); | 214 weak_ptr_factory_.GetWeakPtr()); |
| 212 DCHECK(request_->method() == "POST" || request_->method() == "GET"); | 215 DCHECK(request_->method() == "POST" || request_->method() == "GET"); |
| 213 BrowserThread::PostTask( | 216 BrowserThread::PostTask( |
| 214 BrowserThread::UI, FROM_HERE, | 217 BrowserThread::UI, FROM_HERE, |
| 215 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, | 218 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, |
| 216 render_frame_id, request_->method(), info->body(), | 219 render_frame_id, request_->method(), info->body(), |
| 217 Referrer::SanitizeForRequest( | 220 Referrer::SanitizeForRequest( |
| 218 request_->url(), Referrer(GURL(request_->referrer()), | 221 request_->url(), Referrer(GURL(request_->referrer()), |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 232 return; | 235 return; |
| 233 | 236 |
| 234 if (redirect_info.new_method != "POST") | 237 if (redirect_info.new_method != "POST") |
| 235 info->ResetBody(); | 238 info->ResetBody(); |
| 236 | 239 |
| 237 int render_process_id, render_frame_id; | 240 int render_process_id, render_frame_id; |
| 238 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) | 241 if (!info->GetAssociatedRenderFrame(&render_process_id, &render_frame_id)) |
| 239 return; | 242 return; |
| 240 | 243 |
| 241 bool new_is_external_protocol = | 244 bool new_is_external_protocol = |
| 242 !info->GetContext()->GetRequestContext()->job_factory()->IsHandledURL( | 245 request_->url().is_valid() && |
| 243 request_->url()); | 246 !info->GetContext() |
| 247 ->GetRequestContext() | |
| 248 ->job_factory() | |
| 249 ->IsHandledProtocol(request_->url().scheme()); | |
| 244 DCHECK(redirect_info.new_method == "POST" || | 250 DCHECK(redirect_info.new_method == "POST" || |
| 245 redirect_info.new_method == "GET"); | 251 redirect_info.new_method == "GET"); |
| 246 UIChecksPerformedCallback callback = | 252 UIChecksPerformedCallback callback = |
| 247 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, | 253 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, |
| 248 weak_ptr_factory_.GetWeakPtr()); | 254 weak_ptr_factory_.GetWeakPtr()); |
| 249 | 255 |
| 250 // Send the redirect info to the NavigationHandle on the UI thread. | 256 // Send the redirect info to the NavigationHandle on the UI thread. |
| 251 // Note: to avoid threading issues, a copy of the HttpResponseHeaders is sent | 257 // Note: to avoid threading issues, a copy of the HttpResponseHeaders is sent |
| 252 // in lieu of the original. | 258 // in lieu of the original. |
| 253 scoped_refptr<net::HttpResponseHeaders> response_headers; | 259 scoped_refptr<net::HttpResponseHeaders> response_headers; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 | 389 |
| 384 // If the results of the checks on the UI thread are known, unblock the | 390 // If the results of the checks on the UI thread are known, unblock the |
| 385 // navigation. Otherwise, wait until the callback has executed. | 391 // navigation. Otherwise, wait until the callback has executed. |
| 386 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 392 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 387 OnUIChecksPerformed(on_transfer_done_result_); | 393 OnUIChecksPerformed(on_transfer_done_result_); |
| 388 on_transfer_done_result_ = NavigationThrottle::DEFER; | 394 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 389 } | 395 } |
| 390 } | 396 } |
| 391 | 397 |
| 392 } // namespace content | 398 } // namespace content |
| OLD | NEW |