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

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

Issue 1250163002: Fix cross-process location.replace for main frames and subframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and remove some code Created 4 years, 11 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE); 840 pending_entry_->set_restore_type(NavigationEntryImpl::RESTORE_NONE);
841 841
842 // If we are doing a cross-site reload, we need to replace the existing 842 // If we are doing a cross-site reload, we need to replace the existing
843 // navigation entry, not add another entry to the history. This has the side 843 // navigation entry, not add another entry to the history. This has the side
844 // effect of removing forward browsing history, if such existed. Or if we are 844 // effect of removing forward browsing history, if such existed. Or if we are
845 // doing a cross-site redirect navigation, we will do a similar thing. 845 // doing a cross-site redirect navigation, we will do a similar thing.
846 // 846 //
847 // If this is an error load, we may have already removed the pending entry 847 // If this is an error load, we may have already removed the pending entry
848 // when we got the notice of the load failure. If so, look at the copy of the 848 // when we got the notice of the load failure. If so, look at the copy of the
849 // pending parameters that were saved. 849 // pending parameters that were saved.
850 //
851 // TODO(creis): This block should be unnecessary now that we pass
852 // params.should_replace_current_entry. Remove it once we verify with the
853 // check below.
850 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) { 854 if (params.url_is_unreachable && failed_pending_entry_id_ != 0) {
851 details->did_replace_entry = failed_pending_entry_should_replace_; 855 details->did_replace_entry = failed_pending_entry_should_replace_;
852 } else { 856 } else {
853 details->did_replace_entry = pending_entry_ && 857 details->did_replace_entry = (pending_entry_ &&
854 pending_entry_->should_replace_entry(); 858 pending_entry_->should_replace_entry());
855 } 859 }
860 CHECK(!details->did_replace_entry || params.should_replace_current_entry);
861 if (params.should_replace_current_entry)
862 details->did_replace_entry = true;
856 863
857 // Do navigation-type specific actions. These will make and commit an entry. 864 // Do navigation-type specific actions. These will make and commit an entry.
858 details->type = ClassifyNavigation(rfh, params); 865 details->type = ClassifyNavigation(rfh, params);
859 866
860 // is_in_page must be computed before the entry gets committed. 867 // is_in_page must be computed before the entry gets committed.
861 details->is_in_page = IsURLInPageNavigation( 868 details->is_in_page = IsURLInPageNavigation(
862 params.url, params.was_within_same_page, rfh); 869 params.url, params.was_within_same_page, rfh);
863 870
864 switch (details->type) { 871 switch (details->type) {
865 case NAVIGATION_TYPE_NEW_PAGE: 872 case NAVIGATION_TYPE_NEW_PAGE:
866 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry); 873 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry);
867 break; 874 break;
868 case NAVIGATION_TYPE_EXISTING_PAGE: 875 case NAVIGATION_TYPE_EXISTING_PAGE:
869 details->did_replace_entry = details->is_in_page; 876 details->did_replace_entry = details->is_in_page;
870 RendererDidNavigateToExistingPage(rfh, params); 877 RendererDidNavigateToExistingPage(rfh, params);
871 break; 878 break;
872 case NAVIGATION_TYPE_SAME_PAGE: 879 case NAVIGATION_TYPE_SAME_PAGE:
873 RendererDidNavigateToSamePage(rfh, params); 880 RendererDidNavigateToSamePage(rfh, params);
874 break; 881 break;
875 case NAVIGATION_TYPE_NEW_SUBFRAME: 882 case NAVIGATION_TYPE_NEW_SUBFRAME:
876 RendererDidNavigateNewSubframe(rfh, params); 883 RendererDidNavigateNewSubframe(rfh, params, details->did_replace_entry);
877 break; 884 break;
878 case NAVIGATION_TYPE_AUTO_SUBFRAME: 885 case NAVIGATION_TYPE_AUTO_SUBFRAME:
879 if (!RendererDidNavigateAutoSubframe(rfh, params)) 886 if (!RendererDidNavigateAutoSubframe(rfh, params))
880 return false; 887 return false;
881 break; 888 break;
882 case NAVIGATION_TYPE_NAV_IGNORE: 889 case NAVIGATION_TYPE_NAV_IGNORE:
883 // If a pending navigation was in progress, this canceled it. We should 890 // If a pending navigation was in progress, this canceled it. We should
884 // discard it and make sure it is removed from the URL bar. After that, 891 // discard it and make sure it is removed from the URL bar. After that,
885 // there is nothing we can do with this navigation, so we just return to 892 // there is nothing we can do with this navigation, so we just return to
886 // the caller that nothing has happened. 893 // the caller that nothing has happened.
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 1256
1250 // The page may have been requested with a different HTTP method. 1257 // The page may have been requested with a different HTTP method.
1251 existing_entry->SetHasPostData(params.is_post); 1258 existing_entry->SetHasPostData(params.is_post);
1252 existing_entry->SetPostID(params.post_id); 1259 existing_entry->SetPostID(params.post_id);
1253 1260
1254 DiscardNonCommittedEntries(); 1261 DiscardNonCommittedEntries();
1255 } 1262 }
1256 1263
1257 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1264 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1258 RenderFrameHostImpl* rfh, 1265 RenderFrameHostImpl* rfh,
1259 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1266 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1267 bool replace_entry) {
1260 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1268 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1261 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); 1269 ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
1262 1270
1263 // Manual subframe navigations just get the current entry cloned so the user 1271 // Manual subframe navigations just get the current entry cloned so the user
1264 // can go back or forward to it. The actual subframe information will be 1272 // can go back or forward to it. The actual subframe information will be
1265 // stored in the page state for each of those entries. This happens out of 1273 // stored in the page state for each of those entries. This happens out of
1266 // band with the actual navigations. 1274 // band with the actual navigations.
1267 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1275 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1268 << "that a last committed entry exists."; 1276 << "that a last committed entry exists.";
1269 1277
1270 scoped_ptr<NavigationEntryImpl> new_entry; 1278 scoped_ptr<NavigationEntryImpl> new_entry;
1271 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1279 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1272 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. 1280 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr.
1273 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 1281 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
1274 rfh->frame_tree_node()->frame_tree_node_id(), params.frame_unique_name, 1282 rfh->frame_tree_node()->frame_tree_node_id(), params.frame_unique_name,
1275 params.item_sequence_number, params.document_sequence_number, 1283 params.item_sequence_number, params.document_sequence_number,
1276 rfh->GetSiteInstance(), params.url, params.referrer); 1284 rfh->GetSiteInstance(), params.url, params.referrer);
1277 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), 1285 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(),
1278 frame_entry); 1286 frame_entry);
1279 1287
1280 // TODO(creis): Make sure the last committed entry always has the subframe 1288 // TODO(creis): Make sure the last committed entry always has the subframe
1281 // entry to replace, and CHECK(frame_entry->HasOneRef). For now, we might 1289 // entry to replace, and CHECK(frame_entry->HasOneRef). For now, we might
1282 // not find the entry to replace, and new_entry will be deleted when it goes 1290 // not find the entry to replace, and new_entry will be deleted when it goes
1283 // out of scope. See https://crbug.com/522193. 1291 // out of scope. See https://crbug.com/522193.
1284 } else { 1292 } else {
1285 new_entry = GetLastCommittedEntry()->Clone(); 1293 new_entry = GetLastCommittedEntry()->Clone();
1286 } 1294 }
1287 1295
1288 new_entry->SetPageID(params.page_id); 1296 new_entry->SetPageID(params.page_id);
1289 InsertOrReplaceEntry(std::move(new_entry), false); 1297 InsertOrReplaceEntry(std::move(new_entry), replace_entry);
1290 } 1298 }
1291 1299
1292 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( 1300 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
1293 RenderFrameHostImpl* rfh, 1301 RenderFrameHostImpl* rfh,
1294 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1302 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1295 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1303 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1296 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); 1304 ui::PAGE_TRANSITION_AUTO_SUBFRAME));
1297 1305
1298 // We're guaranteed to have a previously committed entry, and we now need to 1306 // We're guaranteed to have a previously committed entry, and we now need to
1299 // handle navigation inside of a subframe in it without creating a new entry. 1307 // handle navigation inside of a subframe in it without creating a new entry.
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
2042 } 2050 }
2043 } 2051 }
2044 } 2052 }
2045 2053
2046 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2054 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2047 const base::Callback<base::Time()>& get_timestamp_callback) { 2055 const base::Callback<base::Time()>& get_timestamp_callback) {
2048 get_timestamp_callback_ = get_timestamp_callback; 2056 get_timestamp_callback_ = get_timestamp_callback;
2049 } 2057 }
2050 2058
2051 } // namespace content 2059 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698