| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 716 | 716 |
| 717 void NavigationControllerImpl::UpdateVirtualURLToURL( | 717 void NavigationControllerImpl::UpdateVirtualURLToURL( |
| 718 NavigationEntryImpl* entry, const GURL& new_url) { | 718 NavigationEntryImpl* entry, const GURL& new_url) { |
| 719 GURL new_virtual_url(new_url); | 719 GURL new_virtual_url(new_url); |
| 720 if (BrowserURLHandlerImpl::GetInstance()->ReverseURLRewrite( | 720 if (BrowserURLHandlerImpl::GetInstance()->ReverseURLRewrite( |
| 721 &new_virtual_url, entry->GetVirtualURL(), browser_context_)) { | 721 &new_virtual_url, entry->GetVirtualURL(), browser_context_)) { |
| 722 entry->SetVirtualURL(new_virtual_url); | 722 entry->SetVirtualURL(new_virtual_url); |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 | 725 |
| 726 void NavigationControllerImpl::AddTransientEntry(NavigationEntryImpl* entry) { | |
| 727 // Discard any current transient entry, we can only have one at a time. | |
| 728 int index = 0; | |
| 729 if (last_committed_entry_index_ != -1) | |
| 730 index = last_committed_entry_index_ + 1; | |
| 731 DiscardTransientEntry(); | |
| 732 entries_.insert( | |
| 733 entries_.begin() + index, linked_ptr<NavigationEntryImpl>(entry)); | |
| 734 transient_entry_index_ = index; | |
| 735 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); | |
| 736 } | |
| 737 | |
| 738 void NavigationControllerImpl::LoadURL( | 726 void NavigationControllerImpl::LoadURL( |
| 739 const GURL& url, | 727 const GURL& url, |
| 740 const Referrer& referrer, | 728 const Referrer& referrer, |
| 741 PageTransition transition, | 729 PageTransition transition, |
| 742 const std::string& extra_headers) { | 730 const std::string& extra_headers) { |
| 743 LoadURLParams params(url); | 731 LoadURLParams params(url); |
| 744 params.referrer = referrer; | 732 params.referrer = referrer; |
| 745 params.transition_type = transition; | 733 params.transition_type = transition; |
| 746 params.extra_headers = extra_headers; | 734 params.extra_headers = extra_headers; |
| 747 LoadURLWithParams(params); | 735 LoadURLWithParams(params); |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1730 } | 1718 } |
| 1731 return -1; | 1719 return -1; |
| 1732 } | 1720 } |
| 1733 | 1721 |
| 1734 NavigationEntry* NavigationControllerImpl::GetTransientEntry() const { | 1722 NavigationEntry* NavigationControllerImpl::GetTransientEntry() const { |
| 1735 if (transient_entry_index_ == -1) | 1723 if (transient_entry_index_ == -1) |
| 1736 return NULL; | 1724 return NULL; |
| 1737 return entries_[transient_entry_index_].get(); | 1725 return entries_[transient_entry_index_].get(); |
| 1738 } | 1726 } |
| 1739 | 1727 |
| 1728 void NavigationControllerImpl::AddTransientEntry(NavigationEntry* entry) { |
| 1729 // Discard any current transient entry, we can only have one at a time. |
| 1730 int index = 0; |
| 1731 if (last_committed_entry_index_ != -1) |
| 1732 index = last_committed_entry_index_ + 1; |
| 1733 DiscardTransientEntry(); |
| 1734 entries_.insert( |
| 1735 entries_.begin() + index, linked_ptr<NavigationEntryImpl>( |
| 1736 NavigationEntryImpl::FromNavigationEntry(entry))); |
| 1737 transient_entry_index_ = index; |
| 1738 web_contents_->NotifyNavigationStateChanged(kInvalidateAll); |
| 1739 } |
| 1740 |
| 1740 void NavigationControllerImpl::InsertEntriesFrom( | 1741 void NavigationControllerImpl::InsertEntriesFrom( |
| 1741 const NavigationControllerImpl& source, | 1742 const NavigationControllerImpl& source, |
| 1742 int max_index) { | 1743 int max_index) { |
| 1743 DCHECK_LE(max_index, source.GetEntryCount()); | 1744 DCHECK_LE(max_index, source.GetEntryCount()); |
| 1744 size_t insert_index = 0; | 1745 size_t insert_index = 0; |
| 1745 for (int i = 0; i < max_index; i++) { | 1746 for (int i = 0; i < max_index; i++) { |
| 1746 // When cloning a tab, copy all entries except interstitial pages | 1747 // When cloning a tab, copy all entries except interstitial pages |
| 1747 if (source.entries_[i].get()->GetPageType() != | 1748 if (source.entries_[i].get()->GetPageType() != |
| 1748 PAGE_TYPE_INTERSTITIAL) { | 1749 PAGE_TYPE_INTERSTITIAL) { |
| 1749 entries_.insert(entries_.begin() + insert_index++, | 1750 entries_.insert(entries_.begin() + insert_index++, |
| 1750 linked_ptr<NavigationEntryImpl>( | 1751 linked_ptr<NavigationEntryImpl>( |
| 1751 new NavigationEntryImpl(*source.entries_[i]))); | 1752 new NavigationEntryImpl(*source.entries_[i]))); |
| 1752 } | 1753 } |
| 1753 } | 1754 } |
| 1754 } | 1755 } |
| 1755 | 1756 |
| 1756 void NavigationControllerImpl::SetGetTimestampCallbackForTest( | 1757 void NavigationControllerImpl::SetGetTimestampCallbackForTest( |
| 1757 const base::Callback<base::Time()>& get_timestamp_callback) { | 1758 const base::Callback<base::Time()>& get_timestamp_callback) { |
| 1758 get_timestamp_callback_ = get_timestamp_callback; | 1759 get_timestamp_callback_ = get_timestamp_callback; |
| 1759 } | 1760 } |
| 1760 | 1761 |
| 1761 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( | 1762 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( |
| 1762 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { | 1763 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { |
| 1763 take_screenshot_callback_ = take_screenshot_callback; | 1764 take_screenshot_callback_ = take_screenshot_callback; |
| 1764 } | 1765 } |
| 1765 | 1766 |
| 1766 } // namespace content | 1767 } // namespace content |
| OLD | NEW |