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" |
11 #include "base/location.h" | 11 #include "base/location.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "content/browser/frame_host/navigation_handle_impl.h" | 14 #include "content/browser/frame_host/navigation_handle_impl.h" |
15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
16 #include "content/browser/frame_host/render_frame_host_impl.h" | 16 #include "content/browser/frame_host/render_frame_host_impl.h" |
17 #include "content/browser/loader/navigation_resource_handler.h" | 17 #include "content/browser/loader/navigation_resource_handler.h" |
18 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 18 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
19 #include "content/browser/loader/resource_loader.h" | 19 #include "content/browser/loader/resource_loader.h" |
20 #include "content/browser/loader/resource_request_info_impl.h" | 20 #include "content/browser/loader/resource_request_info_impl.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/navigation_data.h" | 22 #include "content/public/browser/navigation_data.h" |
23 #include "content/public/browser/resource_context.h" | 23 #include "content/public/browser/resource_context.h" |
24 #include "content/public/browser/resource_controller.h" | |
25 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 24 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
26 #include "content/public/browser/resource_request_info.h" | 25 #include "content/public/browser/resource_request_info.h" |
27 #include "content/public/browser/ssl_status.h" | 26 #include "content/public/browser/ssl_status.h" |
28 #include "content/public/common/referrer.h" | 27 #include "content/public/common/referrer.h" |
29 #include "net/url_request/redirect_info.h" | 28 #include "net/url_request/redirect_info.h" |
30 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
31 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
32 #include "net/url_request/url_request_job_factory.h" | 31 #include "net/url_request/url_request_job_factory.h" |
33 #include "ui/base/page_transition_types.h" | 32 #include "ui/base/page_transition_types.h" |
34 | 33 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 void NavigationResourceThrottle::OnUIChecksPerformed( | 332 void NavigationResourceThrottle::OnUIChecksPerformed( |
334 NavigationThrottle::ThrottleCheckResult result) { | 333 NavigationThrottle::ThrottleCheckResult result) { |
335 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 334 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
336 DCHECK_NE(NavigationThrottle::DEFER, result); | 335 DCHECK_NE(NavigationThrottle::DEFER, result); |
337 if (in_cross_site_transition_) { | 336 if (in_cross_site_transition_) { |
338 on_transfer_done_result_ = result; | 337 on_transfer_done_result_ = result; |
339 return; | 338 return; |
340 } | 339 } |
341 | 340 |
342 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { | 341 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
343 controller()->CancelAndIgnore(); | 342 CancelAndIgnore(); |
344 } else if (result == NavigationThrottle::CANCEL) { | 343 } else if (result == NavigationThrottle::CANCEL) { |
345 controller()->Cancel(); | 344 Cancel(); |
346 } else if (result == NavigationThrottle::BLOCK_REQUEST) { | 345 } else if (result == NavigationThrottle::BLOCK_REQUEST) { |
347 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); | 346 CancelWithError(net::ERR_BLOCKED_BY_CLIENT); |
348 } else { | 347 } else { |
349 controller()->Resume(); | 348 Resume(); |
350 } | 349 } |
351 } | 350 } |
352 | 351 |
353 void NavigationResourceThrottle::InitiateTransfer() { | 352 void NavigationResourceThrottle::InitiateTransfer() { |
354 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 353 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
355 in_cross_site_transition_ = true; | 354 in_cross_site_transition_ = true; |
356 ResourceRequestInfoImpl* info = | 355 ResourceRequestInfoImpl* info = |
357 ResourceRequestInfoImpl::ForRequest(request_); | 356 ResourceRequestInfoImpl::ForRequest(request_); |
358 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation( | 357 ResourceDispatcherHostImpl::Get()->MarkAsTransferredNavigation( |
359 info->GetGlobalRequestID(), | 358 info->GetGlobalRequestID(), |
360 base::Bind(&NavigationResourceThrottle::OnTransferComplete, | 359 base::Bind(&NavigationResourceThrottle::OnTransferComplete, |
361 weak_ptr_factory_.GetWeakPtr())); | 360 weak_ptr_factory_.GetWeakPtr())); |
362 } | 361 } |
363 | 362 |
364 void NavigationResourceThrottle::OnTransferComplete() { | 363 void NavigationResourceThrottle::OnTransferComplete() { |
365 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 364 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
366 DCHECK(in_cross_site_transition_); | 365 DCHECK(in_cross_site_transition_); |
367 in_cross_site_transition_ = false; | 366 in_cross_site_transition_ = false; |
368 | 367 |
369 // If the results of the checks on the UI thread are known, unblock the | 368 // If the results of the checks on the UI thread are known, unblock the |
370 // navigation. Otherwise, wait until the callback has executed. | 369 // navigation. Otherwise, wait until the callback has executed. |
371 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 370 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
372 OnUIChecksPerformed(on_transfer_done_result_); | 371 OnUIChecksPerformed(on_transfer_done_result_); |
373 on_transfer_done_result_ = NavigationThrottle::DEFER; | 372 on_transfer_done_result_ = NavigationThrottle::DEFER; |
374 } | 373 } |
375 } | 374 } |
376 | 375 |
377 } // namespace content | 376 } // namespace content |
OLD | NEW |