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