| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 void CheckWillRedirectRequestOnUIThread( | 118 void CheckWillRedirectRequestOnUIThread( |
| 119 UIChecksPerformedCallback callback, | 119 UIChecksPerformedCallback callback, |
| 120 int render_process_id, | 120 int render_process_id, |
| 121 int render_frame_host_id, | 121 int render_frame_host_id, |
| 122 const GURL& new_url, | 122 const GURL& new_url, |
| 123 const std::string& new_method, | 123 const std::string& new_method, |
| 124 const GURL& new_referrer_url, | 124 const GURL& new_referrer_url, |
| 125 bool new_is_external_protocol, | 125 bool new_is_external_protocol, |
| 126 scoped_refptr<net::HttpResponseHeaders> headers) { | 126 scoped_refptr<net::HttpResponseHeaders> headers, |
| 127 net::HttpResponseInfo::ConnectionInfo connection_info) { |
| 127 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 128 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 128 NavigationHandleImpl* navigation_handle = | 129 NavigationHandleImpl* navigation_handle = |
| 129 FindNavigationHandle(render_process_id, render_frame_host_id, callback); | 130 FindNavigationHandle(render_process_id, render_frame_host_id, callback); |
| 130 if (!navigation_handle) | 131 if (!navigation_handle) |
| 131 return; | 132 return; |
| 132 | 133 |
| 133 GURL new_validated_url(new_url); | 134 GURL new_validated_url(new_url); |
| 134 RenderProcessHost::FromID(render_process_id) | 135 RenderProcessHost::FromID(render_process_id) |
| 135 ->FilterURL(false, &new_validated_url); | 136 ->FilterURL(false, &new_validated_url); |
| 136 navigation_handle->WillRedirectRequest( | 137 navigation_handle->WillRedirectRequest( |
| 137 new_validated_url, new_method, new_referrer_url, new_is_external_protocol, | 138 new_validated_url, new_method, new_referrer_url, new_is_external_protocol, |
| 138 headers, base::Bind(&SendCheckResultToIOThread, callback)); | 139 headers, connection_info, |
| 140 base::Bind(&SendCheckResultToIOThread, callback)); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void WillProcessResponseOnUIThread( | 143 void WillProcessResponseOnUIThread( |
| 142 UIChecksPerformedCallback callback, | 144 UIChecksPerformedCallback callback, |
| 143 int render_process_id, | 145 int render_process_id, |
| 144 int render_frame_host_id, | 146 int render_frame_host_id, |
| 145 scoped_refptr<net::HttpResponseHeaders> headers, | 147 scoped_refptr<net::HttpResponseHeaders> headers, |
| 148 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 146 const SSLStatus& ssl_status, | 149 const SSLStatus& ssl_status, |
| 147 const GlobalRequestID& request_id, | 150 const GlobalRequestID& request_id, |
| 148 bool should_replace_current_entry, | 151 bool should_replace_current_entry, |
| 149 bool is_download, | 152 bool is_download, |
| 150 bool is_stream, | 153 bool is_stream, |
| 151 const base::Closure& transfer_callback, | 154 const base::Closure& transfer_callback, |
| 152 std::unique_ptr<NavigationData> navigation_data) { | 155 std::unique_ptr<NavigationData> navigation_data) { |
| 153 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 156 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 154 | 157 |
| 155 if (g_force_transfer) { | 158 if (g_force_transfer) { |
| 156 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback); | 159 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback); |
| 157 } | 160 } |
| 158 | 161 |
| 159 NavigationHandleImpl* navigation_handle = | 162 NavigationHandleImpl* navigation_handle = |
| 160 FindNavigationHandle(render_process_id, render_frame_host_id, callback); | 163 FindNavigationHandle(render_process_id, render_frame_host_id, callback); |
| 161 if (!navigation_handle) | 164 if (!navigation_handle) |
| 162 return; | 165 return; |
| 163 | 166 |
| 164 if (navigation_data) | 167 if (navigation_data) |
| 165 navigation_handle->set_navigation_data(std::move(navigation_data)); | 168 navigation_handle->set_navigation_data(std::move(navigation_data)); |
| 166 | 169 |
| 167 RenderFrameHostImpl* render_frame_host = | 170 RenderFrameHostImpl* render_frame_host = |
| 168 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); | 171 RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id); |
| 169 DCHECK(render_frame_host); | 172 DCHECK(render_frame_host); |
| 170 navigation_handle->WillProcessResponse( | 173 navigation_handle->WillProcessResponse( |
| 171 render_frame_host, headers, ssl_status, request_id, | 174 render_frame_host, headers, connection_info, ssl_status, request_id, |
| 172 should_replace_current_entry, is_download, is_stream, transfer_callback, | 175 should_replace_current_entry, is_download, is_stream, transfer_callback, |
| 173 base::Bind(&SendCheckResultToIOThread, callback)); | 176 base::Bind(&SendCheckResultToIOThread, callback)); |
| 174 } | 177 } |
| 175 | 178 |
| 176 } // namespace | 179 } // namespace |
| 177 | 180 |
| 178 NavigationResourceThrottle::NavigationResourceThrottle( | 181 NavigationResourceThrottle::NavigationResourceThrottle( |
| 179 net::URLRequest* request, | 182 net::URLRequest* request, |
| 180 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, | 183 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
| 181 RequestContextType request_context_type) | 184 RequestContextType request_context_type) |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if (request_->response_headers()) { | 252 if (request_->response_headers()) { |
| 250 response_headers = new net::HttpResponseHeaders( | 253 response_headers = new net::HttpResponseHeaders( |
| 251 request_->response_headers()->raw_headers()); | 254 request_->response_headers()->raw_headers()); |
| 252 } | 255 } |
| 253 | 256 |
| 254 BrowserThread::PostTask( | 257 BrowserThread::PostTask( |
| 255 BrowserThread::UI, FROM_HERE, | 258 BrowserThread::UI, FROM_HERE, |
| 256 base::Bind(&CheckWillRedirectRequestOnUIThread, callback, | 259 base::Bind(&CheckWillRedirectRequestOnUIThread, callback, |
| 257 render_process_id, render_frame_id, redirect_info.new_url, | 260 render_process_id, render_frame_id, redirect_info.new_url, |
| 258 redirect_info.new_method, GURL(redirect_info.new_referrer), | 261 redirect_info.new_method, GURL(redirect_info.new_referrer), |
| 259 new_is_external_protocol, response_headers)); | 262 new_is_external_protocol, response_headers, |
| 263 request_->response_info().connection_info)); |
| 260 *defer = true; | 264 *defer = true; |
| 261 } | 265 } |
| 262 | 266 |
| 263 void NavigationResourceThrottle::WillProcessResponse(bool* defer) { | 267 void NavigationResourceThrottle::WillProcessResponse(bool* defer) { |
| 264 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 268 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 265 const ResourceRequestInfoImpl* info = | 269 const ResourceRequestInfoImpl* info = |
| 266 ResourceRequestInfoImpl::ForRequest(request_); | 270 ResourceRequestInfoImpl::ForRequest(request_); |
| 267 if (!info) | 271 if (!info) |
| 268 return; | 272 return; |
| 269 | 273 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 299 | 303 |
| 300 SSLStatus ssl_status; | 304 SSLStatus ssl_status; |
| 301 if (request_->ssl_info().cert.get()) { | 305 if (request_->ssl_info().cert.get()) { |
| 302 NavigationResourceHandler::GetSSLStatusForRequest( | 306 NavigationResourceHandler::GetSSLStatusForRequest( |
| 303 request_->url(), request_->ssl_info(), info->GetChildID(), &ssl_status); | 307 request_->url(), request_->ssl_info(), info->GetChildID(), &ssl_status); |
| 304 } | 308 } |
| 305 | 309 |
| 306 BrowserThread::PostTask( | 310 BrowserThread::PostTask( |
| 307 BrowserThread::UI, FROM_HERE, | 311 BrowserThread::UI, FROM_HERE, |
| 308 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id, | 312 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id, |
| 309 render_frame_id, response_headers, ssl_status, | 313 render_frame_id, response_headers, |
| 314 request_->response_info().connection_info, ssl_status, |
| 310 info->GetGlobalRequestID(), | 315 info->GetGlobalRequestID(), |
| 311 info->should_replace_current_entry(), info->IsDownload(), | 316 info->should_replace_current_entry(), info->IsDownload(), |
| 312 info->is_stream(), transfer_callback, | 317 info->is_stream(), transfer_callback, |
| 313 base::Passed(&cloned_data))); | 318 base::Passed(&cloned_data))); |
| 314 *defer = true; | 319 *defer = true; |
| 315 } | 320 } |
| 316 | 321 |
| 317 const char* NavigationResourceThrottle::GetNameForLogging() const { | 322 const char* NavigationResourceThrottle::GetNameForLogging() const { |
| 318 return "NavigationResourceThrottle"; | 323 return "NavigationResourceThrottle"; |
| 319 } | 324 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 | 371 |
| 367 // If the results of the checks on the UI thread are known, unblock the | 372 // If the results of the checks on the UI thread are known, unblock the |
| 368 // navigation. Otherwise, wait until the callback has executed. | 373 // navigation. Otherwise, wait until the callback has executed. |
| 369 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 374 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 370 OnUIChecksPerformed(on_transfer_done_result_); | 375 OnUIChecksPerformed(on_transfer_done_result_); |
| 371 on_transfer_done_result_ = NavigationThrottle::DEFER; | 376 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 372 } | 377 } |
| 373 } | 378 } |
| 374 | 379 |
| 375 } // namespace content | 380 } // namespace content |
| OLD | NEW |