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