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 #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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 details->did_replace_entry = | 762 details->did_replace_entry = |
763 pending_entry_ && pending_entry_->should_replace_entry(); | 763 pending_entry_ && pending_entry_->should_replace_entry(); |
764 | 764 |
765 // Do navigation-type specific actions. These will make and commit an entry. | 765 // Do navigation-type specific actions. These will make and commit an entry. |
766 details->type = ClassifyNavigation(rfh, params); | 766 details->type = ClassifyNavigation(rfh, params); |
767 | 767 |
768 // is_in_page must be computed before the entry gets committed. | 768 // is_in_page must be computed before the entry gets committed. |
769 details->is_in_page = IsURLInPageNavigation( | 769 details->is_in_page = IsURLInPageNavigation( |
770 params.url, params.was_within_same_page, details->type); | 770 params.url, params.was_within_same_page, details->type); |
771 | 771 |
| 772 bool clear_blocked_page_entry = true; |
772 switch (details->type) { | 773 switch (details->type) { |
773 case NAVIGATION_TYPE_NEW_PAGE: | 774 case NAVIGATION_TYPE_NEW_PAGE: |
774 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry); | 775 RendererDidNavigateToNewPage(rfh, params, details->did_replace_entry); |
775 break; | 776 break; |
776 case NAVIGATION_TYPE_EXISTING_PAGE: | 777 case NAVIGATION_TYPE_EXISTING_PAGE: |
777 RendererDidNavigateToExistingPage(rfh, params); | 778 RendererDidNavigateToExistingPage(rfh, params); |
| 779 clear_blocked_page_entry = false; |
778 break; | 780 break; |
779 case NAVIGATION_TYPE_SAME_PAGE: | 781 case NAVIGATION_TYPE_SAME_PAGE: |
780 RendererDidNavigateToSamePage(rfh, params); | 782 RendererDidNavigateToSamePage(rfh, params); |
781 break; | 783 break; |
782 case NAVIGATION_TYPE_IN_PAGE: | 784 case NAVIGATION_TYPE_IN_PAGE: |
783 RendererDidNavigateInPage(rfh, params, &details->did_replace_entry); | 785 RendererDidNavigateInPage(rfh, params, &details->did_replace_entry); |
784 break; | 786 break; |
785 case NAVIGATION_TYPE_NEW_SUBFRAME: | 787 case NAVIGATION_TYPE_NEW_SUBFRAME: |
786 RendererDidNavigateNewSubframe(rfh, params); | 788 RendererDidNavigateNewSubframe(rfh, params); |
787 break; | 789 break; |
788 case NAVIGATION_TYPE_AUTO_SUBFRAME: | 790 case NAVIGATION_TYPE_AUTO_SUBFRAME: |
789 if (!RendererDidNavigateAutoSubframe(rfh, params)) | 791 if (!RendererDidNavigateAutoSubframe(rfh, params)) |
790 return false; | 792 return false; |
791 break; | 793 break; |
792 case NAVIGATION_TYPE_NAV_IGNORE: | 794 case NAVIGATION_TYPE_NAV_IGNORE: |
793 // If a pending navigation was in progress, this canceled it. We should | 795 // If a pending navigation was in progress, this canceled it. We should |
794 // discard it and make sure it is removed from the URL bar. After that, | 796 // discard it and make sure it is removed from the URL bar. After that, |
795 // there is nothing we can do with this navigation, so we just return to | 797 // there is nothing we can do with this navigation, so we just return to |
796 // the caller that nothing has happened. | 798 // the caller that nothing has happened. |
797 if (pending_entry_) { | 799 if (pending_entry_) { |
798 DiscardNonCommittedEntries(); | 800 DiscardNonCommittedEntries(); |
799 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 801 delegate_->NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
800 } | 802 } |
801 return false; | 803 return false; |
802 default: | 804 default: |
803 NOTREACHED(); | 805 NOTREACHED(); |
804 } | 806 } |
805 | 807 |
| 808 if (clear_blocked_page_entry) |
| 809 blocked_page_entry_.reset(NULL); |
| 810 |
806 // At this point, we know that the navigation has just completed, so | 811 // At this point, we know that the navigation has just completed, so |
807 // record the time. | 812 // record the time. |
808 // | 813 // |
809 // TODO(akalin): Use "sane time" as described in | 814 // TODO(akalin): Use "sane time" as described in |
810 // http://www.chromium.org/developers/design-documents/sane-time . | 815 // http://www.chromium.org/developers/design-documents/sane-time . |
811 base::Time timestamp = | 816 base::Time timestamp = |
812 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); | 817 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
813 DVLOG(1) << "Navigation finished at (smoothed) timestamp " | 818 DVLOG(1) << "Navigation finished at (smoothed) timestamp " |
814 << timestamp.ToInternalValue(); | 819 << timestamp.ToInternalValue(); |
815 | 820 |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1748 if (last_committed_entry_index_ != -1) | 1753 if (last_committed_entry_index_ != -1) |
1749 index = last_committed_entry_index_ + 1; | 1754 index = last_committed_entry_index_ + 1; |
1750 DiscardTransientEntry(); | 1755 DiscardTransientEntry(); |
1751 entries_.insert( | 1756 entries_.insert( |
1752 entries_.begin() + index, linked_ptr<NavigationEntryImpl>( | 1757 entries_.begin() + index, linked_ptr<NavigationEntryImpl>( |
1753 NavigationEntryImpl::FromNavigationEntry(entry))); | 1758 NavigationEntryImpl::FromNavigationEntry(entry))); |
1754 transient_entry_index_ = index; | 1759 transient_entry_index_ = index; |
1755 delegate_->NotifyNavigationStateChanged(kInvalidateAll); | 1760 delegate_->NotifyNavigationStateChanged(kInvalidateAll); |
1756 } | 1761 } |
1757 | 1762 |
| 1763 NavigationEntry* NavigationControllerImpl::GetBlockedPageEntry() const { |
| 1764 return blocked_page_entry_.get(); |
| 1765 } |
| 1766 |
| 1767 void NavigationControllerImpl::SetBlockedPageEntry(NavigationEntry* entry) { |
| 1768 NavigationEntry* copy = NavigationEntry::Create(*entry); |
| 1769 blocked_page_entry_.reset(static_cast<NavigationEntryImpl*>(copy)); |
| 1770 } |
| 1771 |
1758 void NavigationControllerImpl::InsertEntriesFrom( | 1772 void NavigationControllerImpl::InsertEntriesFrom( |
1759 const NavigationControllerImpl& source, | 1773 const NavigationControllerImpl& source, |
1760 int max_index) { | 1774 int max_index) { |
1761 DCHECK_LE(max_index, source.GetEntryCount()); | 1775 DCHECK_LE(max_index, source.GetEntryCount()); |
1762 size_t insert_index = 0; | 1776 size_t insert_index = 0; |
1763 for (int i = 0; i < max_index; i++) { | 1777 for (int i = 0; i < max_index; i++) { |
1764 // When cloning a tab, copy all entries except interstitial pages | 1778 // When cloning a tab, copy all entries except interstitial pages |
1765 if (source.entries_[i].get()->GetPageType() != | 1779 if (source.entries_[i].get()->GetPageType() != |
1766 PAGE_TYPE_INTERSTITIAL) { | 1780 PAGE_TYPE_INTERSTITIAL) { |
1767 entries_.insert(entries_.begin() + insert_index++, | 1781 entries_.insert(entries_.begin() + insert_index++, |
1768 linked_ptr<NavigationEntryImpl>( | 1782 linked_ptr<NavigationEntryImpl>( |
1769 new NavigationEntryImpl(*source.entries_[i]))); | 1783 new NavigationEntryImpl(*source.entries_[i]))); |
1770 } | 1784 } |
1771 } | 1785 } |
1772 } | 1786 } |
1773 | 1787 |
1774 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1788 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
1775 const base::Callback<base::Time()>& get_timestamp_callback) { | 1789 const base::Callback<base::Time()>& get_timestamp_callback) { |
1776 get_timestamp_callback_ = get_timestamp_callback; | 1790 get_timestamp_callback_ = get_timestamp_callback; |
1777 } | 1791 } |
1778 | 1792 |
1779 } // namespace content | 1793 } // namespace content |
OLD | NEW |