• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     virtual HRESULT STDMETHODCALLTYPE isEqual(
117         /* [in] */ IWebURLRequest* other,
118         /* [out, retval] */ BOOL* result);
119 
120     // IWebMutableURLRequest
121     virtual HRESULT STDMETHODCALLTYPE addValue(
122         /* [in] */ BSTR value,
123         /* [in] */ BSTR field);
124 
125     virtual HRESULT STDMETHODCALLTYPE setAllHTTPHeaderFields(
126         /* [in] */ IPropertyBag *headerFields);
127 
128     virtual HRESULT STDMETHODCALLTYPE setCachePolicy(
129         /* [in] */ WebURLRequestCachePolicy policy);
130 
131     virtual HRESULT STDMETHODCALLTYPE setHTTPBody(
132         /* [in] */ IStream *data);
133 
134     virtual HRESULT STDMETHODCALLTYPE setHTTPBodyStream(
135         /* [in] */ IStream *data);
136 
137     virtual HRESULT STDMETHODCALLTYPE setHTTPMethod(
138         /* [in] */ BSTR method);
139 
140     virtual HRESULT STDMETHODCALLTYPE setHTTPShouldHandleCookies(
141         /* [in] */ BOOL handleCookies);
142 
143     virtual HRESULT STDMETHODCALLTYPE setMainDocumentURL(
144         /* [in] */ BSTR theURL);
145 
146     virtual HRESULT STDMETHODCALLTYPE setTimeoutInterval(
147         /* [in] */ double timeoutInterval);
148 
149     virtual HRESULT STDMETHODCALLTYPE setURL(
150         /* [in] */ BSTR theURL);
151 
152     virtual HRESULT STDMETHODCALLTYPE setValue(
153         /* [in] */ BSTR value,
154         /* [in] */ BSTR field);
155 
156     virtual HRESULT STDMETHODCALLTYPE setAllowsAnyHTTPSCertificate(void);
157 
158     // IWebMutableURLRequestPrivate
159 
160     virtual HRESULT STDMETHODCALLTYPE setClientCertificate(
161         /* [in] */ OLE_HANDLE cert);
162 
163     virtual /* [local] */ CFURLRequestRef STDMETHODCALLTYPE cfRequest();
164 
165     // WebMutableURLRequest
166     void setFormData(const PassRefPtr<WebCore::FormData> data);
167     const PassRefPtr<WebCore::FormData> formData() const;
168 
169     void addHTTPHeaderFields(const WebCore::HTTPHeaderMap& headerFields);
170     const WebCore::HTTPHeaderMap& httpHeaderFields() const;
171 
172     const WebCore::ResourceRequest& resourceRequest() const;
173 protected:
174     ULONG m_refCount;
175     bool m_isMutable;
176     WebCore::ResourceRequest m_request;
177 };
178 
179 #endif
180