diff options
author | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:37:07 +0000 |
---|---|---|
committer | brettw@google.com <brettw@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-20 22:37:07 +0000 |
commit | 6e83cb81e5e0c974a0782bc319e5a79ea0cca70b (patch) | |
tree | cfa8c9c14de3637fa40de8d322fabe75fec1ab50 /webkit | |
parent | 1c9c4e8e63c96e4255f81ae14e9e861a8ec56d7f (diff) | |
download | chromium_src-6e83cb81e5e0c974a0782bc319e5a79ea0cca70b.zip chromium_src-6e83cb81e5e0c974a0782bc319e5a79ea0cca70b.tar.gz chromium_src-6e83cb81e5e0c974a0782bc319e5a79ea0cca70b.tar.bz2 |
Merge NavigationController and NavigationControllerBase for test_shell. I also removed all the inapplicable crap that was in there like transition and tab types.
BUG=1319488
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1120 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/test_shell/SConscript | 1 | ||||
-rw-r--r-- | webkit/tools/test_shell/temp/navigation_controller_base.cc | 301 | ||||
-rw-r--r-- | webkit/tools/test_shell/temp/navigation_controller_base.h | 220 | ||||
-rw-r--r-- | webkit/tools/test_shell/temp/navigation_entry.h | 154 | ||||
-rw-r--r-- | webkit/tools/test_shell/temp/page_transition_types.h | 173 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_navigation_controller.cc | 188 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_navigation_controller.h | 158 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.cc | 8 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell.vcproj | 42 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_tests.vcproj | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 21 |
12 files changed, 316 insertions, 959 deletions
diff --git a/webkit/tools/test_shell/SConscript b/webkit/tools/test_shell/SConscript index ed7a21c..8185377 100644 --- a/webkit/tools/test_shell/SConscript +++ b/webkit/tools/test_shell/SConscript @@ -121,7 +121,6 @@ input_files = [ 'text_input_controller.cc', 'webview_host.cc', 'webwidget_host.cc', - 'temp/navigation_controller_base.cc', ] lib = env.ChromeStaticLibrary('test_shell', input_files) diff --git a/webkit/tools/test_shell/temp/navigation_controller_base.cc b/webkit/tools/test_shell/temp/navigation_controller_base.cc deleted file mode 100644 index 287e870..0000000 --- a/webkit/tools/test_shell/temp/navigation_controller_base.cc +++ /dev/null @@ -1,301 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#include "webkit/tools/test_shell/temp/navigation_controller_base.h" - -#include <algorithm> - -#include "webkit/tools/test_shell/temp/navigation_entry.h" -#include "base/logging.h" - -NavigationControllerBase::NavigationControllerBase() - : pending_entry_(NULL), - last_committed_entry_index_(-1), - pending_entry_index_(-1) { -} - -NavigationControllerBase::~NavigationControllerBase() { - // NOTE: This does NOT invoke Reset as Reset is virtual. - ResetInternal(); -} - -void NavigationControllerBase::Reset() { - ResetInternal(); - - last_committed_entry_index_ = -1; -} - -NavigationEntry* NavigationControllerBase::GetActiveEntry() const { - NavigationEntry* entry = pending_entry_; - if (!entry) - entry = GetLastCommittedEntry(); - return entry; -} - -int NavigationControllerBase::GetCurrentEntryIndex() const { - if (pending_entry_index_ != -1) - return pending_entry_index_; - return last_committed_entry_index_; -} - -NavigationEntry* NavigationControllerBase::GetLastCommittedEntry() const { - if (last_committed_entry_index_ == -1) - return NULL; - return entries_[last_committed_entry_index_]; -} - -int NavigationControllerBase::GetEntryIndexWithPageID( - TabContentsType type, int32 page_id) const { - for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) { - if (entries_[i]->GetType() == type && entries_[i]->GetPageID() == page_id) - return i; - } - return -1; -} - -NavigationEntry* NavigationControllerBase::GetEntryWithPageID( - TabContentsType type, int32 page_id) const { - int index = GetEntryIndexWithPageID(type, page_id); - return (index != -1) ? entries_[index] : NULL; -} - -NavigationEntry* NavigationControllerBase::GetEntryAtOffset(int offset) const { - int index = last_committed_entry_index_ + offset; - if (index < 0 || index >= GetEntryCount()) - return NULL; - - return entries_[index]; -} - -bool NavigationControllerBase::CanStop() const { - // TODO(darin): do we have something pending that we can stop? - return false; -} - -bool NavigationControllerBase::CanGoBack() const { - return entries_.size() > 1 && GetCurrentEntryIndex() > 0; -} - -bool NavigationControllerBase::CanGoForward() const { - int index = GetCurrentEntryIndex(); - return index >= 0 && index < (static_cast<int>(entries_.size()) - 1); -} - -void NavigationControllerBase::GoBack() { - DCHECK(CanGoBack()); - - // Base the navigation on where we are now... - int current_index = GetCurrentEntryIndex(); - - DiscardPendingEntry(); - - pending_entry_index_ = current_index - 1; - NavigateToPendingEntry(false); -} - -void NavigationControllerBase::GoForward() { - DCHECK(CanGoForward()); - - // Base the navigation on where we are now... - int current_index = GetCurrentEntryIndex(); - - DiscardPendingEntry(); - - pending_entry_index_ = current_index + 1; - NavigateToPendingEntry(false); -} - -void NavigationControllerBase::GoToIndex(int index) { - DCHECK(index >= 0); - DCHECK(index < static_cast<int>(entries_.size())); - - DiscardPendingEntry(); - - pending_entry_index_ = index; - NavigateToPendingEntry(false); -} - -void NavigationControllerBase::GoToOffset(int offset) { - int index = last_committed_entry_index_ + offset; - if (index < 0 || index >= GetEntryCount()) - return; - - GoToIndex(index); -} - -void NavigationControllerBase::Stop() { - DCHECK(CanStop()); - - // TODO(darin): we probably want to just call Stop on the active tab - // contents, but should we also call DiscardPendingEntry? - NOTREACHED() << "implement me"; -} - -void NavigationControllerBase::Reload() { - // Base the navigation on where we are now... - int current_index = GetCurrentEntryIndex(); - - // If we are no where, then we can't reload. TODO(darin): We should add a - // CanReload method. - if (current_index == -1) - return; - - DiscardPendingEntryInternal(); - - pending_entry_index_ = current_index; - entries_[pending_entry_index_]->SetTransition(PageTransition::RELOAD); - NavigateToPendingEntry(true); -} - -void NavigationControllerBase::LoadEntry(NavigationEntry* entry) { - // When navigating to a new page, we don't know for sure if we will actually - // end up leaving the current page. The new page load could for example - // result in a download or a 'no content' response (e.g., a mailto: URL). - - DiscardPendingEntryInternal(); - pending_entry_ = entry; - NavigateToPendingEntry(false); -} - -void NavigationControllerBase::DidNavigateToEntry(NavigationEntry* entry) { - // If the entry is that of a page with PageID larger than any this Tab has - // seen before, then consider it a new navigation. - if (entry->GetPageID() > GetMaxPageID()) { - InsertEntry(entry); - return; - } - - // Otherwise, we just need to update an existing entry with matching PageID. - // If the existing entry corresponds to the entry which is pending, then we - // must update the current entry index accordingly. When navigating to the - // same URL, a new PageID is not created. - - int existing_entry_index = GetEntryIndexWithPageID(entry->GetType(), - entry->GetPageID()); - NavigationEntry* existing_entry = - (existing_entry_index != -1) ? entries_[existing_entry_index] : NULL; - if (!existing_entry) { - // No existing entry, then simply ignore this navigation! - DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); - } else if (existing_entry == pending_entry_) { - // The given entry might provide a new URL... e.g., navigating back to a - // page in session history could have resulted in a new client redirect. - existing_entry->SetURL(entry->GetURL()); - existing_entry->SetContentState(entry->GetContentState()); - last_committed_entry_index_ = pending_entry_index_; - pending_entry_index_ = -1; - pending_entry_ = NULL; - IndexOfActiveEntryChanged(); - } else if (pending_entry_ && pending_entry_->GetPageID() == -1 && - pending_entry_->GetURL() == existing_entry->GetURL()) { - // Not a new navigation - DiscardPendingEntry(); - } else { - // The given entry might provide a new URL... e.g., navigating to a page - // might result in a client redirect, which should override the URL of the - // existing entry. - existing_entry->SetURL(entry->GetURL()); - existing_entry->SetContentState(entry->GetContentState()); - - // The navigation could have been issued by the renderer, so be sure that - // we update our current index. - last_committed_entry_index_ = existing_entry_index; - IndexOfActiveEntryChanged(); - } - - delete entry; - - NotifyNavigationStateChanged(); -} - -void NavigationControllerBase::DiscardPendingEntry() { - DiscardPendingEntryInternal(); - - // Derived classes may do additional things in this case. -} - -int NavigationControllerBase::GetIndexOfEntry( - const NavigationEntry* entry) const { - NavigationEntryList::const_iterator i = find(entries_.begin(), entries_.end(), entry); - if (i == entries_.end()) - return -1; - return static_cast<int>(i - entries_.begin()); -} - -void NavigationControllerBase::DiscardPendingEntryInternal() { - if (pending_entry_index_ == -1) - delete pending_entry_; - pending_entry_ = NULL; - pending_entry_index_ = -1; -} - -void NavigationControllerBase::InsertEntry(NavigationEntry* entry) { - DCHECK(entry->GetTransition() != PageTransition::AUTO_SUBFRAME); - - DiscardPendingEntryInternal(); - - int current_size = static_cast<int>(entries_.size()); - - // Prune any entry which are in front of the current entry - if (current_size > 0) { - while (last_committed_entry_index_ < (current_size - 1)) { - PruneEntryAtIndex(current_size - 1); - delete entries_[current_size - 1]; - entries_.pop_back(); - current_size--; - } - NotifyPrunedEntries(); - } - - entries_.push_back(entry); - last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; - - NotifyNavigationStateChanged(); -} - -void NavigationControllerBase::ResetInternal() { - // WARNING: this is invoked from the destructor, be sure not to invoke any - // virtual methods from this. - for (int i = 0, c = static_cast<int>(entries_.size()); i < c; ++i) - delete entries_[i]; - entries_.clear(); - - DiscardPendingEntryInternal(); -} - -#ifndef NDEBUG - -void NavigationControllerBase::Dump() { - int i,c; - for (i = 1, c = static_cast<int>(entries_.size()); i < c; ++i) { - DLOG(INFO) << entries_[i]->GetURL().spec(); - } -} - -#endif diff --git a/webkit/tools/test_shell/temp/navigation_controller_base.h b/webkit/tools/test_shell/temp/navigation_controller_base.h deleted file mode 100644 index d4b3785..0000000 --- a/webkit/tools/test_shell/temp/navigation_controller_base.h +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_CONTROLLER_BASE_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_CONTROLLER_BASE_H__ - -#include <vector> - -#include "webkit/tools/test_shell/temp/page_transition_types.h" - -class NavigationEntry; - -typedef int TabContentsType; - -//////////////////////////////////////////////////////////////////////////////// -// -// NavigationControllerBase class -// -// A NavigationControllerBase maintains navigation data (like session history). -// -//////////////////////////////////////////////////////////////////////////////// -class NavigationControllerBase { - public: - NavigationControllerBase(); - virtual ~NavigationControllerBase(); - - // Empties the history list. - virtual void Reset(); - - // Returns the active entry, which is the pending entry if a navigation is in - // progress or the last committed entry otherwise. NOTE: This can be NULL!! - // - // If you are trying to get the current state of the NavigationControllerBase, - // this is the method you will typically want to call. - // - NavigationEntry* GetActiveEntry() const; - - // Returns the index from which we would go back/forward or reload. This is - // the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise, - // it is the pending_entry_index_. - int GetCurrentEntryIndex() const; - - // Returns the pending entry corresponding to the navigation that is - // currently in progress, or null if there is none. - NavigationEntry* GetPendingEntry() const { - return pending_entry_; - } - - // Returns the index of the pending entry or -1 if the pending entry - // corresponds to a new navigation (created via LoadURL). - int GetPendingEntryIndex() const { - return pending_entry_index_; - } - - // Returns the last committed entry, which may be null if there are no - // committed entries. - NavigationEntry* GetLastCommittedEntry() const; - - // Returns the index of the last committed entry. - int GetLastCommittedEntryIndex() const { - return last_committed_entry_index_; - } - - // Returns the number of entries in the NavigationControllerBase, excluding - // the pending entry if there is one. - int GetEntryCount() const { - return static_cast<int>(entries_.size()); - } - - NavigationEntry* GetEntryAtIndex(int index) const { - return entries_.at(index); - } - - // Returns the entry at the specified offset from current. Returns NULL - // if out of bounds. - NavigationEntry* GetEntryAtOffset(int offset) const; - - bool CanStop() const; - - // Return whether this controller can go back. - bool CanGoBack() const; - - // Return whether this controller can go forward. - bool CanGoForward() const; - - // Causes the controller to go back. - void GoBack(); - - // Causes the controller to go forward. - void GoForward(); - - // Causes the controller to go to the specified index. - void GoToIndex(int index); - - // Causes the controller to go to the specified offset from current. Does - // nothing if out of bounds. - void GoToOffset(int offset); - - // Causes the controller to stop a pending navigation if any. - void Stop(); - - // Causes the controller to reload the current (or pending) entry. - void Reload(); - - // Causes the controller to load the specified entry. The controller - // assumes ownership of the entry. - // NOTE: Do not pass an entry that the controller already owns! - void LoadEntry(NavigationEntry* entry); - - // Return the entry with the corresponding type and page_id, or NULL if - // not found. - NavigationEntry* GetEntryWithPageID(TabContentsType type, - int32 page_id) const; - -#ifndef NDEBUG - void Dump(); -#endif - - // -------------------------------------------------------------------------- - // For use by NavigationControllerBase clients: - - // Used to inform the NavigationControllerBase of a navigation being committed - // for a tab. The controller takes ownership of the entry. Any entry located - // forward to the current entry will be deleted. The new entry becomes the - // current entry. - virtual void DidNavigateToEntry(NavigationEntry* entry); - - // Used to inform the NavigationControllerBase to discard its pending entry. - virtual void DiscardPendingEntry(); - - // Returns the index of the specified entry, or -1 if entry is not contained - // in this NavigationControllerBase. - int GetIndexOfEntry(const NavigationEntry* entry) const; - - protected: - // Returns the largest page ID seen. When PageIDs come in larger than - // this (via DidNavigateToEntry), we know that we've navigated to a new page. - virtual int GetMaxPageID() const = 0; - - // Actually issues the navigation held in pending_entry. - virtual void NavigateToPendingEntry(bool reload) = 0; - - // Allows the derived class to issue notifications that a load has been - // committed. - virtual void NotifyNavigationStateChanged() {} - - // Invoked when entries have been pruned, or removed. For example, if the - // current entries are [google, digg, yahoo], with the current entry google, - // and the user types in cnet, then digg and yahoo are pruned. - virtual void NotifyPrunedEntries() {} - - // Invoked when the index of the active entry may have changed. - virtual void IndexOfActiveEntryChanged() {} - - // Inserts an entry after the current position, removing all entries after it. - // The new entry will become the active one. - virtual void InsertEntry(NavigationEntry* entry); - - // Called when navigations cause entries forward of and including the - // specified index are pruned. - virtual void PruneEntryAtIndex(int prune_index) { } - - // Discards the pending entry without updating active_contents_ - void DiscardPendingEntryInternal(); - - // Return the index of the entry with the corresponding type and page_id, - // or -1 if not found. - int GetEntryIndexWithPageID(TabContentsType type, int32 page_id) const; - - // List of NavigationEntry for this tab - typedef std::vector<NavigationEntry*> NavigationEntryList; - typedef NavigationEntryList::iterator NavigationEntryListIterator; - NavigationEntryList entries_; - - // An entry we haven't gotten a response for yet. This will be discarded - // when we navigate again. It's used only so we know what the currently - // displayed tab is. - NavigationEntry* pending_entry_; - - // currently visible entry - int last_committed_entry_index_; - - // index of pending entry if it is in entries_, or -1 if pending_entry_ is a - // new entry (created by LoadURL). - int pending_entry_index_; - - private: - // Implementation of Reset and the destructor. Deletes entries - void ResetInternal(); - - DISALLOW_EVIL_CONSTRUCTORS(NavigationControllerBase); -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_CONTROLLER_BASE_H__ diff --git a/webkit/tools/test_shell/temp/navigation_entry.h b/webkit/tools/test_shell/temp/navigation_entry.h deleted file mode 100644 index c40eb5b..0000000 --- a/webkit/tools/test_shell/temp/navigation_entry.h +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_ENTRY_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_ENTRY_H__ - -#include "base/basictypes.h" -#include "base/scoped_ptr.h" -#include "webkit/tools/test_shell/temp/page_transition_types.h" -#include "googleurl/src/gurl.h" - -//////////////////////////////////////////////////////////////////////////////// -// -// NavigationEntry class -// -// A NavigationEntry is a data structure that captures all the information -// required to recreate a browsing state. This includes some opaque binary -// state as provided by the TabContents as well as some clear text title and -// uri which is used for our user interface. -// -//////////////////////////////////////////////////////////////////////////////// -class NavigationEntry { - public: - // Create a new NavigationEntry. - explicit NavigationEntry(TabContentsType type) - : type_(type), - page_id_(-1), - transition_(PageTransition::LINK) { - } - - NavigationEntry(TabContentsType type, - int page_id, - const GURL& url, - const std::wstring& title, - PageTransition::Type transition) - : type_(type), - page_id_(page_id), - url_(url), - title_(title), - transition_(transition) { - } - - // virtual to allow test_shell to extend the class. - virtual ~NavigationEntry() { - } - - // Return the TabContents type required to display this entry. Immutable - // because a tab can never change its type. - TabContentsType GetType() const { return type_; } - - // Set / Get the URI - void SetURL(const GURL& url) { url_ = url; } - const GURL& GetURL() const { return url_; } - - void SetDisplayURL(const GURL& url) { - if (url == url_) { - display_url_ = GURL::EmptyGURL(); - } else { - display_url_ = url; - } - } - - bool HasDisplayURL() { return !display_url_.is_empty(); } - - const GURL& GetDisplayURL() const { - if (display_url_.is_empty()) { - return url_; - } else { - return display_url_; - } - } - - // Set / Get the title - void SetTitle(const std::wstring& a_title) { title_ = a_title; } - const std::wstring& GetTitle() const { return title_; } - - // Set / Get opaque state. - // WARNING: This state is saved to the database and used to restore previous - // states. If you use write a custom TabContents and provide your own - // state make sure you have the ability to modify the format in the future - // while being able to deal with older versions. - void SetContentState(const std::string& state) { state_ = state; } - const std::string& GetContentState() const { return state_; } - - // Get the page id corresponding to the tab's state. - void SetPageID(int page_id) { page_id_ = page_id; } - int32 GetPageID() const { return page_id_; } - - // The transition type indicates what the user did to move to this page from - // the previous page. - void SetTransition(PageTransition::Type transition) { - transition_ = transition; - } - PageTransition::Type GetTransition() const { return transition_; } - - // Set / Get favicon URL. - void SetFavIconURL(const GURL& url) { fav_icon_url_ = url; } - const GURL& GetFavIconURL() const { return fav_icon_url_; } - - // This is the URL the user typed in. This may be invalid. - void SetUserTypedURL(const GURL& url) { user_typed_url_ = url; } - const GURL& GetUserTypedURL() const { return user_typed_url_; } - - // If the user typed url is valid it is returned, otherwise url is returned. - const GURL& GetUserTypedURLOrURL() const { - return user_typed_url_.is_valid() ? user_typed_url_ : url_; - } - - private: - TabContentsType type_; - - // Describes the current page that the tab represents. This is not relevant - // for all tab contents types. - int32 page_id_; - - GURL url_; - // The URL the user typed in. - GURL user_typed_url_; - std::wstring title_; - GURL fav_icon_url_; - GURL display_url_; - - std::string state_; - - PageTransition::Type transition_; -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEMP_NAVIGATION_ENTRY_H__ diff --git a/webkit/tools/test_shell/temp/page_transition_types.h b/webkit/tools/test_shell/temp/page_transition_types.h deleted file mode 100644 index 1253963..0000000 --- a/webkit/tools/test_shell/temp/page_transition_types.h +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2008, Google Inc. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEMP_PAGE_TRANSITION_TYPES_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEMP_PAGE_TRANSITION_TYPES_H__ - -#include "base/basictypes.h" -#include "base/logging.h" - -// This class is for scoping only. -class PageTransition { - public: - // Types of transitions between pages. These are stored in the history - // database to separate visits, and are reported by the renderer for page - // navigations. - // - // WARNING: don't change these numbers, they are written directly into the - // history database, so future versions will need the same values to match - // the enums. - // - // A type is made of a core value and a set of qualifiers. A type has one - // core value and 0 or or more qualifiers. - enum Type { - // User got to this page by clicking a link on another page. - LINK = 0, - - // User got this page by typing the URL in the URL bar. This should not be - // used for cases where the user selected a choice that didn't look at all - // like a URL; see GENERATED below. - // - // We also use this for other "explicit" navigation actions such as command - // line arguments. - TYPED = 1, - - // User got to this page through a suggestion in the UI, for example, - // through the destinations page. - AUTO_BOOKMARK = 2, - - // This is a subframe navigation. This is any content that is automatically - // loaded in a non-toplevel frame. For example, if a page consists of - // several frames containing ads, those ad URLs will have this transition - // type. The user may not even realize the content in these pages is a - // separate frame, so may not care about the URL (see MANUAL below). - AUTO_SUBFRAME = 3, - - // For subframe navigations that are explicitly requested by the user and - // generate new navigation entries in the back/forward list. These are - // probably more important than frames that were automatically loaded in - // the background because the user probably cares about the fact that this - // link was loaded. - MANUAL_SUBFRAME = 4, - - // User got to this page by typing in the URL bar and selecting an entry - // that did not look like a URL. For example, a match might have the URL - // of a Google search result page, but appear like "Search Google for ...". - // These are not quite the same as TYPED navigations because the user - // didn't type or see the destination URL. - GENERATED = 5, - - // The page was specified in the command line or is the start page. - START_PAGE = 6, - - // The user filled out values in a form and submitted it. NOTE that in - // some situations submitting a form does not result in this transition - // type. This can happen if the form uses script to submit the contents. - FORM_SUBMIT = 7, - - // The user "reloaded" the page, either by hitting the reload button or by - // hitting enter in the address bar. NOTE: This is distinct from the - // concept of whether a particular load uses "reload semantics" (i.e. - // bypasses cached data). For this reason, lots of code needs to pass - // around the concept of whether a load should be treated as a "reload" - // separately from their tracking of this transition type, which is mainly - // used for proper scoring for consumers who care about how frequently a - // user typed/visited a particular URL. - RELOAD = 8, - - // ADDING NEW CORE VALUE? Be sure to update the LAST_CORE and CORE_MASK - // values below. - LAST_CORE = RELOAD, - CORE_MASK = 0xFF, - - // Qualifiers - // Any of the core values above can be augmented by one or more qualifiers. - // These qualifiers further define the transition - - // The beginning of a navigation chain. - CHAIN_START = 0x10000000, - - // The last transition in a redirect chain. - CHAIN_END = 0x20000000, - - // Redirects caused by JavaScript or a meta refresh tag on the page. - CLIENT_REDIRECT = 0x40000000, - - // Redirects sent from the server by HTTP headers. It might be nice to - // break this out into 2 types in the future: permanent or temporary if we - // can get that information from WebKit. - SERVER_REDIRECT = 0x80000000, - - // Used to test whether a transition involves a redirect - IS_REDIRECT_MASK = 0xC0000000, - - // General mask defining the bits used for the qualifiers - QUALIFIER_MASK = 0xFFFFFF00 - }; - - static bool ValidType(int32 type) { - int32 t = StripQualifier(static_cast<Type>(type)); - return (t >= 0 && t <= LAST_CORE && - (type & ~(QUALIFIER_MASK | CORE_MASK)) == 0); - } - - static Type FromInt(int32 type) { - if (!ValidType(type)) { - NOTREACHED() << "Invalid transition type " << type; - - // Return a safe default so we don't have corrupt data in release mode. - return LINK; - } - return static_cast<Type>(type); - } - - // Returns true if the given transition is a top-level frame transition, or - // false if the transition was for a subframe. - static bool IsMainFrame(Type type) { - int32 t = StripQualifier(type); - return (t != AUTO_SUBFRAME && t != MANUAL_SUBFRAME); - } - - // Returns whether a transition involves a redirection - static bool IsRedirect(Type type) { - return (type & IS_REDIRECT_MASK) != 0; - } - - // Simplifies the provided transition by removing any qualifier - static Type StripQualifier(Type type) { - return static_cast<Type>(type & ~QUALIFIER_MASK); - } - - // Return the qualifier - static int32 GetQualifier(Type type) { - return type & QUALIFIER_MASK; - } -}; - -#endif // WEBKIT_TOOLS_TEST_SHELL_TEMP_PAGE_TRANSITION_TYPES_H__ diff --git a/webkit/tools/test_shell/test_navigation_controller.cc b/webkit/tools/test_shell/test_navigation_controller.cc index 8262967..07a23fe 100644 --- a/webkit/tools/test_shell/test_navigation_controller.cc +++ b/webkit/tools/test_shell/test_navigation_controller.cc @@ -37,15 +37,16 @@ // TestNavigationEntry TestNavigationEntry::TestNavigationEntry() - : NavigationEntry(GetTabContentsType()) { + : page_id_(-1) { } TestNavigationEntry::TestNavigationEntry(int page_id, const GURL& url, const std::wstring& title, - PageTransition::Type transition, const std::wstring& target_frame) - : NavigationEntry(GetTabContentsType(), page_id, url, title, transition), + : page_id_(page_id), + url_(url), + title_(title), target_frame_(target_frame) { } @@ -54,13 +55,13 @@ TestNavigationEntry::~TestNavigationEntry() { void TestNavigationEntry::SetContentState(const std::string& state) { cached_history_item_ = NULL; // invalidate our cached item - NavigationEntry::SetContentState(state); + state_ = state; } WebHistoryItem* TestNavigationEntry::GetHistoryItem() const { if (!cached_history_item_) { TestShellExtraRequestData* extra_data = - new TestShellExtraRequestData(GetPageID(), GetTransition()); + new TestShellExtraRequestData(GetPageID()); cached_history_item_ = WebHistoryItem::Create(GetURL(), GetTitle(), GetContentState(), extra_data); @@ -72,7 +73,10 @@ WebHistoryItem* TestNavigationEntry::GetHistoryItem() const { // TestNavigationController TestNavigationController::TestNavigationController(TestShell* shell) - : shell_(shell), + : pending_entry_(NULL), + last_committed_entry_index_(-1), + pending_entry_index_(-1), + shell_(shell), max_page_id_(-1) { } @@ -80,8 +84,170 @@ TestNavigationController::~TestNavigationController() { } void TestNavigationController::Reset() { - NavigationControllerBase::Reset(); - max_page_id_ = -1; + for (int i = 0, c = static_cast<int>(entries_.size()); i < c; ++i) + delete entries_[i]; + entries_.clear(); + DiscardPendingEntry(); + + last_committed_entry_index_ = -1; +} + +void TestNavigationController::Reload() { + // Base the navigation on where we are now... + int current_index = GetCurrentEntryIndex(); + + // If we are no where, then we can't reload. TODO(darin): We should add a + // CanReload method. + if (current_index == -1) + return; + + DiscardPendingEntry(); + + pending_entry_index_ = current_index; + NavigateToPendingEntry(true); +} + +void TestNavigationController::GoToOffset(int offset) { + int index = last_committed_entry_index_ + offset; + if (index < 0 || index >= GetEntryCount()) + return; + + GoToIndex(index); +} + +void TestNavigationController::GoToIndex(int index) { + DCHECK(index >= 0); + DCHECK(index < static_cast<int>(entries_.size())); + + DiscardPendingEntry(); + + pending_entry_index_ = index; + NavigateToPendingEntry(false); +} + +void TestNavigationController::LoadEntry(TestNavigationEntry* entry) { + // When navigating to a new page, we don't know for sure if we will actually + // end up leaving the current page. The new page load could for example + // result in a download or a 'no content' response (e.g., a mailto: URL). + DiscardPendingEntry(); + pending_entry_ = entry; + NavigateToPendingEntry(false); +} + + +TestNavigationEntry* TestNavigationController::GetLastCommittedEntry() const { + if (last_committed_entry_index_ == -1) + return NULL; + return entries_[last_committed_entry_index_]; +} + +TestNavigationEntry* TestNavigationController::GetActiveEntry() const { + TestNavigationEntry* entry = pending_entry_; + if (!entry) + entry = GetLastCommittedEntry(); + return entry; +} + +int TestNavigationController::GetCurrentEntryIndex() const { + if (pending_entry_index_ != -1) + return pending_entry_index_; + return last_committed_entry_index_; +} + + +TestNavigationEntry* TestNavigationController::GetEntryAtOffset( + int offset) const { + int index = last_committed_entry_index_ + offset; + if (index < 0 || index >= GetEntryCount()) + return NULL; + + return entries_[index]; +} + +TestNavigationEntry* TestNavigationController::GetEntryWithPageID( + int32 page_id) const { + int index = GetEntryIndexWithPageID(page_id); + return (index != -1) ? entries_[index] : NULL; +} + +void TestNavigationController::DidNavigateToEntry(TestNavigationEntry* entry) { + // If the entry is that of a page with PageID larger than any this Tab has + // seen before, then consider it a new navigation. + if (entry->GetPageID() > GetMaxPageID()) { + InsertEntry(entry); + return; + } + + // Otherwise, we just need to update an existing entry with matching PageID. + // If the existing entry corresponds to the entry which is pending, then we + // must update the current entry index accordingly. When navigating to the + // same URL, a new PageID is not created. + + int existing_entry_index = GetEntryIndexWithPageID(entry->GetPageID()); + TestNavigationEntry* existing_entry = + (existing_entry_index != -1) ? entries_[existing_entry_index] : NULL; + if (!existing_entry) { + // No existing entry, then simply ignore this navigation! + DLOG(WARNING) << "ignoring navigation for page: " << entry->GetPageID(); + } else if (existing_entry == pending_entry_) { + // The given entry might provide a new URL... e.g., navigating back to a + // page in session history could have resulted in a new client redirect. + existing_entry->SetURL(entry->GetURL()); + existing_entry->SetContentState(entry->GetContentState()); + last_committed_entry_index_ = pending_entry_index_; + pending_entry_index_ = -1; + pending_entry_ = NULL; + } else if (pending_entry_ && pending_entry_->GetPageID() == -1 && + pending_entry_->GetURL() == existing_entry->GetURL()) { + // Not a new navigation + DiscardPendingEntry(); + } else { + // The given entry might provide a new URL... e.g., navigating to a page + // might result in a client redirect, which should override the URL of the + // existing entry. + existing_entry->SetURL(entry->GetURL()); + existing_entry->SetContentState(entry->GetContentState()); + + // The navigation could have been issued by the renderer, so be sure that + // we update our current index. + last_committed_entry_index_ = existing_entry_index; + } + + delete entry; + UpdateMaxPageID(); +} + +void TestNavigationController::DiscardPendingEntry() { + if (pending_entry_index_ == -1) + delete pending_entry_; + pending_entry_ = NULL; + pending_entry_index_ = -1; +} + +void TestNavigationController::InsertEntry(TestNavigationEntry* entry) { + DiscardPendingEntry(); + + // Prune any entry which are in front of the current entry + int current_size = static_cast<int>(entries_.size()); + if (current_size > 0) { + while (last_committed_entry_index_ < (current_size - 1)) { + delete entries_[current_size - 1]; + entries_.pop_back(); + current_size--; + } + } + + entries_.push_back(entry); + last_committed_entry_index_ = static_cast<int>(entries_.size()) - 1; + UpdateMaxPageID(); +} + +int TestNavigationController::GetEntryIndexWithPageID(int32 page_id) const { + for (int i = static_cast<int>(entries_.size())-1; i >= 0; --i) { + if (entries_[i]->GetPageID() == page_id) + return i; + } + return -1; } void TestNavigationController::NavigateToPendingEntry(bool reload) { @@ -94,14 +260,14 @@ void TestNavigationController::NavigateToPendingEntry(bool reload) { if (shell_->Navigate(*pending_entry_, reload)) { // Note: this is redundant if navigation completed synchronously because // DidNavigateToEntry call this as well. - NotifyNavigationStateChanged(); + UpdateMaxPageID(); } else { DiscardPendingEntry(); } } -void TestNavigationController::NotifyNavigationStateChanged() { - NavigationEntry* entry = GetActiveEntry(); +void TestNavigationController::UpdateMaxPageID() { + TestNavigationEntry* entry = GetActiveEntry(); if (entry) max_page_id_ = std::max(max_page_id_, entry->GetPageID()); } diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h index 4bdcad8..c99a238 100644 --- a/webkit/tools/test_shell/test_navigation_controller.h +++ b/webkit/tools/test_shell/test_navigation_controller.h @@ -27,18 +27,16 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H__ -#define WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H__ +#ifndef WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ +#define WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ -#include <vector> #include <string> +#include <vector> #include "base/basictypes.h" #include "base/ref_counted.h" +#include "googleurl/src/gurl.h" #include "webkit/glue/weburlrequest.h" -#include "webkit/tools/test_shell/temp/navigation_controller_base.h" -#include "webkit/tools/test_shell/temp/navigation_entry.h" -#include "webkit/tools/test_shell/temp/page_transition_types.h" class GURL; class TestShell; @@ -47,67 +45,169 @@ class WebHistoryItem; // Associated with browser-initated navigations to hold tracking data. class TestShellExtraRequestData : public WebRequest::ExtraData { public: - TestShellExtraRequestData(int32 pending_page_id, - PageTransition::Type transition) + TestShellExtraRequestData(int32 pending_page_id) : WebRequest::ExtraData(), pending_page_id(pending_page_id), - transition_type(transition), request_committed(false) { } // Contains the page_id for this navigation or -1 if there is none yet. int32 pending_page_id; - // Contains the transition type that the browser specified when it - // initiated the load. - PageTransition::Type transition_type; - // True if we have already processed the "DidCommitLoad" event for this // request. Used by session history. bool request_committed; }; -// Same as TestNavigationEntry, but caches the HistoryItem. -class TestNavigationEntry : public NavigationEntry { +// Stores one back/forward navigation state for the test shell. +class TestNavigationEntry { public: TestNavigationEntry(); TestNavigationEntry(int page_id, const GURL& url, const std::wstring& title, - PageTransition::Type transition, const std::wstring& target_frame); + // Virtual to allow test_shell to extend the class. ~TestNavigationEntry(); - // We don't care about tab contents types, so just pick one and use it - // everywhere. - static TabContentsType GetTabContentsType() { - return 0; - } + // Set / Get the URI + void SetURL(const GURL& url) { url_ = url; } + const GURL& GetURL() const { return url_; } + // Set / Get the title + void SetTitle(const std::wstring& a_title) { title_ = a_title; } + const std::wstring& GetTitle() const { return title_; } + + // Set / Get opaque state. + // WARNING: This state is saved to the database and used to restore previous + // states. If you use write a custom TabContents and provide your own + // state make sure you have the ability to modify the format in the future + // while being able to deal with older versions. void SetContentState(const std::string& state); - WebHistoryItem* GetHistoryItem() const; + const std::string& GetContentState() const { return state_; } + // Get the page id corresponding to the tab's state. + void SetPageID(int page_id) { page_id_ = page_id; } + int32 GetPageID() const { return page_id_; } + + WebHistoryItem* GetHistoryItem() const; const std::wstring& GetTargetFrame() const { return target_frame_; } -private: + private: + // Describes the current page that the tab represents. This is not relevant + // for all tab contents types. + int32 page_id_; + + GURL url_; + std::wstring title_; + std::string state_; + mutable scoped_refptr<WebHistoryItem> cached_history_item_; + std::wstring target_frame_; + + DISALLOW_COPY_AND_ASSIGN(TestNavigationEntry); }; // Test shell's NavigationController. The goal is to be as close to the Chrome // version as possible. -class TestNavigationController : public NavigationControllerBase { +class TestNavigationController { public: TestNavigationController(TestShell* shell); ~TestNavigationController(); - virtual void Reset(); + void Reset(); + + // Causes the controller to reload the current (or pending) entry. + void Reload(); + + // Causes the controller to go to the specified offset from current. Does + // nothing if out of bounds. + void GoToOffset(int offset); + + // Causes the controller to go to the specified index. + void GoToIndex(int index); + + // Causes the controller to load the specified entry. The controller + // assumes ownership of the entry. + // NOTE: Do not pass an entry that the controller already owns! + void LoadEntry(TestNavigationEntry* entry); + + // Returns the last committed entry, which may be null if there are no + // committed entries. + TestNavigationEntry* GetLastCommittedEntry() const; + + // Returns the number of entries in the NavigationControllerBase, excluding + // the pending entry if there is one. + int GetEntryCount() const { + return static_cast<int>(entries_.size()); + } + + // Returns the active entry, which is the pending entry if a navigation is in + // progress or the last committed entry otherwise. NOTE: This can be NULL!! + // + // If you are trying to get the current state of the NavigationControllerBase, + // this is the method you will typically want to call. + TestNavigationEntry* GetActiveEntry() const; + + // Returns the index from which we would go back/forward or reload. This is + // the last_committed_entry_index_ if pending_entry_index_ is -1. Otherwise, + // it is the pending_entry_index_. + int GetCurrentEntryIndex() const; + + // Returns the entry at the specified offset from current. Returns NULL + // if out of bounds. + TestNavigationEntry* GetEntryAtOffset(int offset) const; + + // Return the entry with the corresponding type and page_id, or NULL if + // not found. + TestNavigationEntry* GetEntryWithPageID(int32 page_id) const; + + // Returns the index of the last committed entry. + int GetLastCommittedEntryIndex() const { + return last_committed_entry_index_; + } + + // Used to inform us of a navigation being committed for a tab. We will take + // ownership of the entry. Any entry located forward to the current entry will + // be deleted. The new entry becomes the current entry. + void DidNavigateToEntry(TestNavigationEntry* entry); + + // Used to inform us to discard its pending entry. + void DiscardPendingEntry(); private: - virtual int GetMaxPageID() const { return max_page_id_; } - virtual void NavigateToPendingEntry(bool reload); - virtual void NotifyNavigationStateChanged(); + // Inserts an entry after the current position, removing all entries after it. + // The new entry will become the active one. + void InsertEntry(TestNavigationEntry* entry); + + int GetMaxPageID() const { return max_page_id_; } + void NavigateToPendingEntry(bool reload); + + // Return the index of the entry with the corresponding type and page_id, + // or -1 if not found. + int GetEntryIndexWithPageID(int32 page_id) const; + + // Updates the max page ID with that of the given entry, if is larger. + void UpdateMaxPageID(); + + // List of NavigationEntry for this tab + typedef std::vector<TestNavigationEntry*> NavigationEntryList; + typedef NavigationEntryList::iterator NavigationEntryListIterator; + NavigationEntryList entries_; + + // An entry we haven't gotten a response for yet. This will be discarded + // when we navigate again. It's used only so we know what the currently + // displayed tab is. + TestNavigationEntry* pending_entry_; + + // currently visible entry + int last_committed_entry_index_; + + // index of pending entry if it is in entries_, or -1 if pending_entry_ is a + // new entry (created by LoadURL). + int pending_entry_index_; TestShell* shell_; int max_page_id_; @@ -115,4 +215,4 @@ class TestNavigationController : public NavigationControllerBase { DISALLOW_EVIL_CONSTRUCTORS(TestNavigationController); }; -#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H__ +#endif // WEBKIT_TOOLS_TEST_SHELL_TEST_NAVIGATION_CONTROLLER_H_ diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 89585ae..d1e5042 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -862,11 +862,10 @@ void TestShell::LoadURLForFrame(const wchar_t* url, frame_string = frame_name; navigation_controller_->LoadEntry(new TestNavigationEntry( - -1, GURL(urlString), std::wstring(), PageTransition::LINK, - frame_string)); + -1, GURL(urlString), std::wstring(), frame_string)); } -bool TestShell::Navigate(const NavigationEntry& entry, bool reload) { +bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { const TestNavigationEntry& test_entry = *static_cast<const TestNavigationEntry*>(&entry); @@ -887,8 +886,7 @@ bool TestShell::Navigate(const NavigationEntry& entry, bool reload) { request->SetHistoryState(entry.GetContentState()); request->SetExtraData( - new TestShellExtraRequestData(entry.GetPageID(), - entry.GetTransition())); + new TestShellExtraRequestData(entry.GetPageID())); // Get the right target frame for the entry. WebFrame* frame = webView()->GetMainFrame(); diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index b9b110a8..b6cf9ec 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -35,7 +35,6 @@ #include "webkit/tools/test_shell/event_sending_controller.h" #include "webkit/tools/test_shell/layout_test_controller.h" #include "webkit/tools/test_shell/resource.h" -#include "webkit/tools/test_shell/temp/page_transition_types.h" #include "webkit/tools/test_shell/text_input_controller.h" #include "webkit/tools/test_shell/test_webview_delegate.h" #include "webkit/tools/test_shell/webview_host.h" @@ -44,7 +43,7 @@ typedef std::list<HWND> WindowList; struct WebPreferences; -class NavigationEntry; +class TestNavigationEntry; class TestNavigationController; class TestShell { @@ -138,7 +137,7 @@ public: void LoadURLForFrame(const wchar_t* url, const wchar_t* frame_name); void GoBackOrForward(int offset); void Reload(); - bool Navigate(const NavigationEntry& entry, bool reload); + bool Navigate(const TestNavigationEntry& entry, bool reload); bool PromptForSaveFile(const wchar_t* prompt_title, std::wstring* result); std::wstring GetDocumentText(); diff --git a/webkit/tools/test_shell/test_shell.vcproj b/webkit/tools/test_shell/test_shell.vcproj index d05c1ed..03544c7 100644 --- a/webkit/tools/test_shell/test_shell.vcproj +++ b/webkit/tools/test_shell/test_shell.vcproj @@ -198,44 +198,6 @@ > </File> </Filter> - <Filter - Name="temp" - > - <File - RelativePath=".\temp\navigation_controller_base.cc" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - ObjectFile="$(IntDir)\$(InputName)1.obj" - XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - ObjectFile="$(IntDir)\$(InputName)1.obj" - XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" - /> - </FileConfiguration> - </File> - <File - RelativePath=".\temp\navigation_controller_base.h" - > - </File> - <File - RelativePath=".\temp\navigation_entry.h" - > - </File> - <File - RelativePath=".\temp\page_transition_types.h" - > - </File> - </Filter> <File RelativePath=".\drag_delegate.cc" > @@ -281,6 +243,10 @@ > </File> <File + RelativePath=".\test_navigation_entry.h" + > + </File> + <File RelativePath=".\test_shell.cc" > </File> diff --git a/webkit/tools/test_shell/test_shell_tests.vcproj b/webkit/tools/test_shell/test_shell_tests.vcproj index 567e772..34d3970 100644 --- a/webkit/tools/test_shell/test_shell_tests.vcproj +++ b/webkit/tools/test_shell/test_shell_tests.vcproj @@ -183,10 +183,6 @@ > </File> <File - RelativePath=".\temp\navigation_controller_base.cc" - > - </File> - <File RelativePath="..\..\..\net\base\net_resources.rc" > </File> diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 3e23252..92959f6 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -879,24 +879,6 @@ void TestWebViewDelegate::UpdateURL(WebFrame* frame) { entry->SetURL(GURL(request.GetURL())); } - if (shell_->webView()->GetMainFrame() == frame) { - // Top-level navigation. - - PageTransition::Type transition = extra_data ? - extra_data->transition_type : PageTransition::LINK; - if (!PageTransition::IsMainFrame(transition)) { - transition = PageTransition::LINK; - } - entry->SetTransition(transition); - } else { - PageTransition::Type transition; - if (page_id_ > last_page_id_updated_) - transition = PageTransition::MANUAL_SUBFRAME; - else - transition = PageTransition::AUTO_SUBFRAME; - entry->SetTransition(transition); - } - shell_->navigation_controller()->DidNavigateToEntry(entry.release()); last_page_id_updated_ = std::max(last_page_id_updated_, page_id_); @@ -910,8 +892,7 @@ void TestWebViewDelegate::UpdateSessionHistory(WebFrame* frame) { return; TestNavigationEntry* entry = static_cast<TestNavigationEntry*>( - shell_->navigation_controller()->GetEntryWithPageID( - TestNavigationEntry::GetTabContentsType(), page_id_)); + shell_->navigation_controller()->GetEntryWithPageID(page_id_)); if (!entry) return; |