summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 06:02:39 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-13 06:02:39 +0000
commitefdb3e59f68fe34ef19dd6e52a5555e19f9b26b4 (patch)
tree717f7caca9e5b8191c0f1ff4cb1f3b00c0281e75 /webkit/glue
parent235df3ac876638d8f09eb62c6b8504446e19b63b (diff)
downloadchromium_src-efdb3e59f68fe34ef19dd6e52a5555e19f9b26b4.zip
chromium_src-efdb3e59f68fe34ef19dd6e52a5555e19f9b26b4.tar.gz
chromium_src-efdb3e59f68fe34ef19dd6e52a5555e19f9b26b4.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. BUG=11423 TBR=mpcomplete Review URL: http://codereview.chromium.org/115288 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-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/webview_delegate.h8
-rw-r--r--webkit/glue/webview_impl.cc1
11 files changed, 63 insertions, 237 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 0ed8a39..b401d15 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"
@@ -787,16 +786,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();
@@ -1021,13 +1010,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) {
@@ -1637,6 +1632,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/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"