diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 17:12:55 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-01 17:12:55 +0000 |
commit | e6f546c3ab626d39d375376890b7f4bfef92f48e (patch) | |
tree | cbf7b1218db462116ea45f8536ee0900cb1f9ea6 /chrome | |
parent | 0e2dc851dc1ba72d849d22eba47ea053b2721916 (diff) | |
download | chromium_src-e6f546c3ab626d39d375376890b7f4bfef92f48e.zip chromium_src-e6f546c3ab626d39d375376890b7f4bfef92f48e.tar.gz chromium_src-e6f546c3ab626d39d375376890b7f4bfef92f48e.tar.bz2 |
Add Reload and LoadData methods to WebFrame. LoadData replaces
LoadAlternateHTMLString, changing types to WebKit API types and
allowing for more flexibility (supports loading non-HTML data).
LoadHTMLString is modified to support some optional parameters.
Note: Since WebFrame is going to soon be part of the WebKit API,
it is OK style-wise for it to use optional parameters.
This patch also includes a change to remove the securityInfo
property from WebURLRequest. I did this so that I could eliminate
the need to pass a WebURLRequest to LoadData / LoadHTMLString.
This also fixes a TODO of mine to eliminate this field on
WebCore::ResourceRequest since securityInfo (SSL cert info) is
really more of a response property. It was only part of the
request as a hack to support certain error pages. I work around
that by leveraging NavigationState in chrome/renderer.
I added some templatized, implicit constructors to WebData for
convenience. I plan to make similar changes to WebCString and
WebString in a future CL.
This CL is a incremental step toward moving ResourceFetcher out
of WebFrame.
BUG=15648
TEST=none
R=dglazkov
Review URL: http://codereview.chromium.org/150146
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19742 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/navigation_state.h | 8 | ||||
-rw-r--r-- | chrome/renderer/render_view.cc | 55 |
2 files changed, 32 insertions, 31 deletions
diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h index 0428f2a..771ef55 100644 --- a/chrome/renderer/navigation_state.h +++ b/chrome/renderer/navigation_state.h @@ -132,6 +132,13 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { password_form_data_.reset(data); } + const std::string& security_info() const { + return security_info_; + } + void set_security_info(const std::string& security_info) { + security_info_ = security_info; + } + private: NavigationState(PageTransition::Type transition_type, const base::Time& request_time, @@ -159,6 +166,7 @@ class NavigationState : public WebKit::WebDataSource::ExtraData { int32 pending_page_id_; scoped_ptr<webkit_glue::SearchableFormData> searchable_form_data_; scoped_ptr<webkit_glue::PasswordForm> password_form_data_; + std::string security_info_; DISALLOW_COPY_AND_ASSIGN(NavigationState); }; diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index b2c505a..f59cfce 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -100,6 +100,7 @@ using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; using webkit_glue::SearchableFormData; using WebKit::WebConsoleMessage; +using WebKit::WebData; using WebKit::WebDataSource; using WebKit::WebDragData; using WebKit::WebForm; @@ -652,7 +653,9 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { // 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()) { + if (is_reload) { + main_frame->Reload(); + } else if (!params.state.empty()) { // We must know the page ID of the page we are navigating back to. DCHECK_NE(params.page_id, -1); main_frame->LoadHistoryItem( @@ -661,21 +664,11 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { // Navigate to the given URL. WebURLRequest request(params.url); - // TODO(darin): WebFrame should just have a Reload method. + // A session history navigation should have been accompanied by state. + DCHECK_EQ(params.page_id, -1); - WebURLRequest::CachePolicy cache_policy; - if (is_reload) { - cache_policy = WebURLRequest::ReloadIgnoringCacheData; - } else { - // A session history navigation should have been accompanied by state. - DCHECK_EQ(params.page_id, -1); - if (main_frame->GetInViewSourceMode()) { - cache_policy = WebURLRequest::ReturnCacheDataElseLoad; - } else { - cache_policy = WebURLRequest::UseProtocolCachePolicy; - } - } - request.setCachePolicy(cache_policy); + if (main_frame->GetInViewSourceMode()) + request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); if (params.referrer.is_valid()) { request.setHTTPHeaderField(WebString::fromUTF8("Referer"), @@ -695,22 +688,23 @@ void RenderView::OnStop() { webview()->StopLoading(); } -void RenderView::OnLoadAlternateHTMLText(const std::string& html_contents, +void RenderView::OnLoadAlternateHTMLText(const std::string& html, bool new_navigation, const GURL& display_url, const std::string& security_info) { if (!webview()) return; - WebURLRequest request; - request.initialize(); - request.setURL(GURL(kUnreachableWebDataURL)); - request.setSecurityInfo(security_info); + pending_navigation_state_.reset(NavigationState::CreateBrowserInitiated( + new_navigation ? -1 : page_id_, PageTransition::LINK, Time::Now())); + pending_navigation_state_->set_security_info(security_info); - webview()->GetMainFrame()->LoadAlternateHTMLString(request, - html_contents, - display_url, - !new_navigation); + webview()->GetMainFrame()->LoadHTMLString(html, + GURL(kUnreachableWebDataURL), + display_url, + !new_navigation); + + pending_navigation_state_.reset(); } void RenderView::OnCopyImageAt(int x, int y) { @@ -852,13 +846,13 @@ void RenderView::UpdateURL(WebFrame* frame) { params.is_post = false; params.page_id = page_id_; params.is_content_filtered = response.isContentFiltered(); - if (!request.securityInfo().isEmpty()) { + if (!navigation_state->security_info().empty()) { // SSL state specified in the request takes precedence over the one in the // response. // So far this is only intended for error pages that are not expected to be // over ssl, so we should not get any clash. DCHECK(response.securityInfo().isEmpty()); - params.security_info = request.securityInfo(); + params.security_info = navigation_state->security_info(); } else { params.security_info = response.securityInfo(); } @@ -1251,11 +1245,10 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, alt_html = html; } - // Use a data: URL as the site URL to prevent against XSS attacks. - WebURLRequest request(failed_request); - request.setURL(GURL(kUnreachableWebDataURL)); - - frame->LoadAlternateHTMLString(request, alt_html, failed_url, replace); + frame->LoadHTMLString(alt_html, + GURL(kUnreachableWebDataURL), + failed_url, + replace); } void RenderView::DidCommitLoadForFrame(WebView *webview, WebFrame* frame, |