| 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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 navigation_handle->WillProcessResponse( | 136 navigation_handle->WillProcessResponse( |
| 137 render_frame_host, headers, ssl_status, | 137 render_frame_host, headers, ssl_status, |
| 138 base::Bind(&SendCheckResultToIOThread, callback)); | 138 base::Bind(&SendCheckResultToIOThread, callback)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace | 141 } // namespace |
| 142 | 142 |
| 143 NavigationResourceThrottle::NavigationResourceThrottle( | 143 NavigationResourceThrottle::NavigationResourceThrottle( |
| 144 net::URLRequest* request, | 144 net::URLRequest* request, |
| 145 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, | 145 ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate, |
| 146 CertStore* cert_store, | |
| 147 RequestContextType request_context_type) | 146 RequestContextType request_context_type) |
| 148 : request_(request), | 147 : request_(request), |
| 149 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), | 148 resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate), |
| 150 cert_store_(cert_store), | |
| 151 request_context_type_(request_context_type), | 149 request_context_type_(request_context_type), |
| 152 weak_ptr_factory_(this) {} | 150 weak_ptr_factory_(this) {} |
| 153 | 151 |
| 154 NavigationResourceThrottle::~NavigationResourceThrottle() {} | 152 NavigationResourceThrottle::~NavigationResourceThrottle() {} |
| 155 | 153 |
| 156 void NavigationResourceThrottle::WillStartRequest(bool* defer) { | 154 void NavigationResourceThrottle::WillStartRequest(bool* defer) { |
| 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 155 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 158 const ResourceRequestInfoImpl* info = | 156 const ResourceRequestInfoImpl* info = |
| 159 ResourceRequestInfoImpl::ForRequest(request_); | 157 ResourceRequestInfoImpl::ForRequest(request_); |
| 160 if (!info) | 158 if (!info) |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 cloned_data = navigation_data->Clone(); | 252 cloned_data = navigation_data->Clone(); |
| 255 } | 253 } |
| 256 | 254 |
| 257 UIChecksPerformedCallback callback = | 255 UIChecksPerformedCallback callback = |
| 258 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, | 256 base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed, |
| 259 weak_ptr_factory_.GetWeakPtr()); | 257 weak_ptr_factory_.GetWeakPtr()); |
| 260 | 258 |
| 261 SSLStatus ssl_status; | 259 SSLStatus ssl_status; |
| 262 if (request_->ssl_info().cert.get()) { | 260 if (request_->ssl_info().cert.get()) { |
| 263 ResourceLoader::GetSSLStatusForRequest( | 261 ResourceLoader::GetSSLStatusForRequest( |
| 264 request_->url(), request_->ssl_info(), info->GetChildID(), | 262 request_->url(), request_->ssl_info(), info->GetChildID(), &ssl_status); |
| 265 cert_store_, &ssl_status); | |
| 266 } | 263 } |
| 267 | 264 |
| 268 BrowserThread::PostTask( | 265 BrowserThread::PostTask( |
| 269 BrowserThread::UI, FROM_HERE, | 266 BrowserThread::UI, FROM_HERE, |
| 270 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id, | 267 base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id, |
| 271 render_frame_id, response_headers, ssl_status, | 268 render_frame_id, response_headers, ssl_status, |
| 272 base::Passed(&cloned_data))); | 269 base::Passed(&cloned_data))); |
| 273 *defer = true; | 270 *defer = true; |
| 274 } | 271 } |
| 275 | 272 |
| 276 const char* NavigationResourceThrottle::GetNameForLogging() const { | 273 const char* NavigationResourceThrottle::GetNameForLogging() const { |
| 277 return "NavigationResourceThrottle"; | 274 return "NavigationResourceThrottle"; |
| 278 } | 275 } |
| 279 | 276 |
| 280 void NavigationResourceThrottle::OnUIChecksPerformed( | 277 void NavigationResourceThrottle::OnUIChecksPerformed( |
| 281 NavigationThrottle::ThrottleCheckResult result) { | 278 NavigationThrottle::ThrottleCheckResult result) { |
| 282 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 279 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 283 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { | 280 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
| 284 controller()->CancelAndIgnore(); | 281 controller()->CancelAndIgnore(); |
| 285 } else if (result == NavigationThrottle::CANCEL) { | 282 } else if (result == NavigationThrottle::CANCEL) { |
| 286 controller()->Cancel(); | 283 controller()->Cancel(); |
| 287 } else if (result == NavigationThrottle::BLOCK_REQUEST) { | 284 } else if (result == NavigationThrottle::BLOCK_REQUEST) { |
| 288 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); | 285 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); |
| 289 } else { | 286 } else { |
| 290 controller()->Resume(); | 287 controller()->Resume(); |
| 291 } | 288 } |
| 292 } | 289 } |
| 293 | 290 |
| 294 } // namespace content | 291 } // namespace content |
| OLD | NEW |