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

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

Issue 1440573003: Remove ScopedVector from NavigationController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 case NavigationController::RESTORE_LAST_SESSION_CRASHED: 120 case NavigationController::RESTORE_LAST_SESSION_CRASHED:
121 return NavigationEntryImpl::RESTORE_LAST_SESSION_CRASHED; 121 return NavigationEntryImpl::RESTORE_LAST_SESSION_CRASHED;
122 } 122 }
123 NOTREACHED(); 123 NOTREACHED();
124 return NavigationEntryImpl::RESTORE_CURRENT_SESSION; 124 return NavigationEntryImpl::RESTORE_CURRENT_SESSION;
125 } 125 }
126 126
127 // Configure all the NavigationEntries in entries for restore. This resets 127 // Configure all the NavigationEntries in entries for restore. This resets
128 // the transition type to reload and makes sure the content state isn't empty. 128 // the transition type to reload and makes sure the content state isn't empty.
129 void ConfigureEntriesForRestore( 129 void ConfigureEntriesForRestore(
130 ScopedVector<NavigationEntryImpl>* entries, 130 std::vector<scoped_ptr<NavigationEntryImpl>>* entries,
131 NavigationController::RestoreType type) { 131 NavigationController::RestoreType type) {
132 for (size_t i = 0; i < entries->size(); ++i) { 132 for (size_t i = 0; i < entries->size(); ++i) {
133 // Use a transition type of reload so that we don't incorrectly increase 133 // Use a transition type of reload so that we don't incorrectly increase
134 // the typed count. 134 // the typed count.
135 (*entries)[i]->SetTransitionType(ui::PAGE_TRANSITION_RELOAD); 135 (*entries)[i]->SetTransitionType(ui::PAGE_TRANSITION_RELOAD);
136 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type)); 136 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type));
137 // NOTE(darin): This code is only needed for backwards compat. 137 // NOTE(darin): This code is only needed for backwards compat.
138 SetPageStateIfEmpty((*entries)[i]); 138 SetPageStateIfEmpty((*entries)[i].get());
139 } 139 }
140 } 140 }
141 141
142 // Determines whether or not we should be carrying over a user agent override 142 // Determines whether or not we should be carrying over a user agent override
143 // between two NavigationEntries. 143 // between two NavigationEntries.
144 bool ShouldKeepOverride(const NavigationEntry* last_entry) { 144 bool ShouldKeepOverride(const NavigationEntry* last_entry) {
145 return last_entry && last_entry->GetIsOverridingUserAgent(); 145 return last_entry && last_entry->GetIsOverridingUserAgent();
146 } 146 }
147 147
148 // Helper method for FrameTree::ForEach to set the nav_entry_id on each current 148 // Helper method for FrameTree::ForEach to set the nav_entry_id on each current
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 262
263 void NavigationControllerImpl::SetBrowserContext( 263 void NavigationControllerImpl::SetBrowserContext(
264 BrowserContext* browser_context) { 264 BrowserContext* browser_context) {
265 browser_context_ = browser_context; 265 browser_context_ = browser_context;
266 } 266 }
267 267
268 void NavigationControllerImpl::Restore( 268 void NavigationControllerImpl::Restore(
269 int selected_navigation, 269 int selected_navigation,
270 RestoreType type, 270 RestoreType type,
271 ScopedVector<NavigationEntry>* entries) { 271 std::vector<scoped_ptr<NavigationEntry>>* entries) {
272 // Verify that this controller is unused and that the input is valid. 272 // Verify that this controller is unused and that the input is valid.
273 DCHECK(GetEntryCount() == 0 && !GetPendingEntry()); 273 DCHECK(GetEntryCount() == 0 && !GetPendingEntry());
274 DCHECK(selected_navigation >= 0 && 274 DCHECK(selected_navigation >= 0 &&
275 selected_navigation < static_cast<int>(entries->size())); 275 selected_navigation < static_cast<int>(entries->size()));
276 276
277 needs_reload_ = true; 277 needs_reload_ = true;
278 for (size_t i = 0; i < entries->size(); ++i) { 278 entries_.reserve(entries->size());
279 NavigationEntryImpl* entry = 279 for (auto& entry : *entries)
280 NavigationEntryImpl::FromNavigationEntry((*entries)[i]); 280 entries_.push_back(NavigationEntryImpl::FromNavigationEntry(entry.Pass()));
281 entries_.push_back(entry); 281
282 } 282 // At this point, the |entries| is full of empty scoped_ptrs, so it can be
283 entries->weak_clear(); 283 // cleared out safely.
284 entries->clear();
284 285
285 // And finish the restore. 286 // And finish the restore.
286 FinishRestore(selected_navigation, type); 287 FinishRestore(selected_navigation, type);
287 } 288 }
288 289
289 void NavigationControllerImpl::Reload(bool check_for_repost) { 290 void NavigationControllerImpl::Reload(bool check_for_repost) {
290 ReloadInternal(check_for_repost, RELOAD); 291 ReloadInternal(check_for_repost, RELOAD);
291 } 292 }
292 void NavigationControllerImpl::ReloadIgnoringCache(bool check_for_repost) { 293 void NavigationControllerImpl::ReloadIgnoringCache(bool check_for_repost) {
293 ReloadInternal(check_for_repost, RELOAD_IGNORING_CACHE); 294 ReloadInternal(check_for_repost, RELOAD_IGNORING_CACHE);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 bool NavigationControllerImpl::IsInitialBlankNavigation() const { 416 bool NavigationControllerImpl::IsInitialBlankNavigation() const {
416 // TODO(creis): Once we create a NavigationEntry for the initial blank page, 417 // TODO(creis): Once we create a NavigationEntry for the initial blank page,
417 // we'll need to check for entry count 1 and restore_type RESTORE_NONE (to 418 // we'll need to check for entry count 1 and restore_type RESTORE_NONE (to
418 // exclude the cloned tab case). 419 // exclude the cloned tab case).
419 return IsInitialNavigation() && GetEntryCount() == 0; 420 return IsInitialNavigation() && GetEntryCount() == 0;
420 } 421 }
421 422
422 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( 423 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID(
423 SiteInstance* instance, int32 page_id) const { 424 SiteInstance* instance, int32 page_id) const {
424 int index = GetEntryIndexWithPageID(instance, page_id); 425 int index = GetEntryIndexWithPageID(instance, page_id);
425 return (index != -1) ? entries_[index] : nullptr; 426 return (index != -1) ? entries_[index].get() : nullptr;
426 } 427 }
427 428
428 NavigationEntryImpl* 429 NavigationEntryImpl*
429 NavigationControllerImpl::GetEntryWithUniqueID(int nav_entry_id) const { 430 NavigationControllerImpl::GetEntryWithUniqueID(int nav_entry_id) const {
430 int index = GetEntryIndexWithUniqueID(nav_entry_id); 431 int index = GetEntryIndexWithUniqueID(nav_entry_id);
431 return (index != -1) ? entries_[index] : nullptr; 432 return (index != -1) ? entries_[index].get() : nullptr;
432 } 433 }
433 434
434 void NavigationControllerImpl::LoadEntry( 435 void NavigationControllerImpl::LoadEntry(
435 scoped_ptr<NavigationEntryImpl> entry) { 436 scoped_ptr<NavigationEntryImpl> entry) {
436 // When navigating to a new page, we don't know for sure if we will actually 437 // When navigating to a new page, we don't know for sure if we will actually
437 // end up leaving the current page. The new page load could for example 438 // end up leaving the current page. The new page load could for example
438 // result in a download or a 'no content' response (e.g., a mailto: URL). 439 // result in a download or a 'no content' response (e.g., a mailto: URL).
439 SetPendingEntry(entry.Pass()); 440 SetPendingEntry(entry.Pass());
440 NavigateToPendingEntry(NO_RELOAD); 441 NavigateToPendingEntry(NO_RELOAD);
441 } 442 }
442 443
443 void NavigationControllerImpl::SetPendingEntry( 444 void NavigationControllerImpl::SetPendingEntry(
444 scoped_ptr<NavigationEntryImpl> entry) { 445 scoped_ptr<NavigationEntryImpl> entry) {
445 DiscardNonCommittedEntriesInternal(); 446 DiscardNonCommittedEntriesInternal();
446 pending_entry_ = entry.release(); 447 pending_entry_ = entry.release();
447 NotificationService::current()->Notify( 448 NotificationService::current()->Notify(
448 NOTIFICATION_NAV_ENTRY_PENDING, 449 NOTIFICATION_NAV_ENTRY_PENDING,
449 Source<NavigationController>(this), 450 Source<NavigationController>(this),
450 Details<NavigationEntry>(pending_entry_)); 451 Details<NavigationEntry>(pending_entry_));
451 } 452 }
452 453
453 NavigationEntryImpl* NavigationControllerImpl::GetActiveEntry() const { 454 NavigationEntryImpl* NavigationControllerImpl::GetActiveEntry() const {
454 if (transient_entry_index_ != -1) 455 if (transient_entry_index_ != -1)
455 return entries_[transient_entry_index_]; 456 return entries_[transient_entry_index_].get();
456 if (pending_entry_) 457 if (pending_entry_)
457 return pending_entry_; 458 return pending_entry_;
458 return GetLastCommittedEntry(); 459 return GetLastCommittedEntry();
459 } 460 }
460 461
461 NavigationEntryImpl* NavigationControllerImpl::GetVisibleEntry() const { 462 NavigationEntryImpl* NavigationControllerImpl::GetVisibleEntry() const {
462 if (transient_entry_index_ != -1) 463 if (transient_entry_index_ != -1)
463 return entries_[transient_entry_index_]; 464 return entries_[transient_entry_index_].get();
464 // The pending entry is safe to return for new (non-history), browser- 465 // The pending entry is safe to return for new (non-history), browser-
465 // initiated navigations. Most renderer-initiated navigations should not 466 // initiated navigations. Most renderer-initiated navigations should not
466 // show the pending entry, to prevent URL spoof attacks. 467 // show the pending entry, to prevent URL spoof attacks.
467 // 468 //
468 // We make an exception for renderer-initiated navigations in new tabs, as 469 // We make an exception for renderer-initiated navigations in new tabs, as
469 // long as no other page has tried to access the initial empty document in 470 // long as no other page has tried to access the initial empty document in
470 // the new tab. If another page modifies this blank page, a URL spoof is 471 // the new tab. If another page modifies this blank page, a URL spoof is
471 // possible, so we must stop showing the pending entry. 472 // possible, so we must stop showing the pending entry.
472 bool safe_to_show_pending = 473 bool safe_to_show_pending =
473 pending_entry_ && 474 pending_entry_ &&
(...skipping 21 matching lines...) Expand all
495 if (transient_entry_index_ != -1) 496 if (transient_entry_index_ != -1)
496 return transient_entry_index_; 497 return transient_entry_index_;
497 if (pending_entry_index_ != -1) 498 if (pending_entry_index_ != -1)
498 return pending_entry_index_; 499 return pending_entry_index_;
499 return last_committed_entry_index_; 500 return last_committed_entry_index_;
500 } 501 }
501 502
502 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const { 503 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const {
503 if (last_committed_entry_index_ == -1) 504 if (last_committed_entry_index_ == -1)
504 return NULL; 505 return NULL;
505 return entries_[last_committed_entry_index_]; 506 return entries_[last_committed_entry_index_].get();
506 } 507 }
507 508
508 bool NavigationControllerImpl::CanViewSource() const { 509 bool NavigationControllerImpl::CanViewSource() const {
509 const std::string& mime_type = delegate_->GetContentsMimeType(); 510 const std::string& mime_type = delegate_->GetContentsMimeType();
510 bool is_viewable_mime_type = 511 bool is_viewable_mime_type =
511 mime_util::IsSupportedNonImageMimeType(mime_type) && 512 mime_util::IsSupportedNonImageMimeType(mime_type) &&
512 !media::IsSupportedMediaMimeType(mime_type); 513 !media::IsSupportedMediaMimeType(mime_type);
513 NavigationEntry* visible_entry = GetVisibleEntry(); 514 NavigationEntry* visible_entry = GetVisibleEntry();
514 return visible_entry && !visible_entry->IsViewSourceMode() && 515 return visible_entry && !visible_entry->IsViewSourceMode() &&
515 is_viewable_mime_type && !delegate_->GetInterstitialPage(); 516 is_viewable_mime_type && !delegate_->GetInterstitialPage();
516 } 517 }
517 518
518 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { 519 int NavigationControllerImpl::GetLastCommittedEntryIndex() const {
519 return last_committed_entry_index_; 520 return last_committed_entry_index_;
520 } 521 }
521 522
522 int NavigationControllerImpl::GetEntryCount() const { 523 int NavigationControllerImpl::GetEntryCount() const {
523 DCHECK(entries_.size() <= max_entry_count()); 524 DCHECK(entries_.size() <= max_entry_count());
524 return static_cast<int>(entries_.size()); 525 return static_cast<int>(entries_.size());
525 } 526 }
526 527
527 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex( 528 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex(
528 int index) const { 529 int index) const {
529 if (index < 0 || index >= GetEntryCount()) 530 if (index < 0 || index >= GetEntryCount())
530 return nullptr; 531 return nullptr;
531 532
532 return entries_[index]; 533 return entries_[index].get();
533 } 534 }
534 535
535 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtOffset( 536 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtOffset(
536 int offset) const { 537 int offset) const {
537 return GetEntryAtIndex(GetIndexForOffset(offset)); 538 return GetEntryAtIndex(GetIndexForOffset(offset));
538 } 539 }
539 540
540 int NavigationControllerImpl::GetIndexForOffset(int offset) const { 541 int NavigationControllerImpl::GetIndexForOffset(int offset) const {
541 return GetCurrentEntryIndex() + offset; 542 return GetCurrentEntryIndex() + offset;
542 } 543 }
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 } 1337 }
1337 } 1338 }
1338 1339
1339 // We do not need to discard the pending entry in this case, since we will 1340 // We do not need to discard the pending entry in this case, since we will
1340 // not generate commit notifications for this auto-subframe navigation. 1341 // not generate commit notifications for this auto-subframe navigation.
1341 return false; 1342 return false;
1342 } 1343 }
1343 1344
1344 int NavigationControllerImpl::GetIndexOfEntry( 1345 int NavigationControllerImpl::GetIndexOfEntry(
1345 const NavigationEntryImpl* entry) const { 1346 const NavigationEntryImpl* entry) const {
1346 const NavigationEntries::const_iterator i(std::find( 1347 for (size_t i = 0; i < entries_.size(); ++i) {
1347 entries_.begin(), 1348 if (entries_[i].get() == entry)
1348 entries_.end(), 1349 return i;
ncarter (slow) 2015/11/12 23:56:58 Huh, I'm surprised this works -- I didn't think im
1349 entry)); 1350 }
1350 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin()); 1351 return -1;
1351 } 1352 }
1352 1353
1353 // There are two general cases where a navigation is "in page": 1354 // There are two general cases where a navigation is "in page":
1354 // 1. A fragment navigation, in which the url is kept the same except for the 1355 // 1. A fragment navigation, in which the url is kept the same except for the
1355 // reference fragment. 1356 // reference fragment.
1356 // 2. A history API navigation (pushState and replaceState). This case is 1357 // 2. A history API navigation (pushState and replaceState). This case is
1357 // always in-page, but the urls are not guaranteed to match excluding the 1358 // always in-page, but the urls are not guaranteed to match excluding the
1358 // fragment. The relevant spec allows pushState/replaceState to any URL on 1359 // fragment. The relevant spec allows pushState/replaceState to any URL on
1359 // the same origin. 1360 // the same origin.
1360 // However, due to reloads, even identical urls are *not* guaranteed to be 1361 // However, due to reloads, even identical urls are *not* guaranteed to be
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 entry->set_unique_id(pending_entry_->GetUniqueID()); 1660 entry->set_unique_id(pending_entry_->GetUniqueID());
1660 1661
1661 DiscardNonCommittedEntriesInternal(); 1662 DiscardNonCommittedEntriesInternal();
1662 1663
1663 int current_size = static_cast<int>(entries_.size()); 1664 int current_size = static_cast<int>(entries_.size());
1664 1665
1665 // When replacing, don't prune the forward history. 1666 // When replacing, don't prune the forward history.
1666 if (replace && current_size > 0) { 1667 if (replace && current_size > 0) {
1667 int32 page_id = entry->GetPageID(); 1668 int32 page_id = entry->GetPageID();
1668 1669
1669 // ScopedVectors don't automatically delete the replaced value, so make sure 1670 entries_[last_committed_entry_index_] = entry.Pass();
1670 // the previous value gets deleted.
1671 scoped_ptr<NavigationEntryImpl> old_entry(
1672 entries_[last_committed_entry_index_]);
1673 entries_[last_committed_entry_index_] = entry.release();
1674 1671
1675 // This is a new page ID, so we need everybody to know about it. 1672 // This is a new page ID, so we need everybody to know about it.
1676 delegate_->UpdateMaxPageID(page_id); 1673 delegate_->UpdateMaxPageID(page_id);
1677 return; 1674 return;
1678 } 1675 }
1679 1676
1680 // We shouldn't see replace == true when there's no committed entries. 1677 // We shouldn't see replace == true when there's no committed entries.
1681 DCHECK(!replace); 1678 DCHECK(!replace);
1682 1679
1683 if (current_size > 0) { 1680 if (current_size > 0) {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 // navigation to succeed. The interstitial will stay visible until the 1742 // navigation to succeed. The interstitial will stay visible until the
1746 // resulting DidNavigate. 1743 // resulting DidNavigate.
1747 if (delegate_->GetInterstitialPage()) { 1744 if (delegate_->GetInterstitialPage()) {
1748 static_cast<InterstitialPageImpl*>(delegate_->GetInterstitialPage())-> 1745 static_cast<InterstitialPageImpl*>(delegate_->GetInterstitialPage())->
1749 CancelForNavigation(); 1746 CancelForNavigation();
1750 } 1747 }
1751 1748
1752 // For session history navigations only the pending_entry_index_ is set. 1749 // For session history navigations only the pending_entry_index_ is set.
1753 if (!pending_entry_) { 1750 if (!pending_entry_) {
1754 CHECK_NE(pending_entry_index_, -1); 1751 CHECK_NE(pending_entry_index_, -1);
1755 pending_entry_ = entries_[pending_entry_index_]; 1752 pending_entry_ = entries_[pending_entry_index_].get();
1756 } 1753 }
1757 1754
1758 // Any renderer-side debug URLs or javascript: URLs should be ignored if the 1755 // Any renderer-side debug URLs or javascript: URLs should be ignored if the
1759 // renderer process is not live, unless it is the initial navigation of the 1756 // renderer process is not live, unless it is the initial navigation of the
1760 // tab. 1757 // tab.
1761 if (IsRendererDebugURL(pending_entry_->GetURL())) { 1758 if (IsRendererDebugURL(pending_entry_->GetURL())) {
1762 // TODO(creis): Find the RVH for the correct frame. 1759 // TODO(creis): Find the RVH for the correct frame.
1763 if (!delegate_->GetRenderViewHost()->IsRenderViewLive() && 1760 if (!delegate_->GetRenderViewHost()->IsRenderViewLive() &&
1764 !IsInitialNavigation()) { 1761 !IsInitialNavigation()) {
1765 DiscardNonCommittedEntries(); 1762 DiscardNonCommittedEntries();
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1992 for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) { 1989 for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) {
1993 if (entries_[i]->GetUniqueID() == nav_entry_id) 1990 if (entries_[i]->GetUniqueID() == nav_entry_id)
1994 return i; 1991 return i;
1995 } 1992 }
1996 return -1; 1993 return -1;
1997 } 1994 }
1998 1995
1999 NavigationEntryImpl* NavigationControllerImpl::GetTransientEntry() const { 1996 NavigationEntryImpl* NavigationControllerImpl::GetTransientEntry() const {
2000 if (transient_entry_index_ == -1) 1997 if (transient_entry_index_ == -1)
2001 return NULL; 1998 return NULL;
2002 return entries_[transient_entry_index_]; 1999 return entries_[transient_entry_index_].get();
2003 } 2000 }
2004 2001
2005 void NavigationControllerImpl::SetTransientEntry( 2002 void NavigationControllerImpl::SetTransientEntry(
2006 scoped_ptr<NavigationEntry> entry) { 2003 scoped_ptr<NavigationEntry> entry) {
2007 // Discard any current transient entry, we can only have one at a time. 2004 // Discard any current transient entry, we can only have one at a time.
2008 int index = 0; 2005 int index = 0;
2009 if (last_committed_entry_index_ != -1) 2006 if (last_committed_entry_index_ != -1)
2010 index = last_committed_entry_index_ + 1; 2007 index = last_committed_entry_index_ + 1;
2011 DiscardTransientEntry(); 2008 DiscardTransientEntry();
2012 entries_.insert(entries_.begin() + index, 2009 entries_.insert(entries_.begin() + index,
2013 NavigationEntryImpl::FromNavigationEntry(entry.release())); 2010 NavigationEntryImpl::FromNavigationEntry(entry.Pass()));
2014 transient_entry_index_ = index; 2011 transient_entry_index_ = index;
2015 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); 2012 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL);
2016 } 2013 }
2017 2014
2018 void NavigationControllerImpl::InsertEntriesFrom( 2015 void NavigationControllerImpl::InsertEntriesFrom(
2019 const NavigationControllerImpl& source, 2016 const NavigationControllerImpl& source,
2020 int max_index) { 2017 int max_index) {
2021 DCHECK_LE(max_index, source.GetEntryCount()); 2018 DCHECK_LE(max_index, source.GetEntryCount());
2022 size_t insert_index = 0; 2019 size_t insert_index = 0;
2023 for (int i = 0; i < max_index; i++) { 2020 for (int i = 0; i < max_index; i++) {
2024 // When cloning a tab, copy all entries except interstitial pages. 2021 // When cloning a tab, copy all entries except interstitial pages.
2025 if (source.entries_[i]->GetPageType() != PAGE_TYPE_INTERSTITIAL) { 2022 if (source.entries_[i]->GetPageType() != PAGE_TYPE_INTERSTITIAL) {
2026 // TODO(creis): Once we start sharing FrameNavigationEntries between 2023 // TODO(creis): Once we start sharing FrameNavigationEntries between
2027 // NavigationEntries, it will not be safe to share them with another tab. 2024 // NavigationEntries, it will not be safe to share them with another tab.
2028 // Must have a version of Clone that recreates them. 2025 // Must have a version of Clone that recreates them.
2029 entries_.insert(entries_.begin() + insert_index++, 2026 entries_.insert(entries_.begin() + insert_index++,
2030 source.entries_[i]->Clone().Pass()); 2027 source.entries_[i]->Clone().Pass());
2031 } 2028 }
2032 } 2029 }
2033 } 2030 }
2034 2031
2035 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2032 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2036 const base::Callback<base::Time()>& get_timestamp_callback) { 2033 const base::Callback<base::Time()>& get_timestamp_callback) {
2037 get_timestamp_callback_ = get_timestamp_callback; 2034 get_timestamp_callback_ = get_timestamp_callback;
2038 } 2035 }
2039 2036
2040 } // namespace content 2037 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698