| 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 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 on_transfer_done_result_ = result; | 343 on_transfer_done_result_ = result; |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 | 346 |
| 347 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { | 347 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
| 348 CancelAndIgnore(); | 348 CancelAndIgnore(); |
| 349 } else if (result == NavigationThrottle::CANCEL) { | 349 } else if (result == NavigationThrottle::CANCEL) { |
| 350 Cancel(); | 350 Cancel(); |
| 351 } else if (result == NavigationThrottle::BLOCK_REQUEST) { | 351 } else if (result == NavigationThrottle::BLOCK_REQUEST) { |
| 352 CancelWithError(net::ERR_BLOCKED_BY_CLIENT); | 352 CancelWithError(net::ERR_BLOCKED_BY_CLIENT); |
| 353 } else if (result == NavigationThrottle::BLOCK_REQUEST_AND_COLLAPSE) { |
| 354 int render_process_id, render_frame_id; |
| 355 if (ResourceRequestInfo::ForRequest(request_)->GetAssociatedRenderFrame( |
| 356 &render_process_id, &render_frame_id)) { |
| 357 RenderFrameHostImpl* render_frame_host = |
| 358 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); |
| 359 render_frame_host->frame_tree_node()->SetFrameOwnerCollapsedState(true); |
| 360 } |
| 361 CancelWithError(net::ERR_BLOCKED_BY_CLIENT); |
| 353 } else if (result == NavigationThrottle::BLOCK_RESPONSE) { | 362 } else if (result == NavigationThrottle::BLOCK_RESPONSE) { |
| 354 // TODO(mkwst): If we cancel the main frame request with anything other than | 363 // TODO(mkwst): If we cancel the main frame request with anything other than |
| 355 // 'net::ERR_ABORTED', we'll trigger some special behavior that might not be | 364 // 'net::ERR_ABORTED', we'll trigger some special behavior that might not be |
| 356 // desirable here (non-POSTs will reload the page, while POST has some logic | 365 // desirable here (non-POSTs will reload the page, while POST has some logic |
| 357 // around reloading to avoid duplicating actions server-side). For the | 366 // around reloading to avoid duplicating actions server-side). For the |
| 358 // moment, only child frame navigations should be blocked. If we need to | 367 // moment, only child frame navigations should be blocked. If we need to |
| 359 // block main frame navigations in the future, we'll need to carefully | 368 // block main frame navigations in the future, we'll need to carefully |
| 360 // consider the right thing to do here. | 369 // consider the right thing to do here. |
| 361 DCHECK(!ResourceRequestInfo::ForRequest(request_)->IsMainFrame()); | 370 DCHECK(!ResourceRequestInfo::ForRequest(request_)->IsMainFrame()); |
| 362 CancelWithError(net::ERR_BLOCKED_BY_RESPONSE); | 371 CancelWithError(net::ERR_BLOCKED_BY_RESPONSE); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 383 | 392 |
| 384 // If the results of the checks on the UI thread are known, unblock the | 393 // If the results of the checks on the UI thread are known, unblock the |
| 385 // navigation. Otherwise, wait until the callback has executed. | 394 // navigation. Otherwise, wait until the callback has executed. |
| 386 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { | 395 if (on_transfer_done_result_ != NavigationThrottle::DEFER) { |
| 387 OnUIChecksPerformed(on_transfer_done_result_); | 396 OnUIChecksPerformed(on_transfer_done_result_); |
| 388 on_transfer_done_result_ = NavigationThrottle::DEFER; | 397 on_transfer_done_result_ = NavigationThrottle::DEFER; |
| 389 } | 398 } |
| 390 } | 399 } |
| 391 | 400 |
| 392 } // namespace content | 401 } // namespace content |
| OLD | NEW |