diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 06:21:01 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-13 06:21:01 +0000 |
commit | 4781156a2c2dca5839906c18f7eedf0fe808fb23 (patch) | |
tree | ebc644136085edd95ee30b72dcade4654257dce4 /chrome/renderer | |
parent | 876b0c451041fad7be429632de5066e4e30bf625 (diff) | |
download | chromium_src-4781156a2c2dca5839906c18f7eedf0fe808fb23.zip chromium_src-4781156a2c2dca5839906c18f7eedf0fe808fb23.tar.gz chromium_src-4781156a2c2dca5839906c18f7eedf0fe808fb23.tar.bz2 |
Revert r15940 again. Unexpected layout test failures :(
TBR=mpcomplete
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_view.cc | 23 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 11 |
2 files changed, 32 insertions, 2 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index b8dff80..979f74f 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -68,6 +68,7 @@ #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" @@ -1560,6 +1561,13 @@ 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. + } } } } @@ -2437,7 +2445,20 @@ void RenderView::OnAutofillFormSubmitted(WebView* webview, Send(new ViewHostMsg_AutofillFormSubmitted(routing_id_, form)); } -void RenderView::NavigateBackForwardSoon(int offset) { +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) { 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 436772c..a993327 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -279,7 +279,7 @@ class RenderView : public RenderWidget, virtual void TakeFocus(WebView* webview, bool reverse); virtual void JSOutOfMemory(); - virtual void NavigateBackForwardSoon(int offset); + virtual WebHistoryItem* GetHistoryEntryAtOffset(int offset); virtual int GetHistoryBackListCount(); virtual int GetHistoryForwardListCount(); virtual void OnNavStateChanged(WebView* webview); @@ -463,6 +463,10 @@ class RenderView : public RenderWidget, // keyword search. void AddGURLSearchProvider(const GURL& osd_url, bool autodetected); + // 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(); @@ -766,6 +770,11 @@ 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 query the Browser process. We cannot wait for the Browser |