Chromium Code Reviews| 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 /* | 5 /* |
| 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 6 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 7 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
| 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
| 9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
| 10 * | 10 * |
| (...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 823 entry->SetCanLoadLocalResources(params.can_load_local_resources); | 823 entry->SetCanLoadLocalResources(params.can_load_local_resources); |
| 824 break; | 824 break; |
| 825 default: | 825 default: |
| 826 NOTREACHED(); | 826 NOTREACHED(); |
| 827 break; | 827 break; |
| 828 }; | 828 }; |
| 829 | 829 |
| 830 LoadEntry(std::move(entry)); | 830 LoadEntry(std::move(entry)); |
| 831 } | 831 } |
| 832 | 832 |
| 833 bool NavigationControllerImpl::PendingEntryMatchesHandle( | |
| 834 NavigationHandleImpl* handle) const { | |
| 835 return pending_entry_ && | |
| 836 pending_entry_->GetUniqueID() == handle->pending_nav_entry_id(); | |
| 837 } | |
| 838 | |
| 833 bool NavigationControllerImpl::RendererDidNavigate( | 839 bool NavigationControllerImpl::RendererDidNavigate( |
| 834 RenderFrameHostImpl* rfh, | 840 RenderFrameHostImpl* rfh, |
| 835 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 841 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 836 LoadCommittedDetails* details) { | 842 LoadCommittedDetails* details) { |
| 837 is_initial_navigation_ = false; | 843 is_initial_navigation_ = false; |
| 838 | 844 |
| 839 // Save the previous state before we clobber it. | 845 // Save the previous state before we clobber it. |
| 840 if (GetLastCommittedEntry()) { | 846 if (GetLastCommittedEntry()) { |
| 841 details->previous_url = GetLastCommittedEntry()->GetURL(); | 847 details->previous_url = GetLastCommittedEntry()->GetURL(); |
| 842 details->previous_entry_index = GetLastCommittedEntryIndex(); | 848 details->previous_entry_index = GetLastCommittedEntryIndex(); |
| 843 } else { | 849 } else { |
| 844 details->previous_url = GURL(); | 850 details->previous_url = GURL(); |
| 845 details->previous_entry_index = -1; | 851 details->previous_entry_index = -1; |
| 846 } | 852 } |
| 847 | 853 |
| 848 // If there is a pending entry at this point, it should have a SiteInstance, | 854 // If there is a pending entry at this point, it should have a SiteInstance, |
| 849 // except for restored entries. | 855 // except for restored entries. |
| 850 DCHECK(pending_entry_index_ == -1 || | 856 DCHECK(pending_entry_index_ == -1 || |
| 851 pending_entry_->site_instance() || | 857 pending_entry_->site_instance() || |
| 852 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE); | 858 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE); |
| 853 if (pending_entry_ && | 859 if (pending_entry_ && |
| 854 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) | 860 pending_entry_->restore_type() != NavigationEntryImpl::RESTORE_NONE) |
| 855 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); | 861 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); |
| 856 | 862 |
| 857 // If we are doing a cross-site reload, we need to replace the existing | 863 // If the pending entry matches this commit, check if it says to replace the |
| 858 // navigation entry, not add another entry to the history. This has the side | 864 // current entry (which preserves forward history). This is used for things |
| 859 // effect of removing forward browsing history, if such existed. Or if we are | 865 // like cross-process location.replace and client redirects, as well as |
| 860 // doing a cross-site redirect navigation, we will do a similar thing. | 866 // cross-process reloads (which can happen with embedder features like |
| 867 // hosted apps). | |
| 861 // | 868 // |
| 862 // If this is an error load, we may have already removed the pending entry | 869 // If this is an error load, we may have already removed the pending entry |
| 863 // when we got the notice of the load failure. If so, look at the copy of the | 870 // when we got the notice of the load failure. If so, look at the copy of the |
| 864 // pending parameters that were saved. | 871 // pending parameters that were saved and see if they match the handle. |
| 865 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { | 872 NavigationHandleImpl* handle = rfh->navigation_handle(); |
| 873 DCHECK(handle); | |
| 874 if (params.url_is_unreachable && failed_pending_entry_id_ != 0 && | |
| 875 handle->pending_nav_entry_id() == failed_pending_entry_id_) { | |
| 866 details->did_replace_entry = failed_pending_entry_should_replace_; | 876 details->did_replace_entry = failed_pending_entry_should_replace_; |
| 877 } else if (PendingEntryMatchesHandle(handle) && | |
| 878 pending_entry_->should_replace_entry()) { | |
| 879 details->did_replace_entry = pending_entry_->should_replace_entry(); | |
| 867 } else { | 880 } else { |
| 868 details->did_replace_entry = pending_entry_ && | 881 details->did_replace_entry = false; |
| 869 pending_entry_->should_replace_entry(); | |
| 870 } | 882 } |
| 871 | 883 |
| 872 // Do navigation-type specific actions. These will make and commit an entry. | 884 // Do navigation-type specific actions. These will make and commit an entry. |
| 873 details->type = ClassifyNavigation(rfh, params); | 885 details->type = ClassifyNavigation(rfh, params); |
| 874 | 886 |
| 875 // is_in_page must be computed before the entry gets committed. | 887 // is_in_page must be computed before the entry gets committed. |
| 876 details->is_in_page = IsURLInPageNavigation( | 888 details->is_in_page = IsURLInPageNavigation( |
| 877 params.url, params.was_within_same_page, rfh); | 889 params.url, params.was_within_same_page, rfh); |
| 878 | 890 |
| 879 switch (details->type) { | 891 switch (details->type) { |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1102 // that was just loaded. Verify this by checking if the entry corresponds | 1114 // that was just loaded. Verify this by checking if the entry corresponds |
| 1103 // to the current navigation handle. Note that in some tests the render frame | 1115 // to the current navigation handle. Note that in some tests the render frame |
| 1104 // host does not have a valid handle. Additionally, coarsely check that: | 1116 // host does not have a valid handle. Additionally, coarsely check that: |
| 1105 // 1. The SiteInstance hasn't been assigned to something else. | 1117 // 1. The SiteInstance hasn't been assigned to something else. |
| 1106 // 2. The pending entry was intended as a new entry, rather than being a | 1118 // 2. The pending entry was intended as a new entry, rather than being a |
| 1107 // history navigation that was interrupted by an unrelated, | 1119 // history navigation that was interrupted by an unrelated, |
| 1108 // renderer-initiated navigation. | 1120 // renderer-initiated navigation. |
| 1109 // TODO(csharrison): Investigate whether we can remove some of the coarser | 1121 // TODO(csharrison): Investigate whether we can remove some of the coarser |
| 1110 // checks. | 1122 // checks. |
| 1111 NavigationHandleImpl* handle = rfh->navigation_handle(); | 1123 NavigationHandleImpl* handle = rfh->navigation_handle(); |
| 1112 if (pending_entry_ && handle && | 1124 DCHECK(handle); |
| 1113 handle->pending_nav_entry_id() == pending_entry_->GetUniqueID() && | 1125 if (PendingEntryMatchesHandle(handle) && |
| 1114 pending_entry_index_ == -1 && | 1126 pending_entry_index_ == -1 && |
|
nasko
2016/03/11 20:21:56
nit: Wouldn't this fit on the previous line? git c
Charlie Reis
2016/03/11 21:11:37
Done.
| |
| 1115 (!pending_entry_->site_instance() || | 1127 (!pending_entry_->site_instance() || |
| 1116 pending_entry_->site_instance() == rfh->GetSiteInstance())) { | 1128 pending_entry_->site_instance() == rfh->GetSiteInstance())) { |
| 1117 new_entry = pending_entry_->Clone(); | 1129 new_entry = pending_entry_->Clone(); |
| 1118 | 1130 |
| 1119 update_virtual_url = new_entry->update_virtual_url_with_url(); | 1131 update_virtual_url = new_entry->update_virtual_url_with_url(); |
| 1120 } else { | 1132 } else { |
| 1121 new_entry = make_scoped_ptr(new NavigationEntryImpl); | 1133 new_entry = make_scoped_ptr(new NavigationEntryImpl); |
| 1122 | 1134 |
| 1123 // Find out whether the new entry needs to update its virtual URL on URL | 1135 // Find out whether the new entry needs to update its virtual URL on URL |
| 1124 // change and set up the entry accordingly. This is needed to correctly | 1136 // change and set up the entry accordingly. This is needed to correctly |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2071 } | 2083 } |
| 2072 } | 2084 } |
| 2073 } | 2085 } |
| 2074 | 2086 |
| 2075 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2087 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 2076 const base::Callback<base::Time()>& get_timestamp_callback) { | 2088 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 2077 get_timestamp_callback_ = get_timestamp_callback; | 2089 get_timestamp_callback_ = get_timestamp_callback; |
| 2078 } | 2090 } |
| 2079 | 2091 |
| 2080 } // namespace content | 2092 } // namespace content |
| OLD | NEW |