OLD | NEW |
---|---|
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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
729 DCHECK(GetLastCommittedEntry()); | 729 DCHECK(GetLastCommittedEntry()); |
730 | 730 |
731 // Update the FTN ID to use below in case we found a named frame. | 731 // Update the FTN ID to use below in case we found a named frame. |
732 frame_tree_node_id = node->frame_tree_node_id(); | 732 frame_tree_node_id = node->frame_tree_node_id(); |
733 | 733 |
734 // In --site-per-process, create an identical NavigationEntry with a | 734 // In --site-per-process, create an identical NavigationEntry with a |
735 // new FrameNavigationEntry for the target subframe. | 735 // new FrameNavigationEntry for the target subframe. |
736 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 736 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
737 entry = GetLastCommittedEntry()->Clone(); | 737 entry = GetLastCommittedEntry()->Clone(); |
738 entry->SetPageID(-1); | 738 entry->SetPageID(-1); |
739 entry->AddOrUpdateFrameEntry(node, "", -1, -1, nullptr, params.url, | 739 entry->AddOrUpdateFrameEntry(node, -1, -1, nullptr, params.url, |
740 params.referrer, PageState(), "GET", -1); | 740 params.referrer, PageState(), "GET", -1); |
741 } | 741 } |
742 } | 742 } |
743 } | 743 } |
744 | 744 |
745 // Otherwise, create a pending entry for the main frame. | 745 // Otherwise, create a pending entry for the main frame. |
746 if (!entry) { | 746 if (!entry) { |
747 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( | 747 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( |
748 params.url, params.referrer, params.transition_type, | 748 params.url, params.referrer, params.transition_type, |
749 params.is_renderer_initiated, params.extra_headers, browser_context_)); | 749 params.is_renderer_initiated, params.extra_headers, browser_context_)); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 | 970 |
971 // Valid subframe navigation. | 971 // Valid subframe navigation. |
972 return NAVIGATION_TYPE_NEW_SUBFRAME; | 972 return NAVIGATION_TYPE_NEW_SUBFRAME; |
973 } | 973 } |
974 | 974 |
975 // Cross-process location.replace navigations should be classified as New with | 975 // Cross-process location.replace navigations should be classified as New with |
976 // replacement rather than ExistingPage, since it is not safe to reuse the | 976 // replacement rather than ExistingPage, since it is not safe to reuse the |
977 // NavigationEntry. | 977 // NavigationEntry. |
978 // TODO(creis): Have the renderer classify location.replace as | 978 // TODO(creis): Have the renderer classify location.replace as |
979 // did_create_new_entry for all cases and eliminate this special case. This | 979 // did_create_new_entry for all cases and eliminate this special case. This |
980 // requires updating several test expectations. See https://crbug.com/317872. | 980 // requires updating several test expectations. See https://crbug.com/596707. |
981 if (!rfh->GetParent() && GetLastCommittedEntry() && | 981 if (!rfh->GetParent() && GetLastCommittedEntry() && |
982 GetLastCommittedEntry()->site_instance() != rfh->GetSiteInstance() && | 982 GetLastCommittedEntry()->site_instance() != rfh->GetSiteInstance() && |
983 params.should_replace_current_entry) { | 983 params.should_replace_current_entry) { |
984 return NAVIGATION_TYPE_NEW_PAGE; | 984 return NAVIGATION_TYPE_NEW_PAGE; |
985 } | 985 } |
986 | 986 |
987 // We only clear the session history when navigating to a new page. | 987 // We only clear the session history when navigating to a new page. |
988 DCHECK(!params.history_list_was_cleared); | 988 DCHECK(!params.history_list_was_cleared); |
989 | 989 |
990 if (rfh->GetParent()) { | 990 if (rfh->GetParent()) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1183 entry->SetReferrer(params.referrer); | 1183 entry->SetReferrer(params.referrer); |
1184 if (entry->update_virtual_url_with_url()) | 1184 if (entry->update_virtual_url_with_url()) |
1185 UpdateVirtualURLToURL(entry, params.url); | 1185 UpdateVirtualURLToURL(entry, params.url); |
1186 | 1186 |
1187 // Update the post parameters. | 1187 // Update the post parameters. |
1188 FrameNavigationEntry* frame_entry = | 1188 FrameNavigationEntry* frame_entry = |
1189 entry->GetFrameEntry(rfh->frame_tree_node()); | 1189 entry->GetFrameEntry(rfh->frame_tree_node()); |
1190 frame_entry->set_method(params.method); | 1190 frame_entry->set_method(params.method); |
1191 frame_entry->set_post_id(params.post_id); | 1191 frame_entry->set_post_id(params.post_id); |
1192 | 1192 |
1193 // Update the ISN and DSN in case this was a location.replace, which can cause | |
1194 // them to change. | |
1195 // TODO(creis): Classify location.replace as NEW_PAGE instead of EXISTING_PAGE | |
1196 // in https://crbug.com/596707. | |
1197 frame_entry->set_item_sequence_number(params.item_sequence_number); | |
1198 frame_entry->set_document_sequence_number(params.document_sequence_number); | |
1199 | |
1193 // The redirected to page should not inherit the favicon from the previous | 1200 // The redirected to page should not inherit the favicon from the previous |
1194 // page. | 1201 // page. |
1195 if (ui::PageTransitionIsRedirect(params.transition)) | 1202 if (ui::PageTransitionIsRedirect(params.transition)) |
1196 entry->GetFavicon() = FaviconStatus(); | 1203 entry->GetFavicon() = FaviconStatus(); |
1197 | 1204 |
1198 // The site instance will normally be the same except during session restore, | 1205 // The site instance will normally be the same except during session restore, |
1199 // when no site instance will be assigned. | 1206 // when no site instance will be assigned. |
1200 DCHECK(entry->site_instance() == nullptr || | 1207 DCHECK(entry->site_instance() == nullptr || |
1201 entry->site_instance() == rfh->GetSiteInstance()); | 1208 entry->site_instance() == rfh->GetSiteInstance()); |
1202 entry->set_site_instance( | 1209 entry->set_site_instance( |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 | 1268 |
1262 // Manual subframe navigations just get the current entry cloned so the user | 1269 // Manual subframe navigations just get the current entry cloned so the user |
1263 // can go back or forward to it. The actual subframe information will be | 1270 // can go back or forward to it. The actual subframe information will be |
1264 // stored in the page state for each of those entries. This happens out of | 1271 // stored in the page state for each of those entries. This happens out of |
1265 // band with the actual navigations. | 1272 // band with the actual navigations. |
1266 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1273 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
1267 << "that a last committed entry exists."; | 1274 << "that a last committed entry exists."; |
1268 | 1275 |
1269 std::unique_ptr<NavigationEntryImpl> new_entry; | 1276 std::unique_ptr<NavigationEntryImpl> new_entry; |
1270 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1277 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1271 // Make sure new_entry takes ownership of frame_entry in a scoped_refptr. | 1278 // Make sure we don't leak frame_entry if new_entry doesn't take ownership. |
1272 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( | 1279 scoped_refptr<FrameNavigationEntry> frame_entry(new FrameNavigationEntry( |
Charlie Reis
2016/04/27 19:12:57
This was a bug in my https://codereview.chromium.o
alexmos
2016/04/28 01:05:03
Acknowledged.
| |
1273 rfh->frame_tree_node()->frame_tree_node_id(), params.frame_unique_name, | 1280 params.frame_unique_name, params.item_sequence_number, |
1274 params.item_sequence_number, params.document_sequence_number, | 1281 params.document_sequence_number, rfh->GetSiteInstance(), params.url, |
1275 rfh->GetSiteInstance(), params.url, params.referrer, params.method, | 1282 params.referrer, params.method, params.post_id)); |
1276 params.post_id); | |
1277 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), | 1283 new_entry = GetLastCommittedEntry()->CloneAndReplace(rfh->frame_tree_node(), |
1278 frame_entry); | 1284 frame_entry.get()); |
1279 | 1285 |
1280 // TODO(creis): Make sure the last committed entry always has the subframe | 1286 // TODO(creis): Update this to add the frame_entry if we can't find the one |
1281 // entry to replace, and CHECK(frame_entry->HasOneRef). For now, we might | 1287 // to replace, which can happen due to a unique name change. See |
1282 // not find the entry to replace, and new_entry will be deleted when it goes | 1288 // https://crbug.com/607205. For now, frame_entry will be deleted when it |
1283 // out of scope. See https://crbug.com/522193. | 1289 // goes out of scope if it doesn't get used. |
1284 } else { | 1290 } else { |
1285 new_entry = GetLastCommittedEntry()->Clone(); | 1291 new_entry = GetLastCommittedEntry()->Clone(); |
1286 } | 1292 } |
1287 | 1293 |
1288 new_entry->SetPageID(params.page_id); | 1294 new_entry->SetPageID(params.page_id); |
1289 InsertOrReplaceEntry(std::move(new_entry), replace_entry); | 1295 InsertOrReplaceEntry(std::move(new_entry), replace_entry); |
1290 } | 1296 } |
1291 | 1297 |
1292 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( | 1298 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( |
1293 RenderFrameHostImpl* rfh, | 1299 RenderFrameHostImpl* rfh, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1325 DiscardNonCommittedEntriesInternal(); | 1331 DiscardNonCommittedEntriesInternal(); |
1326 return true; | 1332 return true; |
1327 } | 1333 } |
1328 } | 1334 } |
1329 | 1335 |
1330 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1336 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
1331 // This may be a "new auto" case where we add a new FrameNavigationEntry, or | 1337 // This may be a "new auto" case where we add a new FrameNavigationEntry, or |
1332 // it may be a "history auto" case where we update an existing one. | 1338 // it may be a "history auto" case where we update an existing one. |
1333 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); | 1339 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); |
1334 last_committed->AddOrUpdateFrameEntry( | 1340 last_committed->AddOrUpdateFrameEntry( |
1335 rfh->frame_tree_node(), params.frame_unique_name, | 1341 rfh->frame_tree_node(), params.item_sequence_number, |
1336 params.item_sequence_number, params.document_sequence_number, | 1342 params.document_sequence_number, rfh->GetSiteInstance(), params.url, |
1337 rfh->GetSiteInstance(), params.url, params.referrer, params.page_state, | 1343 params.referrer, params.page_state, params.method, params.post_id); |
1338 params.method, params.post_id); | |
1339 | 1344 |
1340 // Cross-process subframe navigations may leave a pending entry around. | 1345 // Cross-process subframe navigations may leave a pending entry around. |
1341 // Clear it if it's actually for the subframe. | 1346 // Clear it if it's actually for the subframe. |
1342 // TODO(creis): Don't use pending entries for subframe navigations. | 1347 // TODO(creis): Don't use pending entries for subframe navigations. |
1343 // See https://crbug.com/495161. | 1348 // See https://crbug.com/495161. |
1344 if (pending_entry_ && | 1349 if (pending_entry_ && |
1345 pending_entry_->frame_tree_node_id() == | 1350 pending_entry_->frame_tree_node_id() == |
1346 rfh->frame_tree_node()->frame_tree_node_id()) { | 1351 rfh->frame_tree_node()->frame_tree_node_id()) { |
1347 DiscardPendingEntry(false); | 1352 DiscardPendingEntry(false); |
1348 } | 1353 } |
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2048 } | 2053 } |
2049 } | 2054 } |
2050 } | 2055 } |
2051 | 2056 |
2052 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2057 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
2053 const base::Callback<base::Time()>& get_timestamp_callback) { | 2058 const base::Callback<base::Time()>& get_timestamp_callback) { |
2054 get_timestamp_callback_ = get_timestamp_callback; | 2059 get_timestamp_callback_ = get_timestamp_callback; |
2055 } | 2060 } |
2056 | 2061 |
2057 } // namespace content | 2062 } // namespace content |
OLD | NEW |