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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 const std::string& mime_type = delegate_->GetContentsMimeType(); | 527 const std::string& mime_type = delegate_->GetContentsMimeType(); |
528 bool is_viewable_mime_type = | 528 bool is_viewable_mime_type = |
529 mime_util::IsSupportedNonImageMimeType(mime_type) && | 529 mime_util::IsSupportedNonImageMimeType(mime_type) && |
530 !media::IsSupportedMediaMimeType(mime_type); | 530 !media::IsSupportedMediaMimeType(mime_type); |
531 NavigationEntry* visible_entry = GetVisibleEntry(); | 531 NavigationEntry* visible_entry = GetVisibleEntry(); |
532 return visible_entry && !visible_entry->IsViewSourceMode() && | 532 return visible_entry && !visible_entry->IsViewSourceMode() && |
533 is_viewable_mime_type && !delegate_->GetInterstitialPage(); | 533 is_viewable_mime_type && !delegate_->GetInterstitialPage(); |
534 } | 534 } |
535 | 535 |
536 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { | 536 int NavigationControllerImpl::GetLastCommittedEntryIndex() const { |
| 537 // The last committed entry index must always be less than the number of |
| 538 // entries. It should be -1 iff there are no entries. |
| 539 DCHECK_LT(last_committed_entry_index_, GetEntryCount()); |
| 540 DCHECK_EQ(last_committed_entry_index_ == -1, GetEntryCount() == 0); |
537 return last_committed_entry_index_; | 541 return last_committed_entry_index_; |
538 } | 542 } |
539 | 543 |
540 int NavigationControllerImpl::GetEntryCount() const { | 544 int NavigationControllerImpl::GetEntryCount() const { |
541 DCHECK(entries_.size() <= max_entry_count()); | 545 DCHECK_LE(entries_.size(), max_entry_count()); |
542 return static_cast<int>(entries_.size()); | 546 return static_cast<int>(entries_.size()); |
543 } | 547 } |
544 | 548 |
545 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex( | 549 NavigationEntryImpl* NavigationControllerImpl::GetEntryAtIndex( |
546 int index) const { | 550 int index) const { |
547 if (index < 0 || index >= GetEntryCount()) | 551 if (index < 0 || index >= GetEntryCount()) |
548 return nullptr; | 552 return nullptr; |
549 | 553 |
550 return entries_[index].get(); | 554 return entries_[index].get(); |
551 } | 555 } |
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 DiscardNonCommittedEntriesInternal(); | 1723 DiscardNonCommittedEntriesInternal(); |
1720 | 1724 |
1721 // If there was a transient entry, invalidate everything so the new active | 1725 // If there was a transient entry, invalidate everything so the new active |
1722 // entry state is shown. | 1726 // entry state is shown. |
1723 if (transient) { | 1727 if (transient) { |
1724 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); | 1728 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_ALL); |
1725 } | 1729 } |
1726 } | 1730 } |
1727 | 1731 |
1728 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const { | 1732 NavigationEntryImpl* NavigationControllerImpl::GetPendingEntry() const { |
| 1733 // If there is no pending_entry_, there should be no pending_entry_index_. |
| 1734 DCHECK(pending_entry_ || pending_entry_index_ == -1); |
| 1735 |
| 1736 // If there is a pending_entry_index_, then pending_entry_ must be the entry |
| 1737 // at that index. |
| 1738 DCHECK(pending_entry_index_ == -1 || |
| 1739 pending_entry_ == GetEntryAtIndex(pending_entry_index_)); |
| 1740 |
1729 return pending_entry_; | 1741 return pending_entry_; |
1730 } | 1742 } |
1731 | 1743 |
1732 int NavigationControllerImpl::GetPendingEntryIndex() const { | 1744 int NavigationControllerImpl::GetPendingEntryIndex() const { |
| 1745 // The pending entry index must always be less than the number of entries. |
| 1746 // If there are no entries, it must be exactly -1. |
| 1747 DCHECK_LT(pending_entry_index_, GetEntryCount()); |
| 1748 DCHECK(GetEntryCount() != 0 || pending_entry_index_ == -1); |
1733 return pending_entry_index_; | 1749 return pending_entry_index_; |
1734 } | 1750 } |
1735 | 1751 |
1736 void NavigationControllerImpl::InsertOrReplaceEntry( | 1752 void NavigationControllerImpl::InsertOrReplaceEntry( |
1737 std::unique_ptr<NavigationEntryImpl> entry, | 1753 std::unique_ptr<NavigationEntryImpl> entry, |
1738 bool replace) { | 1754 bool replace) { |
1739 DCHECK(!ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), | 1755 DCHECK(!ui::PageTransitionCoreTypeIs(entry->GetTransitionType(), |
1740 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); | 1756 ui::PAGE_TRANSITION_AUTO_SUBFRAME)); |
1741 | 1757 |
1742 // If the pending_entry_index_ is -1, the navigation was to a new page, and we | 1758 // If the pending_entry_index_ is -1, the navigation was to a new page, and we |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2155 } | 2171 } |
2156 } | 2172 } |
2157 } | 2173 } |
2158 | 2174 |
2159 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 2175 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
2160 const base::Callback<base::Time()>& get_timestamp_callback) { | 2176 const base::Callback<base::Time()>& get_timestamp_callback) { |
2161 get_timestamp_callback_ = get_timestamp_callback; | 2177 get_timestamp_callback_ = get_timestamp_callback; |
2162 } | 2178 } |
2163 | 2179 |
2164 } // namespace content | 2180 } // namespace content |
OLD | NEW |