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