diff options
54 files changed, 590 insertions, 1105 deletions
diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc index d3ed834..4b800a7 100644 --- a/chrome/renderer/loadtimes_extension_bindings.cc +++ b/chrome/renderer/loadtimes_extension_bindings.cc @@ -8,7 +8,9 @@ #include "v8/include/v8.h" #include "chrome/renderer/navigation_state.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/webdatasource.h" + +using WebKit::WebDataSource; +using WebKit::WebNavigationType; namespace extensions_v8 { @@ -45,12 +47,18 @@ class LoadTimesExtensionWrapper : public v8::Extension { static const char *GetNavigationType(WebNavigationType nav_type) { switch (nav_type) { - case WebNavigationTypeLinkClicked: return "LinkClicked"; - case WebNavigationTypeFormSubmitted: return "FormSubmitted"; - case WebNavigationTypeBackForward: return "BackForward"; - case WebNavigationTypeReload: return "Reload"; - case WebNavigationTypeFormResubmitted: return "Resubmitted"; - case WebNavigationTypeOther: return "Other"; + case WebKit::WebNavigationTypeLinkClicked: + return "LinkClicked"; + case WebKit::WebNavigationTypeFormSubmitted: + return "FormSubmitted"; + case WebKit::WebNavigationTypeBackForward: + return "BackForward"; + case WebKit::WebNavigationTypeReload: + return "Reload"; + case WebKit::WebNavigationTypeFormResubmitted: + return "Resubmitted"; + case WebKit::WebNavigationTypeOther: + return "Other"; } return ""; } @@ -81,8 +89,7 @@ class LoadTimesExtensionWrapper : public v8::Extension { v8::Number::New(navigation_state->first_layout_time().ToDoubleT())); load_times->Set( v8::String::New("navigationType"), - v8::String::New( - GetNavigationType(data_source->GetNavigationType()))); + v8::String::New(GetNavigationType(data_source->navigationType()))); return load_times; } } diff --git a/chrome/renderer/localized_error.cc b/chrome/renderer/localized_error.cc index a310d60..ab47125 100644 --- a/chrome/renderer/localized_error.cc +++ b/chrome/renderer/localized_error.cc @@ -12,9 +12,11 @@ #include "grit/generated_resources.h" #include "net/base/escape.h" #include "net/base/net_errors.h" -#include "webkit/glue/weberror.h" +#include "webkit/api/public/WebURLError.h" #include "webkit/glue/webkit_glue.h" +using WebKit::WebURLError; + namespace { static const char* kRedirectLoopLearnMoreUrl = @@ -83,7 +85,7 @@ WebErrorNetErrorMap net_error_options[] = { } // namespace -void GetLocalizedErrorValues(const WebError& error, +void GetLocalizedErrorValues(const WebURLError& error, DictionaryValue* error_strings) { // Grab strings that are applicable to all error pages error_strings->SetString(L"detailsLink", @@ -101,7 +103,7 @@ void GetLocalizedErrorValues(const WebError& error, IDS_ERRORPAGES_DETAILS_UNKNOWN, SUGGEST_NONE, }; - int error_code = error.GetErrorCode(); + int error_code = error.reason; for (size_t i = 0; i < arraysize(net_error_options); ++i) { if (net_error_options[i].error_code == error_code) { memcpy(&options, &net_error_options[i], sizeof(WebErrorNetErrorMap)); @@ -116,7 +118,8 @@ void GetLocalizedErrorValues(const WebError& error, } error_strings->SetString(L"suggestionsHeading", suggestions_heading); - std::wstring failed_url(ASCIIToWide(error.GetFailedURL().spec())); + std::wstring failed_url( + ASCIIToWide(std::string(error.unreachableURL.spec()))); // URLs are always LTR. if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) l10n_util::WrapStringWithLTRFormatting(&failed_url); @@ -152,7 +155,7 @@ void GetLocalizedErrorValues(const WebError& error, if (options.suggestions & SUGGEST_HOSTNAME) { // Only show the "Go to hostname" suggestion if the failed_url has a path. - const GURL& failed_url = error.GetFailedURL(); + const GURL& failed_url = error.unreachableURL; if (std::string() == failed_url.path()) { DictionaryValue* suggest_home_page = new DictionaryValue; suggest_home_page->SetString(L"suggestionsHomepageMsg", diff --git a/chrome/renderer/localized_error.h b/chrome/renderer/localized_error.h index b5024a7..ff7da34 100644 --- a/chrome/renderer/localized_error.h +++ b/chrome/renderer/localized_error.h @@ -6,10 +6,13 @@ #define CHROME_RENDERER_LOCALIZED_ERROR_VALUES_H__ class DictionaryValue; -class WebError; class GURL; -void GetLocalizedErrorValues(const WebError& error, +namespace WebKit { +struct WebURLError; +} + +void GetLocalizedErrorValues(const WebKit::WebURLError& error, DictionaryValue* error_strings); // Fills |error_strings| with values to be used to build an error page which diff --git a/chrome/renderer/navigation_state.h b/chrome/renderer/navigation_state.h index eabe25f6..7d6aed5 100644 --- a/chrome/renderer/navigation_state.h +++ b/chrome/renderer/navigation_state.h @@ -8,13 +8,13 @@ #include "base/scoped_ptr.h" #include "base/time.h" #include "chrome/common/page_transition_types.h" +#include "webkit/api/public/WebDataSource.h" #include "webkit/glue/password_form.h" #include "webkit/glue/searchable_form_data.h" -#include "webkit/glue/webdatasource.h" // The RenderView stores an instance of this class in the "extra data" of each // WebDataSource (see RenderView::DidCreateDataSource). -class NavigationState : public WebDataSource::ExtraData { +class NavigationState : public WebKit::WebDataSource::ExtraData { public: static NavigationState* CreateBrowserInitiated( int32 pending_page_id, @@ -29,8 +29,8 @@ class NavigationState : public WebDataSource::ExtraData { return new NavigationState(PageTransition::LINK, base::Time(), true, -1); } - static NavigationState* FromDataSource(WebDataSource* ds) { - return static_cast<NavigationState*>(ds->GetExtraData()); + static NavigationState* FromDataSource(WebKit::WebDataSource* ds) { + return static_cast<NavigationState*>(ds->extraData()); } // Contains the page_id for this navigation or -1 if there is none yet. diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc index d281a76..049dbb8 100644 --- a/chrome/renderer/print_web_view_helper.cc +++ b/chrome/renderer/print_web_view_helper.cc @@ -14,7 +14,6 @@ #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebSize.h" #include "webkit/glue/webframe.h" -#include "webkit/glue/weburlrequest.h" #if defined(OS_WIN) #include "chrome/common/gfx/emf.h" diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index e4905982..7ccb5b1 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -26,7 +26,6 @@ #else #include "base/scoped_handle.h" #include "chrome/plugin/plugin_channel_base.h" -#include "webkit/glue/weburlrequest.h" #endif #include "chrome/renderer/devtools_agent_filter.h" #include "chrome/renderer/extensions/event_bindings.h" diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index b92cd53..6151878 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -54,12 +54,18 @@ #include "net/base/net_errors.h" #include "skia/ext/bitmap_platform_device.h" #include "skia/ext/image_operations.h" +#include "webkit/api/public/WebDataSource.h" #include "webkit/api/public/WebDragData.h" #include "webkit/api/public/WebForm.h" #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebScriptSource.h" #include "webkit/api/public/WebSize.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLError.h" +#include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/public/WebURLResponse.h" +#include "webkit/api/public/WebVector.h" #include "webkit/default_plugin/default_plugin_shared.h" #include "webkit/glue/dom_operations.h" #include "webkit/glue/dom_serializer.h" @@ -68,18 +74,14 @@ #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/searchable_form_data.h" #include "webkit/glue/webaccessibilitymanager_impl.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webdevtoolsagent_delegate.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/weberror.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webmediaplayer_impl.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin_delegate.h" -#include "webkit/glue/webresponse.h" #include "webkit/glue/webtextinput.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview.h" #if defined(OS_WIN) @@ -95,12 +97,20 @@ using webkit_glue::PasswordForm; using webkit_glue::PasswordFormDomManager; using webkit_glue::SearchableFormData; using WebKit::WebConsoleMessage; +using WebKit::WebDataSource; using WebKit::WebDragData; using WebKit::WebForm; +using WebKit::WebNavigationType; using WebKit::WebRect; using WebKit::WebScriptSource; +using WebKit::WebString; +using WebKit::WebURL; +using WebKit::WebURLError; +using WebKit::WebURLRequest; +using WebKit::WebURLResponse; using WebKit::WebWorker; using WebKit::WebWorkerClient; +using WebKit::WebVector; //----------------------------------------------------------------------------- @@ -143,6 +153,14 @@ static const char* const kUnreachableWebDataURL = static const char* const kBackForwardNavigationScheme = "history"; +static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { + WebVector<WebURL> urls; + ds->redirectChain(urls); + result->reserve(urls.size()); + for (size_t i = 0; i < urls.size(); ++i) + result->push_back(urls[i]); +} + /////////////////////////////////////////////////////////////////////////////// RenderView::RenderView(RenderThreadBase* render_thread) @@ -456,7 +474,7 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { // Don't index/capture pages that failed to load. This only checks the top // level frame so the thumbnail may contain a frame that failed to load. WebDataSource* ds = main_frame->GetDataSource(); - if (ds && ds->HasUnreachableURL()) + if (ds && ds->hasUnreachableURL()) return; if (!preliminary_capture) @@ -631,28 +649,30 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { main_frame->LoadHistoryState(params.state); } else { // Navigate to the given URL. - scoped_ptr<WebRequest> request(WebRequest::Create(params.url)); + WebURLRequest request(params.url); // TODO(darin): WebFrame should just have a Reload method. - WebRequestCachePolicy cache_policy; + WebURLRequest::CachePolicy cache_policy; if (is_reload) { - cache_policy = WebRequestReloadIgnoringCacheData; + 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 = WebRequestReturnCacheDataElseLoad; + cache_policy = WebURLRequest::ReturnCacheDataElseLoad; } else { - cache_policy = WebRequestUseProtocolCachePolicy; + cache_policy = WebURLRequest::UseProtocolCachePolicy; } } - request->SetCachePolicy(cache_policy); + request.setCachePolicy(cache_policy); - if (params.referrer.is_valid()) - request->SetHttpHeaderValue("Referer", params.referrer.spec()); + if (params.referrer.is_valid()) { + request.setHTTPHeaderField(WebString::fromUTF8("Referer"), + WebString::fromUTF8(params.referrer.spec())); + } - main_frame->LoadRequest(request.get()); + main_frame->LoadRequest(request); } // In case LoadRequest failed before DidCreateDataSource was called. @@ -672,11 +692,12 @@ void RenderView::OnLoadAlternateHTMLText(const std::string& html_contents, if (!webview()) return; - scoped_ptr<WebRequest> request(WebRequest::Create( - GURL(kUnreachableWebDataURL))); - request->SetSecurityInfo(security_info); + WebURLRequest request; + request.initialize(); + request.setURL(GURL(kUnreachableWebDataURL)); + request.setSecurityInfo(security_info); - webview()->GetMainFrame()->LoadAlternateHTMLString(request.get(), + webview()->GetMainFrame()->LoadAlternateHTMLString(request, html_contents, display_url, !new_navigation); @@ -809,38 +830,38 @@ void RenderView::UpdateURL(WebFrame* frame) { WebDataSource* ds = frame->GetDataSource(); DCHECK(ds); - const WebRequest& request = ds->GetRequest(); - const WebRequest& initial_request = ds->GetInitialRequest(); - const WebResponse& response = ds->GetResponse(); + const WebURLRequest& request = ds->request(); + const WebURLRequest& original_request = ds->originalRequest(); + const WebURLResponse& response = ds->response(); NavigationState* navigation_state = NavigationState::FromDataSource(ds); DCHECK(navigation_state); ViewHostMsg_FrameNavigate_Params params; - params.http_status_code = response.GetHttpStatusCode(); + params.http_status_code = response.httpStatusCode(); params.is_post = false; params.page_id = page_id_; - params.is_content_filtered = response.IsContentFiltered(); - if (!request.GetSecurityInfo().empty()) { + params.is_content_filtered = response.isContentFiltered(); + if (!request.securityInfo().isEmpty()) { // 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.GetSecurityInfo().empty()); - params.security_info = request.GetSecurityInfo(); + DCHECK(response.securityInfo().isEmpty()); + params.security_info = request.securityInfo(); } else { - params.security_info = response.GetSecurityInfo(); + params.security_info = response.securityInfo(); } // Set the URL to be displayed in the browser UI to the user. - if (ds->HasUnreachableURL()) { - params.url = ds->GetUnreachableURL(); + if (ds->hasUnreachableURL()) { + params.url = ds->unreachableURL(); } else { - params.url = request.GetURL(); + params.url = request.url(); } - params.redirects = ds->GetRedirectChain(); - params.should_update_history = !ds->HasUnreachableURL(); + GetRedirectChain(ds, ¶ms.redirects); + params.should_update_history = !ds->hasUnreachableURL(); const SearchableFormData* searchable_form_data = navigation_state->searchable_form_data(); @@ -862,7 +883,7 @@ void RenderView::UpdateURL(WebFrame* frame) { // Top-level navigation. // Update contents MIME type for main frame. - params.contents_mime_type = ds->GetResponse().GetMimeType(); + params.contents_mime_type = UTF16ToUTF8(ds->response().mimeType()); params.transition = navigation_state->transition_type(); if (!PageTransition::IsMainFrame(params.transition)) { @@ -891,11 +912,12 @@ void RenderView::UpdateURL(WebFrame* frame) { } else { // Bug 654101: the referrer will be empty on https->http transitions. It // would be nice if we could get the real referrer from somewhere. - params.referrer = GURL(initial_request.GetHttpReferrer()); + params.referrer = GURL( + original_request.httpHeaderField(WebString::fromUTF8("Referer"))); } - std::string method = request.GetHttpMethod(); - if (method == "POST") + string16 method = request.httpMethod(); + if (EqualsASCII(method, "POST")) params.is_post = true; Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); @@ -1030,9 +1052,9 @@ void RenderView::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { // The rest of RenderView assumes that a WebDataSource will always have a // non-null NavigationState. if (pending_navigation_state_.get()) { - ds->SetExtraData(pending_navigation_state_.release()); + ds->setExtraData(pending_navigation_state_.release()); } else { - ds->SetExtraData(NavigationState::CreateContentInitiated()); + ds->setExtraData(NavigationState::CreateContentInitiated()); } } @@ -1047,7 +1069,7 @@ void RenderView::DidStartProvisionalLoadForFrame( // Update the request time if WebKit has better knowledge of it. if (navigation_state->request_time().is_null()) { - double event_time = ds->GetTriggeringEventTime(); + double event_time = ds->triggeringEventTime(); if (event_time != 0.0) navigation_state->set_request_time(Time::FromDoubleT(event_time)); } @@ -1061,19 +1083,19 @@ void RenderView::DidStartProvisionalLoadForFrame( } Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( - routing_id_, is_top_most, ds->GetRequest().GetURL())); + routing_id_, is_top_most, ds->request().url())); } bool RenderView::DidLoadResourceFromMemoryCache(WebView* webview, - const WebRequest& request, - const WebResponse& response, + const WebURLRequest& request, + const WebURLResponse& response, WebFrame* frame) { // Let the browser know we loaded a resource from the memory cache. This // message is needed to display the correct SSL indicators. Send(new ViewHostMsg_DidLoadResourceFromMemoryCache(routing_id_, - request.GetURL(), frame->GetSecurityOrigin(), + request.url(), frame->GetSecurityOrigin(), frame->GetTop()->GetSecurityOrigin(), - response.GetSecurityInfo())); + response.securityInfo())); return false; } @@ -1089,7 +1111,8 @@ void RenderView::DidReceiveProvisionalLoadServerRedirect(WebView* webview, NOTREACHED(); return; } - const std::vector<GURL>& redirects = data_source->GetRedirectChain(); + std::vector<GURL> redirects; + GetRedirectChain(data_source, &redirects); if (redirects.size() >= 2) { Send(new ViewHostMsg_DidRedirectProvisionalLoad( routing_id_, page_id_, redirects[redirects.size() - 2], @@ -1099,7 +1122,7 @@ void RenderView::DidReceiveProvisionalLoadServerRedirect(WebView* webview, } void RenderView::DidFailProvisionalLoadWithError(WebView* webview, - const WebError& error, + const WebURLError& error, WebFrame* frame) { // Notify the browser that we failed a provisional load with an error. // @@ -1110,19 +1133,19 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, WebDataSource* ds = frame->GetProvisionalDataSource(); DCHECK(ds); - const WebRequest& failed_request = ds->GetRequest(); + const WebURLRequest& failed_request = ds->request(); bool show_repost_interstitial = - (error.GetErrorCode() == net::ERR_CACHE_MISS && - LowerCaseEqualsASCII(failed_request.GetHttpMethod(), "post")); + (error.reason == net::ERR_CACHE_MISS && + EqualsASCII(failed_request.httpMethod(), "POST")); Send(new ViewHostMsg_DidFailProvisionalLoadWithError( - routing_id_, frame == webview->GetMainFrame(), - error.GetErrorCode(), error.GetFailedURL(), + routing_id_, !frame->GetParent(), + error.reason, error.unreachableURL, show_repost_interstitial)); // Don't display an error page if this is simply a cancelled load. Aside // from being dumb, WebCore doesn't expect it and it will cause a crash. - if (error.GetErrorCode() == net::ERR_ABORTED) + if (error.reason == net::ERR_ABORTED) return; // If this is a failed back/forward/reload navigation, then we need to do a @@ -1134,43 +1157,43 @@ void RenderView::DidFailProvisionalLoadWithError(WebView* webview, // Use the alternate error page service if this is a DNS failure or // connection failure. ERR_CONNECTION_FAILED can be dropped once we no longer // use winhttp. - int ec = error.GetErrorCode(); + int ec = error.reason; if (ec == net::ERR_NAME_NOT_RESOLVED || ec == net::ERR_CONNECTION_FAILED || ec == net::ERR_CONNECTION_REFUSED || ec == net::ERR_ADDRESS_UNREACHABLE || ec == net::ERR_TIMED_OUT) { - const GURL& failed_url = error.GetFailedURL(); + const GURL& failed_url = error.unreachableURL; const GURL& error_page_url = GetAlternateErrorPageURL(failed_url, ec == net::ERR_NAME_NOT_RESOLVED ? WebViewDelegate::DNS_ERROR : WebViewDelegate::CONNECTION_ERROR); if (error_page_url.is_valid()) { // Ask the WebFrame to fetch the alternate error page for us. - frame->LoadAlternateHTMLErrorPage(&failed_request, error, error_page_url, + frame->LoadAlternateHTMLErrorPage(failed_request, error, error_page_url, replace, GURL(kUnreachableWebDataURL)); return; } } // Fallback to a local error page. - LoadNavigationErrorPage(frame, &failed_request, error, std::string(), + LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); } void RenderView::LoadNavigationErrorPage(WebFrame* frame, - const WebRequest* failed_request, - const WebError& error, + const WebURLRequest& failed_request, + const WebURLError& error, const std::string& html, bool replace) { - const GURL& failed_url = error.GetFailedURL(); + GURL failed_url = error.unreachableURL; std::string alt_html; if (html.empty()) { // Use a local error page. int resource_id; DictionaryValue error_strings; - if (error.GetErrorCode() == net::ERR_CACHE_MISS && - LowerCaseEqualsASCII(failed_request->GetHttpMethod(), "post")) { + if (error.reason == net::ERR_CACHE_MISS && + EqualsASCII(failed_request.httpMethod(), "POST")) { GetFormRepostErrorValues(failed_url, &error_strings); resource_id = IDR_ERROR_NO_DETAILS_HTML; } else { @@ -1187,11 +1210,10 @@ void RenderView::LoadNavigationErrorPage(WebFrame* frame, } // Use a data: URL as the site URL to prevent against XSS attacks. - scoped_ptr<WebRequest> request(failed_request->Clone()); - request->SetURL(GURL(kUnreachableWebDataURL)); + WebURLRequest request(failed_request); + request.setURL(GURL(kUnreachableWebDataURL)); - frame->LoadAlternateHTMLString(request.get(), alt_html, failed_url, - replace); + frame->LoadAlternateHTMLString(request, alt_html, failed_url, replace); } void RenderView::DidCommitLoadForFrame(WebView *webview, WebFrame* frame, @@ -1266,7 +1288,7 @@ void RenderView::DidFinishLoadForFrame(WebView* webview, WebFrame* frame) { } void RenderView::DidFailLoadWithError(WebView* webview, - const WebError& error, + const WebURLError& error, WebFrame* frame) { } @@ -1305,7 +1327,7 @@ void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview, DidCommitLoadForFrame(webview, frame, is_new_navigation); const string16& title = - webview->GetMainFrame()->GetDataSource()->GetPageTitle(); + webview->GetMainFrame()->GetDataSource()->pageTitle(); UpdateTitle(frame, UTF16ToWideHack(title)); } @@ -1339,8 +1361,8 @@ void RenderView::WillSubmitForm(WebView* webview, WebFrame* frame, void RenderView::WillSendRequest(WebView* webview, uint32 identifier, - WebRequest* request) { - request->SetRequestorID(routing_id_); + WebURLRequest* request) { + request->setRequestorID(routing_id_); } void RenderView::BindDOMAutomationController(WebFrame* webframe) { @@ -1387,7 +1409,7 @@ void RenderView::DocumentElementAvailable(WebFrame* frame) { WindowOpenDisposition RenderView::DispositionForNavigationAction( WebView* webview, WebFrame* frame, - const WebRequest* request, + const WebURLRequest& request, WebNavigationType type, WindowOpenDisposition disposition, bool is_redirect) { @@ -1400,7 +1422,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // Webkit is asking whether to navigate to a new URL. // This is fine normally, except if we're showing UI from one security // context and they're trying to navigate to a different context. - const GURL& url = request->GetURL(); + const GURL& url = request.url(); // We only care about navigations that are within the current tab (as opposed // to, for example, opening a new window). @@ -1446,7 +1468,7 @@ WindowOpenDisposition RenderView::DispositionForNavigationAction( // Must be targeted at the current tab. disposition == CURRENT_TAB && // Must be a JavaScript navigation, which appears as "other". - type == WebNavigationTypeOther; + type == WebKit::WebNavigationTypeOther; if (is_fork) { // Open the URL via the browser, not via WebKit. OpenURL(webview, url, GURL(), disposition); diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 3a710d7..5e9d75b 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -52,7 +52,6 @@ class NavigationState; class PrintWebViewHelper; class RenderThread; class ResourceDispatcher; -class WebError; class WebFrame; class WebPluginDelegate; class WebPluginDelegateProxy; @@ -174,21 +173,23 @@ class RenderView : public RenderWidget, virtual void DidStartLoading(WebView* webview); virtual void DidStopLoading(WebView* webview); - virtual void DidCreateDataSource(WebFrame* frame, WebDataSource* ds); + virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds); virtual void DidStartProvisionalLoadForFrame( WebView* webview, WebFrame* frame, NavigationGesture gesture); virtual void DidReceiveProvisionalLoadServerRedirect(WebView* webview, WebFrame* frame); - virtual void DidFailProvisionalLoadWithError(WebView* webview, - const WebError& error, - WebFrame* frame); - virtual void LoadNavigationErrorPage(WebFrame* frame, - const WebRequest* failed_request, - const WebError& error, - const std::string& html, - bool replace); + virtual void DidFailProvisionalLoadWithError( + WebView* webview, + const WebKit::WebURLError& error, + WebFrame* frame); + virtual void LoadNavigationErrorPage( + WebFrame* frame, + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error, + const std::string& html, + bool replace); virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, bool is_new_navigation); virtual void DidReceiveTitle(WebView* webview, @@ -197,13 +198,14 @@ class RenderView : public RenderWidget, virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame); virtual void DidFailLoadWithError(WebView* webview, - const WebError& error, + const WebKit::WebURLError& error, WebFrame* forFrame); virtual void DidFinishDocumentLoadForFrame(WebView* webview, WebFrame* frame); - virtual bool DidLoadResourceFromMemoryCache(WebView* webview, - const WebRequest& request, - const WebResponse& response, - WebFrame* frame); + virtual bool DidLoadResourceFromMemoryCache( + WebView* webview, + const WebKit::WebURLRequest& request, + const WebKit::WebURLResponse& response, + WebFrame* frame); virtual void DidHandleOnloadEventsForFrame(WebView* webview, WebFrame* frame); virtual void DidChangeLocationWithinPageForFrame(WebView* webview, WebFrame* frame, @@ -219,7 +221,7 @@ class RenderView : public RenderWidget, const WebKit::WebForm& form); virtual void WillSendRequest(WebView* webview, uint32 identifier, - WebRequest* request); + WebKit::WebURLRequest* request); virtual void WindowObjectCleared(WebFrame* webframe); virtual void DocumentElementAvailable(WebFrame* webframe); @@ -227,8 +229,8 @@ class RenderView : public RenderWidget, virtual WindowOpenDisposition DispositionForNavigationAction( WebView* webview, WebFrame* frame, - const WebRequest* request, - WebNavigationType type, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationType type, WindowOpenDisposition disposition, bool is_redirect); diff --git a/chrome/test/render_view_test.cc b/chrome/test/render_view_test.cc index 0f31d8c5..b223f88 100644 --- a/chrome/test/render_view_test.cc +++ b/chrome/test/render_view_test.cc @@ -16,11 +16,12 @@ #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptSource.h" -#include "webkit/glue/weburlrequest.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/webview.h" using WebKit::WebScriptSource; using WebKit::WebString; +using WebKit::WebURLRequest; namespace { @@ -47,8 +48,7 @@ void RenderViewTest::LoadHTML(const char* html) { url_str.append(html); GURL url(url_str); - scoped_ptr<WebRequest> request(WebRequest::Create(url)); - GetMainFrame()->LoadRequest(request.get()); + GetMainFrame()->LoadRequest(WebURLRequest(url)); // The load actually happens asynchronously, so we pump messages to process // the pending continuation. diff --git a/webkit/api/public/WebDataSource.h b/webkit/api/public/WebDataSource.h index b163221..66681da 100644 --- a/webkit/api/public/WebDataSource.h +++ b/webkit/api/public/WebDataSource.h @@ -31,12 +31,11 @@ #ifndef WebDataSource_h #define WebDataSource_h -#error "This header file is still a work in progress; do not include!" - #include "WebCommon.h" #include "WebNavigationType.h" namespace WebKit { + class WebString; class WebURL; class WebURLRequest; class WebURLResponse; @@ -78,23 +77,18 @@ namespace WebKit { virtual WebString pageTitle() const = 0; // The type of navigation that triggered the creation of this datasource. - virtual WebNavigationType triggeringActionNavigationType() const = 0; + virtual WebNavigationType navigationType() const = 0; - // The time in seconds of the event that triggered the creation of this - // datasource. This may be 0 if there was no triggering event. - virtual double triggeringActionEventTime() const = 0; + // The time in seconds (since the epoch) of the event that triggered + // the creation of this datasource. Returns 0 if unknown. + virtual double triggeringEventTime() const = 0; // Extra data associated with this datasource. If non-null, the extra // data pointer will be deleted when the datasource is destroyed. // Setting the extra data pointer will cause any existing non-null // extra data pointer to be deleted. virtual ExtraData* extraData() const = 0; - virtual void SetExtraData(ExtraData*) = 0; - - // FIXME provide alternatives to: - // GetSearchableFormData() - // GetPasswordFormData() - // IsFormSubmit() + virtual void setExtraData(ExtraData*) = 0; }; } // namespace WebKit diff --git a/webkit/api/public/WebNavigationType.h b/webkit/api/public/WebNavigationType.h index 8e57376..032f2d0 100644 --- a/webkit/api/public/WebNavigationType.h +++ b/webkit/api/public/WebNavigationType.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google 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: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -31,8 +31,6 @@ #ifndef WebNavigationType_h #define WebNavigationType_h -#error "This header file is still a work in progress; do not include!" - namespace WebKit { enum WebNavigationType { diff --git a/webkit/api/public/WebVector.h b/webkit/api/public/WebVector.h index 2f3cf71..ed6f01c 100644 --- a/webkit/api/public/WebVector.h +++ b/webkit/api/public/WebVector.h @@ -1,10 +1,10 @@ /* * Copyright (C) 2009 Google 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: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -51,11 +51,11 @@ namespace WebKit { // // It is also possible to assign from other types of random access // containers: - // + // // void Foo(const std::vector<std::string>& input) // { // WebVector<WebCString> cstrings = input; - // ... + // ... // } // template <typename T> @@ -86,13 +86,13 @@ namespace WebKit { assign(other); return *this; } - + template <typename C> void assign(const C& other) { assign(other.size() ? &other[0] : 0, other.size()); } - + template <typename U> void assign(const U* values, size_t size) { @@ -101,6 +101,7 @@ namespace WebKit { } size_t size() const { return m_size; } + bool isEmpty() const { return m_size == 0; } T& operator[](size_t i) { return m_ptr[i]; } const T& operator[](size_t i) const { return m_ptr[i]; } @@ -139,7 +140,7 @@ namespace WebKit { new (&m_ptr[i]) T(values[i]); } } - + void destroy() { for (size_t i = 0; i < m_size; ++i) diff --git a/webkit/api/src/WebURLRequest.cpp b/webkit/api/src/WebURLRequest.cpp index 66483f9..b62206c 100644 --- a/webkit/api/src/WebURLRequest.cpp +++ b/webkit/api/src/WebURLRequest.cpp @@ -238,6 +238,8 @@ const ResourceRequest& WebURLRequest::toResourceRequest() const void WebURLRequest::assign(WebURLRequestPrivate* p) { + if (m_private == p) + return; if (m_private) m_private->dispose(); m_private = p; diff --git a/webkit/api/src/WebURLRequestPrivate.h b/webkit/api/src/WebURLRequestPrivate.h index 57ef3d1..a2b0187 100644 --- a/webkit/api/src/WebURLRequestPrivate.h +++ b/webkit/api/src/WebURLRequestPrivate.h @@ -31,7 +31,9 @@ #ifndef WebURLRequestPrivate_h #define WebURLRequestPrivate_h -#include "WebHTTPBody.h" +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebHTTPBody.h" namespace WebCore { struct ResourceRequest; } diff --git a/webkit/api/src/WebURLResponse.cpp b/webkit/api/src/WebURLResponse.cpp index 8b6f604..066000d 100644 --- a/webkit/api/src/WebURLResponse.cpp +++ b/webkit/api/src/WebURLResponse.cpp @@ -241,6 +241,8 @@ const ResourceResponse& WebURLResponse::toResourceResponse() const void WebURLResponse::assign(WebURLResponsePrivate* p) { + if (m_private == p) + return; if (m_private) m_private->dispose(); m_private = p; diff --git a/webkit/api/src/WrappedResourceRequest.h b/webkit/api/src/WrappedResourceRequest.h index 58188c1..f232375 100644 --- a/webkit/api/src/WrappedResourceRequest.h +++ b/webkit/api/src/WrappedResourceRequest.h @@ -28,6 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifndef WrappedResourceRequest_h +#define WrappedResourceRequest_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebURLRequest.h" #include "WebURLRequestPrivate.h" namespace WebKit { @@ -39,23 +45,31 @@ namespace WebKit { reset(); // Need to drop reference to m_handle } + WrappedResourceRequest() { } + WrappedResourceRequest(WebCore::ResourceRequest& resourceRequest) { - bind(&resourceRequest); + bind(resourceRequest); } WrappedResourceRequest(const WebCore::ResourceRequest& resourceRequest) { - bind(const_cast<WebCore::ResourceRequest*>(&resourceRequest)); + bind(resourceRequest); } - private: - void bind(WebCore::ResourceRequest* resourceRequest) + void bind(WebCore::ResourceRequest& resourceRequest) { - m_handle.m_resourceRequest = resourceRequest; + m_handle.m_resourceRequest = &resourceRequest; assign(&m_handle); } + void bind(const WebCore::ResourceRequest& resourceRequest) + { + m_handle.m_resourceRequest = const_cast<WebCore::ResourceRequest*>(&resourceRequest); + assign(&m_handle); + } + + private: class Handle : public WebURLRequestPrivate { public: virtual void dispose() { m_resourceRequest = 0; } @@ -65,3 +79,5 @@ namespace WebKit { }; } // namespace WebKit + +#endif diff --git a/webkit/api/src/WrappedResourceResponse.h b/webkit/api/src/WrappedResourceResponse.h index fe7bb99..8c44315 100644 --- a/webkit/api/src/WrappedResourceResponse.h +++ b/webkit/api/src/WrappedResourceResponse.h @@ -28,7 +28,12 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "WebURLResponse.h" +#ifndef WrappedResourceResponse_h +#define WrappedResourceResponse_h + +// FIXME: This relative path is a temporary hack to support using this +// header from webkit/glue. +#include "../public/WebURLResponse.h" #include "WebURLResponsePrivate.h" namespace WebKit { @@ -40,23 +45,31 @@ namespace WebKit { reset(); // Need to drop reference to m_handle } + WrappedResourceResponse() { } + WrappedResourceResponse(WebCore::ResourceResponse& resourceResponse) { - bind(&resourceResponse); + bind(resourceResponse); } WrappedResourceResponse(const WebCore::ResourceResponse& resourceResponse) { - bind(const_cast<WebCore::ResourceResponse*>(&resourceResponse)); + bind(resourceResponse); } - private: - void bind(WebCore::ResourceResponse* resourceResponse) + void bind(WebCore::ResourceResponse& resourceResponse) { - m_handle.m_resourceResponse = resourceResponse; + m_handle.m_resourceResponse = &resourceResponse; assign(&m_handle); } + void bind(const WebCore::ResourceResponse& resourceResponse) + { + m_handle.m_resourceResponse = const_cast<WebCore::ResourceResponse*>(&resourceResponse); + assign(&m_handle); + } + + private: class Handle : public WebURLResponsePrivate { public: virtual void dispose() { m_resourceResponse = 0; } @@ -66,3 +79,5 @@ namespace WebKit { }; } // namespace WebKit + +#endif diff --git a/webkit/glue/alt_error_page_resource_fetcher.cc b/webkit/glue/alt_error_page_resource_fetcher.cc index 53f7a26..139b7cd 100644 --- a/webkit/glue/alt_error_page_resource_fetcher.cc +++ b/webkit/glue/alt_error_page_resource_fetcher.cc @@ -13,27 +13,28 @@ MSVC_POP_WARNING(); #include "webkit/glue/alt_error_page_resource_fetcher.h" +#include "webkit/api/public/WebDataSource.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webframe_impl.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview.h" +using WebKit::WebURLError; + // Number of seconds to wait for the alternate error page server. If it takes // too long, just use the local error page. static const double kDownloadTimeoutSec = 3.0; AltErrorPageResourceFetcher::AltErrorPageResourceFetcher( WebView* web_view, - const WebErrorImpl& web_error, + const WebURLError& web_error, WebFrameImpl* web_frame, const GURL& url) : web_view_(web_view), web_error_(web_error), web_frame_(web_frame) { - failed_request_.reset(web_frame_->GetProvisionalDataSource()-> - GetRequest().Clone()); + failed_request_ = web_frame_->GetProvisionalDataSource()->request(); fetcher_.reset(new ResourceFetcherWithTimeout(url, web_frame->frame(), kDownloadTimeoutSec, this)); } @@ -51,10 +52,10 @@ void AltErrorPageResourceFetcher::OnURLFetchComplete( if (response.httpStatusCode() == 200) { // We successfully got a response from the alternate error page server, so // load it. - delegate->LoadNavigationErrorPage(web_frame_, failed_request_.get(), + delegate->LoadNavigationErrorPage(web_frame_, failed_request_, web_error_, data, true); } else { - delegate->LoadNavigationErrorPage(web_frame_, failed_request_.get(), + delegate->LoadNavigationErrorPage(web_frame_, failed_request_, web_error_, std::string(), true); } } diff --git a/webkit/glue/alt_error_page_resource_fetcher.h b/webkit/glue/alt_error_page_resource_fetcher.h index e729d5a..1f42892 100644 --- a/webkit/glue/alt_error_page_resource_fetcher.h +++ b/webkit/glue/alt_error_page_resource_fetcher.h @@ -14,12 +14,12 @@ MSVC_PUSH_WARNING_LEVEL(0); MSVC_POP_WARNING(); #include "base/scoped_ptr.h" +#include "webkit/api/public/WebURLError.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/resource_fetcher.h" -#include "webkit/glue/weberror_impl.h" class ResourceFetcherWithTimeout; class WebFrameImpl; -class WebRequest; class WebView; // Used for downloading alternate dns error pages. Once downloading is done @@ -27,7 +27,7 @@ class WebView; class AltErrorPageResourceFetcher : public ResourceFetcher::Delegate { public: AltErrorPageResourceFetcher(WebView* web_view, - const WebErrorImpl& web_error, + const WebKit::WebURLError& web_error, WebFrameImpl* web_frame, const GURL& url); ~AltErrorPageResourceFetcher(); @@ -38,9 +38,9 @@ class AltErrorPageResourceFetcher : public ResourceFetcher::Delegate { private: // References to our owners WebView* web_view_; - WebErrorImpl web_error_; + WebKit::WebURLError web_error_; WebFrameImpl* web_frame_; - scoped_ptr<WebRequest> failed_request_; + WebKit::WebURLRequest failed_request_; // Does the actual fetching. scoped_ptr<ResourceFetcherWithTimeout> fetcher_; diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 160833e..ff8aeb5 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -39,10 +39,11 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebInputEvent.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/src/WrappedResourceRequest.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webkit_glue.h" -#include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" #include "webkit/glue/webwidget_impl.h" @@ -50,6 +51,8 @@ MSVC_POP_WARNING(); using WebKit::WebInputEvent; using WebKit::WebMouseEvent; using WebKit::WebRect; +using WebKit::WebURLRequest; +using WebKit::WrappedResourceRequest; // Callback class that's given to the WebViewDelegate during a file choose // operation. @@ -210,8 +213,8 @@ WebCore::Page* ChromeClientImpl::createWindow( // The request is empty when we are just being asked to open a blank window. // This corresponds to window.open(""), for example. if (!r.resourceRequest().isEmpty()) { - WebRequestImpl request(r.resourceRequest()); - new_view->main_frame()->LoadRequest(&request); + WrappedResourceRequest request(r.resourceRequest()); + new_view->main_frame()->LoadRequest(request); } WebViewImpl* new_view_impl = static_cast<WebViewImpl*>(new_view); diff --git a/webkit/glue/context_menu_client_impl.cc b/webkit/glue/context_menu_client_impl.cc index 8fca4a6..26bb558 100644 --- a/webkit/glue/context_menu_client_impl.cc +++ b/webkit/glue/context_menu_client_impl.cc @@ -23,15 +23,17 @@ MSVC_POP_WARNING(); #include "webkit/glue/context_menu_client_impl.h" #include "base/string_util.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLResponse.h" #include "webkit/glue/context_menu.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webdatasource_impl.h" -#include "webkit/glue/webresponse.h" -#include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webview_impl.h" #include "base/word_iterator.h" +using WebKit::WebDataSource; + namespace { // Helper function to determine whether text is a single word or a sentence. @@ -132,8 +134,8 @@ static ContextNode GetTypeAndURLFromFrame(WebCore::Frame* frame, WebDataSource* ds = WebDataSourceImpl::FromLoader(dl); if (ds) { node = page_node; - *url = ds->HasUnreachableURL() ? ds->GetUnreachableURL() - : ds->GetRequest().GetURL(); + *url = ds->hasUnreachableURL() ? ds->unreachableURL() + : ds->request().url(); } } } @@ -218,10 +220,8 @@ WebCore::PlatformMenuDescription // Now retrieve the security info. WebCore::DocumentLoader* dl = selected_frame->loader()->documentLoader(); WebDataSource* ds = WebDataSourceImpl::FromLoader(dl); - if (ds) { - const WebResponse& response = ds->GetResponse(); - security_info = response.GetSecurityInfo(); - } + if (ds) + security_info = ds->response().securityInfo(); int edit_flags = ContextNode::CAN_DO_NONE; if (webview_->GetFocusedWebCoreFrame()->editor()->canUndo()) diff --git a/webkit/glue/glue_util.cc b/webkit/glue/glue_util.cc index 34bd0fe..ffe9623 100644 --- a/webkit/glue/glue_util.cc +++ b/webkit/glue/glue_util.cc @@ -20,8 +20,9 @@ #include "HTMLFormElement.h" #include "IntPoint.h" #include "IntRect.h" -#include "PlatformString.h" #include "KURL.h" +#include "PlatformString.h" +#include "ResourceError.h" #undef LOG #include "base/compiler_specific.h" @@ -37,6 +38,7 @@ #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLError.h" #include "webkit/api/public/WebURLRequest.h" #include "webkit/api/public/WebURLResponse.h" @@ -240,6 +242,18 @@ WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement( return form; } +// WebURLError conversions ----------------------------------------------------- + +WebKit::WebURLError ResourceErrorToWebURLError( + const WebCore::ResourceError& error) { + return error; +} + +WebCore::ResourceError WebURLErrorToResourceError( + const WebKit::WebURLError& error) { + return error; +} + // WebURLRequest conversions --------------------------------------------------- WebCore::ResourceRequest* WebURLRequestToMutableResourceRequest( diff --git a/webkit/glue/glue_util.h b/webkit/glue/glue_util.h index 776dc7e..8d2f5cd 100644 --- a/webkit/glue/glue_util.h +++ b/webkit/glue/glue_util.h @@ -18,6 +18,7 @@ class IntPoint; class IntRect; class IntSize; class KURL; +class ResourceError; class ResourceResponse; class String; struct ResourceRequest; @@ -34,6 +35,7 @@ class WebURLResponse; struct WebPoint; struct WebRect; struct WebSize; +struct WebURLError; } namespace WTF { @@ -115,6 +117,12 @@ WebKit::WebForm HTMLFormElementToWebForm( WTF::PassRefPtr<WebCore::HTMLFormElement> WebFormToHTMLFormElement( const WebKit::WebForm&); +// WebURLError <-> ResourceError +WebKit::WebURLError ResourceErrorToWebURLError( + const WebCore::ResourceError& error); +WebCore::ResourceError WebURLErrorToResourceError( + const WebKit::WebURLError& error); + // Exposes the ResourceRequest contained by a WebURLRequest WebCore::ResourceRequest* WebURLRequestToMutableResourceRequest( WebKit::WebURLRequest* req); diff --git a/webkit/glue/iframe_redirect_unittest.cc b/webkit/glue/iframe_redirect_unittest.cc index dc280e2..dfa6e08 100644 --- a/webkit/glue/iframe_redirect_unittest.cc +++ b/webkit/glue/iframe_redirect_unittest.cc @@ -10,12 +10,18 @@ #include "base/file_util.h" #include "base/string_util.h" -#include "webkit/glue/webdatasource.h" +#include "webkit/api/public/WebDataSource.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebVector.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webview.h" #include "webkit/tools/test_shell/test_shell_test.h" +using WebKit::WebDataSource; +using WebKit::WebURL; +using WebKit::WebVector; + typedef TestShellTest IFrameRedirectTest; // Tests that loading a page in an iframe from javascript results in @@ -35,7 +41,8 @@ TEST_F(IFrameRedirectTest, Test) { ASSERT_TRUE(iframe != NULL); WebDataSource* iframe_ds = iframe->GetDataSource(); ASSERT_TRUE(iframe_ds != NULL); - const std::vector<GURL>& redirects = iframe_ds->GetRedirectChain(); - ASSERT_FALSE(redirects.empty()); - ASSERT_TRUE(redirects[0] == GURL("about:blank")); + WebVector<WebURL> redirects; + iframe_ds->redirectChain(redirects); + ASSERT_FALSE(redirects.isEmpty()); + ASSERT_TRUE(GURL(redirects[0]) == GURL("about:blank")); } diff --git a/webkit/glue/inspector_client_impl.cc b/webkit/glue/inspector_client_impl.cc index b208190..b7be8b5 100644 --- a/webkit/glue/inspector_client_impl.cc +++ b/webkit/glue/inspector_client_impl.cc @@ -20,11 +20,12 @@ MSVC_POP_WARNING(); #include "base/gfx/rect.h" #include "base/string_util.h" #include "webkit/api/public/WebRect.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/inspector_client_impl.h" #include "webkit/glue/webdevtoolsagent_impl.h" #include "webkit/glue/webkit_glue.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview_impl.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" @@ -33,6 +34,7 @@ using namespace WebCore; using WebKit::WebRect; using WebKit::WebSize; +using WebKit::WebURLRequest; static const float kDefaultInspectorXPos = 10; static const float kDefaultInspectorYPos = 50; @@ -73,9 +75,8 @@ Page* WebInspectorClient::createPage() { if (!inspector_web_view_) return NULL; - GURL inspector_url(webkit_glue::GetInspectorURL()); - scoped_ptr<WebRequest> request(WebRequest::Create(inspector_url)); - inspector_web_view_->main_frame()->LoadRequest(request.get()); + inspector_web_view_->main_frame()->LoadRequest( + WebURLRequest(webkit_glue::GetInspectorURL())); page = inspector_web_view_->page(); diff --git a/webkit/glue/webdatasource.h b/webkit/glue/webdatasource.h deleted file mode 100644 index 4625508..0000000 --- a/webkit/glue/webdatasource.h +++ /dev/null @@ -1,100 +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_WEBDATASOURCE_H_ -#define WEBKIT_GLUE_WEBDATASOURCE_H_ - -#include <vector> - -#include "base/string16.h" - -class GURL; -class WebFrame; -class WebRequest; -class WebResponse; - -namespace base { -class Time; -} - -enum WebNavigationType { - WebNavigationTypeLinkClicked, - WebNavigationTypeFormSubmitted, - WebNavigationTypeBackForward, - WebNavigationTypeReload, - WebNavigationTypeFormResubmitted, - WebNavigationTypeOther -}; - -class WebDataSource { - public: - // A base class for extra data that may be associated with this datasource. - // See Set/GetExtraData below. - class ExtraData { - public: - virtual ~ExtraData() {} - }; - - virtual ~WebDataSource() {} - - // Returns a reference to the original request data that created the - // datasource. This request will be unmodified by WebKit. - // - // Note that this will be a different physical object than the WebRequest - // that was specified in the load request initiated by the embedder, but the - // data members will be copied. - // - // This call will update the request with the latest information from WebKit, - // so it is important that the caller not cache the result or keep the - // reference across entries into WebKit. - virtual const WebRequest& GetInitialRequest() const = 0; - - // Returns the request that was used to create this datasource. This may - // be modified by WebKit. This is the same as what GetInitialRequest - // returns unless there was a redirect. - // - // Note that this will be a different physical object than the WebRequest - // that was specified in the load request initiated by the embedder. - // - // This call will update the request with the latest information from WebKit, - // so it is important that the caller not cache the result or keep the - // reference across entries into WebKit. - virtual const WebRequest& GetRequest() const = 0; - - // Returns the response associated to this datasource. - virtual const WebResponse& GetResponse() const = 0; - - // Returns the unreachable URL for which this datasource is showing alternate - // content. See WebFrame::LoadAlternateHTML{ErrorPage,String}. - virtual GURL GetUnreachableURL() const = 0; - - // Returns true if there is a non-null unreachable URL. - virtual bool HasUnreachableURL() const = 0; - - // Returns all redirects that occurred (both client and server) before at - // last committing the current page. This will contain one entry for each - // intermediate URL, and one entry for the last URL (so if there are no - // redirects, it will contain exactly the current URL, and if there is one - // redirect, it will contain the source and destination URL). - virtual const std::vector<GURL>& GetRedirectChain() const = 0; - - // Returns the page title. - virtual string16 GetPageTitle() const = 0; - - // The time in seconds (since the epoch) of the event if any that triggered - // this navigation. Returns 0 if unknown. - virtual double GetTriggeringEventTime() const = 0; - - // Returns the reason the document was loaded. - virtual WebNavigationType GetNavigationType() const = 0; - - // Extra data associated with this datasource. If non-null, the extra data - // pointer will be deleted when the datasource is destroyed. Setting the - // extra data pointer will cause any existing non-null extra data pointer to - // be deleted. - virtual ExtraData* GetExtraData() const = 0; - virtual void SetExtraData(ExtraData* extra_data) = 0; -}; - -#endif // #ifndef WEBKIT_GLUE_WEBDATASOURCE_H_ diff --git a/webkit/glue/webdatasource_impl.cc b/webkit/glue/webdatasource_impl.cc index 01e174b..b67c57d 100644 --- a/webkit/glue/webdatasource_impl.cc +++ b/webkit/glue/webdatasource_impl.cc @@ -5,79 +5,74 @@ #include "config.h" #include "webkit/glue/webdatasource_impl.h" -#include "FrameLoaderTypes.h" -#include "FrameLoadRequest.h" -#include "KURL.h" -#include "ResourceRequest.h" - -#undef LOG +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebVector.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/password_form.h" -#include "webkit/glue/webdatasource_impl.h" -#include "webkit/glue/webframe_impl.h" -#include "webkit/glue/weburlrequest_impl.h" -#include "webkit/glue/webview_delegate.h" + +using WebCore::DocumentLoader; +using WebCore::ResourceRequest; +using WebCore::ResourceResponse; +using WebCore::SubstituteData; + +using WebKit::WebDataSource; +using WebKit::WebNavigationType; +using WebKit::WebString; +using WebKit::WebURL; +using WebKit::WebURLRequest; +using WebKit::WebURLResponse; +using WebKit::WebVector; // static PassRefPtr<WebDataSourceImpl> WebDataSourceImpl::Create( - const WebCore::ResourceRequest& request, - const WebCore::SubstituteData& data) { + const ResourceRequest& request, + const SubstituteData& data) { return adoptRef(new WebDataSourceImpl(request, data)); } -WebDataSourceImpl::WebDataSourceImpl(const WebCore::ResourceRequest& request, - const WebCore::SubstituteData& data) - : WebCore::DocumentLoader(request, data) { +WebDataSourceImpl::WebDataSourceImpl(const ResourceRequest& request, + const SubstituteData& data) + : DocumentLoader(request, data) { } WebDataSourceImpl::~WebDataSourceImpl() { } -const WebRequest& WebDataSourceImpl::GetInitialRequest() const { - // WebKit may change the frame load request as it sees fit, so we must sync - // our request object. - initial_request_.set_resource_request(originalRequest()); - return initial_request_; +const WebURLRequest& WebDataSourceImpl::originalRequest() const { + original_request_.bind(DocumentLoader::originalRequest()); + return original_request_; } -const WebRequest& WebDataSourceImpl::GetRequest() const { - // WebKit may change the frame load request as it sees fit, so we must sync - // our request object. - request_.set_resource_request(request()); +const WebURLRequest& WebDataSourceImpl::request() const { + request_.bind(DocumentLoader::request()); return request_; } -const WebResponse& WebDataSourceImpl::GetResponse() const { - response_.set_resource_response(response()); +const WebURLResponse& WebDataSourceImpl::response() const { + response_.bind(DocumentLoader::response()); return response_; } -GURL WebDataSourceImpl::GetUnreachableURL() const { - const WebCore::KURL& url = unreachableURL(); - return url.isEmpty() ? GURL() : webkit_glue::KURLToGURL(url); +bool WebDataSourceImpl::hasUnreachableURL() const { + return !DocumentLoader::unreachableURL().isEmpty(); } -bool WebDataSourceImpl::HasUnreachableURL() const { - return !unreachableURL().isEmpty(); +WebURL WebDataSourceImpl::unreachableURL() const { + return webkit_glue::KURLToWebURL(DocumentLoader::unreachableURL()); } -const std::vector<GURL>& WebDataSourceImpl::GetRedirectChain() const { - return redirect_chain_; +void WebDataSourceImpl::redirectChain(WebVector<WebURL>& result) const { + result.assign(redirect_chain_); } -void WebDataSourceImpl::ClearRedirectChain() { - redirect_chain_.clear(); +WebString WebDataSourceImpl::pageTitle() const { + return webkit_glue::StringToWebString(title()); } -void WebDataSourceImpl::AppendRedirect(const GURL& url) { - redirect_chain_.push_back(url); -} - -string16 WebDataSourceImpl::GetPageTitle() const { - return webkit_glue::StringToString16(title()); +WebNavigationType WebDataSourceImpl::navigationType() const { + return NavigationTypeToWebNavigationType(triggeringAction().type()); } -double WebDataSourceImpl::GetTriggeringEventTime() const { +double WebDataSourceImpl::triggeringEventTime() const { if (!triggeringAction().event()) return 0.0; @@ -85,15 +80,11 @@ double WebDataSourceImpl::GetTriggeringEventTime() const { return triggeringAction().event()->timeStamp() / 1000.0; } -WebNavigationType WebDataSourceImpl::GetNavigationType() const { - return NavigationTypeToWebNavigationType(triggeringAction().type()); -} - -WebDataSource::ExtraData* WebDataSourceImpl::GetExtraData() const { +WebDataSource::ExtraData* WebDataSourceImpl::extraData() const { return extra_data_.get(); } -void WebDataSourceImpl::SetExtraData(ExtraData* extra_data) { +void WebDataSourceImpl::setExtraData(ExtraData* extra_data) { extra_data_.set(extra_data); } @@ -101,17 +92,30 @@ WebNavigationType WebDataSourceImpl::NavigationTypeToWebNavigationType( WebCore::NavigationType type) { switch (type) { case WebCore::NavigationTypeLinkClicked: - return WebNavigationTypeLinkClicked; + return WebKit::WebNavigationTypeLinkClicked; case WebCore::NavigationTypeFormSubmitted: - return WebNavigationTypeFormSubmitted; + return WebKit::WebNavigationTypeFormSubmitted; case WebCore::NavigationTypeBackForward: - return WebNavigationTypeBackForward; + return WebKit::WebNavigationTypeBackForward; case WebCore::NavigationTypeReload: - return WebNavigationTypeReload; + return WebKit::WebNavigationTypeReload; case WebCore::NavigationTypeFormResubmitted: - return WebNavigationTypeFormResubmitted; + return WebKit::WebNavigationTypeFormResubmitted; case WebCore::NavigationTypeOther: default: - return WebNavigationTypeOther; + return WebKit::WebNavigationTypeOther; } } + +GURL WebDataSourceImpl::GetEndOfRedirectChain() const { + ASSERT(!redirect_chain_.isEmpty()); + return redirect_chain_.last(); +} + +void WebDataSourceImpl::ClearRedirectChain() { + redirect_chain_.clear(); +} + +void WebDataSourceImpl::AppendRedirect(const GURL& url) { + redirect_chain_.append(url); +} diff --git a/webkit/glue/webdatasource_impl.h b/webkit/glue/webdatasource_impl.h index deecf64..e1f9029 100644 --- a/webkit/glue/webdatasource_impl.h +++ b/webkit/glue/webdatasource_impl.h @@ -6,15 +6,19 @@ #define WEBKIT_GLUE_WEBDATASOURCE_IMPL_H_ #include "DocumentLoader.h" +#include <wtf/Vector.h> +#include <wtf/OwnPtr.h> -#include "webkit/glue/webdatasource.h" -#include "webkit/glue/webresponse_impl.h" -#include "webkit/glue/weburlrequest_impl.h" +#include "webkit/api/public/WebDataSource.h" +#include "webkit/api/src/WrappedResourceRequest.h" +#include "webkit/api/src/WrappedResourceResponse.h" +class GURL; class WebFrameImpl; class WebDocumentLoaderImpl; -class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { +class WebDataSourceImpl : public WebCore::DocumentLoader, + public WebKit::WebDataSource { public: static PassRefPtr<WebDataSourceImpl> Create(const WebCore::ResourceRequest&, const WebCore::SubstituteData&); @@ -24,21 +28,23 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { } // WebDataSource methods: - virtual const WebRequest& GetInitialRequest() const; - virtual const WebRequest& GetRequest() const; - virtual const WebResponse& GetResponse() const; - virtual GURL GetUnreachableURL() const; - virtual bool HasUnreachableURL() const; - virtual const std::vector<GURL>& GetRedirectChain() const; - virtual string16 GetPageTitle() const; - virtual double GetTriggeringEventTime() const; - virtual WebNavigationType GetNavigationType() const; - virtual ExtraData* GetExtraData() const; - virtual void SetExtraData(ExtraData*); + virtual const WebKit::WebURLRequest& originalRequest() const; + virtual const WebKit::WebURLRequest& request() const; + virtual const WebKit::WebURLResponse& response() const; + virtual bool hasUnreachableURL() const; + virtual WebKit::WebURL unreachableURL() const; + virtual void redirectChain(WebKit::WebVector<WebKit::WebURL>&) const; + virtual WebKit::WebString pageTitle() const; + virtual WebKit::WebNavigationType navigationType() const; + virtual double triggeringEventTime() const; + virtual ExtraData* extraData() const; + virtual void setExtraData(ExtraData*); - static WebNavigationType NavigationTypeToWebNavigationType( + static WebKit::WebNavigationType NavigationTypeToWebNavigationType( WebCore::NavigationType type); + bool HasRedirectChain() const { return !redirect_chain_.isEmpty(); } + GURL GetEndOfRedirectChain() const; void ClearRedirectChain(); void AppendRedirect(const GURL& url); @@ -49,15 +55,15 @@ class WebDataSourceImpl : public WebCore::DocumentLoader, public WebDataSource { // Mutable because the const getters will magically sync these to the // latest version from WebKit. - mutable WebRequestImpl initial_request_; - mutable WebRequestImpl request_; - mutable WebResponseImpl response_; + mutable WebKit::WrappedResourceRequest original_request_; + mutable WebKit::WrappedResourceRequest request_; + mutable WebKit::WrappedResourceResponse response_; // Lists all intermediate URLs that have redirected for the current // provisional load. See WebFrameLoaderClient:: // dispatchDidReceiveServerRedirectForProvisionalLoad for a description of // who modifies this when to keep it up to date. - std::vector<GURL> redirect_chain_; + Vector<WebKit::WebURL> redirect_chain_; OwnPtr<ExtraData> extra_data_; diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index d885b01..ac50d37 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -23,15 +23,16 @@ #include "V8Binding.h" #include "base/values.h" +#include "webkit/api/public/WebDataSource.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/devtools/bound_object.h" #include "webkit/glue/devtools/debugger_agent_impl.h" #include "webkit/glue/devtools/debugger_agent_manager.h" #include "webkit/glue/devtools/dom_agent_impl.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webdevtoolsagent_delegate.h" #include "webkit/glue/webdevtoolsagent_impl.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview_impl.h" using WebCore::Document; @@ -44,6 +45,8 @@ using WebCore::ScriptValue; using WebCore::String; using WebCore::V8ClassIndex; using WebCore::V8Proxy; +using WebKit::WebDataSource; +using WebKit::WebURLRequest; WebDevToolsAgentImpl::WebDevToolsAgentImpl( WebViewImpl* web_view_impl, @@ -148,10 +151,10 @@ void WebDevToolsAgentImpl::DidCommitLoadForFrame( return; } WebDataSource* ds = frame->GetDataSource(); - const WebRequest& request = ds->GetRequest(); - GURL url = ds->HasUnreachableURL() ? - ds->GetUnreachableURL() : - request.GetURL(); + const WebURLRequest& request = ds->request(); + GURL url = ds->hasUnreachableURL() ? + ds->unreachableURL() : + request.url(); tools_agent_delegate_stub_->FrameNavigate( url.possibly_invalid_spec(), webview->GetMainFrame() == frame); diff --git a/webkit/glue/weberror.h b/webkit/glue/weberror.h deleted file mode 100644 index c7ad644..0000000 --- a/webkit/glue/weberror.h +++ /dev/null @@ -1,19 +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_WEBERROR_H__ -#define WEBKIT_GLUE_WEBERROR_H__ - -class GURL; - -class WebError { - public: - // The network error code. - virtual int GetErrorCode() const = 0; - - // The URL that failed. - virtual const GURL& GetFailedURL() const = 0; -}; - -#endif // WEBKIT_GLUE_WEBERROR_H__ diff --git a/webkit/glue/weberror_impl.cc b/webkit/glue/weberror_impl.cc deleted file mode 100644 index 0950624..0000000 --- a/webkit/glue/weberror_impl.cc +++ /dev/null @@ -1,30 +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. - -#include "config.h" -#include "ResourceError.h" - -#undef LOG -#include "webkit/glue/weberror_impl.h" - -#include "webkit/glue/glue_util.h" -#include "webkit/glue/webkit_glue.h" - -WebErrorImpl::WebErrorImpl(const WebCore::ResourceError& e) - : error_code_(e.errorCode()), - failed_url_(webkit_glue::StringToStdString(e.failingURL())) { -} - -WebErrorImpl::WebErrorImpl(const WebError& e) - : error_code_(e.GetErrorCode()), - failed_url_(e.GetFailedURL()) { -} - -int WebErrorImpl::GetErrorCode() const { - return error_code_; -} - -const GURL& WebErrorImpl::GetFailedURL() const { - return failed_url_; -} diff --git a/webkit/glue/weberror_impl.h b/webkit/glue/weberror_impl.h deleted file mode 100644 index 210f402..0000000 --- a/webkit/glue/weberror_impl.h +++ /dev/null @@ -1,34 +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_WEBERROR_IMPL_H__ -#define WEBKIT_GLUE_WEBERROR_IMPL_H__ - -#include "base/basictypes.h" -#include "webkit/glue/weberror.h" -#include "googleurl/src/gurl.h" - -namespace WebCore { -class ResourceError; -}; - -class WebErrorImpl : public WebError { - public: - explicit WebErrorImpl(const WebCore::ResourceError& error); - explicit WebErrorImpl(const WebError& error); - ~WebErrorImpl() {} - - // WebError implementation: - virtual int GetErrorCode() const; - virtual const GURL& GetFailedURL() const; - - private: - int error_code_; - GURL failed_url_; - - // Disallow assignment operator - void operator=(const WebErrorImpl&); -}; - -#endif // WEBKIT_GLUE_WEBERROR_IMPL_H__ diff --git a/webkit/glue/webframe.h b/webkit/glue/webframe.h index ad80a0d..1789bfb 100644 --- a/webkit/glue/webframe.h +++ b/webkit/glue/webframe.h @@ -14,20 +14,20 @@ class GURL; class WebAppCacheContext; -class WebDataSource; -class WebError; -class WebRequest; class WebView; class WebTextInput; struct NPObject; namespace WebKit { +class WebDataSource; class WebForm; +class WebURLRequest; struct WebConsoleMessage; struct WebFindOptions; struct WebRect; struct WebScriptSource; struct WebSize; +struct WebURLError; } // Every frame in a web page is represented by one WebFrame, including the @@ -69,8 +69,8 @@ class WebFrame { virtual NPObject* GetWindowNPObject() = 0; - // Loads the given WebRequest. - virtual void LoadRequest(WebRequest* request) = 0; + // Loads the given WebURLRequest. + virtual void LoadRequest(const WebKit::WebURLRequest& request) = 0; // Loads the given history state. This corresponds to a back/forward // navigation. @@ -96,7 +96,7 @@ class WebFrame { // it is the given request /w the |display_url| substituted for the request's // URL, which is repeated. The |html_text| is not stored in session history. // - virtual void LoadAlternateHTMLString(const WebRequest* request, + virtual void LoadAlternateHTMLString(const WebKit::WebURLRequest& request, const std::string& html_text, const GURL& display_url, bool replace) = 0; @@ -105,8 +105,8 @@ class WebFrame { // the WebViewDelegate of the results so it can decide whether or not to show // something to the user (e.g., a local error page or the alternate error // page). - virtual void LoadAlternateHTMLErrorPage(const WebRequest* request, - const WebError& error, + virtual void LoadAlternateHTMLErrorPage(const WebKit::WebURLRequest& request, + const WebKit::WebURLError& error, const GURL& error_page_url, bool replace, const GURL& fake_url) = 0; @@ -164,14 +164,14 @@ class WebFrame { // Returns the committed data source, which is the last data source that has // successfully started loading. Will return NULL if no provisional data // has been committed. - virtual WebDataSource* GetDataSource() const = 0; + virtual WebKit::WebDataSource* GetDataSource() const = 0; // Returns the provisional data source, which is a data source where a // request has been made, but we are not sure if we will use data from it // (for example, it may be an invalid URL). When the provisional load is // "committed," it will become the "real" data source (see GetDataSource // above) and the provisional data source will be NULL. - virtual WebDataSource* GetProvisionalDataSource() const = 0; + virtual WebKit::WebDataSource* GetProvisionalDataSource() const = 0; // // @method stopLoading diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index f573dcb..24d1e4b 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -154,9 +154,7 @@ MSVC_POP_WARNING(); #include "webkit/glue/glue_util.h" #include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webdatasource_impl.h" -#include "webkit/glue/weberror_impl.h" #include "webkit/glue/webframe_impl.h" -#include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webtextinput_impl.h" #include "webkit/glue/webview_impl.h" @@ -205,11 +203,16 @@ using WebCore::VisiblePosition; using WebCore::XPathResult; using WebKit::WebConsoleMessage; +using WebKit::WebDataSource; using WebKit::WebFindOptions; using WebKit::WebForm; using WebKit::WebRect; using WebKit::WebScriptSource; using WebKit::WebSize; +using WebKit::WebURL; +using WebKit::WebURLError; +using WebKit::WebURLRequest; +using WebKit::WebURLResponse; // Key for a StatsCounter tracking how many WebFrames are active. static const char* const kWebFrameActiveCount = "WebFrameActiveCount"; @@ -410,8 +413,8 @@ void WebFrameImpl::InitMainFrame(WebViewImpl* webview_impl) { app_cache_context_->Initialize(WebAppCacheContext::MAIN_FRAME, NULL); } -void WebFrameImpl::LoadRequest(WebRequest* request) { - InternalLoadRequest(request, SubstituteData(), NULL, false); +void WebFrameImpl::LoadRequest(const WebURLRequest& request) { + InternalLoadRequest(request, SubstituteData(), false); } void WebFrameImpl::LoadHistoryState(const std::string& history_state) { @@ -419,35 +422,46 @@ void WebFrameImpl::LoadHistoryState(const std::string& history_state) { webkit_glue::HistoryItemFromString(history_state); DCHECK(history_item.get()); - WebRequestImpl dummy_request; - InternalLoadRequest(&dummy_request, SubstituteData(), history_item, false); + StopLoading(); // make sure existing activity stops + + // If there is no current_item, which happens when we are navigating in + // session history after a crash, we need to manufacture one otherwise WebKit + // hoarks. This is probably the wrong thing to do, but it seems to work. + RefPtr<HistoryItem> current_item = frame_->loader()->currentHistoryItem(); + if (!current_item) { + current_item = HistoryItem::create(); + current_item->setLastVisitWasFailure(true); + frame_->loader()->setCurrentHistoryItem(current_item); + GetWebViewImpl()->SetCurrentHistoryItem(current_item.get()); + } + + frame_->loader()->goToItem(history_item.get(), + WebCore::FrameLoadTypeIndexedBackForward); } -void WebFrameImpl::InternalLoadRequest(const WebRequest* request, +void WebFrameImpl::InternalLoadRequest(const WebURLRequest& request, const SubstituteData& data, - PassRefPtr<HistoryItem> history_item, bool replace) { - const WebRequestImpl* request_impl = - static_cast<const WebRequestImpl*>(request); - - const ResourceRequest& resource_request = request_impl->resource_request(); + const ResourceRequest* resource_request = + webkit_glue::WebURLRequestToResourceRequest(&request); + DCHECK(resource_request); // Special-case javascript URLs. Do not interrupt the existing load when - // asked to load a javascript URL unless the script generates a result. - // We can't just use FrameLoader::executeIfJavaScriptURL because it doesn't + // asked to load a javascript URL unless the script generates a result. We + // can't just use FrameLoader::executeIfJavaScriptURL because it doesn't // handle redirects properly. - const KURL& kurl = resource_request.url(); + const KURL& kurl = resource_request->url(); if (!data.isValid() && kurl.protocol() == "javascript") { // Don't attempt to reload javascript URLs. - if (resource_request.cachePolicy() == ReloadIgnoringCacheData) + if (resource_request->cachePolicy() == ReloadIgnoringCacheData) return; // We can't load a javascript: URL if there is no Document! if (!frame_->document()) return; - // TODO(darin): Is this the best API to use here? It works and seems good, - // but will it change out from under us? + // TODO(darin): Is this the best API to use here? It works and seems + // good, but will it change out from under us? String script = decodeURLEscapeSequences( kurl.string().substring(sizeof("javascript:")-1)); WebCore::ScriptValue result = frame_->loader()->executeScript(script, true); @@ -455,8 +469,8 @@ void WebFrameImpl::InternalLoadRequest(const WebRequest* request, if (result.getString(scriptResult) && !frame_->loader()->isScheduledLocationChangePending()) { // TODO(darin): We need to figure out how to represent this in session - // history. Hint: don't re-eval script when the user or script navigates - // back-n-forth (instead store the script result somewhere). + // history. Hint: don't re-eval script when the user or script + // navigates back-n-forth (instead store the script result somewhere). LoadDocumentData(kurl, scriptResult, String("text/html"), String()); } return; @@ -465,44 +479,26 @@ void WebFrameImpl::InternalLoadRequest(const WebRequest* request, StopLoading(); // make sure existing activity stops if (data.isValid()) { - frame_->loader()->load(resource_request, data, false); + DCHECK(resource_request); + frame_->loader()->load(*resource_request, data, false); if (replace) { // Do this to force WebKit to treat the load as replacing the currently // loaded page. frame_->loader()->setReplacing(); } - } else if (history_item.get()) { - // Use the history item if we have one, otherwise fall back to standard - // load. - RefPtr<HistoryItem> current_item = frame_->loader()->currentHistoryItem(); - - // If there is no current_item, which happens when we are navigating in - // session history after a crash, we need to manufacture one otherwise - // WebKit hoarks. This is probably the wrong thing to do, but it seems to - // work. - if (!current_item) { - current_item = HistoryItem::create(); - current_item->setLastVisitWasFailure(true); - frame_->loader()->setCurrentHistoryItem(current_item); - GetWebViewImpl()->SetCurrentHistoryItem(current_item.get()); - } - - frame_->loader()->goToItem(history_item.get(), - WebCore::FrameLoadTypeIndexedBackForward); - } else if (resource_request.cachePolicy() == ReloadIgnoringCacheData) { + } else if (resource_request->cachePolicy() == ReloadIgnoringCacheData) { frame_->loader()->reload(); } else { - frame_->loader()->load(resource_request, false); + frame_->loader()->load(*resource_request, false); } } void WebFrameImpl::LoadHTMLString(const std::string& html_text, const GURL& base_url) { - WebRequestImpl request(base_url); - LoadAlternateHTMLString(&request, html_text, GURL(), false); + LoadAlternateHTMLString(WebURLRequest(base_url), html_text, GURL(), false); } -void WebFrameImpl::LoadAlternateHTMLString(const WebRequest* request, +void WebFrameImpl::LoadAlternateHTMLString(const WebURLRequest& request, const std::string& html_text, const GURL& display_url, bool replace) { @@ -514,14 +510,14 @@ void WebFrameImpl::LoadAlternateHTMLString(const WebRequest* request, webkit_glue::GURLToKURL(display_url)); DCHECK(subst_data.isValid()); - InternalLoadRequest(request, subst_data, NULL, replace); + InternalLoadRequest(request, subst_data, replace); } GURL WebFrameImpl::GetURL() const { const WebDataSource* ds = GetDataSource(); if (!ds) return GURL(); - return ds->GetRequest().GetURL(); + return ds->request().url(); } GURL WebFrameImpl::GetFavIconURL() const { @@ -1632,7 +1628,8 @@ void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { WebViewImpl* web_view = GetWebViewImpl(); WebViewDelegate* delegate = web_view->delegate(); if (delegate) { - WebErrorImpl web_error(error); + const WebURLError& web_error = + webkit_glue::ResourceErrorToWebURLError(error); if (was_provisional) { delegate->DidFailProvisionalLoadWithError(web_view, web_error, this); } else { @@ -1641,8 +1638,8 @@ void WebFrameImpl::DidFail(const ResourceError& error, bool was_provisional) { } } -void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebRequest* request, - const WebError& error, +void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebURLRequest& request, + const WebURLError& error, const GURL& error_page_url, bool replace, const GURL& fake_url) { @@ -1650,16 +1647,14 @@ void WebFrameImpl::LoadAlternateHTMLErrorPage(const WebRequest* request, // the original request so we can replace its URL with a dummy URL. That // prevents other web content from the same origin as the failed URL to // script the error page. - scoped_ptr<WebRequest> failed_request(request->Clone()); - failed_request->SetURL(fake_url); + WebURLRequest failed_request(request); + failed_request.setURL(fake_url); - LoadAlternateHTMLString(failed_request.get(), std::string(), - error.GetFailedURL(), replace); + LoadAlternateHTMLString(failed_request, std::string(), + error.unreachableURL, replace); - WebErrorImpl weberror_impl(error); - alt_error_page_fetcher_.reset( - new AltErrorPageResourceFetcher(GetWebViewImpl(), weberror_impl, this, - error_page_url)); + alt_error_page_fetcher_.reset(new AltErrorPageResourceFetcher( + GetWebViewImpl(), error, this, error_page_url)); } void WebFrameImpl::ExecuteScript(const WebScriptSource& source) { @@ -1877,26 +1872,26 @@ float WebFrameImpl::PrintPage(int page, skia::PlatformCanvas* canvas) { void WebFrameImpl::SelectAppCacheWithoutManifest() { WebDataSource* ds = GetDataSource(); DCHECK(ds); - if (ds->HasUnreachableURL()) { + if (ds->hasUnreachableURL()) { app_cache_context_->SelectAppCacheWithoutManifest( - ds->GetUnreachableURL(), + ds->unreachableURL(), WebAppCacheContext::kNoAppCacheId); } else { - const WebResponse& response = ds->GetResponse(); + const WebURLResponse& response = ds->response(); app_cache_context_->SelectAppCacheWithoutManifest( GetURL(), - response.GetAppCacheID()); + response.appCacheID()); } } void WebFrameImpl::SelectAppCacheWithManifest(const GURL &manifest_url) { WebDataSource* ds = GetDataSource(); DCHECK(ds); - DCHECK(!ds->HasUnreachableURL()); - const WebResponse& response = ds->GetResponse(); + DCHECK(!ds->hasUnreachableURL()); + const WebURLResponse& response = ds->response(); app_cache_context_->SelectAppCacheWithManifest( GetURL(), - response.GetAppCacheID(), + response.appCacheID(), manifest_url); } diff --git a/webkit/glue/webframe_impl.h b/webkit/glue/webframe_impl.h index 54da684..6db3aa0 100644 --- a/webkit/glue/webframe_impl.h +++ b/webkit/glue/webframe_impl.h @@ -42,9 +42,7 @@ MSVC_POP_WARNING(); class AltErrorPageResourceFetcher; class ChromePrintContext; class WebDataSourceImpl; -class WebErrorImpl; class WebPluginDelegate; -class WebRequest; class WebView; class WebViewImpl; class WebTextInput; @@ -78,16 +76,16 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { void InitMainFrame(WebViewImpl* webview_impl); // WebFrame - virtual void LoadRequest(WebRequest* request); + virtual void LoadRequest(const WebKit::WebURLRequest& request); virtual void LoadHistoryState(const std::string& history_state); virtual void LoadHTMLString(const std::string& html_text, const GURL& base_url); - virtual void LoadAlternateHTMLString(const WebRequest* request, + virtual void LoadAlternateHTMLString(const WebKit::WebURLRequest& request, const std::string& html_text, const GURL& display_url, bool replace); - virtual void LoadAlternateHTMLErrorPage(const WebRequest* request, - const WebError& error, + virtual void LoadAlternateHTMLErrorPage(const WebKit::WebURLRequest& request, + const WebKit::WebURLError& error, const GURL& error_page_url, bool replace, const GURL& fake_url); @@ -102,8 +100,8 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { virtual GURL GetFavIconURL() const; virtual GURL GetOSDDURL() const; virtual int GetContentsPreferredWidth() const; - virtual WebDataSource* GetDataSource() const; - virtual WebDataSource* GetProvisionalDataSource() const; + virtual WebKit::WebDataSource* GetDataSource() const; + virtual WebKit::WebDataSource* GetProvisionalDataSource() const; virtual void StopLoading(); virtual WebFrame* GetOpener() const; virtual WebFrame* GetParent() const; @@ -393,9 +391,8 @@ class WebFrameImpl : public WebFrame, public base::RefCounted<WebFrameImpl> { // Determines whether to invalidate the content area and scrollbar. void InvalidateIfNecessary(); - void InternalLoadRequest(const WebRequest* request, + void InternalLoadRequest(const WebKit::WebURLRequest& request, const WebCore::SubstituteData& data, - PassRefPtr<WebCore::HistoryItem> history_item, bool replace); // Clears the map of password listeners. diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 5a31352..d5e950f 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -45,6 +45,11 @@ MSVC_POP_WARNING(); #include "webkit/activex_shim/activex_shared.h" #endif #include "webkit/api/public/WebForm.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLError.h" +#include "webkit/api/public/WebVector.h" +#include "webkit/api/src/WrappedResourceRequest.h" +#include "webkit/api/src/WrappedResourceResponse.h" #include "webkit/glue/autofill_form.h" #include "webkit/glue/alt_404_page_resource_fetcher.h" #include "webkit/glue/glue_util.h" @@ -54,20 +59,21 @@ MSVC_POP_WARNING(); #include "webkit/glue/webappcachecontext.h" #include "webkit/glue/webdatasource_impl.h" #include "webkit/glue/webdevtoolsagent_impl.h" -#include "webkit/glue/weberror_impl.h" #include "webkit/glue/webframeloaderclient_impl.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webplugin_delegate.h" #include "webkit/glue/webplugin_impl.h" -#include "webkit/glue/webresponse_impl.h" #include "webkit/glue/webview_delegate.h" #include "webkit/glue/webview_impl.h" -#include "webkit/glue/weburlrequest.h" -#include "webkit/glue/weburlrequest_impl.h" using namespace WebCore; using base::Time; using base::TimeDelta; +using WebKit::WebNavigationType; +using WebKit::WebURL; +using WebKit::WebVector; +using WebKit::WrappedResourceRequest; +using WebKit::WrappedResourceResponse; // Domain for internal error codes. static const char kInternalErrorDomain[] = "webkit_glue"; @@ -179,7 +185,7 @@ void WebFrameLoaderClient::assignIdentifierToInitialRequest( WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); if (d) { - WebRequestImpl webreq(request); + WrappedResourceRequest webreq(request); d->AssignIdentifierToRequest(webview, identifier, webreq); } } @@ -226,9 +232,8 @@ void WebFrameLoaderClient::dispatchWillSendRequest( WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); if (d) { - WebRequestImpl webreq(request); + WrappedResourceRequest webreq(request); d->WillSendRequest(webview, identifier, &webreq); - request = webreq.resource_request(); } request.setAppCacheContextID( @@ -360,8 +365,8 @@ void WebFrameLoaderClient::dispatchDidFailLoading(DocumentLoader* loader, const ResourceError& error) { WebViewImpl* webview = webframe_->GetWebViewImpl(); if (webview && webview->delegate()) { - webview->delegate()->DidFailLoadingWithError(webview, identifier, - WebErrorImpl(error)); + webview->delegate()->DidFailLoadingWithError( + webview, identifier, webkit_glue::ResourceErrorToWebURLError(error)); } } @@ -391,8 +396,8 @@ bool WebFrameLoaderClient::dispatchDidLoadResourceFromMemoryCache( bool result = false; if (d) { - WebRequestImpl webreq(request); - WebResponseImpl webresp(response); + WrappedResourceRequest webreq(request); + WrappedResourceResponse webresp(response); result = d->DidLoadResourceFromMemoryCache(webview, webreq, webresp, webframe_); } @@ -505,13 +510,13 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() // A provisional load should have started already, which should have put an // entry in our redirect chain. - DCHECK(!ds->GetRedirectChain().empty()); + DCHECK(ds->HasRedirectChain()); // The URL of the destination is on the provisional data source. We also need // to update the redirect chain to account for this addition (we do this // before the callback so the callback can look at the redirect chain to see // what happened). - ds->AppendRedirect(ds->GetRequest().GetURL()); + ds->AppendRedirect(ds->request().url()); // Dispatch callback WebViewImpl* webview = webframe_->GetWebViewImpl(); @@ -579,8 +584,8 @@ void WebFrameLoaderClient::dispatchDidChangeLocationWithinPage() { WebDataSourceImpl* ds = webframe_->GetDataSourceImpl(); DCHECK(ds) << "DataSource NULL when navigating to reference fragment"; if (ds) { - GURL url = ds->GetRequest().GetURL(); - GURL chain_end = ds->GetRedirectChain().back(); + GURL url = ds->request().url(); + GURL chain_end = ds->GetEndOfRedirectChain(); ds->ClearRedirectChain(); // Figure out if this location change is because of a JS-initiated client @@ -651,11 +656,11 @@ void WebFrameLoaderClient::dispatchDidStartProvisionalLoad() { NOTREACHED() << "Attempting to provisional load but there isn't one"; return; } - const GURL& url = ds->GetRequest().GetURL(); + GURL url = ds->request().url(); // Since the provisional load just started, we should have not gotten // any redirects yet. - DCHECK(ds->GetRedirectChain().empty()); + DCHECK(!ds->HasRedirectChain()); WebViewImpl* webview = webframe_->GetWebViewImpl(); WebViewDelegate* d = webview->delegate(); @@ -910,18 +915,18 @@ void WebFrameLoaderClient::dispatchDecidePolicyForNavigationAction( // such navigations. const WebDataSourceImpl* ds = webframe_->GetProvisionalDataSourceImpl(); if (ds) { - const GURL& url = ds->GetRequest().GetURL(); + GURL url = ds->request().url(); if (url.SchemeIs(webkit_glue::kBackForwardNavigationScheme)) { HandleBackForwardNavigation(url); disposition = IGNORE_ACTION; } else { - bool is_redirect = !ds->GetRedirectChain().empty(); + bool is_redirect = ds->HasRedirectChain(); WebNavigationType webnav_type = WebDataSourceImpl::NavigationTypeToWebNavigationType(action.type()); disposition = d->DispositionForNavigationAction( - wv, webframe_, &ds->GetRequest(), webnav_type, disposition, is_redirect); + wv, webframe_, ds->request(), webnav_type, disposition, is_redirect); } if (disposition != IGNORE_ACTION) { diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc index 6d5a0c3..80e97f8 100644 --- a/webkit/glue/webkit_glue.cc +++ b/webkit/glue/webkit_glue.cc @@ -42,7 +42,6 @@ #include "webkit/glue/event_conversion.h" #include "webkit/glue/glue_serialize.h" #include "webkit/glue/glue_util.h" -#include "webkit/glue/weburlrequest_impl.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webview_impl.h" diff --git a/webkit/glue/webresponse.h b/webkit/glue/webresponse.h deleted file mode 100644 index 3ee4ed5..0000000 --- a/webkit/glue/webresponse.h +++ /dev/null @@ -1,40 +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_WEBURLRESPONSE_H_ -#define WEBKIT_GLUE_WEBURLRESPONSE_H_ - -#include <string> - -#include "base/basictypes.h" - -class GURL; - -class WebResponse { - public: - // Get the URL. - virtual GURL GetURL() const = 0; - - // Get the http status code. - virtual int GetHttpStatusCode() const = 0; - - // Returns the mime type of the response. - virtual std::string GetMimeType() const = 0; - - // Returns an opaque value containing the state of the SSL connection that - // the resource was loaded on, or an empty string if no SSL connection was - // used. - virtual std::string GetSecurityInfo() const = 0; - - // Returns whether the content of this resource was filtered (usually for - // security reasons). - virtual bool IsContentFiltered() const = 0; - - // Returns the appcacheId this response was loaded from, or kNoAppCacheId. - virtual int64 GetAppCacheID() const = 0; - - virtual ~WebResponse() {} -}; - -#endif // #ifndef WEBKIT_GLUE_WEBURLRESPONSE_H_ diff --git a/webkit/glue/webresponse_impl.h b/webkit/glue/webresponse_impl.h deleted file mode 100644 index 47f097c..0000000 --- a/webkit/glue/webresponse_impl.h +++ /dev/null @@ -1,57 +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_WEBRESPONSEIMPL_H_ -#define WEBKIT_GLUE_WEBRESPONSEIMPL_H_ - -#include "googleurl/src/gurl.h" -#include "webkit/glue/glue_util.h" -#include "webkit/glue/webresponse.h" - -#include "ResourceResponse.h" - -class WebResponseImpl : public WebResponse { - public: - WebResponseImpl() { } - explicit WebResponseImpl(const WebCore::ResourceResponse& response) - : response_(response) { } - - virtual ~WebResponseImpl() { } - - // Get the URL. - virtual GURL GetURL() const { - return webkit_glue::KURLToGURL(response_.url()); - } - - // Get the http status code. - virtual int GetHttpStatusCode() const { return response_.httpStatusCode(); } - - virtual std::string GetMimeType() const { - return webkit_glue::StringToStdString(response_.mimeType()); - } - - // Get the security info (state of the SSL connection). - virtual std::string GetSecurityInfo() const { - return webkit_glue::CStringToStdString(response_.getSecurityInfo()); - } - - void set_resource_response(const WebCore::ResourceResponse& response) { - response_ = response; - } - - virtual bool IsContentFiltered() const { - return response_.isContentFiltered(); - } - - virtual int64 GetAppCacheID() const { - return response_.getAppCacheID(); - } - - private: - WebCore::ResourceResponse response_; - - DISALLOW_EVIL_CONSTRUCTORS(WebResponseImpl); -}; - -#endif // #ifndef WEBKIT_GLUE_WEBRESPONSEIMPL_H_ diff --git a/webkit/glue/weburlrequest.h b/webkit/glue/weburlrequest.h deleted file mode 100644 index d26886a..0000000 --- a/webkit/glue/weburlrequest.h +++ /dev/null @@ -1,103 +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_WEBURLREQUEST_H_ -#define WEBKIT_GLUE_WEBURLREQUEST_H_ - -#include <map> -#include <string> - -enum WebRequestCachePolicy { - WebRequestUseProtocolCachePolicy, - WebRequestReloadIgnoringCacheData, - WebRequestReturnCacheDataElseLoad, - WebRequestReturnCacheDataDontLoad -}; - -namespace net { -class UploadData; -} - -class GURL; - -class WebRequest { - public: - typedef std::map<std::string, std::string> HeaderMap; - - // Creates a WebRequest. - static WebRequest* Create(const GURL& url); - - // Creates a copy of this WebRequest. - virtual WebRequest* Clone() const = 0; - - // Get/set the URL. - virtual GURL GetURL() const = 0; - virtual void SetURL(const GURL& url) = 0; - - // Get/set the URL of the first party for cookies, which may be different - // from the URL for a subframe load. - virtual GURL GetFirstPartyForCookies() const = 0; - virtual void SetFirstPartyForCookies(const GURL& url) = 0; - - // Get/set the cache policy. - virtual WebRequestCachePolicy GetCachePolicy() const = 0; - virtual void SetCachePolicy(WebRequestCachePolicy policy) = 0; - - // Get/set the HTTP request method. - virtual std::string GetHttpMethod() const = 0; - virtual void SetHttpMethod(const std::string& method) = 0; - - // Returns the string corresponding to a header set in the request. If the - // given header was not set in the request, the empty string is returned. - virtual std::string GetHttpHeaderValue(const std::string& field) const = 0; - - // Set a value for a header in the request. - virtual void SetHttpHeaderValue(const std::string& field, - const std::string& value) = 0; - - // Fills a map with all header name/value pairs set in the request. - virtual void GetHttpHeaders(HeaderMap* headers) const = 0; - - // Sets the header name/value pairs for the request from a map. Values set - // using this method replace any pre-existing values with the same name. - // Passing in a blank value will result in a header with a blank value being - // sent as part of the request. - virtual void SetHttpHeaders(const HeaderMap& headers) = 0; - - // Helper function for GetHeaderValue to retrieve the referrer. This - // referrer is generated automatically by WebKit when navigation events - // occur. If there was no referrer (for example, the browser instructed - // WebKit to navigate), the returned string will be empty. - // - // It is preferred to call this instead of GetHttpHeaderValue, because the - // way referrers are stored may change in the future. - // - virtual std::string GetHttpReferrer() const = 0; - - // Get/set an opaque value containing the security info (including SSL - // connection state) that should be reported as used in the response for that - // request, or an empty string if no security info should be reported. This - // is usually used to simulate security errors on a page (typically an error - // page that should contain the errors of the actual page that has the - // errors). - virtual std::string GetSecurityInfo() const = 0; - virtual void SetSecurityInfo(const std::string& info) = 0; - - // Returns true if the request has upload data. - virtual bool HasUploadData() const = 0; - - // Returns the request upload data. This object is temporary and should be - // deleted after use. - virtual void GetUploadData(net::UploadData* data) const = 0; - - // Set the request upload data. - virtual void SetUploadData(const net::UploadData& data) = 0; - - // Sets the requestor id. - virtual void SetRequestorID(int requestor_id) = 0; - - virtual ~WebRequest() { } -}; - -#endif // #ifndef WEBKIT_GLUE_WEBURLREQUEST_H_ diff --git a/webkit/glue/weburlrequest_impl.cc b/webkit/glue/weburlrequest_impl.cc deleted file mode 100644 index 7e82ba9..0000000 --- a/webkit/glue/weburlrequest_impl.cc +++ /dev/null @@ -1,184 +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. - -#include "config.h" - -#include "FormData.h" -#include "HTTPHeaderMap.h" -#include "ResourceRequest.h" - -#undef LOG -#include "base/logging.h" -#include "googleurl/src/gurl.h" -#include "net/base/upload_data.h" -#include "webkit/glue/weburlrequest_impl.h" -#include "webkit/glue/glue_serialize.h" -#include "webkit/glue/glue_util.h" - -using WebCore::FormData; -using WebCore::FormDataElement; -using WebCore::HTTPHeaderMap; -using WebCore::ResourceRequest; -using WebCore::ResourceRequestCachePolicy; -using WebCore::String; - -// WebRequest ----------------------------------------------------------------- - -WebRequestImpl::WebRequestImpl() { -} - -WebRequestImpl::WebRequestImpl(const GURL& url) - : request_(ResourceRequest(webkit_glue::GURLToKURL(url))) { -} - -WebRequestImpl::WebRequestImpl(const ResourceRequest& request) - : request_(request) { -} - -WebRequest* WebRequestImpl::Clone() const { - return new WebRequestImpl(*this); -} - -GURL WebRequestImpl::GetURL() const { - return webkit_glue::KURLToGURL(request_.url()); -} - -void WebRequestImpl::SetURL(const GURL& url) { - request_.setURL(webkit_glue::GURLToKURL(url)); -} - -GURL WebRequestImpl::GetFirstPartyForCookies() const { - return webkit_glue::KURLToGURL(request_.firstPartyForCookies()); -} - -void WebRequestImpl::SetFirstPartyForCookies(const GURL& url) { - request_.setFirstPartyForCookies(webkit_glue::GURLToKURL(url)); -} - -WebRequestCachePolicy WebRequestImpl::GetCachePolicy() const { - // WebRequestCachePolicy mirrors ResourceRequestCachePolicy - return static_cast<WebRequestCachePolicy>(request_.cachePolicy()); -} - -void WebRequestImpl::SetCachePolicy(WebRequestCachePolicy policy) { - // WebRequestCachePolicy mirrors ResourceRequestCachePolicy - request_.setCachePolicy( - static_cast<ResourceRequestCachePolicy>(policy)); -} - -std::string WebRequestImpl::GetHttpMethod() const { - return webkit_glue::StringToStdString(request_.httpMethod()); -} - -void WebRequestImpl::SetHttpMethod(const std::string& method) { - request_.setHTTPMethod(webkit_glue::StdStringToString(method)); -} - -std::string WebRequestImpl::GetHttpHeaderValue(const std::string& field) const { - return webkit_glue::StringToStdString( - request_.httpHeaderField(webkit_glue::StdStringToString(field))); -} - -void WebRequestImpl::SetHttpHeaderValue(const std::string& field, - const std::string& value) { - request_.setHTTPHeaderField( - webkit_glue::StdStringToString(field), - webkit_glue::StdStringToString(value)); -} - -void WebRequestImpl::GetHttpHeaders(HeaderMap* headers) const { - headers->clear(); - - const HTTPHeaderMap& map = request_.httpHeaderFields(); - HTTPHeaderMap::const_iterator end = map.end(); - HTTPHeaderMap::const_iterator it = map.begin(); - for (; it != end; ++it) { - headers->insert(std::make_pair( - webkit_glue::StringToStdString(it->first), - webkit_glue::StringToStdString(it->second))); - } -} - -void WebRequestImpl::SetHttpHeaders(const HeaderMap& headers) { - HeaderMap::const_iterator end = headers.end(); - HeaderMap::const_iterator it = headers.begin(); - for (; it != end; ++it) { - request_.setHTTPHeaderField( - webkit_glue::StdStringToString(it->first), - webkit_glue::StdStringToString(it->second)); - } -} - -std::string WebRequestImpl::GetHttpReferrer() const { - return webkit_glue::StringToStdString(request_.httpReferrer()); -} - -std::string WebRequestImpl::GetSecurityInfo() const { - return webkit_glue::CStringToStdString(request_.securityInfo()); -} - -void WebRequestImpl::SetSecurityInfo(const std::string& value) { - request_.setSecurityInfo(webkit_glue::StdStringToCString(value)); -} - -bool WebRequestImpl::HasUploadData() const { - FormData* formdata = request_.httpBody(); - return formdata && !formdata->isEmpty(); -} - -void WebRequestImpl::GetUploadData(net::UploadData* data) const { - FormData* formdata = request_.httpBody(); - if (!formdata) - return; - - const Vector<FormDataElement>& elements = formdata->elements(); - Vector<FormDataElement>::const_iterator it = elements.begin(); - for (; it != elements.end(); ++it) { - const FormDataElement& element = (*it); - if (element.m_type == FormDataElement::data) { - data->AppendBytes(element.m_data.data(), element.m_data.size()); - } else if (element.m_type == FormDataElement::encodedFile) { - data->AppendFile( - FilePath(webkit_glue::StringToFilePathString(element.m_filename))); - } else { - NOTREACHED(); - } - } - - data->set_identifier(formdata->identifier()); -} - -void WebRequestImpl::SetUploadData(const net::UploadData& data) -{ - RefPtr<FormData> formdata = FormData::create(); - - const std::vector<net::UploadData::Element>& elements = data.elements(); - std::vector<net::UploadData::Element>::const_iterator it = elements.begin(); - for (; it != elements.end(); ++it) { - const net::UploadData::Element& element = (*it); - if (element.type() == net::UploadData::TYPE_BYTES) { - formdata->appendData( - std::string(element.bytes().begin(), element.bytes().end()).c_str(), - element.bytes().size()); - } else if (element.type() == net::UploadData::TYPE_FILE) { - formdata->appendFile( - webkit_glue::FilePathStringToString(element.file_path().value())); - } else { - NOTREACHED(); - } - } - - formdata->setIdentifier(data.identifier()); - - request_.setHTTPBody(formdata); -} - -void WebRequestImpl::SetRequestorID(int requestor_id) { - request_.setRequestorID(requestor_id); -} - -// static -WebRequest* WebRequest::Create(const GURL& url) { - return new WebRequestImpl(url); -} diff --git a/webkit/glue/weburlrequest_impl.h b/webkit/glue/weburlrequest_impl.h deleted file mode 100644 index 5758504..0000000 --- a/webkit/glue/weburlrequest_impl.h +++ /dev/null @@ -1,54 +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_WEBURLREQUEST_IMPL_H_ -#define WEBKIT_GLUE_WEBURLREQUEST_IMPL_H_ - -#include "webkit/glue/weburlrequest.h" - -#include "ResourceRequest.h" - -class WebRequestImpl : public WebRequest { - public: - WebRequestImpl(); - - explicit WebRequestImpl(const GURL& url); - explicit WebRequestImpl(const WebCore::ResourceRequest& request); - - // WebRequest - virtual WebRequest* Clone() const; - virtual void SetURL(const GURL& url); - virtual GURL GetURL() const; - virtual void SetFirstPartyForCookies(const GURL& url); - virtual GURL GetFirstPartyForCookies() const; - virtual WebRequestCachePolicy GetCachePolicy() const; - virtual void SetCachePolicy(WebRequestCachePolicy policy); - virtual std::string GetHttpMethod() const; - virtual void SetHttpMethod(const std::string& method); - virtual std::string GetHttpHeaderValue(const std::string& field) const; - virtual void SetHttpHeaderValue(const std::string& field, - const std::string& value); - virtual void GetHttpHeaders(HeaderMap* headers) const; - virtual void SetHttpHeaders(const HeaderMap& headers); - virtual std::string GetHttpReferrer() const; - virtual std::string GetSecurityInfo() const; - virtual void SetSecurityInfo(const std::string& value); - virtual bool HasUploadData() const; - virtual void GetUploadData(net::UploadData* data) const; - virtual void SetUploadData(const net::UploadData& data); - virtual void SetRequestorID(int requestor_id); - - // WebRequestImpl - const WebCore::ResourceRequest& resource_request() const { - return request_; - } - void set_resource_request(const WebCore::ResourceRequest& request) { - request_ = request; - } - - protected: - WebCore::ResourceRequest request_; -}; - -#endif // #ifndef WEBKIT_GLUE_WEBURLREQUEST_IMPL_H_ diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 2736103..1002d03 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -28,8 +28,8 @@ #include <vector> +#include "webkit/api/public/WebNavigationType.h" #include "webkit/glue/context_menu.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webwidget_delegate.h" namespace webkit_glue { @@ -41,26 +41,27 @@ class AccessibilityObject; } namespace WebKit { +class WebDataSource; class WebDragData; class WebForm; class WebWorker; class WebWorkerClient; class WebMediaPlayer; class WebMediaPlayerClient; +class WebURLRequest; +class WebURLResponse; struct WebPoint; struct WebRect; +struct WebURLError; } struct WebPreferences; class FilePath; class SkBitmap; class WebDevToolsAgentDelegate; -class WebError; class WebFrame; class WebMediaPlayerDelegate; class WebPluginDelegate; -class WebRequest; -class WebResponse; class WebView; class WebWidget; @@ -224,8 +225,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate { virtual WindowOpenDisposition DispositionForNavigationAction( WebView* webview, WebFrame* frame, - const WebRequest* request, - WebNavigationType type, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationType type, WindowOpenDisposition disposition, bool is_redirect) { return disposition; @@ -235,7 +236,8 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // A datasource has been created for a new navigation. The given datasource // will become the provisional datasource for the frame. - virtual void DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { + virtual void DidCreateDataSource(WebFrame* frame, + WebKit::WebDataSource* ds) { } // Notifies the delegate that the provisional load of a specified frame in a @@ -273,18 +275,19 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // committed data source if there is one. // This notification is only received for errors like network errors. virtual void DidFailProvisionalLoadWithError(WebView* webview, - const WebError& error, + const WebKit::WebURLError& error, WebFrame* frame) { } // If the provisional load fails, we try to load a an error page describing // the user about the load failure. |html| is the UTF8 text to display. If // |html| is empty, we will fall back on a local error page. - virtual void LoadNavigationErrorPage(WebFrame* frame, - const WebRequest* failed_request, - const WebError& error, - const std::string& html, - bool replace) { + virtual void LoadNavigationErrorPage( + WebFrame* frame, + const WebKit::WebURLRequest& failed_request, + const WebKit::WebURLError& error, + const std::string& html, + bool replace) { } // Notifies the delegate that the load has changed from provisional to @@ -339,7 +342,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // @discussion This method is called after a data source has committed but failed to completely load. // - (void)webView:(WebView *)sender didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame; virtual void DidFailLoadWithError(WebView* webview, - const WebError& error, + const WebKit::WebURLError& error, WebFrame* forFrame) { } @@ -358,10 +361,11 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // This method is called when we load a resource from an in-memory cache. // A return value of |false| indicates the load should proceed, but WebCore // appears to largely ignore the return value. - virtual bool DidLoadResourceFromMemoryCache(WebView* webview, - const WebRequest& request, - const WebResponse& response, - WebFrame* frame) { + virtual bool DidLoadResourceFromMemoryCache( + WebView* webview, + const WebKit::WebURLRequest& request, + const WebKit::WebURLResponse& response, + WebFrame* frame) { return false; } @@ -444,9 +448,10 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // Associates the given identifier with the initial resource request. // Resource load callbacks will use the identifier throughout the life of the // request. - virtual void AssignIdentifierToRequest(WebView* webview, - uint32 identifier, - const WebRequest& request) { + virtual void AssignIdentifierToRequest( + WebView* webview, + uint32 identifier, + const WebKit::WebURLRequest& request) { } // Notifies the delegate that a request is about to be sent out, giving the @@ -455,7 +460,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // to be made. virtual void WillSendRequest(WebView* webview, uint32 identifier, - WebRequest* request) { + WebKit::WebURLRequest* request) { } // Notifies the delegate that a subresource load has succeeded. @@ -465,7 +470,7 @@ class WebViewDelegate : virtual public WebWidgetDelegate { // Notifies the delegate that a subresource load has failed, and why. virtual void DidFailLoadingWithError(WebView* webview, uint32 identifier, - const WebError& error) { + const WebKit::WebURLError& error) { } // ChromeClient ------------------------------------------------------------ diff --git a/webkit/glue/webworker_impl.cc b/webkit/glue/webworker_impl.cc index 4b3ba67..6cd3bd0 100644 --- a/webkit/glue/webworker_impl.cc +++ b/webkit/glue/webworker_impl.cc @@ -78,7 +78,7 @@ class WorkerWebViewDelegate : public WebViewDelegate { const std::vector<WebMenuItem> &items) { } // Tell the loader to load the data into the 'shadow page' synchronously, // so we can grab the resulting Document right after load. - virtual void DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { + virtual void DidCreateDataSource(WebFrame* frame, WebKit::WebDataSource* ds) { static_cast<WebDataSourceImpl*>(ds)->setDeferMainResourceDataLoad(false); } // Lazy allocate and leak this instance. diff --git a/webkit/tools/test_shell/test_navigation_controller.h b/webkit/tools/test_shell/test_navigation_controller.h index f0d9fca..bcfa1b2 100644 --- a/webkit/tools/test_shell/test_navigation_controller.h +++ b/webkit/tools/test_shell/test_navigation_controller.h @@ -12,13 +12,13 @@ #include "base/linked_ptr.h" #include "base/ref_counted.h" #include "googleurl/src/gurl.h" -#include "webkit/glue/webdatasource.h" +#include "webkit/api/public/WebDataSource.h" class GURL; class TestShell; // Associated with browser-initated navigations to hold tracking data. -class TestShellExtraData : public WebDataSource::ExtraData { +class TestShellExtraData : public WebKit::WebDataSource::ExtraData { public: TestShellExtraData(int32 pending_page_id) : pending_page_id(pending_page_id), diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 6c94b1d..f141d75 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -32,18 +32,21 @@ #include "skia/ext/bitmap_platform_device.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmap.h" -#include "webkit/glue/webdatasource.h" +#include "webkit/api/public/WebString.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/public/WebURLResponse.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" -#include "webkit/glue/webresponse.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview.h" #include "webkit/glue/webwidget.h" #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" #include "webkit/tools/test_shell/test_navigation_controller.h" #include "webkit/tools/test_shell/test_shell_switches.h" +using WebKit::WebURLRequest; + namespace { // Default timeout in ms for file page loads when in layout test mode. @@ -191,9 +194,9 @@ void TestShell::Dump(TestShell* shell) { // which we handle here. if (!should_dump_as_text) { // Plain text pages should be dumped as text - std::string mime_type = - webFrame->GetDataSource()->GetResponse().GetMimeType(); - should_dump_as_text = (mime_type == "text/plain"); + const string16& mime_type = + webFrame->GetDataSource()->response().mimeType(); + should_dump_as_text = EqualsASCII(mime_type, "text/plain"); } if (should_dump_as_text) { bool recursive = shell->layout_test_controller_-> @@ -515,18 +518,18 @@ bool TestShell::Navigate(const TestNavigationEntry& entry, bool reload) { DCHECK(entry.GetPageID() != -1); frame->LoadHistoryState(entry.GetContentState()); } else { - WebRequestCachePolicy cache_policy; + WebURLRequest::CachePolicy cache_policy; if (reload) { - cache_policy = WebRequestReloadIgnoringCacheData; + cache_policy = WebURLRequest::ReloadIgnoringCacheData; } else { DCHECK(entry.GetPageID() == -1); - cache_policy = WebRequestUseProtocolCachePolicy; + cache_policy = WebURLRequest::UseProtocolCachePolicy; } - scoped_ptr<WebRequest> request(WebRequest::Create(entry.GetURL())); - request->SetCachePolicy(cache_policy); + WebURLRequest request(entry.GetURL()); + request.setCachePolicy(cache_policy); - frame->LoadRequest(request.get()); + frame->LoadRequest(request); } // In case LoadRequest failed before DidCreateDataSource was called. diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index efae470..86a9ac9 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -25,7 +25,6 @@ #include "net/base/net_util.h" #include "webkit/glue/plugins/plugin_list.h" #include "webkit/glue/resource_loader_bridge.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" diff --git a/webkit/tools/test_shell/test_shell_mac.mm b/webkit/tools/test_shell/test_shell_mac.mm index 3811ccc..c2640cc 100644 --- a/webkit/tools/test_shell/test_shell_mac.mm +++ b/webkit/tools/test_shell/test_shell_mac.mm @@ -29,11 +29,9 @@ #include "net/base/mime_util.h" #include "skia/ext/bitmap_platform_device.h" #include "testing/gtest/include/gtest/gtest.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webview.h" #include "webkit/glue/webwidget.h" #include "webkit/glue/plugins/plugin_list.h" diff --git a/webkit/tools/test_shell/test_shell_win.cc b/webkit/tools/test_shell/test_shell_win.cc index 40ba67b..bc4fb43 100644 --- a/webkit/tools/test_shell/test_shell_win.cc +++ b/webkit/tools/test_shell/test_shell_win.cc @@ -28,7 +28,6 @@ #include "net/http/http_network_layer.h" #include "net/url_request/url_request_file_job.h" #include "skia/ext/bitmap_platform_device.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webpreferences.h" diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index 4d0a0bf..da50f28 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -17,16 +17,17 @@ #include "base/string_util.h" #include "base/trace_event.h" #include "net/base/net_errors.h" +#include "webkit/api/public/WebDataSource.h" #include "webkit/api/public/WebDragData.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScreenInfo.h" #include "webkit/api/public/WebString.h" -#include "webkit/glue/webdatasource.h" +#include "webkit/api/public/WebURL.h" +#include "webkit/api/public/WebURLError.h" +#include "webkit/api/public/WebURLRequest.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/weberror.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" #include "webkit/glue/plugins/plugin_list.h" @@ -43,11 +44,16 @@ #include "webkit/tools/test_shell/drop_delegate.h" #endif +using WebKit::WebDataSource; using WebKit::WebDragData; +using WebKit::WebNavigationType; using WebKit::WebRect; using WebKit::WebScreenInfo; using WebKit::WebSize; using WebKit::WebString; +using WebKit::WebURL; +using WebKit::WebURLError; +using WebKit::WebURLRequest; using WebKit::WebWorker; using WebKit::WebWorkerClient; @@ -85,17 +91,17 @@ void AddDRTFakeFileToDataObject(WebDragData* drag_data) { // Get a debugging string from a WebNavigationType. const char* WebNavigationTypeToString(WebNavigationType type) { switch (type) { - case WebNavigationTypeLinkClicked: + case WebKit::WebNavigationTypeLinkClicked: return kLinkClickedString; - case WebNavigationTypeFormSubmitted: + case WebKit::WebNavigationTypeFormSubmitted: return kFormSubmittedString; - case WebNavigationTypeBackForward: + case WebKit::WebNavigationTypeBackForward: return kBackForwardString; - case WebNavigationTypeReload: + case WebKit::WebNavigationTypeReload: return kReloadString; - case WebNavigationTypeFormResubmitted: + case WebKit::WebNavigationTypeFormResubmitted: return kFormResubmittedString; - case WebNavigationTypeOther: + case WebKit::WebNavigationTypeOther: return kOtherString; } return kIllegalString; @@ -156,7 +162,7 @@ void TestWebViewDelegate::WindowObjectCleared(WebFrame* webframe) { WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( WebView* webview, WebFrame* frame, - const WebRequest* request, + const WebURLRequest& request, WebNavigationType type, WindowOpenDisposition disposition, bool is_redirect) { @@ -164,10 +170,11 @@ WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( if (policy_delegate_enabled_) { std::wstring frame_name = frame->GetName(); std::string url_description; - if (request->GetURL().SchemeIs("file")) { - url_description = request->GetURL().ExtractFileName(); + GURL request_url = request.url(); + if (request_url.SchemeIs("file")) { + url_description = request_url.ExtractFileName(); } else { - url_description = request->GetURL().spec(); + url_description = request_url.spec(); } printf("Policy delegate: attempt to load %s with navigation type '%s'\n", url_description.c_str(), WebNavigationTypeToString(type)); @@ -181,12 +188,12 @@ WindowOpenDisposition TestWebViewDelegate::DispositionForNavigationAction( return result; } -void TestWebViewDelegate::AssignIdentifierToRequest(WebView* webview, - uint32 identifier, - const WebRequest& request) { - if (shell_->ShouldDumpResourceLoadCallbacks()) { - resource_identifier_map_[identifier] = request.GetURL().possibly_invalid_spec(); - } +void TestWebViewDelegate::AssignIdentifierToRequest( + WebView* webview, + uint32 identifier, + const WebURLRequest& request) { + if (shell_->ShouldDumpResourceLoadCallbacks()) + resource_identifier_map_[identifier] = request.url().spec(); } std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { @@ -196,10 +203,10 @@ std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { void TestWebViewDelegate::WillSendRequest(WebView* webview, uint32 identifier, - WebRequest* request) { - GURL url = request->GetURL(); + WebURLRequest* request) { + GURL url = request->url(); std::string request_url = url.possibly_invalid_spec(); - std::string host = request->GetURL().host(); + std::string host = url.host(); if (shell_->ShouldDumpResourceLoadCallbacks()) { printf("%s - willSendRequest <WebRequest URL \"%s\">\n", @@ -216,13 +223,13 @@ void TestWebViewDelegate::WillSendRequest(WebView* webview, printf("Blocked access to external URL %s\n", request_url.c_str()); // To block the request, we set its URL to an empty one. - request->SetURL(GURL()); + request->setURL(WebURL()); return; } TRACE_EVENT_BEGIN("url.load", identifier, request_url); // Set the new substituted URL. - request->SetURL(GURL(TestShell::RewriteLocalUrl(request_url))); + request->setURL(GURL(TestShell::RewriteLocalUrl(request_url))); } void TestWebViewDelegate::DidFinishLoading(WebView* webview, @@ -238,13 +245,13 @@ void TestWebViewDelegate::DidFinishLoading(WebView* webview, void TestWebViewDelegate::DidFailLoadingWithError(WebView* webview, uint32 identifier, - const WebError& error) { + const WebURLError& error) { if (shell_->ShouldDumpResourceLoadCallbacks()) { printf("%s - didFailLoadingWithError <WebError code %d," " failing URL \"%s\">\n", GetResourceDescription(identifier).c_str(), - error.GetErrorCode(), - error.GetFailedURL().spec().c_str()); + error.reason, + error.unreachableURL.spec().data()); } resource_identifier_map_.erase(identifier); @@ -252,7 +259,7 @@ void TestWebViewDelegate::DidFailLoadingWithError(WebView* webview, void TestWebViewDelegate::DidCreateDataSource(WebFrame* frame, WebDataSource* ds) { - ds->SetExtraData(pending_extra_data_.release()); + ds->setExtraData(pending_extra_data_.release()); } void TestWebViewDelegate::DidStartProvisionalLoadForFrame( @@ -289,7 +296,7 @@ void TestWebViewDelegate::DidReceiveServerRedirectForProvisionalLoadForFrame( void TestWebViewDelegate::DidFailProvisionalLoadWithError( WebView* webview, - const WebError& error, + const WebURLError& error, WebFrame* frame) { if (shell_->ShouldDumpFrameLoadCallbacks()) { printf("%S - didFailProvisionalLoadWithError\n", @@ -305,24 +312,24 @@ void TestWebViewDelegate::DidFailProvisionalLoadWithError( // Don't display an error page if this is simply a cancelled load. Aside // from being dumb, WebCore doesn't expect it and it will cause a crash. - if (error.GetErrorCode() == net::ERR_ABORTED) + if (error.reason == net::ERR_ABORTED) return; const WebDataSource* failed_ds = frame->GetProvisionalDataSource(); TestShellExtraData* extra_data = - static_cast<TestShellExtraData*>(failed_ds->GetExtraData()); + static_cast<TestShellExtraData*>(failed_ds->extraData()); bool replace = extra_data && extra_data->pending_page_id != -1; - scoped_ptr<WebRequest> request(failed_ds->GetRequest().Clone()); + WebURLRequest request = failed_ds->request(); std::string error_text = - StringPrintf("Error %d when loading url %s", error.GetErrorCode(), - request->GetURL().spec().c_str()); - request->SetURL(GURL("testshell-error:")); + StringPrintf("Error %d when loading url %s", error.reason, + request.url().spec().data()); + request.setURL(GURL("testshell-error:")); - frame->LoadAlternateHTMLString(request.get(), error_text, - error.GetFailedURL(), replace); + frame->LoadAlternateHTMLString( + request, error_text, error.unreachableURL, replace); } void TestWebViewDelegate::DidCommitLoadForFrame(WebView* webview, @@ -364,7 +371,7 @@ void TestWebViewDelegate::DidFinishLoadForFrame(WebView* webview, } void TestWebViewDelegate::DidFailLoadWithError(WebView* webview, - const WebError& error, + const WebURLError& error, WebFrame* frame) { if (shell_->ShouldDumpFrameLoadCallbacks()) { printf("%S - didFailLoadWithError\n", @@ -398,7 +405,7 @@ void TestWebViewDelegate::DidHandleOnloadEventsForFrame(WebView* webview, void TestWebViewDelegate::DidChangeLocationWithinPageForFrame( WebView* webview, WebFrame* frame, bool is_new_navigation) { - frame->GetDataSource()->SetExtraData(pending_extra_data_.release()); + frame->GetDataSource()->setExtraData(pending_extra_data_.release()); if (shell_->ShouldDumpFrameLoadCallbacks()) { printf("%S - didChangeLocationWithinPageForFrame\n", @@ -802,7 +809,7 @@ void TestWebViewDelegate::UpdateAddressBar(WebView* webView) { return; // TODO(abarth): This is wrong! - SetAddressBarURL(dataSource->GetRequest().GetFirstPartyForCookies()); + SetAddressBarURL(dataSource->request().firstPartyForCookies()); } void TestWebViewDelegate::LocationChangeDone(WebFrame* frame) { @@ -826,7 +833,7 @@ void TestWebViewDelegate::UpdateForCommittedLoad(WebFrame* frame, bool is_new_navigation) { // Code duplicated from RenderView::DidCommitLoadForFrame. TestShellExtraData* extra_data = static_cast<TestShellExtraData*>( - frame->GetDataSource()->GetExtraData()); + frame->GetDataSource()->extraData()); if (is_new_navigation) { // New navigation. @@ -850,7 +857,7 @@ void TestWebViewDelegate::UpdateURL(WebFrame* frame) { WebDataSource* ds = frame->GetDataSource(); DCHECK(ds); - const WebRequest& request = ds->GetRequest(); + const WebURLRequest& request = ds->request(); // Type is unused. scoped_ptr<TestNavigationEntry> entry(new TestNavigationEntry); @@ -858,10 +865,10 @@ void TestWebViewDelegate::UpdateURL(WebFrame* frame) { // Bug 654101: the referrer will be empty on https->http transitions. It // would be nice if we could get the real referrer from somewhere. entry->SetPageID(page_id_); - if (ds->HasUnreachableURL()) { - entry->SetURL(GURL(ds->GetUnreachableURL())); + if (ds->hasUnreachableURL()) { + entry->SetURL(ds->unreachableURL()); } else { - entry->SetURL(GURL(request.GetURL())); + entry->SetURL(request.url()); } std::string state; diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 6cd21ff..2c85b8c 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -35,7 +35,6 @@ struct WebPreferences; class GURL; class TestShell; -class WebDataSource; class WebWidgetHost; class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, @@ -128,16 +127,17 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, const std::string& security_info, const std::string& frame_charset); virtual void DidCreateDataSource(WebFrame* frame, - WebDataSource* ds); + WebKit::WebDataSource* ds); virtual void DidStartProvisionalLoadForFrame( WebView* webview, WebFrame* frame, NavigationGesture gesture); virtual void DidReceiveServerRedirectForProvisionalLoadForFrame( WebView* webview, WebFrame* frame); - virtual void DidFailProvisionalLoadWithError(WebView* webview, - const WebError& error, - WebFrame* frame); + virtual void DidFailProvisionalLoadWithError( + WebView* webview, + const WebKit::WebURLError& error, + WebFrame* frame); virtual void DidCommitLoadForFrame(WebView* webview, WebFrame* frame, bool is_new_navigation); virtual void DidReceiveTitle(WebView* webview, @@ -162,19 +162,19 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void DidFinishLoadForFrame(WebView* webview, WebFrame* frame); virtual void DidFailLoadWithError(WebView* webview, - const WebError& error, - WebFrame* forFrame); + const WebKit::WebURLError& error, + WebFrame* for_frame); virtual void AssignIdentifierToRequest(WebView* webview, uint32 identifier, - const WebRequest& request); + const WebKit::WebURLRequest& request); virtual void WillSendRequest(WebView* webview, uint32 identifier, - WebRequest* request); + WebKit::WebURLRequest* request); virtual void DidFinishLoading(WebView* webview, uint32 identifier); virtual void DidFailLoadingWithError(WebView* webview, uint32 identifier, - const WebError& error); + const WebKit::WebURLError& error); virtual bool ShouldBeginEditing(WebView* webview, std::wstring range); virtual bool ShouldEndEditing(WebView* webview, std::wstring range); @@ -209,8 +209,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual WindowOpenDisposition DispositionForNavigationAction( WebView* webview, WebFrame* frame, - const WebRequest* request, - WebNavigationType type, + const WebKit::WebURLRequest& request, + WebKit::WebNavigationType type, WindowOpenDisposition disposition, bool is_redirect); virtual void NavigateBackForwardSoon(int offset); diff --git a/webkit/tools/test_shell/test_webview_delegate_gtk.cc b/webkit/tools/test_shell/test_webview_delegate_gtk.cc index f8822bd..d4a0574 100644 --- a/webkit/tools/test_shell/test_webview_delegate_gtk.cc +++ b/webkit/tools/test_shell/test_webview_delegate_gtk.cc @@ -16,13 +16,10 @@ #include "chrome/common/page_transition_types.h" #include "webkit/api/public/WebRect.h" #include "webkit/glue/webcursor.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/weberror.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" #include "webkit/glue/plugins/plugin_list.h" diff --git a/webkit/tools/test_shell/test_webview_delegate_win.cc b/webkit/tools/test_shell/test_webview_delegate_win.cc index cb98dbf..a0f3254 100644 --- a/webkit/tools/test_shell/test_webview_delegate_win.cc +++ b/webkit/tools/test_shell/test_webview_delegate_win.cc @@ -20,13 +20,10 @@ #include "base/trace_event.h" #include "net/base/net_errors.h" #include "webkit/api/public/WebRect.h" -#include "webkit/glue/webdatasource.h" #include "webkit/glue/webdropdata.h" -#include "webkit/glue/weberror.h" #include "webkit/glue/webframe.h" #include "webkit/glue/webpreferences.h" #include "webkit/glue/webplugin.h" -#include "webkit/glue/weburlrequest.h" #include "webkit/glue/webkit_glue.h" #include "webkit/glue/webview.h" #include "webkit/glue/plugins/plugin_list.h" diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 9747e3f..7709396 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -4193,6 +4193,7 @@ 'api/public/WebConsoleMessage.h', 'api/public/WebCString.h', 'api/public/WebData.h', + 'api/public/WebDataSource.h', 'api/public/WebDragData.h', 'api/public/WebFindOptions.h', 'api/public/WebForm.h', @@ -4204,6 +4205,7 @@ 'api/public/WebMediaPlayer.h', 'api/public/WebMediaPlayerClient.h', 'api/public/WebMimeRegistry.h', + 'api/public/WebNavigationType.h', 'api/public/WebNonCopyable.h', 'api/public/WebPluginListBuilder.h', 'api/public/WebPoint.h', @@ -4544,7 +4546,6 @@ 'glue/webcursor_gtk_data.h', 'glue/webcursor_mac.mm', 'glue/webcursor_win.cc', - 'glue/webdatasource.h', 'glue/webdatasource_impl.cc', 'glue/webdatasource_impl.h', 'glue/webdevtoolsagent.h', @@ -4558,9 +4559,6 @@ 'glue/webdropdata.cc', 'glue/webdropdata_win.cc', 'glue/webdropdata.h', - 'glue/weberror.h', - 'glue/weberror_impl.cc', - 'glue/weberror_impl.h', 'glue/webframe.h', 'glue/webframe_impl.cc', 'glue/webframe_impl.h', @@ -4581,17 +4579,12 @@ 'glue/webplugin_impl.h', 'glue/webplugininfo.h', 'glue/webpreferences.h', - 'glue/webresponse.h', - 'glue/webresponse_impl.h', 'glue/webtextinput.h', 'glue/webtextinput_impl.cc', 'glue/webtextinput_impl.h', 'glue/webthemeengine_impl_win.cc', 'glue/weburlloader_impl.cc', 'glue/weburlloader_impl.h', - 'glue/weburlrequest.h', - 'glue/weburlrequest_impl.cc', - 'glue/weburlrequest_impl.h', 'glue/webview.h', 'glue/webview_delegate.cc', 'glue/webview_delegate.h', |