| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 on_transfer_done_result_ = result; | 336 on_transfer_done_result_ = result; |
| 337 return; | 337 return; |
| 338 } | 338 } |
| 339 | 339 |
| 340 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { | 340 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
| 341 controller()->CancelAndIgnore(); | 341 controller()->CancelAndIgnore(); |
| 342 } else if (result == NavigationThrottle::CANCEL) { | 342 } else if (result == NavigationThrottle::CANCEL) { |
| 343 controller()->Cancel(); | 343 controller()->Cancel(); |
| 344 } else if (result == NavigationThrottle::BLOCK_REQUEST) { | 344 } else if (result == NavigationThrottle::BLOCK_REQUEST) { |
| 345 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); | 345 controller()->CancelWithError(net::ERR_BLOCKED_BY_CLIENT); |
| 346 } else if (result == NavigationThrottle::BLOCK_RESPONSE) { |
| 347 // TODO(mkwst): If we cancel the main frame request with anything other than |
| 348 // 'net::ERR_ABORTED', we'll trigger some special behavior that might not be |
| 349 // desirable here (non-POSTs will reload the page, while POST has some logic |
| 350 // around reloading to avoid duplicating actions server-side). For the |
| 351 // moment, only child frame navigations should be blocked. If we need to |
| 352 // block main frame navigations in the future, we'll need to carefully |
| 353 // consider the right thing to do here. |
| 354 DCHECK(!ResourceRequestInfo::ForRequest(request_)->IsMainFrame()); |
| 355 controller()->CancelWithError(net::ERR_BLOCKED_BY_RESPONSE); |
| 346 } else { | 356 } else { |
| 347 controller()->Resume(); | 357 controller()->Resume(); |
| 348 } | 358 } |
| 349 } | 359 } |
| 350 | 360 |
| 351 void NavigationResourceThrottle::InitiateTransfer() { | 361 void NavigationResourceThrottle::InitiateTransfer() { |
| 352 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 362 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 353 in_cross_site_transition_ = true; | 363 in_cross_site_transition_ = true; |
| 354 ResourceRequestInfoImpl* info = | 364 ResourceRequestInfoImpl* info = |
| 355 ResourceRequestInfoImpl::ForRequest(request_); | 365 ResourceRequestInfoImpl::ForRequest(request_); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 366 | 376 |
| 367 // If the results of the checks on the UI thread are known, unblock the | 377 // If the results of the checks on the UI thread are known, unblock the |
| 368 // navigation. Otherwise, wait until the callback has executed. | 378 // navigation. Otherwise, wait until the callback has executed. |
| 369 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 379 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 370 OnUIChecksPerformed(on_transfer_done_result_); | 380 OnUIChecksPerformed(on_transfer_done_result_); |
| 371 on_transfer_done_result_ = NavigationThrottle::DEFER; | 381 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 372 } | 382 } |
| 373 } | 383 } |
| 374 | 384 |
| 375 } // namespace content | 385 } // namespace content |
| OLD | NEW |