OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_manager.h" | 5 #include "content/browser/frame_host/render_frame_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); | 448 CommitPendingIfNecessary(render_frame_host, was_caused_by_user_gesture); |
449 | 449 |
450 // Make sure any dynamic changes to this frame's sandbox flags that were made | 450 // Make sure any dynamic changes to this frame's sandbox flags that were made |
451 // prior to navigation take effect. | 451 // prior to navigation take effect. |
452 CommitPendingSandboxFlags(); | 452 CommitPendingSandboxFlags(); |
453 } | 453 } |
454 | 454 |
455 void RenderFrameHostManager::CommitPendingIfNecessary( | 455 void RenderFrameHostManager::CommitPendingIfNecessary( |
456 RenderFrameHostImpl* render_frame_host, | 456 RenderFrameHostImpl* render_frame_host, |
457 bool was_caused_by_user_gesture) { | 457 bool was_caused_by_user_gesture) { |
458 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 458 // Note: In PlzNavigate |cross_navigation_pending_| being false means there is |
459 switches::kEnableBrowserSideNavigation)) { | 459 // *no* speculative RenderFrameHost set. |
460 if (render_frame_host == speculative_render_frame_host_.get()) { | 460 if (!cross_navigation_pending_) { |
461 CommitPending(); | |
462 } else if (render_frame_host == render_frame_host_.get()) { | |
463 // TODO(carlosk): this code doesn't properly handle in-page navigation or | |
464 // interwoven navigation requests. | |
465 DCHECK(!speculative_render_frame_host_); | |
466 } else { | |
467 // No one else should be sending us a DidNavigate in this state. | |
468 DCHECK(false); | |
469 } | |
470 DCHECK(!speculative_render_frame_host_); | 461 DCHECK(!speculative_render_frame_host_); |
471 return; | |
472 } | |
473 | |
474 if (!cross_navigation_pending_) { | |
475 DCHECK(!pending_render_frame_host_); | 462 DCHECK(!pending_render_frame_host_); |
| 463 DCHECK_IMPLIES(should_reuse_web_ui_, web_ui_); |
476 | 464 |
477 // We should only hear this from our current renderer. | 465 // We should only hear this from our current renderer. |
478 DCHECK_EQ(render_frame_host_, render_frame_host); | 466 DCHECK_EQ(render_frame_host_, render_frame_host); |
479 | 467 |
480 // Even when there is no pending RVH, there may be a pending Web UI. | 468 // Even when there is no pending RVH, there may be a pending Web UI. |
481 if (pending_web_ui()) | 469 if (pending_web_ui() || speculative_web_ui_) |
482 CommitPending(); | 470 CommitPending(); |
483 return; | 471 return; |
484 } | 472 } |
485 | 473 |
486 if (render_frame_host == pending_render_frame_host_) { | 474 if (render_frame_host == pending_render_frame_host_ || |
| 475 render_frame_host == speculative_render_frame_host_) { |
487 // The pending cross-site navigation completed, so show the renderer. | 476 // The pending cross-site navigation completed, so show the renderer. |
488 CommitPending(); | 477 CommitPending(); |
489 } else if (render_frame_host == render_frame_host_) { | 478 } else if (render_frame_host == render_frame_host_) { |
490 if (was_caused_by_user_gesture) { | 479 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
491 // A navigation in the original page has taken place. Cancel the pending | 480 switches::kEnableBrowserSideNavigation)) { |
492 // one. Only do it for user gesture originated navigations to prevent | 481 CleanUpNavigation(); |
493 // page doing any shenanigans to prevent user from navigating. | 482 } else { |
494 // See https://code.google.com/p/chromium/issues/detail?id=75195 | 483 if (was_caused_by_user_gesture) { |
495 CancelPending(); | 484 // A navigation in the original page has taken place. Cancel the |
496 cross_navigation_pending_ = false; | 485 // pending one. Only do it for user gesture originated navigations to |
| 486 // prevent page doing any shenanigans to prevent user from navigating. |
| 487 // See https://code.google.com/p/chromium/issues/detail?id=75195 |
| 488 CancelPending(); |
| 489 cross_navigation_pending_ = false; |
| 490 } |
497 } | 491 } |
498 } else { | 492 } else { |
499 // No one else should be sending us DidNavigate in this state. | 493 // No one else should be sending us DidNavigate in this state. |
500 DCHECK(false); | 494 DCHECK(false); |
501 } | 495 } |
502 } | 496 } |
503 | 497 |
504 void RenderFrameHostManager::DidDisownOpener( | 498 void RenderFrameHostManager::DidDisownOpener( |
505 RenderFrameHost* render_frame_host) { | 499 RenderFrameHost* render_frame_host) { |
506 // Notify all RenderFrameHosts but the one that notified us. This is necessary | 500 // Notify all RenderFrameHosts but the one that notified us. This is necessary |
(...skipping 1166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 1667 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
1674 bool browser_side_navigation = | 1668 bool browser_side_navigation = |
1675 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1669 base::CommandLine::ForCurrentProcess()->HasSwitch( |
1676 switches::kEnableBrowserSideNavigation); | 1670 switches::kEnableBrowserSideNavigation); |
1677 // First check whether we're going to want to focus the location bar after | 1671 // First check whether we're going to want to focus the location bar after |
1678 // this commit. We do this now because the navigation hasn't formally | 1672 // this commit. We do this now because the navigation hasn't formally |
1679 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1673 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
1680 // this triggers won't be able to figure out what's going on. | 1674 // this triggers won't be able to figure out what's going on. |
1681 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1675 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1682 | 1676 |
1683 if (!browser_side_navigation) { | 1677 // Next commit the Web UI, if any. Either replace |web_ui_| with |
1684 DCHECK(!speculative_web_ui_); | 1678 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1685 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1679 // leave |web_ui_| as is if reusing it. |
1686 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or | 1680 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); |
1687 // leave |web_ui_| as is if reusing it. | 1681 if (pending_web_ui_ || speculative_web_ui_) { |
1688 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1682 DCHECK(!should_reuse_web_ui_); |
1689 if (pending_web_ui_) { | 1683 web_ui_.reset(browser_side_navigation ? speculative_web_ui_.release() |
1690 web_ui_.reset(pending_web_ui_.release()); | 1684 : pending_web_ui_.release()); |
1691 } else if (!pending_and_current_web_ui_.get()) { | 1685 } else if (pending_and_current_web_ui_ || should_reuse_web_ui_) { |
1692 web_ui_.reset(); | 1686 if (browser_side_navigation) { |
| 1687 DCHECK(web_ui_); |
| 1688 should_reuse_web_ui_ = false; |
1693 } else { | 1689 } else { |
1694 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); | 1690 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); |
1695 pending_and_current_web_ui_.reset(); | 1691 pending_and_current_web_ui_.reset(); |
1696 } | 1692 } |
1697 } else { | 1693 } else { |
1698 // PlzNavigate | 1694 web_ui_.reset(); |
1699 if (!should_reuse_web_ui_) | |
1700 web_ui_.reset(speculative_web_ui_.release()); | |
1701 DCHECK(!speculative_web_ui_); | |
1702 } | 1695 } |
| 1696 DCHECK(!speculative_web_ui_); |
| 1697 DCHECK(!should_reuse_web_ui_); |
1703 | 1698 |
1704 // It's possible for the pending_render_frame_host_ to be nullptr when we | 1699 // It's possible for the pending_render_frame_host_ to be nullptr when we |
1705 // aren't crossing process boundaries. If so, we just needed to handle the Web | 1700 // aren't crossing process boundaries. If so, we just needed to handle the Web |
1706 // UI committing above and we're done. | 1701 // UI committing above and we're done. |
1707 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { | 1702 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { |
1708 if (will_focus_location_bar) | 1703 if (will_focus_location_bar) |
1709 delegate_->SetFocusToLocationBar(false); | 1704 delegate_->SetFocusToLocationBar(false); |
1710 return; | 1705 return; |
1711 } | 1706 } |
1712 | 1707 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2090 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2085 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2091 SiteInstance* instance) { | 2086 SiteInstance* instance) { |
2092 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2087 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2093 if (iter != proxy_hosts_.end()) { | 2088 if (iter != proxy_hosts_.end()) { |
2094 delete iter->second; | 2089 delete iter->second; |
2095 proxy_hosts_.erase(iter); | 2090 proxy_hosts_.erase(iter); |
2096 } | 2091 } |
2097 } | 2092 } |
2098 | 2093 |
2099 } // namespace content | 2094 } // namespace content |
OLD | NEW |