diff options
Diffstat (limited to 'webkit/glue/webdatasource.h')
-rw-r--r-- | webkit/glue/webdatasource.h | 219 |
1 files changed, 219 insertions, 0 deletions
diff --git a/webkit/glue/webdatasource.h b/webkit/glue/webdatasource.h new file mode 100644 index 0000000..232e21a --- /dev/null +++ b/webkit/glue/webdatasource.h @@ -0,0 +1,219 @@ +// Copyright 2008, 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 +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * 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 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#ifndef WEBKIT_GLUE_WEBDATASOURCE_H__ +#define WEBKIT_GLUE_WEBDATASOURCE_H__ + +#include <vector> + +#include "base/basictypes.h" +#include "googleurl/src/gurl.h" + +struct PasswordForm; +class SearchableFormData; +class WebFrame; +class WebRequest; +class WebResponse; + +class WebDataSource { + public: + // + // @method webFrame + // @result Return the frame that represents this data source. + // - (WebFrame *)webFrame; + virtual WebFrame* GetWebFrame() = 0; + + // 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. + // + // 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; + + 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; + 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 SearchableFormData, or NULL if the request wasn't a search + // request. The returned object is owned by the WebDataSource (actually + // the WebDocumentLoader) and shouldn't be freed. + virtual const SearchableFormData* GetSearchableFormData() const = 0; + + // Returns the PasswordFormData, or NULL if the request isn't a form submission + // or doesn't have any password fields. The returned object is owned by the + // WebDataSource (actually the WebDocumentLoader) and shouldn't be freed. + virtual const PasswordForm* GetPasswordFormData() const = 0; + + // Returns true if this request was the result of submitting a form. + // NOTE: this returns false if the user submitted a form, but the form used + // script to do the actuall submission. + virtual bool IsFormSubmit() 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; + + // + // @method isLoading + // @discussion Returns YES if there are any pending loads. + // - (BOOL)isLoading; + virtual bool IsLoading() = 0; + + // + // @method pageTitle + // @result Returns nil or the page title. + // - (NSString *)pageTitle; + virtual void GetPageTitle(std::wstring* title) = 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); +}; + + + +#endif // #ifndef WEBKIT_GLUE_WEBDATASOURCE_H__ |