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) { |
Charlie Reis
2015/04/07 23:15:05
Should the PlzNavigate CleanUpNavigation call be i
carlosk
2015/04/08 14:43:45
It is handled differently by PlzNavigate. The deci
| |
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 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1621 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); | 1615 "FrameTreeNode id", frame_tree_node_->frame_tree_node_id()); |
1622 bool browser_side_navigation = | 1616 bool browser_side_navigation = |
1623 base::CommandLine::ForCurrentProcess()->HasSwitch( | 1617 base::CommandLine::ForCurrentProcess()->HasSwitch( |
1624 switches::kEnableBrowserSideNavigation); | 1618 switches::kEnableBrowserSideNavigation); |
1625 // First check whether we're going to want to focus the location bar after | 1619 // First check whether we're going to want to focus the location bar after |
1626 // this commit. We do this now because the navigation hasn't formally | 1620 // this commit. We do this now because the navigation hasn't formally |
1627 // committed yet, so if we've already cleared |pending_web_ui_| the call chain | 1621 // committed yet, so if we've already cleared |pending_web_ui_| the call chain |
1628 // this triggers won't be able to figure out what's going on. | 1622 // this triggers won't be able to figure out what's going on. |
1629 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); | 1623 bool will_focus_location_bar = delegate_->FocusLocationBarByDefault(); |
1630 | 1624 |
1631 if (!browser_side_navigation) { | 1625 // Next commit the Web UI, if any. Either replace |web_ui_| with |
1632 DCHECK(!speculative_web_ui_); | 1626 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or |
1633 // Next commit the Web UI, if any. Either replace |web_ui_| with | 1627 // leave |web_ui_| as is if reusing it. |
1634 // |pending_web_ui_|, or clear |web_ui_| if there is no pending WebUI, or | 1628 DCHECK(!(pending_web_ui_ && pending_and_current_web_ui_)); |
1635 // leave |web_ui_| as is if reusing it. | 1629 if (pending_web_ui_ || speculative_web_ui_) { |
1636 DCHECK(!(pending_web_ui_.get() && pending_and_current_web_ui_.get())); | 1630 DCHECK(!should_reuse_web_ui_); |
1637 if (pending_web_ui_) { | 1631 web_ui_.reset(browser_side_navigation ? speculative_web_ui_.release() |
1638 web_ui_.reset(pending_web_ui_.release()); | 1632 : pending_web_ui_.release()); |
1639 } else if (!pending_and_current_web_ui_.get()) { | 1633 } else if (pending_and_current_web_ui_ || should_reuse_web_ui_) { |
1640 web_ui_.reset(); | 1634 if (browser_side_navigation) { |
1635 DCHECK(web_ui_); | |
1636 should_reuse_web_ui_ = false; | |
1641 } else { | 1637 } else { |
1642 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); | 1638 DCHECK_EQ(pending_and_current_web_ui_.get(), web_ui_.get()); |
1643 pending_and_current_web_ui_.reset(); | 1639 pending_and_current_web_ui_.reset(); |
1644 } | 1640 } |
1645 } else { | 1641 } else { |
1646 // PlzNavigate | 1642 web_ui_.reset(); |
1647 if (!should_reuse_web_ui_) | |
1648 web_ui_.reset(speculative_web_ui_.release()); | |
1649 DCHECK(!speculative_web_ui_); | |
1650 } | 1643 } |
1644 DCHECK(!speculative_web_ui_); | |
1645 DCHECK(!should_reuse_web_ui_); | |
1651 | 1646 |
1652 // It's possible for the pending_render_frame_host_ to be nullptr when we | 1647 // It's possible for the pending_render_frame_host_ to be nullptr when we |
1653 // aren't crossing process boundaries. If so, we just needed to handle the Web | 1648 // aren't crossing process boundaries. If so, we just needed to handle the Web |
1654 // UI committing above and we're done. | 1649 // UI committing above and we're done. |
1655 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { | 1650 if (!pending_render_frame_host_ && !speculative_render_frame_host_) { |
1656 if (will_focus_location_bar) | 1651 if (will_focus_location_bar) |
1657 delegate_->SetFocusToLocationBar(false); | 1652 delegate_->SetFocusToLocationBar(false); |
1658 return; | 1653 return; |
1659 } | 1654 } |
1660 | 1655 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2038 void RenderFrameHostManager::DeleteRenderFrameProxyHost( | 2033 void RenderFrameHostManager::DeleteRenderFrameProxyHost( |
2039 SiteInstance* instance) { | 2034 SiteInstance* instance) { |
2040 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); | 2035 RenderFrameProxyHostMap::iterator iter = proxy_hosts_.find(instance->GetId()); |
2041 if (iter != proxy_hosts_.end()) { | 2036 if (iter != proxy_hosts_.end()) { |
2042 delete iter->second; | 2037 delete iter->second; |
2043 proxy_hosts_.erase(iter); | 2038 proxy_hosts_.erase(iter); |
2044 } | 2039 } |
2045 } | 2040 } |
2046 | 2041 |
2047 } // namespace content | 2042 } // namespace content |
OLD | NEW |