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

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

Issue 994803004: Add Clone and disallow copy construction for NavigationEntryImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 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 #include "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1043 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1044 bool replace_entry) { 1044 bool replace_entry) {
1045 NavigationEntryImpl* new_entry; 1045 NavigationEntryImpl* new_entry;
1046 bool update_virtual_url; 1046 bool update_virtual_url;
1047 // Only make a copy of the pending entry if it is appropriate for the new page 1047 // Only make a copy of the pending entry if it is appropriate for the new page
1048 // that was just loaded. We verify this at a coarse grain by checking that 1048 // that was just loaded. We verify this at a coarse grain by checking that
1049 // the SiteInstance hasn't been assigned to something else. 1049 // the SiteInstance hasn't been assigned to something else.
1050 if (pending_entry_ && 1050 if (pending_entry_ &&
1051 (!pending_entry_->site_instance() || 1051 (!pending_entry_->site_instance() ||
1052 pending_entry_->site_instance() == rfh->GetSiteInstance())) { 1052 pending_entry_->site_instance() == rfh->GetSiteInstance())) {
1053 new_entry = new NavigationEntryImpl(*pending_entry_); 1053 new_entry = pending_entry_->Clone();
1054 1054
1055 update_virtual_url = new_entry->update_virtual_url_with_url(); 1055 update_virtual_url = new_entry->update_virtual_url_with_url();
1056 } else { 1056 } else {
1057 new_entry = new NavigationEntryImpl; 1057 new_entry = new NavigationEntryImpl;
1058 1058
1059 // Find out whether the new entry needs to update its virtual URL on URL 1059 // Find out whether the new entry needs to update its virtual URL on URL
1060 // change and set up the entry accordingly. This is needed to correctly 1060 // change and set up the entry accordingly. This is needed to correctly
1061 // update the virtual URL when replaceState is called after a pushState. 1061 // update the virtual URL when replaceState is called after a pushState.
1062 GURL url = params.url; 1062 GURL url = params.url;
1063 bool needs_update = false; 1063 bool needs_update = false;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 DiscardNonCommittedEntriesInternal(); 1253 DiscardNonCommittedEntriesInternal();
1254 return; 1254 return;
1255 } 1255 }
1256 1256
1257 // Manual subframe navigations just get the current entry cloned so the user 1257 // Manual subframe navigations just get the current entry cloned so the user
1258 // can go back or forward to it. The actual subframe information will be 1258 // can go back or forward to it. The actual subframe information will be
1259 // stored in the page state for each of those entries. This happens out of 1259 // stored in the page state for each of those entries. This happens out of
1260 // band with the actual navigations. 1260 // band with the actual navigations.
1261 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " 1261 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee "
1262 << "that a last committed entry exists."; 1262 << "that a last committed entry exists.";
1263 NavigationEntryImpl* new_entry = 1263 NavigationEntryImpl* new_entry = GetLastCommittedEntry()->Clone();
1264 new NavigationEntryImpl(*GetLastCommittedEntry());
1265 new_entry->SetPageID(params.page_id); 1264 new_entry->SetPageID(params.page_id);
1266 InsertOrReplaceEntry(new_entry, false); 1265 InsertOrReplaceEntry(new_entry, false);
1267 } 1266 }
1268 1267
1269 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe( 1268 bool NavigationControllerImpl::RendererDidNavigateAutoSubframe(
1270 RenderFrameHostImpl* rfh, 1269 RenderFrameHostImpl* rfh,
1271 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { 1270 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {
1272 DCHECK(ui::PageTransitionCoreTypeIs(params.transition, 1271 DCHECK(ui::PageTransitionCoreTypeIs(params.transition,
1273 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); 1272 ui::PAGE_TRANSITION_AUTO_SUBFRAME));
1274 1273
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
1798 transient_entry_index_ = index; 1797 transient_entry_index_ = index;
1799 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); 1798 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL);
1800 } 1799 }
1801 1800
1802 void NavigationControllerImpl::InsertEntriesFrom( 1801 void NavigationControllerImpl::InsertEntriesFrom(
1803 const NavigationControllerImpl& source, 1802 const NavigationControllerImpl& source,
1804 int max_index) { 1803 int max_index) {
1805 DCHECK_LE(max_index, source.GetEntryCount()); 1804 DCHECK_LE(max_index, source.GetEntryCount());
1806 size_t insert_index = 0; 1805 size_t insert_index = 0;
1807 for (int i = 0; i < max_index; i++) { 1806 for (int i = 0; i < max_index; i++) {
1808 // When cloning a tab, copy all entries except interstitial pages 1807 // When cloning a tab, copy all entries except interstitial pages.
1809 if (source.entries_[i].get()->GetPageType() != 1808 if (source.entries_[i].get()->GetPageType() != PAGE_TYPE_INTERSTITIAL) {
1810 PAGE_TYPE_INTERSTITIAL) { 1809 // TODO(creis): Once we start sharing FrameNavigationEntries between
1810 // NavigationEntries, it will not be safe to share them with another tab.
1811 // Must have a version of Clone that recreates them.
1811 entries_.insert(entries_.begin() + insert_index++, 1812 entries_.insert(entries_.begin() + insert_index++,
1812 linked_ptr<NavigationEntryImpl>( 1813 linked_ptr<NavigationEntryImpl>(
1813 new NavigationEntryImpl(*source.entries_[i]))); 1814 source.entries_[i]->Clone()));
1814 } 1815 }
1815 } 1816 }
1816 } 1817 }
1817 1818
1818 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1819 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1819 const base::Callback<base::Time()>& get_timestamp_callback) { 1820 const base::Callback<base::Time()>& get_timestamp_callback) {
1820 get_timestamp_callback_ = get_timestamp_callback; 1821 get_timestamp_callback_ = get_timestamp_callback;
1821 } 1822 }
1822 1823
1823 } // namespace content 1824 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/navigation_entry_impl.h » ('j') | content/browser/frame_host/navigation_entry_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698