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

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

Issue 2224213005: Ensure FrameNavigationEntry is fully updated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on ToT. Created 4 years, 4 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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 1167
1168 InsertOrReplaceEntry(std::move(new_entry), replace_entry); 1168 InsertOrReplaceEntry(std::move(new_entry), replace_entry);
1169 } 1169 }
1170 1170
1171 void NavigationControllerImpl::RendererDidNavigateToExistingPage( 1171 void NavigationControllerImpl::RendererDidNavigateToExistingPage(
1172 RenderFrameHostImpl* rfh, 1172 RenderFrameHostImpl* rfh,
1173 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1173 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1174 // We should only get here for main frame navigations. 1174 // We should only get here for main frame navigations.
1175 DCHECK(!rfh->GetParent()); 1175 DCHECK(!rfh->GetParent());
1176 1176
1177 // TODO(creis): Classify location.replace as NEW_PAGE instead of EXISTING_PAGE
1178 // in https://crbug.com/596707.
1179
1177 NavigationEntryImpl* entry; 1180 NavigationEntryImpl* entry;
1178 if (params.intended_as_new_entry) { 1181 if (params.intended_as_new_entry) {
1179 // This was intended as a new entry but the pending entry was lost in the 1182 // This was intended as a new entry but the pending entry was lost in the
1180 // meanwhile and no new page was created. We are stuck at the last committed 1183 // meanwhile and no new page was created. We are stuck at the last committed
1181 // entry. 1184 // entry.
1182 entry = GetLastCommittedEntry(); 1185 entry = GetLastCommittedEntry();
1183 } else if (params.nav_entry_id) { 1186 } else if (params.nav_entry_id) {
1184 // This is a browser-initiated navigation (back/forward/reload). 1187 // This is a browser-initiated navigation (back/forward/reload).
1185 entry = GetEntryWithUniqueID(params.nav_entry_id); 1188 entry = GetEntryWithUniqueID(params.nav_entry_id);
1186 } else { 1189 } else {
1187 // This is renderer-initiated. The only kinds of renderer-initated 1190 // This is renderer-initiated. The only kinds of renderer-initated
1188 // navigations that are EXISTING_PAGE are reloads and location.replace, 1191 // navigations that are EXISTING_PAGE are reloads and location.replace,
1189 // which land us at the last committed entry. 1192 // which land us at the last committed entry.
1190 entry = GetLastCommittedEntry(); 1193 entry = GetLastCommittedEntry();
1191 } 1194 }
1192 DCHECK(entry); 1195 DCHECK(entry);
1193 1196
1194 // The URL may have changed due to redirects. 1197 // The URL may have changed due to redirects.
1195 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1198 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1196 : PAGE_TYPE_NORMAL); 1199 : PAGE_TYPE_NORMAL);
1197 entry->SetURL(params.url); 1200 entry->SetURL(params.url);
1198 entry->SetReferrer(params.referrer); 1201 entry->SetReferrer(params.referrer);
1199 if (entry->update_virtual_url_with_url()) 1202 if (entry->update_virtual_url_with_url())
1200 UpdateVirtualURLToURL(entry, params.url); 1203 UpdateVirtualURLToURL(entry, params.url);
1201 1204
1202 // Update the post parameters. 1205 // The site instance will normally be the same except during session restore,
1203 FrameNavigationEntry* frame_entry = 1206 // when no site instance will be assigned.
1204 entry->GetFrameEntry(rfh->frame_tree_node()); 1207 DCHECK(entry->site_instance() == nullptr ||
1205 frame_entry->set_method(params.method); 1208 entry->site_instance() == rfh->GetSiteInstance());
1206 frame_entry->set_post_id(params.post_id);
1207 1209
1208 // If the document sequence number has changed due to redirects or a 1210 // Update the existing FrameNavigationEntry to ensure all of its members
1209 // location.replace, then the child FrameNavigationEntries that were there 1211 // reflect the parameters coming from the renderer process.
1210 // before no longer apply. We can leave them around for in-page navigations. 1212 entry->AddOrUpdateFrameEntry(
1211 if (frame_entry->document_sequence_number() != 1213 rfh->frame_tree_node(), params.item_sequence_number,
1212 params.document_sequence_number) 1214 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1213 entry->ClearChildren(rfh->frame_tree_node()); 1215 params.url, params.referrer, params.page_state, params.method,
1214 1216 params.post_id);
1215 // Update the ISN and DSN in case this was a location.replace, which can cause
1216 // them to change.
1217 // TODO(creis): Classify location.replace as NEW_PAGE instead of EXISTING_PAGE
1218 // in https://crbug.com/596707.
1219 frame_entry->set_item_sequence_number(params.item_sequence_number);
1220 frame_entry->set_document_sequence_number(params.document_sequence_number);
1221 1217
1222 // The redirected to page should not inherit the favicon from the previous 1218 // The redirected to page should not inherit the favicon from the previous
1223 // page. 1219 // page.
1224 if (ui::PageTransitionIsRedirect(params.transition)) 1220 if (ui::PageTransitionIsRedirect(params.transition))
1225 entry->GetFavicon() = FaviconStatus(); 1221 entry->GetFavicon() = FaviconStatus();
1226 1222
1227 // The site instance will normally be the same except during session restore,
1228 // when no site instance will be assigned.
1229 DCHECK(entry->site_instance() == nullptr ||
1230 entry->site_instance() == rfh->GetSiteInstance());
1231 entry->set_site_instance(
1232 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1233
1234 // The entry we found in the list might be pending if the user hit 1223 // The entry we found in the list might be pending if the user hit
1235 // back/forward/reload. This load should commit it (since it's already in the 1224 // back/forward/reload. This load should commit it (since it's already in the
1236 // list, we can just discard the pending pointer). We should also discard the 1225 // list, we can just discard the pending pointer). We should also discard the
1237 // pending entry if it corresponds to a different navigation, since that one 1226 // pending entry if it corresponds to a different navigation, since that one
1238 // is now likely canceled. If it is not canceled, we will treat it as a new 1227 // is now likely canceled. If it is not canceled, we will treat it as a new
1239 // navigation when it arrives, which is also ok. 1228 // navigation when it arrives, which is also ok.
1240 // 1229 //
1241 // Note that we need to use the "internal" version since we don't want to 1230 // Note that we need to use the "internal" version since we don't want to
1242 // actually change any other state, just kill the pointer. 1231 // actually change any other state, just kill the pointer.
1243 DiscardNonCommittedEntriesInternal(); 1232 DiscardNonCommittedEntriesInternal();
(...skipping 19 matching lines...) Expand all
1263 // a regular user-initiated navigation. 1252 // a regular user-initiated navigation.
1264 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id); 1253 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id);
1265 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1254 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1266 1255
1267 // The URL may have changed due to redirects. 1256 // The URL may have changed due to redirects.
1268 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1257 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1269 : PAGE_TYPE_NORMAL); 1258 : PAGE_TYPE_NORMAL);
1270 if (existing_entry->update_virtual_url_with_url()) 1259 if (existing_entry->update_virtual_url_with_url())
1271 UpdateVirtualURLToURL(existing_entry, params.url); 1260 UpdateVirtualURLToURL(existing_entry, params.url);
1272 existing_entry->SetURL(params.url); 1261 existing_entry->SetURL(params.url);
1273 existing_entry->SetReferrer(params.referrer);
1274 1262
1275 // The page may have been requested with a different HTTP method. 1263 // Update the existing FrameNavigationEntry to ensure all of its members
1276 FrameNavigationEntry* frame_entry = 1264 // reflect the parameters coming from the renderer process.
1277 existing_entry->GetFrameEntry(rfh->frame_tree_node()); 1265 existing_entry->AddOrUpdateFrameEntry(
1278 frame_entry->set_method(params.method); 1266 rfh->frame_tree_node(), params.item_sequence_number,
1279 frame_entry->set_post_id(params.post_id); 1267 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1268 params.url, params.referrer, params.page_state, params.method,
1269 params.post_id);
1280 1270
1281 DiscardNonCommittedEntries(); 1271 DiscardNonCommittedEntries();
1282 } 1272 }
1283 1273
1284 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1274 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1285 RenderFrameHostImpl* rfh, 1275 RenderFrameHostImpl* rfh,
1286 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1276 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1287 bool is_in_page, 1277 bool is_in_page,
1288 bool replace_entry) { 1278 bool replace_entry) {
1289 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1279 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 } 2094 }
2105 } 2095 }
2106 } 2096 }
2107 2097
2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2098 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2109 const base::Callback<base::Time()>& get_timestamp_callback) { 2099 const base::Callback<base::Time()>& get_timestamp_callback) {
2110 get_timestamp_callback_ = get_timestamp_callback; 2100 get_timestamp_callback_ = get_timestamp_callback;
2111 } 2101 }
2112 2102
2113 } // namespace content 2103 } // 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