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

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: Clear children FNEs of main frame on redirects. 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
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 // Update the existing FrameNavigationEntry to ensure all of its members
1203 FrameNavigationEntry* frame_entry = 1206 // reflect the parameters coming from the renderer process.
1204 entry->GetFrameEntry(rfh->frame_tree_node()); 1207 entry->AddOrUpdateFrameEntry(
1205 frame_entry->set_method(params.method); 1208 rfh->frame_tree_node(), params.item_sequence_number,
1206 frame_entry->set_post_id(params.post_id); 1209 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1207 1210 params.url, params.referrer, params.page_state, params.method,
1208 // If the document sequence number has changed due to redirects or a 1211 params.post_id);
1209 // location.replace, then the child FrameNavigationEntries that were there
1210 // before no longer apply. We can leave them around for in-page navigations.
1211 if (frame_entry->document_sequence_number() !=
1212 params.document_sequence_number)
1213 entry->ClearChildren(rfh->frame_tree_node());
1214
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 1212
1222 // The redirected to page should not inherit the favicon from the previous 1213 // The redirected to page should not inherit the favicon from the previous
1223 // page. 1214 // page.
1224 if (ui::PageTransitionIsRedirect(params.transition)) 1215 if (ui::PageTransitionIsRedirect(params.transition))
1225 entry->GetFavicon() = FaviconStatus(); 1216 entry->GetFavicon() = FaviconStatus();
1226 1217
1227 // The site instance will normally be the same except during session restore, 1218 // The site instance will normally be the same except during session restore,
1228 // when no site instance will be assigned. 1219 // when no site instance will be assigned.
1229 DCHECK(entry->site_instance() == nullptr || 1220 DCHECK(entry->site_instance() == nullptr ||
1230 entry->site_instance() == rfh->GetSiteInstance()); 1221 entry->site_instance() == rfh->GetSiteInstance());
1231 entry->set_site_instance( 1222 entry->set_site_instance(
1232 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1223 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
Charlie Reis 2016/08/10 17:03:08 This line is redundant with AddOrUpdateFrameEntry.
nasko 2016/08/10 18:08:51 Done.
1233 1224
1234 // The entry we found in the list might be pending if the user hit 1225 // 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 1226 // 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 1227 // 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 1228 // 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 1229 // 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. 1230 // navigation when it arrives, which is also ok.
1240 // 1231 //
1241 // Note that we need to use the "internal" version since we don't want to 1232 // 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. 1233 // actually change any other state, just kill the pointer.
(...skipping 20 matching lines...) Expand all
1263 // a regular user-initiated navigation. 1254 // a regular user-initiated navigation.
1264 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id); 1255 DCHECK_EQ(pending_entry_->GetUniqueID(), params.nav_entry_id);
1265 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1256 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1266 1257
1267 // The URL may have changed due to redirects. 1258 // The URL may have changed due to redirects.
1268 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1259 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1269 : PAGE_TYPE_NORMAL); 1260 : PAGE_TYPE_NORMAL);
1270 if (existing_entry->update_virtual_url_with_url()) 1261 if (existing_entry->update_virtual_url_with_url())
1271 UpdateVirtualURLToURL(existing_entry, params.url); 1262 UpdateVirtualURLToURL(existing_entry, params.url);
1272 existing_entry->SetURL(params.url); 1263 existing_entry->SetURL(params.url);
1273 existing_entry->SetReferrer(params.referrer); 1264 existing_entry->SetReferrer(params.referrer);
Charlie Reis 2016/08/10 17:03:09 Setting referrer is redundant with AddOrUpdateFram
nasko 2016/08/10 18:08:51 Done.
1274 1265
1275 // The page may have been requested with a different HTTP method. 1266 // Update the existing FrameNavigationEntry to ensure all of its members
1276 FrameNavigationEntry* frame_entry = 1267 // reflect the parameters coming from the renderer process.
1277 existing_entry->GetFrameEntry(rfh->frame_tree_node()); 1268 existing_entry->AddOrUpdateFrameEntry(
1278 frame_entry->set_method(params.method); 1269 rfh->frame_tree_node(), params.item_sequence_number,
1279 frame_entry->set_post_id(params.post_id); 1270 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1271 params.url, params.referrer, params.page_state, params.method,
1272 params.post_id);
1280 1273
1281 DiscardNonCommittedEntries(); 1274 DiscardNonCommittedEntries();
1282 } 1275 }
1283 1276
1284 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1277 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1285 RenderFrameHostImpl* rfh, 1278 RenderFrameHostImpl* rfh,
1286 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1279 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1287 bool is_in_page, 1280 bool is_in_page,
1288 bool replace_entry) { 1281 bool replace_entry) {
1289 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1282 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 } 2097 }
2105 } 2098 }
2106 } 2099 }
2107 2100
2108 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2101 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2109 const base::Callback<base::Time()>& get_timestamp_callback) { 2102 const base::Callback<base::Time()>& get_timestamp_callback) {
2110 get_timestamp_callback_ = get_timestamp_callback; 2103 get_timestamp_callback_ = get_timestamp_callback;
2111 } 2104 }
2112 2105
2113 } // namespace content 2106 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698