diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 21:28:48 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-04 21:28:48 +0000 |
commit | 8ee37f03d400794478584634d3d493a12f6b989d (patch) | |
tree | c6418a199d69b13bf0e05e558da2bcd60e971850 | |
parent | 8165dcf042237c13d41aaad2a9c654c64bc4cb35 (diff) | |
download | chromium_src-8ee37f03d400794478584634d3d493a12f6b989d.zip chromium_src-8ee37f03d400794478584634d3d493a12f6b989d.tar.gz chromium_src-8ee37f03d400794478584634d3d493a12f6b989d.tar.bz2 |
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.
BUG=11423
R=mpcomplete
Review URL: http://codereview.chromium.org/100353
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15244 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/renderer/render_view.cc | 23 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 11 | ||||
-rw-r--r-- | webkit/glue/back_forward_list_client_impl.cc | 35 | ||||
-rw-r--r-- | webkit/glue/back_forward_list_client_impl.h | 5 | ||||
-rw-r--r-- | webkit/glue/glue.vcproj | 12 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 15 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.h | 7 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.cc | 50 | ||||
-rw-r--r-- | webkit/glue/webframeloaderclient_impl.h | 3 | ||||
-rw-r--r-- | webkit/glue/webhistoryitem.h | 39 | ||||
-rw-r--r-- | webkit/glue/webhistoryitem_impl.cc | 90 | ||||
-rw-r--r-- | webkit/glue/webhistoryitem_impl.h | 47 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 8 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 1 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_navigation_controller.cc | 13 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_navigation_controller.h | 4 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_shell.cc | 1 | ||||
-rwxr-xr-x | webkit/tools/test_shell/test_webview_delegate.cc | 29 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 6 | ||||
-rw-r--r-- | webkit/webkit.gyp | 3 |
20 files changed, 87 insertions, 315 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 1236886..262997b 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -68,7 +68,6 @@ #include "webkit/glue/webdropdata.h" #include "webkit/glue/weberror.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webhistoryitem.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin_delegate.h" @@ -1553,13 +1552,6 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( url.SchemeIs(chrome::kViewSourceScheme)) { OpenURL(webview, url, GURL(), disposition); return IGNORE_ACTION; // Suppress the load here. - } else if (url.SchemeIs(kBackForwardNavigationScheme)) { - std::string offset_str = url.ExtractFileName(); - int offset; - if (StringToInt(offset_str, &offset)) { - GoToEntryAtOffset(offset); - return IGNORE_ACTION; // The browser process handles this one. - } } } } @@ -2433,20 +2425,7 @@ void RenderView::OnAutofillFormSubmitted(WebView* webview, Send(new ViewHostMsg_AutofillFormSubmitted(routing_id_, form)); } -WebHistoryItem* RenderView::GetHistoryEntryAtOffset(int offset) { - // Our history list is kept in the browser process on the UI thread. Since - // we can't make a sync IPC call to that thread without risking deadlock, - // we use a trick: construct a fake history item of the form: - // history://go/OFFSET - // When WebCore tells us to navigate to it, we tell the browser process to - // do a back/forward navigation instead. - - GURL url(StringPrintf("%s://go/%d", kBackForwardNavigationScheme, offset)); - history_navigation_item_ = WebHistoryItem::Create(url, L"", "", NULL); - return history_navigation_item_.get(); -} - -void RenderView::GoToEntryAtOffset(int offset) { +void RenderView::NavigateBackForwardSoon(int offset) { history_back_list_count_ += offset; history_forward_list_count_ -= offset; diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index fa88cb1..fa28f0c 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -274,7 +274,7 @@ class RenderView : public RenderWidget, virtual void TakeFocus(WebView* webview, bool reverse); virtual void JSOutOfMemory(); - virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); + virtual void NavigateBackForwardSoon(int offset); virtual int GetHistoryBackListCount(); virtual int GetHistoryForwardListCount(); virtual void OnNavStateChanged(WebView* webview); @@ -453,10 +453,6 @@ class RenderView : public RenderWidget, // Update the feed list. void UpdateFeedList(scoped_refptr<FeedList> feedlist); - // Tells the browser process to navigate to a back/forward entry at the given - // offset from current. - void GoToEntryAtOffset(int offset); - // RenderView IPC message handlers void SendThumbnail(); void OnPrintPages(); @@ -763,11 +759,6 @@ class RenderView : public RenderWidget, // out of date responses. int form_field_autofill_request_id_; - // A cached WebHistoryItem used for back/forward navigations initiated by - // WebCore (via the window.history.go API). We only have one such navigation - // pending at a time. - scoped_refptr<WebHistoryItem> history_navigation_item_; - // We need to prevent windows from closing themselves with a window.close() // call while a blocked popup notification is being displayed. We cannot // synchronously querry the Browser process. We cannot wait for the Browser 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/glue.vcproj b/webkit/glue/glue.vcproj index 0677fbb..f16606e 100644 --- a/webkit/glue/glue.vcproj +++ b/webkit/glue/glue.vcproj @@ -222,10 +222,6 @@ >
</File>
<File
- RelativePath=".\webhistoryitem.h"
- >
- </File>
- <File
RelativePath=".\webmediaplayer.h"
>
</File>
@@ -642,14 +638,6 @@ >
</File>
<File
- RelativePath=".\webhistoryitem_impl.cc"
- >
- </File>
- <File
- RelativePath=".\webhistoryitem_impl.h"
- >
- </File>
- <File
RelativePath=".\webkit_glue.cc"
>
</File>
diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 3b87d4f..46faf37 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -150,7 +150,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" @@ -714,25 +713,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 61162f7..e8abb8b 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; @@ -229,8 +228,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; @@ -316,10 +313,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 b2cdae9..4c66be2a 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -55,7 +55,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" @@ -786,16 +785,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_->webview_impl(); WebViewDelegate* d = webview->delegate(); @@ -1020,13 +1009,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) { @@ -1635,6 +1630,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_->webview_impl()->delegate(); + if (d) + d->NavigateBackForwardSoon(offset); +} + NetAgentImpl* WebFrameLoaderClient::GetNetAgentImpl() { WebViewImpl* web_view = webframe_->webview_impl(); 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/webview_delegate.h b/webkit/glue/webview_delegate.h index 27036db..483ef1c 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -53,7 +53,6 @@ class SkBitmap; class WebDevToolsAgentDelegate; class WebError; class WebFrame; -class WebHistoryItem; class WebMediaPlayerDelegate; class WebPluginDelegate; class WebRequest; @@ -695,10 +694,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 7e41aa9..e4fd16d 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..cf26baf 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 diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h index 07f42f8..e24fff30 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); diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 96a5ca5..3f88d26 100755 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -125,6 +125,7 @@ TestShell::~TestShell() { CallJSGC(); CallJSGC(); + delegate_->clear_test_shell(); webView()->SetDelegate(NULL); PlatformCleanUp(); diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 4bf5601..c891c79 100755 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -114,6 +114,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) { @@ -660,13 +668,11 @@ 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) { + // We start this navigation via a delayed task to match Chrome's asynchronous + // implementation of this method. + MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( + this, &TestWebViewDelegate::NavigateBackForward, offset)); } int TestWebViewDelegate::GetHistoryBackListCount() { @@ -888,10 +894,7 @@ std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { } } -WebWorker* TestWebViewDelegate::CreateWebWorker(WebWorkerClient* client) { -#if ENABLE(WORKERS) - return TestWebWorkerHelper::CreateWebWorker(client); -#else - return NULL; -#endif +void TestWebViewDelegate::NavigateBackForward(int offset) { + if (shell_) + shell_->navigation_controller()->GoToOffset(offset); } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 79fd25d..d6e1001 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -205,7 +205,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(); @@ -269,6 +269,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); void WaitForPolicyDelegate(); + void clear_test_shell() { shell_ = NULL; } + protected: // Called the title of the page changes. // Can be used to update the title of the window. @@ -302,6 +304,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, // Get a string suitable for dumping a frame to the console. std::wstring GetFrameDescription(WebFrame* webframe); + void NavigateBackForward(int offset); + private: // Causes navigation actions just printout the intended navigation instead // of taking you to the page. This is used for cases like mailto, where you diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index f759ba3..53e7602 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4500,9 +4500,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', |