diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 17:00:13 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-22 17:00:13 +0000 |
commit | 04d3c6e85f3aabc08a1d72a72d8c3a82fab65dda (patch) | |
tree | c5082b2d21a434b473a2497aa00a038d7d1ab75a /chrome | |
parent | 8c18cbcb08fba3073f2a362f45c66ebdd72e9cc1 (diff) | |
download | chromium_src-04d3c6e85f3aabc08a1d72a72d8c3a82fab65dda.zip chromium_src-04d3c6e85f3aabc08a1d72a72d8c3a82fab65dda.tar.gz chromium_src-04d3c6e85f3aabc08a1d72a72d8c3a82fab65dda.tar.bz2 |
Remove the HistoryState property of WebRequest.
In the new WebKit API, it seems best if WebRequest is just a wrapper for
WebCore::ResourceRequest since in most contexts that's what we need it to
be.
The solution here is to introduce a LoadHistoryState method on WebFrame that
can be used to navigate to a session history item.
BUG=10038
TEST=covered by existing back/forward navigation tests.
R=brettw
Review URL: http://codereview.chromium.org/113758
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16747 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/render_view.cc | 52 |
1 files changed, 31 insertions, 21 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 79ddf45..9e669fd 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -794,18 +794,6 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { is_reload = false; } - WebRequestCachePolicy cache_policy; - if (is_reload) { - cache_policy = WebRequestReloadIgnoringCacheData; - } else if (params.page_id != -1 || main_frame->GetInViewSourceMode()) { - cache_policy = WebRequestReturnCacheDataElseLoad; - } else { - cache_policy = WebRequestUseProtocolCachePolicy; - } - - scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); - request->SetCachePolicy(cache_policy); - // A navigation resulting from loading a javascript URL should not be treated // as a browser initiated event. Instead, we want it to look as if the page // initiated any load resulting from JS execution. @@ -814,17 +802,39 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { params.page_id, params.transition, params.request_time)); } - // If we are reloading, then WebKit will use the state of the current page. - // Otherwise, we give it the state to navigate to. - if (!is_reload) - request->SetHistoryState(params.state); + // If we are reloading, then WebKit will use the history state of the current + // page, so we should just ignore any given history state. Otherwise, if we + // have history state, then we need to navigate to it, which corresponds to a + // back/forward navigation event. + if (!is_reload && !params.state.empty()) { + // We must know the page ID of the page we are navigating back to. + DCHECK(params.page_id != -1); + main_frame->LoadHistoryState(params.state); + } else { + // Navigate to the given URL. + scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); - if (params.referrer.is_valid()) { - request->SetHttpHeaderValue("Referer", - params.referrer.spec()); - } + // TODO(darin): WebFrame should just have a Reload method. - main_frame->LoadRequest(request.get()); + WebRequestCachePolicy cache_policy; + if (is_reload) { + cache_policy = WebRequestReloadIgnoringCacheData; + } else { + // A session history navigation should have been accompanied by state. + DCHECK(params.page_id == -1); + if (main_frame->GetInViewSourceMode()) { + cache_policy = WebRequestReturnCacheDataElseLoad; + } else { + cache_policy = WebRequestUseProtocolCachePolicy; + } + } + request->SetCachePolicy(cache_policy); + + if (params.referrer.is_valid()) + request->SetHttpHeaderValue("Referer", params.referrer.spec()); + + main_frame->LoadRequest(request.get()); + } // In case LoadRequest failed before DidCreateDataSource was called. pending_navigation_state_.reset(); |