Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 2284533002: Ensure FrameNavigationEntry is fully updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_controller_impl_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1132 matching lines...) Expand 10 before | Expand all | Expand 10 after
1143 1143
1144 InsertOrReplaceEntry(std::move(new_entry), replace_entry); 1144 InsertOrReplaceEntry(std::move(new_entry), replace_entry);
1145 } 1145 }
1146 1146
1147 void NavigationControllerImpl::RendererDidNavigateToExistingPage( 1147 void NavigationControllerImpl::RendererDidNavigateToExistingPage(
1148 RenderFrameHostImpl* rfh, 1148 RenderFrameHostImpl* rfh,
1149 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1149 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1150 // We should only get here for main frame navigations. 1150 // We should only get here for main frame navigations.
1151 DCHECK(!rfh->GetParent()); 1151 DCHECK(!rfh->GetParent());
1152 1152
1153 // TODO(creis): Classify location.replace as NEW_PAGE instead of EXISTING_PAGE
1154 // in https://crbug.com/596707.
1155
1153 NavigationEntryImpl* entry; 1156 NavigationEntryImpl* entry;
1154 if (params.intended_as_new_entry) { 1157 if (params.intended_as_new_entry) {
1155 // This was intended as a new entry but the pending entry was lost in the 1158 // This was intended as a new entry but the pending entry was lost in the
1156 // meanwhile and no new page was created. We are stuck at the last committed 1159 // meanwhile and no new page was created. We are stuck at the last committed
1157 // entry. 1160 // entry.
1158 entry = GetLastCommittedEntry(); 1161 entry = GetLastCommittedEntry();
1159 } else if (params.nav_entry_id) { 1162 } else if (params.nav_entry_id) {
1160 // This is a browser-initiated navigation (back/forward/reload). 1163 // This is a browser-initiated navigation (back/forward/reload).
1161 entry = GetEntryWithUniqueID(params.nav_entry_id); 1164 entry = GetEntryWithUniqueID(params.nav_entry_id);
1162 } else { 1165 } else {
1163 // This is renderer-initiated. The only kinds of renderer-initated 1166 // This is renderer-initiated. The only kinds of renderer-initated
1164 // navigations that are EXISTING_PAGE are reloads and location.replace, 1167 // navigations that are EXISTING_PAGE are reloads and location.replace,
1165 // which land us at the last committed entry. 1168 // which land us at the last committed entry.
1166 entry = GetLastCommittedEntry(); 1169 entry = GetLastCommittedEntry();
1167 } 1170 }
1168 DCHECK(entry); 1171 DCHECK(entry);
1169 1172
1170 // The URL may have changed due to redirects. 1173 // The URL may have changed due to redirects.
1171 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1174 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1172 : PAGE_TYPE_NORMAL); 1175 : PAGE_TYPE_NORMAL);
1173 entry->SetURL(params.url); 1176 entry->SetURL(params.url);
1174 entry->SetReferrer(params.referrer); 1177 entry->SetReferrer(params.referrer);
1175 if (entry->update_virtual_url_with_url()) 1178 if (entry->update_virtual_url_with_url())
1176 UpdateVirtualURLToURL(entry, params.url); 1179 UpdateVirtualURLToURL(entry, params.url);
1177 1180
1178 // Update the post parameters. 1181 // The site instance will normally be the same except during session restore,
1179 FrameNavigationEntry* frame_entry = 1182 // when no site instance will be assigned.
1180 entry->GetFrameEntry(rfh->frame_tree_node()); 1183 DCHECK(entry->site_instance() == nullptr ||
1181 frame_entry->set_method(params.method); 1184 entry->site_instance() == rfh->GetSiteInstance());
1182 frame_entry->set_post_id(params.post_id);
1183 1185
1184 // Update the ISN and DSN in case this was a location.replace, which can cause 1186 // Update the existing FrameNavigationEntry to ensure all of its members
1185 // them to change. 1187 // reflect the parameters coming from the renderer process.
1186 // TODO(creis): Classify location.replace as NEW_PAGE instead of EXISTING_PAGE 1188 entry->AddOrUpdateFrameEntry(
1187 // in https://crbug.com/596707. 1189 rfh->frame_tree_node(), params.item_sequence_number,
1188 frame_entry->set_item_sequence_number(params.item_sequence_number); 1190 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1189 frame_entry->set_document_sequence_number(params.document_sequence_number); 1191 params.url, params.referrer, params.page_state, params.method,
1192 params.post_id);
1190 1193
1191 // The redirected to page should not inherit the favicon from the previous 1194 // The redirected to page should not inherit the favicon from the previous
1192 // page. 1195 // page.
1193 if (ui::PageTransitionIsRedirect(params.transition)) 1196 if (ui::PageTransitionIsRedirect(params.transition))
1194 entry->GetFavicon() = FaviconStatus(); 1197 entry->GetFavicon() = FaviconStatus();
1195 1198
1196 // The site instance will normally be the same except during session restore,
1197 // when no site instance will be assigned.
1198 DCHECK(entry->site_instance() == nullptr ||
1199 entry->site_instance() == rfh->GetSiteInstance());
1200 entry->set_site_instance(
1201 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1202
1203 // The entry we found in the list might be pending if the user hit 1199 // The entry we found in the list might be pending if the user hit
1204 // back/forward/reload. This load should commit it (since it's already in the 1200 // back/forward/reload. This load should commit it (since it's already in the
1205 // list, we can just discard the pending pointer). We should also discard the 1201 // list, we can just discard the pending pointer). We should also discard the
1206 // pending entry if it corresponds to a different navigation, since that one 1202 // pending entry if it corresponds to a different navigation, since that one
1207 // is now likely canceled. If it is not canceled, we will treat it as a new 1203 // is now likely canceled. If it is not canceled, we will treat it as a new
1208 // navigation when it arrives, which is also ok. 1204 // navigation when it arrives, which is also ok.
1209 // 1205 //
1210 // Note that we need to use the "internal" version since we don't want to 1206 // Note that we need to use the "internal" version since we don't want to
1211 // actually change any other state, just kill the pointer. 1207 // actually change any other state, just kill the pointer.
1212 DiscardNonCommittedEntriesInternal(); 1208 DiscardNonCommittedEntriesInternal();
(...skipping 19 matching lines...) Expand all
1232 // a regular user-initiated navigation. 1228 // a regular user-initiated navigation.
1233 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id); 1229 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id);
1234 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1230 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1235 1231
1236 // The URL may have changed due to redirects. 1232 // The URL may have changed due to redirects.
1237 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1233 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1238 : PAGE_TYPE_NORMAL); 1234 : PAGE_TYPE_NORMAL);
1239 if (existing_entry->update_virtual_url_with_url()) 1235 if (existing_entry->update_virtual_url_with_url())
1240 UpdateVirtualURLToURL(existing_entry, params.url); 1236 UpdateVirtualURLToURL(existing_entry, params.url);
1241 existing_entry->SetURL(params.url); 1237 existing_entry->SetURL(params.url);
1242 existing_entry->SetReferrer(params.referrer);
1243 1238
1244 // The page may have been requested with a different HTTP method. 1239 // Update the existing FrameNavigationEntry to ensure all of its members
1245 FrameNavigationEntry* frame_entry = 1240 // reflect the parameters coming from the renderer process.
1246 existing_entry->GetFrameEntry(rfh->frame_tree_node()); 1241 existing_entry->AddOrUpdateFrameEntry(
1247 frame_entry->set_method(params.method); 1242 rfh->frame_tree_node(), params.item_sequence_number,
1248 frame_entry->set_post_id(params.post_id); 1243 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1244 params.url, params.referrer, params.page_state, params.method,
1245 params.post_id);
1249 1246
1250 DiscardNonCommittedEntries(); 1247 DiscardNonCommittedEntries();
1251 } 1248 }
1252 1249
1253 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1250 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1254 RenderFrameHostImpl* rfh, 1251 RenderFrameHostImpl* rfh,
1255 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1252 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1256 bool replace_entry) { 1253 bool replace_entry) {
1257 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1254 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1258 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); 1255 ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 } 2074 }
2078 } 2075 }
2079 } 2076 }
2080 2077
2081 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2078 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2082 const base::Callback<base::Time()>& get_timestamp_callback) { 2079 const base::Callback<base::Time()>& get_timestamp_callback) {
2083 get_timestamp_callback_ = get_timestamp_callback; 2080 get_timestamp_callback_ = get_timestamp_callback;
2084 } 2081 }
2085 2082
2086 } // namespace content 2083 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_controller_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698