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

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

Issue 1305293002: Clone the subframe FrameNavigationEntries for in-page navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 840
841 // Do navigation-type specific actions. These will make and commit an entry. 841 // Do navigation-type specific actions. These will make and commit an entry.
842 details->type = ClassifyNavigation(rfh, params); 842 details->type = ClassifyNavigation(rfh, params);
843 843
844 // is_in_page must be computed before the entry gets committed. 844 // is_in_page must be computed before the entry gets committed.
845 details->is_in_page = IsURLInPageNavigation( 845 details->is_in_page = IsURLInPageNavigation(
846 params.url, params.was_within_same_page, rfh); 846 params.url, params.was_within_same_page, rfh);
847 847
848 switch (details->type) { 848 switch (details->type) {
849 case NAVIGATION_TYPE_NEW_PAGE: 849 case NAVIGATION_TYPE_NEW_PAGE:
850 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry); 850 RendererDidNavigateToNewPage(rfh, params, details->is_in_page,
851 details->did_replace_entry);
851 break; 852 break;
852 case NAVIGATION_TYPE_EXISTING_PAGE: 853 case NAVIGATION_TYPE_EXISTING_PAGE:
853 details->did_replace_entry = details->is_in_page; 854 details->did_replace_entry = details->is_in_page;
854 RendererDidNavigateToExistingPage(rfh, params); 855 RendererDidNavigateToExistingPage(rfh, params);
855 break; 856 break;
856 case NAVIGATION_TYPE_SAME_PAGE: 857 case NAVIGATION_TYPE_SAME_PAGE:
857 RendererDidNavigateToSamePage(rfh, params); 858 RendererDidNavigateToSamePage(rfh, params);
858 break; 859 break;
859 case NAVIGATION_TYPE_NEW_SUBFRAME: 860 case NAVIGATION_TYPE_NEW_SUBFRAME:
860 RendererDidNavigateNewSubframe(rfh, params); 861 RendererDidNavigateNewSubframe(rfh, params, details->is_in_page);
861 break; 862 break;
862 case NAVIGATION_TYPE_AUTO_SUBFRAME: 863 case NAVIGATION_TYPE_AUTO_SUBFRAME:
863 if (!RendererDidNavigateAutoSubframe(rfh, params)) 864 if (!RendererDidNavigateAutoSubframe(rfh, params))
864 return false; 865 return false;
865 break; 866 break;
866 case NAVIGATION_TYPE_NAV_IGNORE: 867 case NAVIGATION_TYPE_NAV_IGNORE:
867 // If a pending navigation was in progress, this canceled it. We should 868 // If a pending navigation was in progress, this canceled it. We should
868 // discard it and make sure it is removed from the URL bar. After that, 869 // discard it and make sure it is removed from the URL bar. After that,
869 // there is nothing we can do with this navigation, so we just return to 870 // there is nothing we can do with this navigation, so we just return to
870 // the caller that nothing has happened. 871 // the caller that nothing has happened.
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 } 1046 }
1046 1047
1047 // Since we weeded out "new" navigations above, we know this is an existing 1048 // Since we weeded out "new" navigations above, we know this is an existing
1048 // (back/forward) navigation. 1049 // (back/forward) navigation.
1049 return NAVIGATION_TYPE_EXISTING_PAGE; 1050 return NAVIGATION_TYPE_EXISTING_PAGE;
1050 } 1051 }
1051 1052
1052 void NavigationControllerImpl::RendererDidNavigateToNewPage( 1053 void NavigationControllerImpl::RendererDidNavigateToNewPage(
1053 RenderFrameHostImpl* rfh, 1054 RenderFrameHostImpl* rfh,
1054 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1055 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1056 bool is_in_page,
1055 bool replace_entry) { 1057 bool replace_entry) {
1056 scoped_ptr<NavigationEntryImpl> new_entry; 1058 scoped_ptr<NavigationEntryImpl> new_entry;
1057 bool update_virtual_url; 1059 bool update_virtual_url;
1058 // Only make a copy of the pending entry if it is appropriate for the new page 1060 // Only make a copy of the pending entry if it is appropriate for the new page
1059 // that was just loaded. We verify this at a coarse grain by checking that 1061 // that was just loaded. We verify this at a coarse grain by checking that
1060 // the SiteInstance hasn't been assigned to something else, and by making sure 1062 // the SiteInstance hasn't been assigned to something else, and by making sure
1061 // that the pending entry was intended as a new entry (rather than being a 1063 // that the pending entry was intended as a new entry (rather than being a
1062 // history navigation that was interrupted by an unrelated, renderer-initiated 1064 // history navigation that was interrupted by an unrelated, renderer-initiated
1063 // navigation). 1065 // navigation).
1064 if (pending_entry_ && pending_entry_index_ == -1 && 1066 if (pending_entry_ && pending_entry_index_ == -1 &&
(...skipping 14 matching lines...) Expand all
1079 &url, browser_context_, &needs_update); 1081 &url, browser_context_, &needs_update);
1080 new_entry->set_update_virtual_url_with_url(needs_update); 1082 new_entry->set_update_virtual_url_with_url(needs_update);
1081 1083
1082 // When navigating to a new page, give the browser URL handler a chance to 1084 // When navigating to a new page, give the browser URL handler a chance to
1083 // update the virtual URL based on the new URL. For example, this is needed 1085 // update the virtual URL based on the new URL. For example, this is needed
1084 // to show chrome://bookmarks/#1 when the bookmarks webui extension changes 1086 // to show chrome://bookmarks/#1 when the bookmarks webui extension changes
1085 // the URL. 1087 // the URL.
1086 update_virtual_url = needs_update; 1088 update_virtual_url = needs_update;
1087 } 1089 }
1088 1090
1091 CHECK_EQ(0U, new_entry->root_node()->children.size());
1092 if (SiteIsolationPolicy::UseSubframeNavigationEntries() && is_in_page) {
1093 // Clone the tree of FrameNavigationEntries from the last committed entry.
1094 // TODO(creis): Can we do this more cleanly as a clone of the whole last
1095 // committed entry?
1096 // TODO(creis): What about in-page navigations with no last committed entry,
1097 // like pushState on the initial about:blank page?
1098 new_entry->set_root_node(
1099 GetLastCommittedEntry()->root_node()->CloneAndReplace(nullptr, nullptr,
1100 is_in_page));
1101 }
1102
1089 // Don't use the page type from the pending entry. Some interstitial page 1103 // Don't use the page type from the pending entry. Some interstitial page
1090 // may have set the type to interstitial. Once we commit, however, the page 1104 // may have set the type to interstitial. Once we commit, however, the page
1091 // type must always be normal or error. 1105 // type must always be normal or error.
1092 new_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR 1106 new_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1093 : PAGE_TYPE_NORMAL); 1107 : PAGE_TYPE_NORMAL);
1094 new_entry->SetURL(params.url); 1108 new_entry->SetURL(params.url);
1095 if (update_virtual_url) 1109 if (update_virtual_url)
1096 UpdateVirtualURLToURL(new_entry.get(), params.url); 1110 UpdateVirtualURLToURL(new_entry.get(), params.url);
1097 new_entry->SetReferrer(params.referrer); 1111 new_entry->SetReferrer(params.referrer);
1098 new_entry->SetPageID(params.page_id); 1112 new_entry->SetPageID(params.page_id);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 1230
1217 // The page may have been requested with a different HTTP method. 1231 // The page may have been requested with a different HTTP method.
1218 existing_entry->SetHasPostData(params.is_post); 1232 existing_entry->SetHasPostData(params.is_post);
1219 existing_entry->SetPostID(params.post_id); 1233 existing_entry->SetPostID(params.post_id);
1220 1234
1221 DiscardNonCommittedEntries(); 1235 DiscardNonCommittedEntries();
1222 } 1236 }
1223 1237
1224 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1238 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1225 RenderFrameHostImpl* rfh, 1239 RenderFrameHostImpl* rfh,
1226 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1240 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1241 bool is_in_page) {
1227 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1242 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1228 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); 1243 ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
1229 1244
1230 // Manual subframe navigations just get the current entry cloned so the user 1245 // Manual subframe navigations just get the current entry cloned so the user
1231 // can go back or forward to it. The actual subframe information will be 1246 // can go back or forward to it. The actual subframe information will be
1232 // stored in the page state for each of those entries. This happens out of 1247 // stored in the page state for each of those entries. This happens out of
1233 // band with the actual navigations. 1248 // band with the actual navigations.
1234 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1249 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1235 << "that a last committed entry exists."; 1250 << "that a last committed entry exists.";
1236 1251
1237 scoped_ptr<NavigationEntryImpl> new_entry; 1252 scoped_ptr<NavigationEntryImpl> new_entry;
1238 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1253 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1239 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. 1254 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr.
1240 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 1255 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
1241 rfh->frame_tree_node()->frame_tree_node_id(), 1256 rfh->frame_tree_node()->frame_tree_node_id(),
1242 params.item_sequence_number, params.document_sequence_number, 1257 params.item_sequence_number, params.document_sequence_number,
1243 rfh->GetSiteInstance(), params.url, params.referrer); 1258 rfh->GetSiteInstance(), params.url, params.referrer);
1244 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), 1259 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(),
1245 frame_entry); 1260 frame_entry,
1261 is_in_page);
1246 CHECK(frame_entry->HasOneRef()); 1262 CHECK(frame_entry->HasOneRef());
1247 } else { 1263 } else {
1248 new_entry = GetLastCommittedEntry()->Clone(); 1264 new_entry = GetLastCommittedEntry()->Clone();
1249 } 1265 }
1250 1266
1251 new_entry->SetPageID(params.page_id); 1267 new_entry->SetPageID(params.page_id);
1252 InsertOrReplaceEntry(new_entry.Pass(), false); 1268 InsertOrReplaceEntry(new_entry.Pass(), false);
1253 } 1269 }
1254 1270
1255 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( 1271 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 } 2000 }
1985 } 2001 }
1986 } 2002 }
1987 2003
1988 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2004 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1989 const base::Callback<base::Time()>& get_timestamp_callback) { 2005 const base::Callback<base::Time()>& get_timestamp_callback) {
1990 get_timestamp_callback_ = get_timestamp_callback; 2006 get_timestamp_callback_ = get_timestamp_callback;
1991 } 2007 }
1992 2008
1993 } // namespace content 2009 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698