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

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: aw 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;
ncarter (slow) 2015/11/12 18:10:40 Could reserve the additional capacity here too (en
Avi (use Gerrit) 2015/11/12 19:13:04 entries_ is supposed to be empty (and is DCHECKed)
278 for (size_t i = 0; i < entries->size(); ++i) { 278 for (auto& entry : *entries) {
279 NavigationEntryImpl* entry = 279 scoped_ptr<NavigationEntryImpl> entry_impl(
280 NavigationEntryImpl::FromNavigationEntry((*entries)[i]); 280 NavigationEntryImpl::FromNavigationEntry(entry.release()));
ncarter (slow) 2015/11/12 18:10:40 Could use the scoped_ptr variant of ::FromNavigati
Avi (use Gerrit) 2015/11/12 19:13:04 WHY DID I FORGET THAT EXISTED
281 entries_.push_back(entry); 281 entries_.push_back(entry_impl.Pass());
282 } 282 }
283 entries->weak_clear(); 283
284 // At this point, the |entries| is full of empty scoped_ptrs, so it can be
285 // cleared out safely.
286 entries->clear();
284 287
285 // And finish the restore. 288 // And finish the restore.
286 FinishRestore(selected_navigation, type); 289 FinishRestore(selected_navigation, type);
287 } 290 }
288 291
289 void NavigationControllerImpl::Reload(bool check_for_repost) { 292 void NavigationControllerImpl::Reload(bool check_for_repost) {
290 ReloadInternal(check_for_repost, RELOAD); 293 ReloadInternal(check_for_repost, RELOAD);
291 } 294 }
292 void NavigationControllerImpl::ReloadIgnoringCache(bool check_for_repost) { 295 void NavigationControllerImpl::ReloadIgnoringCache(bool check_for_repost) {
293 ReloadInternal(check_for_repost, RELOAD_IGNORING_CACHE); 296 ReloadInternal(check_for_repost, RELOAD_IGNORING_CACHE);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 bool NavigationControllerImpl::IsInitialBlankNavigation() const { 418 bool NavigationControllerImpl::IsInitialBlankNavigation() const {
416 // TODO(creis): Once we create a NavigationEntry for the initial blank page, 419 // 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 420 // we'll need to check for entry count 1 and restore_type RESTORE_NONE (to
418 // exclude the cloned tab case). 421 // exclude the cloned tab case).
419 return IsInitialNavigation() && GetEntryCount() == 0; 422 return IsInitialNavigation() && GetEntryCount() == 0;
420 } 423 }
421 424
422 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID( 425 NavigationEntryImpl* NavigationControllerImpl::GetEntryWithPageID(
423 SiteInstance* instance, int32 page_id) const { 426 SiteInstance* instance, int32 page_id) const {
424 int index = GetEntryIndexWithPageID(instance, page_id); 427 int index = GetEntryIndexWithPageID(instance, page_id);
425 return (index != -1) ? entries_[index] : nullptr; 428 return (index != -1) ? entries_[index].get() : nullptr;
426 } 429 }
427 430
428 NavigationEntryImpl* 431 NavigationEntryImpl*
429 NavigationControllerImpl::GetEntryWithUniqueID(int nav_entry_id) const { 432 NavigationControllerImpl::GetEntryWithUniqueID(int nav_entry_id) const {
430 int index = GetEntryIndexWithUniqueID(nav_entry_id); 433 int index = GetEntryIndexWithUniqueID(nav_entry_id);
431 return (index != -1) ? entries_[index] : nullptr; 434 return (index != -1) ? entries_[index].get() : nullptr;
432 } 435 }
433 436
434 void NavigationControllerImpl::LoadEntry( 437 void NavigationControllerImpl::LoadEntry(
435 scoped_ptr<NavigationEntryImpl> entry) { 438 scoped_ptr<NavigationEntryImpl> entry) {
436 // When navigating to a new page, we don't know for sure if we will actually 439 // 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 440 // 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). 441 // result in a download or a 'no content' response (e.g., a mailto: URL).
439 SetPendingEntry(entry.Pass()); 442 SetPendingEntry(entry.Pass());
440 NavigateToPendingEntry(NO_RELOAD); 443 NavigateToPendingEntry(NO_RELOAD);
441 } 444 }
442 445
443 void NavigationControllerImpl::SetPendingEntry( 446 void NavigationControllerImpl::SetPendingEntry(
444 scoped_ptr<NavigationEntryImpl> entry) { 447 scoped_ptr<NavigationEntryImpl> entry) {
445 DiscardNonCommittedEntriesInternal(); 448 DiscardNonCommittedEntriesInternal();
446 pending_entry_ = entry.release(); 449 pending_entry_ = entry.release();
447 NotificationService::current()->Notify( 450 NotificationService::current()->Notify(
448 NOTIFICATION_NAV_ENTRY_PENDING, 451 NOTIFICATION_NAV_ENTRY_PENDING,
449 Source<NavigationController>(this), 452 Source<NavigationController>(this),
450 Details<NavigationEntry>(pending_entry_)); 453 Details<NavigationEntry>(pending_entry_));
451 } 454 }
452 455
453 NavigationEntryImpl* NavigationControllerImpl::GetActiveEntry() const { 456 NavigationEntryImpl* NavigationControllerImpl::GetActiveEntry() const {
454 if (transient_entry_index_ != -1) 457 if (transient_entry_index_ != -1)
455 return entries_[transient_entry_index_]; 458 return entries_[transient_entry_index_].get();
456 if (pending_entry_) 459 if (pending_entry_)
457 return pending_entry_; 460 return pending_entry_;
458 return GetLastCommittedEntry(); 461 return GetLastCommittedEntry();
459 } 462 }
460 463
461 NavigationEntryImpl* NavigationControllerImpl::GetVisibleEntry() const { 464 NavigationEntryImpl* NavigationControllerImpl::GetVisibleEntry() const {
462 if (transient_entry_index_ != -1) 465 if (transient_entry_index_ != -1)
463 return entries_[transient_entry_index_]; 466 return entries_[transient_entry_index_].get();
464 // The pending entry is safe to return for new (non-history), browser- 467 // The pending entry is safe to return for new (non-history), browser-
465 // initiated navigations. Most renderer-initiated navigations should not 468 // initiated navigations. Most renderer-initiated navigations should not
466 // show the pending entry, to prevent URL spoof attacks. 469 // show the pending entry, to prevent URL spoof attacks.
467 // 470 //
468 // We make an exception for renderer-initiated navigations in new tabs, as 471 // 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 472 // 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 473 // the new tab. If another page modifies this blank page, a URL spoof is
471 // possible, so we must stop showing the pending entry. 474 // possible, so we must stop showing the pending entry.
472 bool safe_to_show_pending = 475 bool safe_to_show_pending =
473 pending_entry_ && 476 pending_entry_ &&
(...skipping 21 matching lines...) Expand all
495 if (transient_entry_index_ != -1) 498 if (transient_entry_index_ != -1)
496 return transient_entry_index_; 499 return transient_entry_index_;
497 if (pending_entry_index_ != -1) 500 if (pending_entry_index_ != -1)
498 return pending_entry_index_; 501 return pending_entry_index_;
499 return last_committed_entry_index_; 502 return last_committed_entry_index_;
500 } 503 }
501 504
502 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const { 505 NavigationEntryImpl* NavigationControllerImpl::GetLastCommittedEntry() const {
503 if (last_committed_entry_index_ == -1) 506 if (last_committed_entry_index_ == -1)
504 return NULL; 507 return NULL;
505 return entries_[last_committed_entry_index_]; 508 return entries_[last_committed_entry_index_].get();
506 } 509 }
507 510
508 bool NavigationControllerImpl::CanViewSource() const { 511 bool NavigationControllerImpl::CanViewSource() const {
509 const std::string& mime_type = delegate_->GetContentsMimeType(); 512 const std::string& mime_type = delegate_->GetContentsMimeType();
510 bool is_viewable_mime_type = 513 bool is_viewable_mime_type =
511 mime_util::IsSupportedNonImageMimeType(mime_type) && 514 mime_util::IsSupportedNonImageMimeType(mime_type) &&
512 !media::IsSupportedMediaMimeType(mime_type); 515 !media::IsSupportedMediaMimeType(mime_type);
513 NavigationEntry* visible_entry = GetVisibleEntry(); 516 NavigationEntry* visible_entry = GetVisibleEntry();
514 return visible_entry && !visible_entry->IsViewSourceMode() && 517 return visible_entry && !visible_entry->IsViewSourceMode() &&
515 is_viewable_mime_type && !delegate_->GetInterstitialPage(); 518 is_viewable_mime_type && !delegate_->GetInterstitialPage();
516 } 519 }
517 520
518 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { 521 int NavigationControllerImpl::GetLastCommittedEntryIndex() const {
519 return last_committed_entry_index_; 522 return last_committed_entry_index_;
520 } 523 }
521 524
522 int NavigationControllerImpl::GetEntryCount() const { 525 int NavigationControllerImpl::GetEntryCount() const {
523 DCHECK(entries_.size() <= max_entry_count()); 526 DCHECK(entries_.size() <= max_entry_count());
524 return static_cast<int>(entries_.size()); 527 return static_cast<int>(entries_.size());
525 } 528 }
526 529
527 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex( 530 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex(
528 int index) const { 531 int index) const {
529 if (index < 0 || index >= GetEntryCount()) 532 if (index < 0 || index >= GetEntryCount())
530 return nullptr; 533 return nullptr;
531 534
532 return entries_[index]; 535 return entries_[index].get();
533 } 536 }
534 537
535 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtOffset( 538 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtOffset(
536 int offset) const { 539 int offset) const {
537 return GetEntryAtIndex(GetIndexForOffset(offset)); 540 return GetEntryAtIndex(GetIndexForOffset(offset));
538 } 541 }
539 542
540 int NavigationControllerImpl::GetIndexForOffset(int offset) const { 543 int NavigationControllerImpl::GetIndexForOffset(int offset) const {
541 return GetCurrentEntryIndex() + offset; 544 return GetCurrentEntryIndex() + offset;
542 } 545 }
(...skipping 793 matching lines...) Expand 10 before | Expand all | Expand 10 after
1336 } 1339 }
1337 } 1340 }
1338 1341
1339 // We do not need to discard the pending entry in this case, since we will 1342 // 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. 1343 // not generate commit notifications for this auto-subframe navigation.
1341 return false; 1344 return false;
1342 } 1345 }
1343 1346
1344 int NavigationControllerImpl::GetIndexOfEntry( 1347 int NavigationControllerImpl::GetIndexOfEntry(
1345 const NavigationEntryImpl* entry) const { 1348 const NavigationEntryImpl* entry) const {
1346 const NavigationEntries::const_iterator i(std::find( 1349 const auto i =
1347 entries_.begin(), 1350 std::find_if(entries_.begin(), entries_.end(),
1348 entries_.end(), 1351 [entry](const scoped_ptr<NavigationEntryImpl>& item) {
1349 entry)); 1352 return item.get() == entry;
1353 });
ncarter (slow) 2015/11/12 18:10:40 A dumb for loop here (using an int or size_t) woul
Avi (use Gerrit) 2015/11/12 19:13:04 Done.
1350 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin()); 1354 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin());
1351 } 1355 }
1352 1356
1353 // There are two general cases where a navigation is "in page": 1357 // 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 1358 // 1. A fragment navigation, in which the url is kept the same except for the
1355 // reference fragment. 1359 // reference fragment.
1356 // 2. A history API navigation (pushState and replaceState). This case is 1360 // 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 1361 // 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 1362 // fragment. The relevant spec allows pushState/replaceState to any URL on
1359 // the same origin. 1363 // the same origin.
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1659 entry->set_unique_id(pending_entry_->GetUniqueID()); 1663 entry->set_unique_id(pending_entry_->GetUniqueID());
1660 1664
1661 DiscardNonCommittedEntriesInternal(); 1665 DiscardNonCommittedEntriesInternal();
1662 1666
1663 int current_size = static_cast<int>(entries_.size()); 1667 int current_size = static_cast<int>(entries_.size());
1664 1668
1665 // When replacing, don't prune the forward history. 1669 // When replacing, don't prune the forward history.
1666 if (replace && current_size > 0) { 1670 if (replace && current_size > 0) {
1667 int32 page_id = entry->GetPageID(); 1671 int32 page_id = entry->GetPageID();
1668 1672
1669 // ScopedVectors don't automatically delete the replaced value, so make sure 1673 entries_[last_committed_entry_index_] = entry.Pass();
ncarter (slow) 2015/11/12 18:10:40 Good riddance.
Avi (use Gerrit) 2015/11/12 19:13:04 Acknowledged.
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 1674
1675 // This is a new page ID, so we need everybody to know about it. 1675 // This is a new page ID, so we need everybody to know about it.
1676 delegate_->UpdateMaxPageID(page_id); 1676 delegate_->UpdateMaxPageID(page_id);
1677 return; 1677 return;
1678 } 1678 }
1679 1679
1680 // We shouldn't see replace == true when there's no committed entries. 1680 // We shouldn't see replace == true when there's no committed entries.
1681 DCHECK(!replace); 1681 DCHECK(!replace);
1682 1682
1683 if (current_size > 0) { 1683 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 1745 // navigation to succeed. The interstitial will stay visible until the
1746 // resulting DidNavigate. 1746 // resulting DidNavigate.
1747 if (delegate_->GetInterstitialPage()) { 1747 if (delegate_->GetInterstitialPage()) {
1748 static_cast<InterstitialPageImpl*>(delegate_->GetInterstitialPage())-> 1748 static_cast<InterstitialPageImpl*>(delegate_->GetInterstitialPage())->
1749 CancelForNavigation(); 1749 CancelForNavigation();
1750 } 1750 }
1751 1751
1752 // For session history navigations only the pending_entry_index_ is set. 1752 // For session history navigations only the pending_entry_index_ is set.
1753 if (!pending_entry_) { 1753 if (!pending_entry_) {
1754 CHECK_NE(pending_entry_index_, -1); 1754 CHECK_NE(pending_entry_index_, -1);
1755 pending_entry_ = entries_[pending_entry_index_]; 1755 pending_entry_ = entries_[pending_entry_index_].get();
1756 } 1756 }
1757 1757
1758 // Any renderer-side debug URLs or javascript: URLs should be ignored if the 1758 // 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 1759 // renderer process is not live, unless it is the initial navigation of the
1760 // tab. 1760 // tab.
1761 if (IsRendererDebugURL(pending_entry_->GetURL())) { 1761 if (IsRendererDebugURL(pending_entry_->GetURL())) {
1762 // TODO(creis): Find the RVH for the correct frame. 1762 // TODO(creis): Find the RVH for the correct frame.
1763 if (!delegate_->GetRenderViewHost()->IsRenderViewLive() && 1763 if (!delegate_->GetRenderViewHost()->IsRenderViewLive() &&
1764 !IsInitialNavigation()) { 1764 !IsInitialNavigation()) {
1765 DiscardNonCommittedEntries(); 1765 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) { 1992 for (int i = static_cast<int>(entries_.size()) - 1; i >= 0; --i) {
1993 if (entries_[i]->GetUniqueID() == nav_entry_id) 1993 if (entries_[i]->GetUniqueID() == nav_entry_id)
1994 return i; 1994 return i;
1995 } 1995 }
1996 return -1; 1996 return -1;
1997 } 1997 }
1998 1998
1999 NavigationEntryImpl* NavigationControllerImpl::GetTransientEntry() const { 1999 NavigationEntryImpl* NavigationControllerImpl::GetTransientEntry() const {
2000 if (transient_entry_index_ == -1) 2000 if (transient_entry_index_ == -1)
2001 return NULL; 2001 return NULL;
2002 return entries_[transient_entry_index_]; 2002 return entries_[transient_entry_index_].get();
2003 } 2003 }
2004 2004
2005 void NavigationControllerImpl::SetTransientEntry( 2005 void NavigationControllerImpl::SetTransientEntry(
2006 scoped_ptr<NavigationEntry> entry) { 2006 scoped_ptr<NavigationEntry> entry) {
2007 // Discard any current transient entry, we can only have one at a time. 2007 // Discard any current transient entry, we can only have one at a time.
2008 int index = 0; 2008 int index = 0;
2009 if (last_committed_entry_index_ != -1) 2009 if (last_committed_entry_index_ != -1)
2010 index = last_committed_entry_index_ + 1; 2010 index = last_committed_entry_index_ + 1;
2011 DiscardTransientEntry(); 2011 DiscardTransientEntry();
2012 entries_.insert(entries_.begin() + index, 2012 scoped_ptr<NavigationEntryImpl> entry_impl(
2013 NavigationEntryImpl::FromNavigationEntry(entry.release())); 2013 NavigationEntryImpl::FromNavigationEntry(entry.release()));
ncarter (slow) 2015/11/12 18:10:40 .Pass() would also work here, which I think would
Avi (use Gerrit) 2015/11/12 19:13:04 Done.
2014 entries_.insert(entries_.begin() + index, entry_impl.Pass());
2014 transient_entry_index_ = index; 2015 transient_entry_index_ = index;
2015 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); 2016 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL);
2016 } 2017 }
2017 2018
2018 void NavigationControllerImpl::InsertEntriesFrom( 2019 void NavigationControllerImpl::InsertEntriesFrom(
2019 const NavigationControllerImpl& source, 2020 const NavigationControllerImpl& source,
2020 int max_index) { 2021 int max_index) {
2021 DCHECK_LE(max_index, source.GetEntryCount()); 2022 DCHECK_LE(max_index, source.GetEntryCount());
2022 size_t insert_index = 0; 2023 size_t insert_index = 0;
2023 for (int i = 0; i < max_index; i++) { 2024 for (int i = 0; i < max_index; i++) {
2024 // When cloning a tab, copy all entries except interstitial pages. 2025 // When cloning a tab, copy all entries except interstitial pages.
2025 if (source.entries_[i]->GetPageType() != PAGE_TYPE_INTERSTITIAL) { 2026 if (source.entries_[i]->GetPageType() != PAGE_TYPE_INTERSTITIAL) {
2026 // TODO(creis): Once we start sharing FrameNavigationEntries between 2027 // TODO(creis): Once we start sharing FrameNavigationEntries between
2027 // NavigationEntries, it will not be safe to share them with another tab. 2028 // NavigationEntries, it will not be safe to share them with another tab.
2028 // Must have a version of Clone that recreates them. 2029 // Must have a version of Clone that recreates them.
2029 entries_.insert(entries_.begin() + insert_index++, 2030 entries_.insert(entries_.begin() + insert_index++,
2030 source.entries_[i]->Clone().Pass()); 2031 source.entries_[i]->Clone().Pass());
2031 } 2032 }
2032 } 2033 }
2033 } 2034 }
2034 2035
2035 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 2036 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
2036 const base::Callback<base::Time()>& get_timestamp_callback) { 2037 const base::Callback<base::Time()>& get_timestamp_callback) {
2037 get_timestamp_callback_ = get_timestamp_callback; 2038 get_timestamp_callback_ = get_timestamp_callback;
2038 } 2039 }
2039 2040
2040 } // namespace content 2041 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698