| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 90 } |
| 91 | 91 |
| 92 void CheckWillStartRequestOnUIThread( | 92 void CheckWillStartRequestOnUIThread( |
| 93 UIChecksPerformedCallback callback, | 93 UIChecksPerformedCallback callback, |
| 94 int render_process_id, | 94 int render_process_id, |
| 95 int render_frame_host_id, | 95 int render_frame_host_id, |
| 96 const std::string& method, | 96 const std::string& method, |
| 97 const scoped_refptr<content::ResourceRequestBodyImpl>& | 97 const scoped_refptr<content::ResourceRequestBodyImpl>& |
| 98 resource_request_body, | 98 resource_request_body, |
| 99 const Referrer& sanitized_referrer, | 99 const Referrer& sanitized_referrer, |
| 100 bool has_user_gesture, | |
| 101 ui::PageTransition transition, | 100 ui::PageTransition transition, |
| 102 bool is_external_protocol, | 101 bool is_external_protocol, |
| 103 RequestContextType request_context_type) { | 102 RequestContextType request_context_type) { |
| 104 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 103 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 105 NavigationHandleImpl* navigation_handle = | 104 NavigationHandleImpl* navigation_handle = |
| 106 FindNavigationHandle(render_process_id, render_frame_host_id, callback); | 105 FindNavigationHandle(render_process_id, render_frame_host_id, callback); |
| 107 if (!navigation_handle) | 106 if (!navigation_handle) |
| 108 return; | 107 return; |
| 109 | 108 |
| 110 navigation_handle->WillStartRequest( | 109 navigation_handle->WillStartRequest( |
| 111 method, resource_request_body, sanitized_referrer, has_user_gesture, | 110 method, resource_request_body, sanitized_referrer, transition, |
| 112 transition, is_external_protocol, request_context_type, | 111 is_external_protocol, request_context_type, |
| 113 base::Bind(&SendCheckResultToIOThread, callback)); | 112 base::Bind(&SendCheckResultToIOThread, callback)); |
| 114 } | 113 } |
| 115 | 114 |
| 116 void CheckWillRedirectRequestOnUIThread( | 115 void CheckWillRedirectRequestOnUIThread( |
| 117 UIChecksPerformedCallback callback, | 116 UIChecksPerformedCallback callback, |
| 118 int render_process_id, | 117 int render_process_id, |
| 119 int render_frame_host_id, | 118 int render_frame_host_id, |
| 120 const GURL& new_url, | 119 const GURL& new_url, |
| 121 const std::string& new_method, | 120 const std::string& new_method, |
| 122 const GURL& new_referrer_url, | 121 const GURL& new_referrer_url, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, | 206 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, |
| 208 weak_ptr_factory_.GetWeakPtr()); | 207 weak_ptr_factory_.GetWeakPtr()); |
| 209 DCHECK(request_->method() == "POST" || request_->method() == "GET"); | 208 DCHECK(request_->method() == "POST" || request_->method() == "GET"); |
| 210 BrowserThread::PostTask( | 209 BrowserThread::PostTask( |
| 211 BrowserThread::UI, FROM_HERE, | 210 BrowserThread::UI, FROM_HERE, |
| 212 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, | 211 base::Bind(&CheckWillStartRequestOnUIThread, callback, render_process_id, |
| 213 render_frame_id, request_->method(), info->body(), | 212 render_frame_id, request_->method(), info->body(), |
| 214 Referrer::SanitizeForRequest( | 213 Referrer::SanitizeForRequest( |
| 215 request_->url(), Referrer(GURL(request_->referrer()), | 214 request_->url(), Referrer(GURL(request_->referrer()), |
| 216 info->GetReferrerPolicy())), | 215 info->GetReferrerPolicy())), |
| 217 info->HasUserGesture(), info->GetPageTransition(), | 216 info->GetPageTransition(), is_external_protocol, |
| 218 is_external_protocol, request_context_type_)); | 217 request_context_type_)); |
| 219 *defer = true; | 218 *defer = true; |
| 220 } | 219 } |
| 221 | 220 |
| 222 void NavigationResourceThrottle::WillRedirectRequest( | 221 void NavigationResourceThrottle::WillRedirectRequest( |
| 223 const net::RedirectInfo& redirect_info, | 222 const net::RedirectInfo& redirect_info, |
| 224 bool* defer) { | 223 bool* defer) { |
| 225 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 224 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 226 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); | 225 ResourceRequestInfoImpl* info = ResourceRequestInfoImpl::ForRequest(request_); |
| 227 if (!info) | 226 if (!info) |
| 228 return; | 227 return; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 | 368 |
| 370 // If the results of the checks on the UI thread are known, unblock the | 369 // If the results of the checks on the UI thread are known, unblock the |
| 371 // navigation. Otherwise, wait until the callback has executed. | 370 // navigation. Otherwise, wait until the callback has executed. |
| 372 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 371 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 373 OnUIChecksPerformed(on_transfer_done_result_); | 372 OnUIChecksPerformed(on_transfer_done_result_); |
| 374 on_transfer_done_result_ = NavigationThrottle::DEFER; | 373 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 375 } | 374 } |
| 376 } | 375 } |
| 377 | 376 |
| 378 } // namespace content | 377 } // namespace content |
| OLD | NEW |