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 WebMutableURLRequest_H
27 #define WebMutableURLRequest_H
28
29 #include "WebKit.h"
30 #pragma warning(push, 0)
31 #include <WebCore/ResourceRequest.h>
32 #pragma warning(pop)
33
34 namespace WebCore
35 {
36 class FormData;
37 }
38
core(WebURLRequestCachePolicy policy)39 inline WebCore::ResourceRequestCachePolicy core(WebURLRequestCachePolicy policy)
40 {
41 return static_cast<WebCore::ResourceRequestCachePolicy>(policy);
42 }
43
kit(WebCore::ResourceRequestCachePolicy policy)44 inline WebURLRequestCachePolicy kit(WebCore::ResourceRequestCachePolicy policy)
45 {
46 return static_cast<WebURLRequestCachePolicy>(policy);
47 }
48
49 class WebMutableURLRequest : public IWebMutableURLRequest, IWebMutableURLRequestPrivate
50 {
51 public:
52 static WebMutableURLRequest* createInstance();
53 static WebMutableURLRequest* createInstance(IWebMutableURLRequest* req);
54 static WebMutableURLRequest* createInstance(const WebCore::ResourceRequest&);
55
56 static WebMutableURLRequest* createImmutableInstance();
57 static WebMutableURLRequest* createImmutableInstance(const WebCore::ResourceRequest&);
58 protected:
59 WebMutableURLRequest(bool isMutable);
60 ~WebMutableURLRequest();
61
62 public:
63 // IUnknown
64 virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject);
65 virtual ULONG STDMETHODCALLTYPE AddRef(void);
66 virtual ULONG STDMETHODCALLTYPE Release(void);
67
68 // IWebURLRequest
69 virtual HRESULT STDMETHODCALLTYPE requestWithURL(
70 /* [in] */ BSTR theURL,
71 /* [optional][in] */ WebURLRequestCachePolicy cachePolicy,
72 /* [optional][in] */ double timeoutInterval);
73
74 virtual HRESULT STDMETHODCALLTYPE allHTTPHeaderFields(
75 /* [retval][out] */ IPropertyBag **result);
76
77 virtual HRESULT STDMETHODCALLTYPE cachePolicy(
78 /* [retval][out] */ WebURLRequestCachePolicy *result);
79
80 virtual HRESULT STDMETHODCALLTYPE HTTPBody(
81 /* [retval][out] */ IStream **result);
82
83 virtual HRESULT STDMETHODCALLTYPE HTTPBodyStream(
84 /* [retval][out] */ IStream **result);
85
86 virtual HRESULT STDMETHODCALLTYPE HTTPMethod(
87 /* [retval][out] */ BSTR *result);
88
89 virtual HRESULT STDMETHODCALLTYPE HTTPShouldHandleCookies(
90 /* [retval][out] */ BOOL *result);
91
92 virtual HRESULT STDMETHODCALLTYPE initWithURL(
93 /* [in] */ BSTR url,
94 /* [optional][in] */ WebURLRequestCachePolicy cachePolicy,
95 /* [optional][in] */ double timeoutInterval);
96
97 virtual HRESULT STDMETHODCALLTYPE mainDocumentURL(
98 /* [retval][out] */ BSTR *result);
99
100 virtual HRESULT STDMETHODCALLTYPE timeoutInterval(
101 /* [retval][out] */ double *result);
102
103 virtual HRESULT STDMETHODCALLTYPE URL(
104 /* [retval][out] */ BSTR *result);
105
106 virtual HRESULT STDMETHODCALLTYPE valueForHTTPHeaderField(
107 /* [in] */ BSTR field,
108 /* [retval][out] */ BSTR *result);
109
110 virtual HRESULT STDMETHODCALLTYPE isEmpty(
111 /* [retval][out] */ BOOL* result);
112
113 virtual HRESULT STDMETHODCALLTYPE mutableCopy(
114 /* [out, retval] */ IWebMutableURLRequest** result);
115
116 // IWebMutableURLRequest
117 virtual HRESULT STDMETHODCALLTYPE addValue(
118 /* [in] */ BSTR value,
119 /* [in] */ BSTR field);
120
121 virtual HRESULT STDMETHODCALLTYPE setAllHTTPHeaderFields(
122 /* [in] */ IPropertyBag *headerFields);
123
124 virtual HRESULT STDMETHODCALLTYPE setCachePolicy(
125 /* [in] */ WebURLRequestCachePolicy policy);
126
127 virtual HRESULT STDMETHODCALLTYPE setHTTPBody(
128 /* [in] */ IStream *data);
129
130 virtual HRESULT STDMETHODCALLTYPE setHTTPBodyStream(
131 /* [in] */ IStream *data);
132
133 virtual HRESULT STDMETHODCALLTYPE setHTTPMethod(
134 /* [in] */ BSTR method);
135
136 virtual HRESULT STDMETHODCALLTYPE setHTTPShouldHandleCookies(
137 /* [in] */ BOOL handleCookies);
138
139 virtual HRESULT STDMETHODCALLTYPE setMainDocumentURL(
140 /* [in] */ BSTR theURL);
141
142 virtual HRESULT STDMETHODCALLTYPE setTimeoutInterval(
143 /* [in] */ double timeoutInterval);
144
145 virtual HRESULT STDMETHODCALLTYPE setURL(
146 /* [in] */ BSTR theURL);
147
148 virtual HRESULT STDMETHODCALLTYPE setValue(
149 /* [in] */ BSTR value,
150 /* [in] */ BSTR field);
151
152 virtual HRESULT STDMETHODCALLTYPE setAllowsAnyHTTPSCertificate(void);
153
154 // IWebMutableURLRequestPrivate
155
156 virtual HRESULT STDMETHODCALLTYPE setClientCertificate(
157 /* [in] */ OLE_HANDLE cert);
158
159 virtual /* [local] */ CFURLRequestRef STDMETHODCALLTYPE cfRequest();
160
161 // WebMutableURLRequest
162 void setFormData(const PassRefPtr<WebCore::FormData> data);
163 const PassRefPtr<WebCore::FormData> formData() const;
164
165 void addHTTPHeaderFields(const WebCore::HTTPHeaderMap& headerFields);
166 const WebCore::HTTPHeaderMap& httpHeaderFields() const;
167
168 const WebCore::ResourceRequest& resourceRequest() const;
169 protected:
170 ULONG m_refCount;
171 bool m_isMutable;
172 WebCore::ResourceRequest m_request;
173 };
174
175 #endif
176