1 /* 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26 #ifndef WebDataSource_H 27 #define WebDataSource_H 28 29 #include "WebKit.h" 30 #include "COMPtr.h" 31 #include <WTF/RefPtr.h> 32 33 class WebDocumentLoader; 34 class WebMutableURLRequest; 35 36 extern const GUID IID_WebDataSource; 37 38 class WebDataSource : public IWebDataSource, public IWebDataSourcePrivate 39 { 40 public: 41 static WebDataSource* createInstance(WebDocumentLoader*); 42 protected: 43 WebDataSource(WebDocumentLoader*); 44 ~WebDataSource(); 45 46 public: 47 // IUnknown 48 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject); 49 virtual ULONG STDMETHODCALLTYPE AddRef(void); 50 virtual ULONG STDMETHODCALLTYPE Release(void); 51 52 // IWebDataSource 53 virtual HRESULT STDMETHODCALLTYPE initWithRequest( 54 /* [in] */ IWebURLRequest *request); 55 56 virtual HRESULT STDMETHODCALLTYPE data( 57 /* [retval][out] */ IStream **stream); 58 59 virtual HRESULT STDMETHODCALLTYPE representation( 60 /* [retval][out] */ IWebDocumentRepresentation **rep); 61 62 virtual HRESULT STDMETHODCALLTYPE webFrame( 63 /* [retval][out] */ IWebFrame **frame); 64 65 virtual HRESULT STDMETHODCALLTYPE initialRequest( 66 /* [retval][out] */ IWebURLRequest **request); 67 68 virtual HRESULT STDMETHODCALLTYPE request( 69 /* [retval][out] */ IWebMutableURLRequest **request); 70 71 virtual HRESULT STDMETHODCALLTYPE response( 72 /* [retval][out] */ IWebURLResponse **response); 73 74 virtual HRESULT STDMETHODCALLTYPE textEncodingName( 75 /* [retval][out] */ BSTR *name); 76 77 virtual HRESULT STDMETHODCALLTYPE isLoading( 78 /* [retval][out] */ BOOL *loading); 79 80 virtual HRESULT STDMETHODCALLTYPE pageTitle( 81 /* [retval][out] */ BSTR *title); 82 83 virtual HRESULT STDMETHODCALLTYPE unreachableURL( 84 /* [retval][out] */ BSTR *url); 85 86 virtual HRESULT STDMETHODCALLTYPE webArchive( 87 /* [retval][out] */ IWebArchive **archive); 88 89 virtual HRESULT STDMETHODCALLTYPE mainResource( 90 /* [retval][out] */ IWebResource **resource); 91 92 virtual HRESULT STDMETHODCALLTYPE subresources( 93 /* [retval][out] */ IEnumVARIANT **enumResources); 94 95 virtual HRESULT STDMETHODCALLTYPE subresourceForURL( 96 /* [in] */ BSTR url, 97 /* [retval][out] */ IWebResource **resource); 98 99 virtual HRESULT STDMETHODCALLTYPE addSubresource( 100 /* [in] */ IWebResource *subresource); 101 102 // IWebDataSourcePrivate 103 104 virtual HRESULT STDMETHODCALLTYPE overrideEncoding( 105 /* [retval][out] */ BSTR *encoding); 106 107 virtual HRESULT STDMETHODCALLTYPE setOverrideEncoding( 108 /* [in] */ BSTR encoding); 109 110 virtual HRESULT STDMETHODCALLTYPE mainDocumentError( 111 /* [retval][out] */ IWebError** error); 112 113 // WebDataSource 114 WebDocumentLoader* documentLoader() const; 115 protected: 116 ULONG m_refCount; 117 RefPtr<WebDocumentLoader> m_loader; 118 COMPtr<IWebDocumentRepresentation> m_representation; 119 }; 120 121 #endif 122