summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 21:12:03 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 21:12:03 +0000
commitf6e59a6f478826a9a1d75b18f10f285487f18fac (patch)
tree0336e7be11b059b8e3cec7a2eef273fa0ef0994d /webkit
parent7502d0224e51f54f1d65fbfce6d100e99dc819dc (diff)
downloadchromium_src-f6e59a6f478826a9a1d75b18f10f285487f18fac.zip
chromium_src-f6e59a6f478826a9a1d75b18f10f285487f18fac.tar.gz
chromium_src-f6e59a6f478826a9a1d75b18f10f285487f18fac.tar.bz2
Re-do r15244 again.
Originally reviewed at http://codereview.chromium.org/100353 Eliminate webkit/glue/webhistoryitem* in favor of adding a NavigateBackForwardSoon method WebViewDelegate. This moves all of the hacky details of how we intercept "history.{back, forward,go}" into the webkit layer. My eventual plan is to teach WebCore how to make this not hacky. In this version of the CL, TestWebViewDelegate performs the back/forward navigation directly in NavigateBackForwardSoon instead of using PostTask to delay it. I'm doing this to minimize regressions so that I can hopefully get the rest of this CL landed. I also already made the changes to WebKit to force history. {back,forward,go} to be processed asynchronously. Finally, it was necessary to move DumpBackForwardList out of webkit_glue.cc since it was using itemAtIndex to generate those results, and now that we return synthetic URLs for that function, the results were very wrong. The fix is to move DumpBackForwardList into TestShell so that it can more directly inspect the TestNavigationController. Now, it is necessary for webkit_glue.h to expose a function to dump a content state string (aka a WebCore::HistoryItem). BUG=11423 R=mpcomplete Review URL: http://codereview.chromium.org/113328 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15997 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/back_forward_list_client_impl.cc35
-rw-r--r--webkit/glue/back_forward_list_client_impl.h5
-rw-r--r--webkit/glue/webframe_impl.cc15
-rw-r--r--webkit/glue/webframe_impl.h7
-rw-r--r--webkit/glue/webframeloaderclient_impl.cc50
-rw-r--r--webkit/glue/webframeloaderclient_impl.h3
-rw-r--r--webkit/glue/webhistoryitem.h39
-rw-r--r--webkit/glue/webhistoryitem_impl.cc90
-rw-r--r--webkit/glue/webhistoryitem_impl.h47
-rw-r--r--webkit/glue/webkit_glue.cc61
-rw-r--r--webkit/glue/webkit_glue.h7
-rw-r--r--webkit/glue/webview_delegate.h8
-rw-r--r--webkit/glue/webview_impl.cc1
-rw-r--r--webkit/tools/test_shell/test_navigation_controller.cc18
-rw-r--r--webkit/tools/test_shell/test_navigation_controller.h10
-rw-r--r--webkit/tools/test_shell/test_shell.cc59
-rw-r--r--webkit/tools/test_shell/test_shell.h9
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc10
-rw-r--r--webkit/tools/test_shell/test_shell_mac.mm4
-rw-r--r--webkit/tools/test_shell/test_shell_win.cc4
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.cc35
-rw-r--r--webkit/tools/test_shell/test_webview_delegate.h2
-rw-r--r--webkit/webkit.gyp3
23 files changed, 169 insertions, 353 deletions
diff --git a/webkit/glue/back_forward_list_client_impl.cc b/webkit/glue/back_forward_list_client_impl.cc
index 99149d1..ec24804 100644
--- a/webkit/glue/back_forward_list_client_impl.cc
+++ b/webkit/glue/back_forward_list_client_impl.cc
@@ -8,11 +8,12 @@
#undef LOG
#include "webkit/glue/back_forward_list_client_impl.h"
-#include "webkit/glue/webhistoryitem_impl.h"
#include "webkit/glue/webview_impl.h"
namespace webkit_glue {
+const char kBackForwardNavigationScheme[] = "chrome-back-forward";
+
BackForwardListClientImpl::BackForwardListClientImpl(WebViewImpl* webview)
: webview_(webview) {
}
@@ -47,15 +48,8 @@ void BackForwardListClientImpl::goToItem(WebCore::HistoryItem* item) {
previous_item_ = current_item_;
current_item_ = item;
- if (pending_history_item_) {
- if (item == pending_history_item_->GetHistoryItem()) {
- // Let the main frame know this HistoryItem is loading, so it can cache
- // any ExtraData when the DataSource is created.
- webview_->main_frame()->set_currently_loading_history_item(
- pending_history_item_);
- pending_history_item_ = NULL;
- }
- }
+ if (pending_history_item_ == item)
+ pending_history_item_ = NULL;
}
WebCore::HistoryItem* BackForwardListClientImpl::currentItem() {
@@ -66,14 +60,21 @@ WebCore::HistoryItem* BackForwardListClientImpl::itemAtIndex(int index) {
if (!webview_->delegate())
return NULL;
- WebHistoryItem* item = webview_->delegate()->GetHistoryEntryAtOffset(index);
- if (!item)
- return NULL;
+ // Since we don't keep the entire back/forward list, we have no way to
+ // properly implement this method. We return a dummy entry instead that we
+ // intercept in our FrameLoaderClient implementation in case WebCore asks
+ // to navigate to this HistoryItem.
+
+ // TODO(darin): We should change WebCore to handle history.{back,forward,go}
+ // differently. It should perhaps just ask the FrameLoaderClient to perform
+ // those navigations.
+
+ WebCore::String url_string = WebCore::String::format(
+ "%s://go/%d", kBackForwardNavigationScheme, index);
- // If someone has asked for a history item, we probably want to navigate to
- // it soon. Keep track of it until goToItem is called.
- pending_history_item_ = static_cast<WebHistoryItemImpl*>(item);
- return pending_history_item_->GetHistoryItem();
+ pending_history_item_ =
+ WebCore::HistoryItem::create(url_string, WebCore::String(), 0.0);
+ return pending_history_item_.get();
}
int BackForwardListClientImpl::backListCount() {
diff --git a/webkit/glue/back_forward_list_client_impl.h b/webkit/glue/back_forward_list_client_impl.h
index 1a26c35..45ad379 100644
--- a/webkit/glue/back_forward_list_client_impl.h
+++ b/webkit/glue/back_forward_list_client_impl.h
@@ -9,11 +9,12 @@
#include "base/ref_counted.h"
-class WebHistoryItemImpl;
class WebViewImpl;
namespace webkit_glue {
+extern const char kBackForwardNavigationScheme[];
+
class BackForwardListClientImpl : public WebCore::BackForwardListClient {
public:
BackForwardListClientImpl(WebViewImpl* webview);
@@ -39,7 +40,7 @@ class BackForwardListClientImpl : public WebCore::BackForwardListClient {
// The last history item that was accessed via itemAtIndex(). We keep track
// of this until goToItem() is called, so we can track the navigation.
- scoped_refptr<WebHistoryItemImpl> pending_history_item_;
+ RefPtr<WebCore::HistoryItem> pending_history_item_;
};
} // namespace webkit_glue
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc
index 834f4a8..6976573 100644
--- a/webkit/glue/webframe_impl.cc
+++ b/webkit/glue/webframe_impl.cc
@@ -154,7 +154,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/webdatasource_impl.h"
#include "webkit/glue/weberror_impl.h"
#include "webkit/glue/webframe_impl.h"
-#include "webkit/glue/webhistoryitem_impl.h"
#include "webkit/glue/weburlrequest_impl.h"
#include "webkit/glue/webtextinput_impl.h"
#include "webkit/glue/webview_impl.h"
@@ -665,25 +664,15 @@ void WebFrameImpl::CacheCurrentRequestInfo(WebDataSourceImpl* datasource) {
// own requests, so the extra data needs to be transferred.
scoped_refptr<WebRequest::ExtraData> extra;
- // Our extra data may come from a request issued via LoadRequest, or a
- // history navigation from WebCore.
- if (currently_loading_request_) {
+ // Our extra data may come from a request issued via LoadRequest.
+ if (currently_loading_request_)
extra = currently_loading_request_->GetExtraData();
- } else if (currently_loading_history_item_) {
- extra = currently_loading_history_item_->GetExtraData();
- currently_loading_history_item_ = 0;
- }
// We must only update this if it is valid, or the valid state will be lost.
if (extra)
datasource->SetExtraData(extra);
}
-void WebFrameImpl::set_currently_loading_history_item(
- WebHistoryItemImpl* item) {
- currently_loading_history_item_ = item;
-}
-
void WebFrameImpl::StopLoading() {
if (!frame_)
return;
diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h
index fe7e3ef..45cdc91 100644
--- a/webkit/glue/webframe_impl.h
+++ b/webkit/glue/webframe_impl.h
@@ -43,7 +43,6 @@ class AltErrorPageResourceFetcher;
class ChromePrintContext;
class WebDataSourceImpl;
class WebErrorImpl;
-class WebHistoryItemImpl;
class WebPluginDelegate;
class WebRequest;
class WebView;
@@ -226,8 +225,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
// If currently_loading_request is NULL, does nothing.
void CacheCurrentRequestInfo(WebDataSourceImpl* datasource);
- void set_currently_loading_history_item(WebHistoryItemImpl* item);
-
// Getters for the impls corresponding to Get(Provisional)DataSource. They
// may return NULL if there is no corresponding data source.
WebDataSourceImpl* GetDataSourceImpl() const;
@@ -310,10 +307,6 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> {
// information to him. Only non-NULL during a call to LoadRequest.
const WebRequest* currently_loading_request_;
- // Similar to currently_loading_request_, except this will be set when
- // WebCore initiates a history navigation (probably via javascript).
- scoped_refptr<WebHistoryItemImpl> currently_loading_history_item_;
-
// Plugins sometimes need to be notified when loads are complete so we keep
// a pointer back to the appropriate plugin.
WebPluginDelegate* plugin_delegate_;
diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc
index 6d1b556..5e22435 100644
--- a/webkit/glue/webframeloaderclient_impl.cc
+++ b/webkit/glue/webframeloaderclient_impl.cc
@@ -56,7 +56,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/weberror_impl.h"
#include "webkit/glue/webframeloaderclient_impl.h"
-#include "webkit/glue/webhistoryitem_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webplugin_impl.h"
#include "webkit/glue/webresponse_impl.h"
@@ -792,16 +791,6 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() {
alt_404_page_fetcher_->Cancel();
}
-NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() {
- // TODO(timsteele): userGestureHint returns too many false positives
- // (see bug 1051891) to trust it and assign NavigationGestureUser, so
- // for now we assign Unknown in those cases and Auto otherwise.
- // (Issue 874811 known false negative as well).
- return webframe_->frame()->loader()->userGestureHint() ?
- NavigationGestureUnknown :
- NavigationGestureAuto;
-}
-
void WebFrameLoaderClient::dispatchDidReceiveTitle(const String& title) {
WebViewImpl* webview = webframe_->GetWebViewImpl();
WebViewDelegate* d = webview->delegate();
@@ -1026,13 +1015,19 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction(
// such navigations.
const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl();
if (ds) {
- bool is_redirect = !ds->GetRedirectChain().empty();
+ const GURL& url = ds->GetRequest().GetURL();
+ if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) {
+ HandleBackForwardNavigation(url);
+ disposition = IGNORE_ACTION;
+ } else {
+ bool is_redirect = !ds->GetRedirectChain().empty();
- WebNavigationType webnav_type =
- WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type());
+ WebNavigationType webnav_type =
+ WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type());
- disposition = d->DispositionForNavigationAction(
- wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirect);
+ disposition = d->DispositionForNavigationAction(
+ wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirect);
+ }
if (disposition != IGNORE_ACTION) {
if (disposition == CURRENT_TAB) {
@@ -1642,6 +1637,29 @@ bool WebFrameLoaderClient::ActionSpecifiesDisposition(
return true;
}
+NavigationGesture WebFrameLoaderClient::NavigationGestureForLastLoad() {
+ // TODO(timsteele): userGestureHint returns too many false positives
+ // (see bug 1051891) to trust it and assign NavigationGestureUser, so
+ // for now we assign Unknown in those cases and Auto otherwise.
+ // (Issue 874811 known false negative as well).
+ return webframe_->frame()->loader()->userGestureHint() ?
+ NavigationGestureUnknown :
+ NavigationGestureAuto;
+}
+
+void WebFrameLoaderClient::HandleBackForwardNavigation(const GURL& url) {
+ DCHECK(url.SchemeIs(webkit_glue::kBackForwardNavigationScheme));
+
+ std::string offset_str = url.ExtractFileName();
+ int offset;
+ if (!StringToInt(offset_str, &offset))
+ return;
+
+ WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate();
+ if (d)
+ d->NavigateBackForwardSoon(offset);
+}
+
NetAgentImpl* WebFrameLoaderClient::GetNetAgentImpl() {
WebViewImpl* web_view = webframe_->GetWebViewImpl();
if (!web_view) {
diff --git a/webkit/glue/webframeloaderclient_impl.h b/webkit/glue/webframeloaderclient_impl.h
index ec51ea8..f616aee 100644
--- a/webkit/glue/webframeloaderclient_impl.h
+++ b/webkit/glue/webframeloaderclient_impl.h
@@ -220,6 +220,9 @@ class WebFrameLoaderClient : public WebCore::FrameLoaderClient {
// otherwise returns NavigationGestureUnknown.
NavigationGesture NavigationGestureForLastLoad();
+ // Called when a dummy back-forward navigation is intercepted.
+ void HandleBackForwardNavigation(const GURL&);
+
// Returns NetAgent instance if network tracking is enabled.
NetAgentImpl* GetNetAgentImpl();
diff --git a/webkit/glue/webhistoryitem.h b/webkit/glue/webhistoryitem.h
deleted file mode 100644
index 6757211..0000000
--- a/webkit/glue/webhistoryitem.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_GLUE_WEBHISTORYITEM_H_
-#define WEBKIT_GLUE_WEBHISTORYITEM_H_
-
-#include "webkit/glue/weburlrequest.h" // for WebRequest::ExtraData
-
-class GURL;
-
-class WebHistoryItem : public base::RefCounted<WebHistoryItem> {
- public:
- // Create a new history item.
- static WebHistoryItem* Create(const GURL& url,
- const std::wstring& title,
- const std::string& history_state,
- WebRequest::ExtraData* extra_data);
-
- WebHistoryItem() { }
- virtual ~WebHistoryItem() { }
-
- // Returns the URL.
- virtual const GURL& GetURL() const = 0;
-
- // Returns the title.
- virtual const std::wstring& GetTitle() const = 0;
-
- // Returns the string representation of the history state for this entry.
- virtual const std::string& GetHistoryState() const = 0;
-
- // Returns any ExtraData associated with this history entry.
- virtual WebRequest::ExtraData* GetExtraData() const = 0;
-
- private:
- DISALLOW_EVIL_CONSTRUCTORS(WebHistoryItem);
-};
-
-#endif // #ifndef WEBKIT_GLUE_WEBHISTORYITEM_H_
diff --git a/webkit/glue/webhistoryitem_impl.cc b/webkit/glue/webhistoryitem_impl.cc
deleted file mode 100644
index c381eed..0000000
--- a/webkit/glue/webhistoryitem_impl.cc
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2006 Apple Computer, 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:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "config.h"
-#include "webkit/glue/webhistoryitem_impl.h"
-
-#include "webkit/glue/glue_serialize.h"
-#include "webkit/glue/glue_util.h"
-
-#include "base/compiler_specific.h"
-
-MSVC_PUSH_WARNING_LEVEL(0);
-#include "HistoryItem.h"
-MSVC_POP_WARNING();
-
-
-WebHistoryItem* WebHistoryItem::Create(const GURL& url,
- const std::wstring& title,
- const std::string& history_state,
- WebRequest::ExtraData* extra_data) {
- return new WebHistoryItemImpl(url, title, history_state, extra_data);
-}
-
-WebHistoryItemImpl::WebHistoryItemImpl(const GURL& url,
- const std::wstring& title,
- const std::string& history_state,
- WebRequest::ExtraData* extra_data) :
- url_(url),
- title_(title),
- history_state_(history_state),
- history_item_(NULL),
- extra_data_(extra_data) {
-}
-
-WebHistoryItemImpl::~WebHistoryItemImpl() {
-}
-
-const std::wstring& WebHistoryItemImpl::GetTitle() const {
- return title_;
-}
-
-const std::string& WebHistoryItemImpl::GetHistoryState() const {
- return history_state_;
-}
-
-WebRequest::ExtraData* WebHistoryItemImpl::GetExtraData() const {
- return extra_data_.get();
-}
-
-WebCore::HistoryItem* WebHistoryItemImpl::GetHistoryItem() const {
- if (history_item_)
- return history_item_.get();
-
- if (history_state_.size() > 0) {
- history_item_ = webkit_glue::HistoryItemFromString(history_state_);
- } else {
- history_item_ = WebCore::HistoryItem::create(
- webkit_glue::StdStringToString(url_.spec()),
- webkit_glue::StdWStringToString(title_),
- 0.0);
- }
-
- return history_item_.get();
-}
-
-const GURL& WebHistoryItemImpl::GetURL() const {
- return url_;
-}
diff --git a/webkit/glue/webhistoryitem_impl.h b/webkit/glue/webhistoryitem_impl.h
deleted file mode 100644
index b28fb91..0000000
--- a/webkit/glue/webhistoryitem_impl.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef WEBKIT_GLUE_WEBHISTORYITEM_IMPL_H_
-#define WEBKIT_GLUE_WEBHISTORYITEM_IMPL_H_
-
-#include "webkit/glue/webhistoryitem.h"
-#include "googleurl/src/gurl.h"
-
-#include "RefPtr.h"
-
-namespace WebCore {
- class HistoryItem;
-}
-
-class WebHistoryItemImpl : public WebHistoryItem {
- public:
- WebHistoryItemImpl(const GURL& url,
- const std::wstring& title,
- const std::string& history_state,
- WebRequest::ExtraData* extra_data);
- virtual ~WebHistoryItemImpl();
-
- // WebHistoryItem
- virtual const GURL& GetURL() const;
- virtual const std::wstring& GetTitle() const;
- virtual const std::string& GetHistoryState() const;
- virtual WebRequest::ExtraData* GetExtraData() const;
-
- // WebHistoryItemImpl
- // Returns a WebCore::HistoryItem based on the history_state. This is
- // lazily-created and cached.
- WebCore::HistoryItem* GetHistoryItem() const;
-
- protected:
- GURL url_;
- std::wstring title_;
- std::string history_state_;
- mutable RefPtr<WebCore::HistoryItem> history_item_;
- scoped_refptr<WebRequest::ExtraData> extra_data_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WebHistoryItemImpl);
-};
-
-#endif // #ifndef WEBKIT_GLUE_WEBHISTORYITEM_IMPL_H_
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 02db375..6d5a0c3 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -40,6 +40,7 @@
#include "webkit/api/public/win/WebInputEventFactory.h"
#endif
#include "webkit/glue/event_conversion.h"
+#include "webkit/glue/glue_serialize.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/weburlrequest_impl.h"
#include "webkit/glue/webframe_impl.h"
@@ -150,62 +151,42 @@ static bool HistoryItemCompareLess(PassRefPtr<WebCore::HistoryItem> item1,
}
// Writes out a HistoryItem into a string in a readable format.
-static void DumpHistoryItem(WebCore::HistoryItem* item, int indent,
- bool is_current, std::wstring* result) {
+static std::wstring DumpHistoryItem(PassRefPtr<WebCore::HistoryItem> item,
+ int indent, bool is_current) {
+ std::wstring result;
+
if (is_current) {
- result->append(L"curr->");
- result->append(indent - 6, L' '); // 6 == L"curr->".length()
+ result.append(L"curr->");
+ result.append(indent - 6, L' '); // 6 == L"curr->".length()
} else {
- result->append(indent, L' ');
+ result.append(indent, L' ');
}
- result->append(StringToStdWString(item->urlString()));
+ result.append(StringToStdWString(item->urlString()));
if (!item->target().isEmpty()) {
- result->append(L" (in frame \"" + StringToStdWString(item->target()) +
- L"\")");
+ result.append(L" (in frame \"" + StringToStdWString(item->target()) +
+ L"\")");
}
if (item->isTargetItem())
- result->append(L" **nav target**");
- result->append(L"\n");
+ result.append(L" **nav target**");
+ result.append(L"\n");
if (item->hasChildren()) {
WebCore::HistoryItemVector children = item->children();
// Must sort to eliminate arbitrary result ordering which defeats
// reproducible testing.
std::sort(children.begin(), children.end(), HistoryItemCompareLess);
- for (unsigned i = 0; i < children.size(); i++) {
- DumpHistoryItem(children[i].get(), indent+4, false, result);
- }
+ for (unsigned i = 0; i < children.size(); i++)
+ result += DumpHistoryItem(children[i].get(), indent+4, false);
}
-}
-void DumpBackForwardList(WebView* view, void* previous_history_item,
- std::wstring* result) {
- result->append(L"\n============== Back Forward List ==============\n");
-
- WebCore::Frame* frame =
- static_cast<WebFrameImpl*>(view->GetMainFrame())->frame();
- WebCore::BackForwardList* list = frame->page()->backForwardList();
-
- // Skip everything before the previous_history_item, if it's in the back list.
- // If it isn't found, assume it fell off the end, and include everything.
- int start_index = -list->backListCount();
- WebCore::HistoryItem* prev_item =
- static_cast<WebCore::HistoryItem*>(previous_history_item);
- for (int i = -list->backListCount(); i < 0; ++i) {
- if (prev_item == list->itemAtIndex(i))
- start_index = i+1;
- }
-
- for (int i = start_index; i < 0; ++i)
- DumpHistoryItem(list->itemAtIndex(i), 8, false, result);
-
- DumpHistoryItem(list->currentItem(), 8, true, result);
-
- for (int i = 1; i <= list->forwardListCount(); ++i)
- DumpHistoryItem(list->itemAtIndex(i), 8, false, result);
+ return result;
+}
- result->append(L"===============================================\n");
+std::wstring DumpHistoryState(const std::string& history_state, int indent,
+ bool is_current) {
+ return DumpHistoryItem(HistoryItemFromString(history_state), indent,
+ is_current);
}
void ResetBeforeTestRun(WebView* view) {
diff --git a/webkit/glue/webkit_glue.h b/webkit/glue/webkit_glue.h
index e9f5ed8..2e7e4e3 100644
--- a/webkit/glue/webkit_glue.h
+++ b/webkit/glue/webkit_glue.h
@@ -54,9 +54,10 @@ std::wstring DumpRenderer(WebFrame* web_frame);
// Returns a dump of the scroll position of the webframe.
std::wstring DumpFrameScrollPosition(WebFrame* web_frame, bool recursive);
-// Returns a representation of the back/forward list.
-void DumpBackForwardList(WebView* view, void* previous_history_item,
- std::wstring* result);
+// Returns a dump of the given history state suitable for implementing the
+// dumpBackForwardList command of the layoutTestController.
+std::wstring DumpHistoryState(const std::string& history_state, int indent,
+ bool is_current);
// Cleans up state left over from the previous test run.
void ResetBeforeTestRun(WebView* view);
diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h
index 186940b..525f745 100644
--- a/webkit/glue/webview_delegate.h
+++ b/webkit/glue/webview_delegate.h
@@ -55,7 +55,6 @@ class SkBitmap;
class WebDevToolsAgentDelegate;
class WebError;
class WebFrame;
-class WebHistoryItem;
class WebMediaPlayerDelegate;
class WebPluginDelegate;
class WebRequest;
@@ -702,10 +701,9 @@ class WebViewDelegate : virtual public WebWidgetDelegate {
// History Related ---------------------------------------------------------
- // Returns the session history entry at a distance |offset| relative to the
- // current entry. Returns NULL on failure.
- virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset) {
- return NULL;
+ // Tells the embedder to navigate back or forward in session history by the
+ // given offset (relative to the current position in session history).
+ virtual void NavigateBackForwardSoon(int offset) {
}
// Returns how many entries are in the back and forward lists, respectively.
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 6830fd8..53d0511 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -100,7 +100,6 @@ MSVC_POP_WARNING();
#include "webkit/glue/searchable_form_data.h"
#include "webkit/glue/webdevtoolsagent_impl.h"
#include "webkit/glue/webdropdata.h"
-#include "webkit/glue/webhistoryitem_impl.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webpreferences.h"
#include "webkit/glue/webdevtoolsagent.h"
diff --git a/webkit/tools/test_shell/test_navigation_controller.cc b/webkit/tools/test_shell/test_navigation_controller.cc
index ff4a753..1142839 100644
--- a/webkit/tools/test_shell/test_navigation_controller.cc
+++ b/webkit/tools/test_shell/test_navigation_controller.cc
@@ -5,7 +5,6 @@
#include "webkit/tools/test_shell/test_navigation_controller.h"
#include "base/logging.h"
-#include "webkit/glue/webhistoryitem.h"
#include "webkit/tools/test_shell/test_shell.h"
// ----------------------------------------------------------------------------
@@ -29,21 +28,9 @@ TestNavigationEntry::~TestNavigationEntry() {
}
void TestNavigationEntry::SetContentState(const std::string& state) {
- cached_history_item_ = NULL; // invalidate our cached item
state_ = state;
}
-WebHistoryItem* TestNavigationEntry::GetHistoryItem() const {
- if (!cached_history_item_) {
- TestShellExtraRequestData* extra_data =
- new TestShellExtraRequestData(GetPageID());
- cached_history_item_ =
- WebHistoryItem::Create(GetURL(), GetTitle(), GetContentState(),
- extra_data);
- }
- return cached_history_item_;
-}
-
// ----------------------------------------------------------------------------
// TestNavigationController
@@ -129,9 +116,8 @@ int TestNavigationController::GetCurrentEntryIndex() const {
}
-TestNavigationEntry* TestNavigationController::GetEntryAtOffset(
- int offset) const {
- int index = last_committed_entry_index_ + offset;
+TestNavigationEntry* TestNavigationController::GetEntryAtIndex(
+ int index) const {
if (index < 0 || index >= GetEntryCount())
return NULL;
diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h
index 07f42f8..d26e994 100644
--- a/webkit/tools/test_shell/test_navigation_controller.h
+++ b/webkit/tools/test_shell/test_navigation_controller.h
@@ -16,7 +16,6 @@
class GURL;
class TestShell;
-class WebHistoryItem;
// Associated with browser-initated navigations to hold tracking data.
class TestShellExtraRequestData : public WebRequest::ExtraData {
@@ -67,7 +66,6 @@ class TestNavigationEntry {
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:
@@ -79,8 +77,6 @@ class TestNavigationEntry {
std::wstring title_;
std::string state_;
- mutable scoped_refptr<WebHistoryItem> cached_history_item_;
-
std::wstring target_frame_;
DISALLOW_COPY_AND_ASSIGN(TestNavigationEntry);
@@ -132,9 +128,9 @@ class TestNavigationController {
// 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;
+ // Returns the entry at the specified index. Returns NULL if out of
+ // bounds.
+ TestNavigationEntry* GetEntryAtIndex(int index) const;
// Return the entry with the corresponding type and page_id, or NULL if
// not found.
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 7150807..0dd4c40 100644
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -217,7 +217,7 @@ void TestShell::Dump(TestShell* shell) {
if (shell->layout_test_controller_->ShouldDumpBackForwardList()) {
std::wstring bfDump;
- DumpBackForwardList(&bfDump);
+ DumpAllBackForwardLists(&bfDump);
printf("%s", WideToUTF8(bfDump).c_str());
}
}
@@ -418,35 +418,52 @@ void TestShell::Show(WebView* webview, WindowOpenDisposition disposition) {
}
void TestShell::BindJSObjectsToWindow(WebFrame* frame) {
- // Only bind the test classes if we're running tests.
- if (layout_test_mode_) {
- layout_test_controller_->BindToJavascript(frame,
- L"layoutTestController");
- event_sending_controller_->BindToJavascript(frame,
- L"eventSender");
- text_input_controller_->BindToJavascript(frame,
- L"textInputController");
- }
+ // Only bind the test classes if we're running tests.
+ if (layout_test_mode_) {
+ layout_test_controller_->BindToJavascript(frame, L"layoutTestController");
+ event_sending_controller_->BindToJavascript(frame, L"eventSender");
+ text_input_controller_->BindToJavascript(frame, L"textInputController");
+ }
}
+void TestShell::DumpBackForwardEntry(int index, std::wstring* result) {
+ int current_index = navigation_controller_->GetLastCommittedEntryIndex();
-void TestShell::CallJSGC() {
- WebFrame* frame = webView()->GetMainFrame();
- frame->CallJSGC();
+ std::string content_state =
+ navigation_controller_->GetEntryAtIndex(index)->GetContentState();
+ if (content_state.empty()) {
+ content_state = webkit_glue::CreateHistoryStateForURL(
+ navigation_controller_->GetEntryAtIndex(index)->GetURL());
+ }
+
+ result->append(
+ webkit_glue::DumpHistoryState(content_state, 8, index == current_index));
}
+void TestShell::DumpBackForwardList(std::wstring* result) {
+ result->append(L"\n============== Back Forward List ==============\n");
+
+ for (int i = 0; i < navigation_controller_->GetEntryCount(); ++i)
+ DumpBackForwardEntry(i, result);
+
+ result->append(L"===============================================\n");
+}
+
+void TestShell::CallJSGC() {
+ webView()->GetMainFrame()->CallJSGC();
+}
WebView* TestShell::CreateWebView(WebView* webview) {
- // If we're running layout tests, only open a new window if the test has
- // called layoutTestController.setCanOpenWindows()
- if (layout_test_mode_ && !layout_test_controller_->CanOpenWindows())
- return NULL;
+ // If we're running layout tests, only open a new window if the test has
+ // called layoutTestController.setCanOpenWindows()
+ if (layout_test_mode_ && !layout_test_controller_->CanOpenWindows())
+ return NULL;
- TestShell* new_win;
- if (!CreateNewWindow(std::wstring(), &new_win))
- return NULL;
+ TestShell* new_win;
+ if (!CreateNewWindow(std::wstring(), &new_win))
+ return NULL;
- return new_win->webView();
+ return new_win->webView();
}
void TestShell::SizeToSVG() {
diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h
index c5806c3..d6ac049 100644
--- a/webkit/tools/test_shell/test_shell.h
+++ b/webkit/tools/test_shell/test_shell.h
@@ -194,7 +194,14 @@ public:
static bool RunFileTest(const TestParams& params);
// Writes the back-forward list data for every open window into result.
- static void DumpBackForwardList(std::wstring* result);
+ // Should call DumpBackForwardListOfWindow on each TestShell window.
+ static void DumpAllBackForwardLists(std::wstring* result);
+
+ // Writes the single back-forward entry into result.
+ void DumpBackForwardEntry(int index, std::wstring* result);
+
+ // Writes the back-forward list data for this test shell into result.
+ void DumpBackForwardList(std::wstring* result);
// Dumps the output from given test as text and/or image depending on
// the flags set.
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 40cd1c1..6971a57 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -482,14 +482,14 @@ void TestShell::ResizeSubViews() {
// GTK manages layout for us so we do nothing.
}
-/* static */ void TestShell::DumpBackForwardList(std::wstring* result) {
+/* static */ void TestShell::DumpAllBackForwardLists(std::wstring* result) {
result->clear();
for (WindowList::iterator iter = TestShell::windowList()->begin();
iter != TestShell::windowList()->end(); iter++) {
- GtkWindow* window = *iter;
- TestShell* shell =
- static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), "test-shell"));
- webkit_glue::DumpBackForwardList(shell->webView(), NULL, result);
+ GtkWindow* window = *iter;
+ TestShell* shell =
+ static_cast<TestShell*>(g_object_get_data(G_OBJECT(window), "test-shell"));
+ shell->DumpBackForwardList(result);
}
}
diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm
index 1fd92f1..5be826d 100644
--- a/webkit/tools/test_shell/test_shell_mac.mm
+++ b/webkit/tools/test_shell/test_shell_mac.mm
@@ -484,14 +484,14 @@ void TestShell::ResizeSubViews() {
// handled by Cocoa for us
}
-/* static */ void TestShell::DumpBackForwardList(std::wstring* result) {
+/* static */ void TestShell::DumpAllBackForwardLists(std::wstring* result) {
result->clear();
for (WindowList::iterator iter = TestShell::windowList()->begin();
iter != TestShell::windowList()->end(); iter++) {
NSWindow* window = *iter;
WindowMap::iterator it = window_map_.Get().find(window);
if (it != window_map_.Get().end())
- webkit_glue::DumpBackForwardList(it->second->webView(), NULL, result);
+ it->second->DumpBackForwardList(result);
else
LOG(ERROR) << "Failed to find shell for window during dump";
}
diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc
index c118ceb..4cba4ad 100644
--- a/webkit/tools/test_shell/test_shell_win.cc
+++ b/webkit/tools/test_shell/test_shell_win.cc
@@ -208,14 +208,14 @@ ATOM TestShell::RegisterWindowClass() {
return RegisterClassEx(&wcex);
}
-void TestShell::DumpBackForwardList(std::wstring* result) {
+void TestShell::DumpAllBackForwardLists(std::wstring* result) {
result->clear();
for (WindowList::iterator iter = TestShell::windowList()->begin();
iter != TestShell::windowList()->end(); iter++) {
HWND hwnd = *iter;
TestShell* shell =
static_cast<TestShell*>(win_util::GetWindowUserData(hwnd));
- webkit_glue::DumpBackForwardList(shell->webView(), NULL, result);
+ shell->DumpBackForwardList(result);
}
}
diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc
index 092b2a56..d886f4d 100644
--- a/webkit/tools/test_shell/test_webview_delegate.cc
+++ b/webkit/tools/test_shell/test_webview_delegate.cc
@@ -115,6 +115,14 @@ WebWidget* TestWebViewDelegate::CreatePopupWidget(WebView* webview,
return shell_->CreatePopupWidget(webview);
}
+WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) {
+#if ENABLE(WORKERS)
+ return TestWebWorkerHelper::CreateWebWorker(client);
+#else
+ return NULL;
+#endif
+}
+
void TestWebViewDelegate::OpenURL(WebView* webview, const GURL& url,
const GURL& referrer,
WindowOpenDisposition disposition) {
@@ -661,13 +669,8 @@ void TestWebViewDelegate::DidEndEditing() {
}
}
-WebHistoryItem* TestWebViewDelegate::GetHistoryEntryAtOffset(int offset) {
- TestNavigationEntry* entry = static_cast<TestNavigationEntry*>(
- shell_->navigation_controller()->GetEntryAtOffset(offset));
- if (!entry)
- return NULL;
-
- return entry->GetHistoryItem();
+void TestWebViewDelegate::NavigateBackForwardSoon(int offset) {
+ shell_->navigation_controller()->GoToOffset(offset);
}
int TestWebViewDelegate::GetHistoryBackListCount() {
@@ -791,6 +794,16 @@ void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) {
if (frame == top_loading_frame_) {
top_loading_frame_ = NULL;
+ // It is important to update the content state for the current navigation
+ // entry in case we are done with the test and need to dump the back/
+ // forward list.
+ std::string state;
+ if (shell_->webView()->GetMainFrame()->GetCurrentHistoryState(&state)) {
+ TestNavigationEntry* entry =
+ shell_->navigation_controller()->GetLastCommittedEntry();
+ entry->SetContentState(state);
+ }
+
if (shell_->layout_test_mode())
shell_->layout_test_controller()->LocationChangeDone();
}
@@ -888,11 +901,3 @@ std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) {
return L"frame (anonymous)";
}
}
-
-WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) {
-#if ENABLE(WORKERS)
- return TestWebWorkerHelper::CreateWebWorker(client);
-#else
- return NULL;
-#endif
-}
diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h
index 0c5ef3b..16db870 100644
--- a/webkit/tools/test_shell/test_webview_delegate.h
+++ b/webkit/tools/test_shell/test_webview_delegate.h
@@ -207,7 +207,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>,
WebNavigationType type,
WindowOpenDisposition disposition,
bool is_redirect);
- virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset);
+ virtual void NavigateBackForwardSoon(int offset);
virtual int GetHistoryBackListCount();
virtual int GetHistoryForwardListCount();
diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp
index c7a8eda..2228e48 100644
--- a/webkit/webkit.gyp
+++ b/webkit/webkit.gyp
@@ -4530,9 +4530,6 @@
'glue/webframe_impl.h',
'glue/webframeloaderclient_impl.cc',
'glue/webframeloaderclient_impl.h',
- 'glue/webhistoryitem.h',
- 'glue/webhistoryitem_impl.cc',
- 'glue/webhistoryitem_impl.h',
'glue/webkit_glue.cc',
'glue/webkit_glue.h',
'glue/webkitclient_impl.cc',