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

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

Issue 2482873002: Add is_srcdoc to FrameNavigationEntry and restore about::srcdoc URL. (Closed)
Patch Set: Addressed comments (@nasko) Created 4 years, 1 month 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 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 frame_tree_node_id = node->frame_tree_node_id(); 705 frame_tree_node_id = node->frame_tree_node_id();
706 706
707 // In --site-per-process, create an identical NavigationEntry with a 707 // In --site-per-process, create an identical NavigationEntry with a
708 // new FrameNavigationEntry for the target subframe. 708 // new FrameNavigationEntry for the target subframe.
709 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 709 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
710 entry = GetLastCommittedEntry()->Clone(); 710 entry = GetLastCommittedEntry()->Clone();
711 entry->AddOrUpdateFrameEntry( 711 entry->AddOrUpdateFrameEntry(
712 node, -1, -1, nullptr, 712 node, -1, -1, nullptr,
713 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()), 713 static_cast<SiteInstanceImpl*>(params.source_site_instance.get()),
714 params.url, params.referrer, params.redirect_chain, PageState(), 714 params.url, params.referrer, params.redirect_chain, PageState(),
715 "GET", -1); 715 "GET", -1, false);
716 } 716 }
717 } 717 }
718 } 718 }
719 719
720 // Otherwise, create a pending entry for the main frame. 720 // Otherwise, create a pending entry for the main frame.
721 if (!entry) { 721 if (!entry) {
722 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry( 722 entry = NavigationEntryImpl::FromNavigationEntry(CreateNavigationEntry(
723 params.url, params.referrer, params.transition_type, 723 params.url, params.referrer, params.transition_type,
724 params.is_renderer_initiated, params.extra_headers, browser_context_)); 724 params.is_renderer_initiated, params.extra_headers, browser_context_));
725 entry->set_source_site_instance( 725 entry->set_source_site_instance(
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 std::unique_ptr<NavigationEntryImpl> new_entry; 1067 std::unique_ptr<NavigationEntryImpl> new_entry;
1068 bool update_virtual_url = false; 1068 bool update_virtual_url = false;
1069 1069
1070 // First check if this is an in-page navigation. If so, clone the current 1070 // First check if this is an in-page navigation. If so, clone the current
1071 // entry instead of looking at the pending entry, because the pending entry 1071 // entry instead of looking at the pending entry, because the pending entry
1072 // does not have any subframe history items. 1072 // does not have any subframe history items.
1073 if (is_in_page && GetLastCommittedEntry()) { 1073 if (is_in_page && GetLastCommittedEntry()) {
1074 FrameNavigationEntry* frame_entry = new FrameNavigationEntry( 1074 FrameNavigationEntry* frame_entry = new FrameNavigationEntry(
1075 params.frame_unique_name, params.item_sequence_number, 1075 params.frame_unique_name, params.item_sequence_number,
1076 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1076 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1077 params.url, params.referrer, params.method, params.post_id); 1077 params.url, params.referrer, params.method, params.post_id,
1078 params.is_srcdoc);
1078 new_entry = GetLastCommittedEntry()->CloneAndReplace( 1079 new_entry = GetLastCommittedEntry()->CloneAndReplace(
1079 frame_entry, true, rfh->frame_tree_node(), 1080 frame_entry, true, rfh->frame_tree_node(),
1080 delegate_->GetFrameTree()->root()); 1081 delegate_->GetFrameTree()->root());
1081 1082
1082 // We expect |frame_entry| to be owned by |new_entry|. This should never 1083 // We expect |frame_entry| to be owned by |new_entry|. This should never
1083 // fail, because it's the main frame. 1084 // fail, because it's the main frame.
1084 CHECK(frame_entry->HasOneRef()); 1085 CHECK(frame_entry->HasOneRef());
1085 1086
1086 update_virtual_url = new_entry->update_virtual_url_with_url(); 1087 update_virtual_url = new_entry->update_virtual_url_with_url();
1087 } 1088 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 // when no site instance will be assigned. 1228 // when no site instance will be assigned.
1228 DCHECK(entry->site_instance() == nullptr || 1229 DCHECK(entry->site_instance() == nullptr ||
1229 entry->site_instance() == rfh->GetSiteInstance()); 1230 entry->site_instance() == rfh->GetSiteInstance());
1230 1231
1231 // Update the existing FrameNavigationEntry to ensure all of its members 1232 // Update the existing FrameNavigationEntry to ensure all of its members
1232 // reflect the parameters coming from the renderer process. 1233 // reflect the parameters coming from the renderer process.
1233 entry->AddOrUpdateFrameEntry( 1234 entry->AddOrUpdateFrameEntry(
1234 rfh->frame_tree_node(), params.item_sequence_number, 1235 rfh->frame_tree_node(), params.item_sequence_number,
1235 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1236 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1236 params.url, params.referrer, params.redirects, params.page_state, 1237 params.url, params.referrer, params.redirects, params.page_state,
1237 params.method, params.post_id); 1238 params.method, params.post_id, params.is_srcdoc);
1238 1239
1239 // The redirected to page should not inherit the favicon from the previous 1240 // The redirected to page should not inherit the favicon from the previous
1240 // page. 1241 // page.
1241 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page) 1242 if (ui::PageTransitionIsRedirect(params.transition) && !is_in_page)
1242 entry->GetFavicon() = FaviconStatus(); 1243 entry->GetFavicon() = FaviconStatus();
1243 1244
1244 // The entry we found in the list might be pending if the user hit 1245 // The entry we found in the list might be pending if the user hit
1245 // back/forward/reload. This load should commit it (since it's already in the 1246 // back/forward/reload. This load should commit it (since it's already in the
1246 // list, we can just discard the pending pointer). We should also discard the 1247 // list, we can just discard the pending pointer). We should also discard the
1247 // pending entry if it corresponds to a different navigation, since that one 1248 // pending entry if it corresponds to a different navigation, since that one
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 1289
1289 // The extra headers may have changed due to reloading with different headers. 1290 // The extra headers may have changed due to reloading with different headers.
1290 existing_entry->set_extra_headers(pending_entry_->extra_headers()); 1291 existing_entry->set_extra_headers(pending_entry_->extra_headers());
1291 1292
1292 // Update the existing FrameNavigationEntry to ensure all of its members 1293 // Update the existing FrameNavigationEntry to ensure all of its members
1293 // reflect the parameters coming from the renderer process. 1294 // reflect the parameters coming from the renderer process.
1294 existing_entry->AddOrUpdateFrameEntry( 1295 existing_entry->AddOrUpdateFrameEntry(
1295 rfh->frame_tree_node(), params.item_sequence_number, 1296 rfh->frame_tree_node(), params.item_sequence_number,
1296 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1297 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1297 params.url, params.referrer, params.redirects, params.page_state, 1298 params.url, params.referrer, params.redirects, params.page_state,
1298 params.method, params.post_id); 1299 params.method, params.post_id, params.is_srcdoc);
1299 1300
1300 DiscardNonCommittedEntries(); 1301 DiscardNonCommittedEntries();
1301 } 1302 }
1302 1303
1303 void NavigationControllerImpl::RendererDidNavigateNewSubframe( 1304 void NavigationControllerImpl::RendererDidNavigateNewSubframe(
1304 RenderFrameHostImpl* rfh, 1305 RenderFrameHostImpl* rfh,
1305 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1306 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1306 bool is_in_page, 1307 bool is_in_page,
1307 bool replace_entry) { 1308 bool replace_entry) {
1308 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1309 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1309 ui::PAGE_TRANSITION_MANUAL_SUBFRAME)); 1310 ui::PAGE_TRANSITION_MANUAL_SUBFRAME));
1310 1311
1311 // Manual subframe navigations just get the current entry cloned so the user 1312 // Manual subframe navigations just get the current entry cloned so the user
1312 // can go back or forward to it. The actual subframe information will be 1313 // can go back or forward to it. The actual subframe information will be
1313 // stored in the page state for each of those entries. This happens out of 1314 // stored in the page state for each of those entries. This happens out of
1314 // band with the actual navigations. 1315 // band with the actual navigations.
1315 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1316 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1316 << "that a last committed entry exists."; 1317 << "that a last committed entry exists.";
1317 1318
1318 std::unique_ptr<NavigationEntryImpl> new_entry; 1319 std::unique_ptr<NavigationEntryImpl> new_entry;
1319 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1320 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1320 // Make sure we don't leak frame_entry if new_entry doesn't take ownership. 1321 // Make sure we don't leak frame_entry if new_entry doesn't take ownership.
1321 scoped_refptr<FrameNavigationEntry> frame_entry(new FrameNavigationEntry( 1322 scoped_refptr<FrameNavigationEntry> frame_entry(new FrameNavigationEntry(
1322 params.frame_unique_name, params.item_sequence_number, 1323 params.frame_unique_name, params.item_sequence_number,
1323 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1324 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1324 params.url, params.referrer, params.method, params.post_id)); 1325 params.url, params.referrer, params.method, params.post_id,
1326 params.is_srcdoc));
1325 new_entry = GetLastCommittedEntry()->CloneAndReplace( 1327 new_entry = GetLastCommittedEntry()->CloneAndReplace(
1326 frame_entry.get(), is_in_page, rfh->frame_tree_node(), 1328 frame_entry.get(), is_in_page, rfh->frame_tree_node(),
1327 delegate_->GetFrameTree()->root()); 1329 delegate_->GetFrameTree()->root());
1328 1330
1329 // TODO(creis): Update this to add the frame_entry if we can't find the one 1331 // TODO(creis): Update this to add the frame_entry if we can't find the one
1330 // to replace, which can happen due to a unique name change. See 1332 // to replace, which can happen due to a unique name change. See
1331 // https://crbug.com/607205. For now, frame_entry will be deleted when it 1333 // https://crbug.com/607205. For now, frame_entry will be deleted when it
1332 // goes out of scope if it doesn't get used. 1334 // goes out of scope if it doesn't get used.
1333 } else { 1335 } else {
1334 new_entry = GetLastCommittedEntry()->Clone(); 1336 new_entry = GetLastCommittedEntry()->Clone();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 } 1388 }
1387 1389
1388 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { 1390 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1389 // This may be a "new auto" case where we add a new FrameNavigationEntry, or 1391 // This may be a "new auto" case where we add a new FrameNavigationEntry, or
1390 // it may be a "history auto" case where we update an existing one. 1392 // it may be a "history auto" case where we update an existing one.
1391 NavigationEntryImpl* last_committed = GetLastCommittedEntry(); 1393 NavigationEntryImpl* last_committed = GetLastCommittedEntry();
1392 last_committed->AddOrUpdateFrameEntry( 1394 last_committed->AddOrUpdateFrameEntry(
1393 rfh->frame_tree_node(), params.item_sequence_number, 1395 rfh->frame_tree_node(), params.item_sequence_number,
1394 params.document_sequence_number, rfh->GetSiteInstance(), nullptr, 1396 params.document_sequence_number, rfh->GetSiteInstance(), nullptr,
1395 params.url, params.referrer, params.redirects, params.page_state, 1397 params.url, params.referrer, params.redirects, params.page_state,
1396 params.method, params.post_id); 1398 params.method, params.post_id, params.is_srcdoc);
1397 } 1399 }
1398 1400
1399 return send_commit_notification; 1401 return send_commit_notification;
1400 } 1402 }
1401 1403
1402 int NavigationControllerImpl::GetIndexOfEntry( 1404 int NavigationControllerImpl::GetIndexOfEntry(
1403 const NavigationEntryImpl* entry) const { 1405 const NavigationEntryImpl* entry) const {
1404 for (size_t i = 0; i < entries_.size(); ++i) { 1406 for (size_t i = 0; i < entries_.size(); ++i) {
1405 if (entries_[i].get() == entry) 1407 if (entries_[i].get() == entry)
1406 return i; 1408 return i;
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
2100 } 2102 }
2101 } 2103 }
2102 } 2104 }
2103 2105
2104 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2106 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2105 const base::Callback<base::Time()>& get_timestamp_callback) { 2107 const base::Callback<base::Time()>& get_timestamp_callback) {
2106 get_timestamp_callback_ = get_timestamp_callback; 2108 get_timestamp_callback_ = get_timestamp_callback;
2107 } 2109 }
2108 2110
2109 } // namespace content 2111 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698