summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 22:50:54 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-12 22:50:54 +0000
commit9d806f57abc6b55a5decad8b230b1f8c31c692ba (patch)
tree2d2d2a8c0be9c543da908b5dadf4a3c5062bc72b
parent56d01f63dc6ddb958dd8ce1d0c711ed87c3f0180 (diff)
downloadchromium_src-9d806f57abc6b55a5decad8b230b1f8c31c692ba.zip
chromium_src-9d806f57abc6b55a5decad8b230b1f8c31c692ba.tar.gz
chromium_src-9d806f57abc6b55a5decad8b230b1f8c31c692ba.tar.bz2
Some minor cleanup in WebDataSource and WebResponse.
R=dglazkov Review URL: http://codereview.chromium.org/42156 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11591 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/renderer/render_view.cc7
-rw-r--r--webkit/glue/webdatasource.h129
-rw-r--r--webkit/glue/webdatasource_impl.cc54
-rw-r--r--webkit/glue/webdatasource_impl.h3
-rw-r--r--webkit/glue/webresponse.h9
-rw-r--r--webkit/glue/webresponse_impl.h4
-rwxr-xr-xwebkit/tools/test_shell/test_shell.cc7
7 files changed, 30 insertions, 183 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index eb0ccf7..2d614b4 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -1074,8 +1074,7 @@ void RenderView::UpdateURL(WebFrame* frame) {
// Top-level navigation.
// Update contents MIME type for main frame.
- std::wstring mime_type = ds->GetResponseMimeType();
- params.contents_mime_type = WideToASCII(mime_type);
+ params.contents_mime_type = ds->GetResponse().GetMimeType();
// We assume top level navigations initiated by the renderer are link
// clicks.
@@ -1479,9 +1478,9 @@ void RenderView::DidChangeLocationWithinPageForFrame(WebView* webview,
WebFrame* frame,
bool is_new_navigation) {
DidCommitLoadForFrame(webview, frame, is_new_navigation);
- const std::wstring& title =
+ const string16& title =
webview->GetMainFrame()->GetDataSource()->GetPageTitle();
- UpdateTitle(frame, title);
+ UpdateTitle(frame, UTF16ToWideHack(title));
}
void RenderView::DidReceiveIconForFrame(WebView* webview,
diff --git a/webkit/glue/webdatasource.h b/webkit/glue/webdatasource.h
index eaad8ec..b7c45a6 100644
--- a/webkit/glue/webdatasource.h
+++ b/webkit/glue/webdatasource.h
@@ -2,26 +2,23 @@
// 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__
+#ifndef WEBKIT_GLUE_WEBDATASOURCE_H_
+#define WEBKIT_GLUE_WEBDATASOURCE_H_
#include <vector>
-#include "base/basictypes.h"
+#include "base/string16.h"
class GURL;
-struct PasswordForm;
class SearchableFormData;
class WebFrame;
class WebRequest;
class WebResponse;
+struct PasswordForm;
class WebDataSource {
public:
- //
- // @method webFrame
- // @result Return the frame that represents this data source.
- // - (WebFrame *)webFrame;
+ // Returns the frame that represents this data source.
virtual WebFrame* GetWebFrame() = 0;
// Returns a reference to the original request data that created the
@@ -37,7 +34,8 @@ class WebDataSource {
virtual const WebRequest& GetInitialRequest() const = 0;
// Returns the request that was used to create this datasource. This may
- // be modified by WebKit.
+ // 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.
@@ -50,14 +48,8 @@ class WebDataSource {
// Returns the response associated to this datasource.
virtual const WebResponse& GetResponse() const = 0;
- virtual std::wstring GetResponseMimeType() const = 0;
-
- //
- // @method unreachableURL
- // @discussion This will be non-nil only for dataSources created by calls to the
- // WebFrame method loadAlternateHTMLString:baseURL:forUnreachableURL:.
- // @result returns the unreachableURL for which this dataSource is showing alternate content, or nil
- // - (NSURL *)unreachableURL;
+ // 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.
@@ -86,106 +78,9 @@ class WebDataSource {
virtual bool IsFormSubmit() const = 0;
// Returns the page title.
- virtual std::wstring GetPageTitle() const = 0;
-
- /*
- These functions are not implemented yet, and we are not yet sure whether or not
- we need them, so we have commented them out both here and in the
- webdatasource_impl.cc file.
-
- //
- // @method data
- // @discussion The data will be incomplete until the datasource has completely loaded.
- // @result Returns the raw data associated with the datasource. Returns nil
- // if the datasource hasn't loaded any data.
- // - (NSData *)data;
- virtual void GetData(IStream** data) = 0;
-
- //
- // @method representation
- // @discussion A representation holds a type specific representation
- // of the datasource's data. The representation class is determined by mapping
- // a MIME type to a class. The representation is created once the MIME type
- // of the datasource content has been determined.
- // @result Returns the representation associated with this datasource.
- // Returns nil if the datasource hasn't created it's representation.
- // - (id <WebDocumentRepresentation>)representation;
- virtual void GetRepresentation(IWebDocumentRepresentation** rep) = 0;
-
- //
- // @method response
- // @result returns the WebResourceResponse for the data source.
- // - (NSURLResponse *)response;
- virtual void GetResponse(IWebURLResponse** response) = 0;
-
- //
- // @method textEncodingName
- // @result Returns either the override encoding, as set on the WebView for this
- // dataSource or the encoding from the response.
- // - (NSString *)textEncodingName;
- virtual void GetTextEncodingName(std::wstring* name) = 0;
+ virtual string16 GetPageTitle() const = 0;
- //
- // @method isLoading
- // @discussion Returns YES if there are any pending loads.
- // - (BOOL)isLoading;
- virtual bool IsLoading() = 0;
-
- //
- // @method webArchive
- // @result A WebArchive representing the data source, its subresources and child frames.
- // @description This method constructs a WebArchive using the original downloaded data.
- // In the case of HTML, if the current state of the document is preferred, webArchive should be
- // called on the DOM document instead.
- // - (WebArchive *)webArchive;
- virtual void GetWebArchive(IWebArchive** archive) = 0;
-
- //
- // @method mainResource
- // @result A WebResource representing the data source.
- // @description This method constructs a WebResource using the original downloaded data.
- // This method can be used to construct a WebArchive in case the archive returned by
- // WebDataSource's webArchive isn't sufficient.
- // - (WebResource *)mainResource;
- virtual void GetMainResource(IWebResource** resource) = 0;
-
- //
- // @method subresources
- // @abstract Returns all the subresources associated with the data source.
- // @description The returned array only contains subresources that have fully downloaded.
- // - (NSArray *)subresources;
- virtual void GetSubresources(int* count, IWebResource*** resources);
-
- //
- // method subresourceForURL:
- // @abstract Returns a subresource for a given URL.
- // @param URL The URL of the subresource.
- // @description Returns non-nil if the data source has fully downloaded a subresource with the given URL.
- // - (WebResource *)subresourceForURL:(NSURL *)URL;
- virtual void GetSubresourceForURL(const std::wstring& url,
- IWebResource** resource) = 0;
-
- //
- // @method addSubresource:
- // @abstract Adds a subresource to the data source.
- // @param subresource The subresource to be added.
- // @description addSubresource: adds a subresource to the data source's list of subresources.
- // Later, if something causes the data source to load the URL of the subresource, the data source
- // will load the data from the subresource instead of from the network. For example, if one wants to add
- // an image that is already downloaded to a web page, addSubresource: can be called so that the data source
- // uses the downloaded image rather than accessing the network. NOTE: If the data source already has a
- // subresource with the same URL, addSubresource: will replace it.
- // - (void)addSubresource:(WebResource *)subresource;
- virtual void AddSubresource(IWebResource* subresource) = 0;
- */
-
- WebDataSource() { }
- virtual ~WebDataSource() { }
-
- private:
- DISALLOW_EVIL_CONSTRUCTORS(WebDataSource);
+ virtual ~WebDataSource() {}
};
-
-
-#endif // #ifndef WEBKIT_GLUE_WEBDATASOURCE_H__
+#endif // #ifndef WEBKIT_GLUE_WEBDATASOURCE_H_
diff --git a/webkit/glue/webdatasource_impl.cc b/webkit/glue/webdatasource_impl.cc
index 70ba01c..6414d45 100644
--- a/webkit/glue/webdatasource_impl.cc
+++ b/webkit/glue/webdatasource_impl.cc
@@ -92,10 +92,6 @@ void WebDataSourceImpl::SetExtraData(WebRequest::ExtraData* extra) {
request_.SetExtraData(extra);
}
-std::wstring WebDataSourceImpl::GetResponseMimeType() const {
- return webkit_glue::StringToStdWString(loader_->responseMIMEType());
-}
-
GURL WebDataSourceImpl::GetUnreachableURL() const {
const WebCore::KURL& url = loader_->unreachableURL();
return url.isEmpty() ? GURL() : webkit_glue::KURLToGURL(url);
@@ -130,52 +126,6 @@ bool WebDataSourceImpl::IsFormSubmit() const {
return loader_->is_form_submit();
}
-std::wstring WebDataSourceImpl::GetPageTitle() const {
- return webkit_glue::StringToStdWString(loader_->title());
-}
-
-/*
-See comment in webdatasource.h
-
-void WebDataSourceImpl::GetData(IStream** data) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetRepresentation(IWebDocumentRepresentation** rep) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetResponse(IWebURLResponse** response) {
- DebugBreak();
-}
-
-std::wstring WebDataSourceImpl::GetTextEncodingName() {
- DebugBreak();
- return L"";
-}
-
-bool WebDataSourceImpl::IsLoading() {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetWebArchive(IWebArchive** archive) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetMainResource(IWebResource** resource) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetSubresources(int* count, IWebResource*** resources) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::GetSubresourceForURL(const std::wstring& url,
- IWebResource** resource) {
- DebugBreak();
-}
-
-void WebDataSourceImpl::AddSubresource(IWebResource* subresource) {
- DebugBreak();
+string16 WebDataSourceImpl::GetPageTitle() const {
+ return webkit_glue::StringToString16(loader_->title());
}
-*/
diff --git a/webkit/glue/webdatasource_impl.h b/webkit/glue/webdatasource_impl.h
index 0b364c4..651abcb 100644
--- a/webkit/glue/webdatasource_impl.h
+++ b/webkit/glue/webdatasource_impl.h
@@ -50,7 +50,6 @@ class WebDataSourceImpl : public WebDataSource {
virtual const WebRequest& GetInitialRequest() const;
virtual const WebRequest& GetRequest() const;
virtual const WebResponse& GetResponse() const;
- virtual std::wstring GetResponseMimeType() const;
virtual GURL GetUnreachableURL() const;
virtual bool HasUnreachableURL() const;
virtual const std::vector<GURL>& GetRedirectChain() const;
@@ -72,7 +71,7 @@ class WebDataSourceImpl : public WebDataSource {
virtual bool IsFormSubmit() const;
- virtual std::wstring GetPageTitle() const;
+ virtual string16 GetPageTitle() const;
private:
WebFrameImpl* frame_;
diff --git a/webkit/glue/webresponse.h b/webkit/glue/webresponse.h
index 9d087c05..1fdf97d 100644
--- a/webkit/glue/webresponse.h
+++ b/webkit/glue/webresponse.h
@@ -19,6 +19,9 @@ class WebResponse {
// 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.
@@ -28,11 +31,7 @@ class WebResponse {
// security reasons).
virtual bool IsContentFiltered() const = 0;
- WebResponse() { }
- virtual ~WebResponse() { }
-
-private:
- DISALLOW_EVIL_CONSTRUCTORS(WebResponse);
+ virtual ~WebResponse() {}
};
#endif // #ifndef WEBKIT_GLUE_WEBURLRESPONSE_H_
diff --git a/webkit/glue/webresponse_impl.h b/webkit/glue/webresponse_impl.h
index 494848b..da7f1cd 100644
--- a/webkit/glue/webresponse_impl.h
+++ b/webkit/glue/webresponse_impl.h
@@ -26,6 +26,10 @@ class WebResponseImpl : public WebResponse {
// 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());
diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc
index 3dc08bb..089ef9d 100755
--- a/webkit/tools/test_shell/test_shell.cc
+++ b/webkit/tools/test_shell/test_shell.cc
@@ -36,6 +36,7 @@
#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"
@@ -192,9 +193,9 @@ void TestShell::Dump(TestShell* shell) {
// which we handle here.
if (!should_dump_as_text) {
// Plain text pages should be dumped as text
- std::wstring mime_type =
- webFrame->GetDataSource()->GetResponseMimeType();
- should_dump_as_text = (mime_type == L"text/plain");
+ std::string mime_type =
+ webFrame->GetDataSource()->GetResponse().GetMimeType();
+ should_dump_as_text = (mime_type == "text/plain");
}
if (should_dump_as_text) {
bool recursive = shell->layout_test_controller_->