OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2009 Google 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 are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #ifndef SKY_ENGINE_PUBLIC_PLATFORM_WEBURLREQUEST_H_ | |
32 #define SKY_ENGINE_PUBLIC_PLATFORM_WEBURLREQUEST_H_ | |
33 | |
34 #include "sky/engine/public/platform/WebCommon.h" | |
35 #include "sky/engine/public/platform/WebHTTPBody.h" | |
36 #include "sky/engine/public/platform/WebReferrerPolicy.h" | |
37 | |
38 namespace blink { | |
39 | |
40 class ResourceRequest; | |
41 class WebCString; | |
42 class WebHTTPBody; | |
43 class WebHTTPHeaderVisitor; | |
44 class WebString; | |
45 class WebURL; | |
46 class WebURLRequestPrivate; | |
47 | |
48 class WebURLRequest { | |
49 public: | |
50 enum CachePolicy { | |
51 UseProtocolCachePolicy, // normal load | |
52 ReloadIgnoringCacheData, // reload | |
53 ReturnCacheDataElseLoad, // back/forward or encoding change - allow stal
e data | |
54 ReturnCacheDataDontLoad, // results of a post - allow stale data and onl
y use cache | |
55 ReloadBypassingCache, // end-to-end reload | |
56 }; | |
57 | |
58 enum Priority { | |
59 PriorityUnresolved = -1, | |
60 PriorityVeryLow, | |
61 PriorityLow, | |
62 PriorityMedium, | |
63 PriorityHigh, | |
64 PriorityVeryHigh, | |
65 }; | |
66 | |
67 // Corresponds to Fetch's "context": http://fetch.spec.whatwg.org/#concept-r
equest-context | |
68 enum RequestContext { | |
69 RequestContextUnspecified = 0, | |
70 RequestContextAudio, | |
71 RequestContextBeacon, | |
72 RequestContextDownload, | |
73 RequestContextEmbed, | |
74 RequestContextFetch, | |
75 RequestContextFont, | |
76 RequestContextForm, | |
77 RequestContextFrame, | |
78 RequestContextHyperlink, | |
79 RequestContextImage, | |
80 RequestContextImageSet, | |
81 RequestContextImport, | |
82 RequestContextInternal, | |
83 RequestContextLocation, | |
84 RequestContextManifest, | |
85 RequestContextObject, | |
86 RequestContextPing, | |
87 RequestContextPrefetch, | |
88 RequestContextScript, | |
89 RequestContextServiceWorker, | |
90 RequestContextSharedWorker, | |
91 RequestContextSubresource, | |
92 RequestContextStyle, | |
93 RequestContextTrack, | |
94 RequestContextVideo, | |
95 RequestContextWorker, | |
96 }; | |
97 | |
98 // Corresponds to Fetch's "context frame type": http://fetch.spec.whatwg.org
/#concept-request-context-frame-type | |
99 enum FrameType { | |
100 FrameTypeAuxiliary, | |
101 FrameTypeNested, | |
102 FrameTypeNone, | |
103 FrameTypeTopLevel | |
104 }; | |
105 | |
106 class ExtraData { | |
107 public: | |
108 virtual ~ExtraData() { } | |
109 }; | |
110 | |
111 ~WebURLRequest() { reset(); } | |
112 | |
113 WebURLRequest() : m_private(0) { } | |
114 WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); } | |
115 WebURLRequest& operator=(const WebURLRequest& r) | |
116 { | |
117 assign(r); | |
118 return *this; | |
119 } | |
120 | |
121 explicit WebURLRequest(const WebURL& url) : m_private(0) | |
122 { | |
123 initialize(); | |
124 setURL(url); | |
125 } | |
126 | |
127 BLINK_PLATFORM_EXPORT void initialize(); | |
128 BLINK_PLATFORM_EXPORT void reset(); | |
129 BLINK_PLATFORM_EXPORT void assign(const WebURLRequest&); | |
130 | |
131 BLINK_PLATFORM_EXPORT bool isNull() const; | |
132 | |
133 BLINK_PLATFORM_EXPORT WebURL url() const; | |
134 BLINK_PLATFORM_EXPORT void setURL(const WebURL&); | |
135 | |
136 // Controls whether user name, password, and cookies may be sent with the | |
137 // request. (If false, this overrides allowCookies.) | |
138 BLINK_PLATFORM_EXPORT bool allowStoredCredentials() const; | |
139 BLINK_PLATFORM_EXPORT void setAllowStoredCredentials(bool); | |
140 | |
141 BLINK_PLATFORM_EXPORT CachePolicy cachePolicy() const; | |
142 BLINK_PLATFORM_EXPORT void setCachePolicy(CachePolicy); | |
143 | |
144 BLINK_PLATFORM_EXPORT WebString httpMethod() const; | |
145 BLINK_PLATFORM_EXPORT void setHTTPMethod(const WebString&); | |
146 | |
147 BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const
; | |
148 // It's not possible to set the referrer header using this method. Use setHT
TPReferrer instead. | |
149 BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const W
ebString& value); | |
150 BLINK_PLATFORM_EXPORT void setHTTPReferrer(const WebString& referrer, WebRef
errerPolicy); | |
151 BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const W
ebString& value); | |
152 BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name); | |
153 BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) cons
t; | |
154 | |
155 BLINK_PLATFORM_EXPORT WebHTTPBody httpBody() const; | |
156 BLINK_PLATFORM_EXPORT void setHTTPBody(const WebHTTPBody&); | |
157 | |
158 // Controls whether upload progress events are generated when a request | |
159 // has a body. | |
160 BLINK_PLATFORM_EXPORT bool reportUploadProgress() const; | |
161 BLINK_PLATFORM_EXPORT void setReportUploadProgress(bool); | |
162 | |
163 // Controls whether actual headers sent and received for request are | |
164 // collected and reported. | |
165 BLINK_PLATFORM_EXPORT bool reportRawHeaders() const; | |
166 BLINK_PLATFORM_EXPORT void setReportRawHeaders(bool); | |
167 | |
168 BLINK_PLATFORM_EXPORT RequestContext requestContext() const; | |
169 BLINK_PLATFORM_EXPORT void setRequestContext(RequestContext); | |
170 | |
171 BLINK_PLATFORM_EXPORT FrameType frameType() const; | |
172 BLINK_PLATFORM_EXPORT void setFrameType(FrameType); | |
173 | |
174 BLINK_PLATFORM_EXPORT WebReferrerPolicy referrerPolicy() const; | |
175 | |
176 // Adds an HTTP origin header if it is empty and the HTTP method of the | |
177 // request requires it. | |
178 BLINK_PLATFORM_EXPORT void addHTTPOriginIfNeeded(const WebString& origin); | |
179 | |
180 // A consumer controlled value intended to be used to identify the | |
181 // requestor. | |
182 BLINK_PLATFORM_EXPORT int requestorID() const; | |
183 BLINK_PLATFORM_EXPORT void setRequestorID(int); | |
184 | |
185 // A consumer controlled value intended to be used to identify the | |
186 // process of the requestor. | |
187 BLINK_PLATFORM_EXPORT int requestorProcessID() const; | |
188 BLINK_PLATFORM_EXPORT void setRequestorProcessID(int); | |
189 | |
190 // If true, the response body will be downloaded to a file managed by the | |
191 // WebURLLoader. See WebURLResponse::downloadedFilePath. | |
192 BLINK_PLATFORM_EXPORT bool downloadToFile() const; | |
193 BLINK_PLATFORM_EXPORT void setDownloadToFile(bool); | |
194 | |
195 // True if the request should not be handled by the ServiceWorker. | |
196 BLINK_PLATFORM_EXPORT bool skipServiceWorker() const; | |
197 BLINK_PLATFORM_EXPORT void setSkipServiceWorker(bool); | |
198 | |
199 // Extra data associated with the underlying resource request. Resource | |
200 // requests can be copied. If non-null, each copy of a resource requests | |
201 // holds a pointer to the extra data, and the extra data pointer will be | |
202 // deleted when the last resource request is destroyed. Setting the extra | |
203 // data pointer will cause the underlying resource request to be | |
204 // dissociated from any existing non-null extra data pointer. | |
205 BLINK_PLATFORM_EXPORT ExtraData* extraData() const; | |
206 BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*); | |
207 | |
208 BLINK_PLATFORM_EXPORT Priority priority() const; | |
209 BLINK_PLATFORM_EXPORT void setPriority(Priority); | |
210 | |
211 #if INSIDE_BLINK | |
212 BLINK_PLATFORM_EXPORT ResourceRequest& toMutableResourceRequest(); | |
213 BLINK_PLATFORM_EXPORT const ResourceRequest& toResourceRequest() const; | |
214 #endif | |
215 | |
216 protected: | |
217 BLINK_PLATFORM_EXPORT void assign(WebURLRequestPrivate*); | |
218 | |
219 private: | |
220 WebURLRequestPrivate* m_private; | |
221 }; | |
222 | |
223 } // namespace blink | |
224 | |
225 #endif // SKY_ENGINE_PUBLIC_PLATFORM_WEBURLREQUEST_H_ | |
OLD | NEW |