tizen beta release
[profile/ivi/webkit-efl.git] / Source / WebKit / chromium / public / platform / WebURLRequest.h
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 WebURLRequest_h
32 #define WebURLRequest_h
33
34 #include "WebCommon.h"
35 #include "WebHTTPBody.h"
36
37 #if defined(WEBKIT_IMPLEMENTATION)
38 namespace WebCore { class ResourceRequest; }
39 #endif
40
41 namespace WebKit {
42
43 class WebCString;
44 class WebHTTPBody;
45 class WebHTTPHeaderVisitor;
46 class WebString;
47 class WebURL;
48 class WebURLRequestPrivate;
49
50 class WebURLRequest {
51 public:
52     enum CachePolicy {
53         UseProtocolCachePolicy, // normal load
54         ReloadIgnoringCacheData, // reload
55         ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
56         ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache
57     };
58
59     enum TargetType {
60         TargetIsMainFrame = 0,
61         TargetIsSubframe = 1,
62         TargetIsSubresource = 2,
63         TargetIsStyleSheet = 3,
64         TargetIsScript = 4,
65         TargetIsFontResource = 5,
66         TargetIsImage = 6,
67         TargetIsObject = 7,
68         TargetIsMedia = 8,
69         TargetIsWorker = 9,
70         TargetIsSharedWorker = 10,
71         TargetIsPrefetch = 11,
72         TargetIsPrerender = 12,
73         TargetIsFavicon = 13,
74         TargetIsXHR = 14,
75         TargetIsTextTrack = 15,
76         TargetIsUnspecified = 16,
77     };
78
79     class ExtraData {
80     public:
81         virtual ~ExtraData() { }
82     };
83
84     ~WebURLRequest() { reset(); }
85
86     WebURLRequest() : m_private(0) { }
87     WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
88     WebURLRequest& operator=(const WebURLRequest& r)
89     {
90         assign(r);
91         return *this;
92     }
93
94     explicit WebURLRequest(const WebURL& url) : m_private(0)
95     {
96         initialize();
97         setURL(url);
98     }
99
100     WEBKIT_EXPORT void initialize();
101     WEBKIT_EXPORT void reset();
102     WEBKIT_EXPORT void assign(const WebURLRequest&);
103
104     WEBKIT_EXPORT bool isNull() const;
105
106     WEBKIT_EXPORT WebURL url() const;
107     WEBKIT_EXPORT void setURL(const WebURL&);
108
109     // Used to implement third-party cookie blocking.
110     WEBKIT_EXPORT WebURL firstPartyForCookies() const;
111     WEBKIT_EXPORT void setFirstPartyForCookies(const WebURL&);
112
113     WEBKIT_EXPORT bool allowCookies() const;
114     WEBKIT_EXPORT void setAllowCookies(bool);
115
116     // Controls whether user name, password, and cookies may be sent with the
117     // request. (If false, this overrides allowCookies.)
118     WEBKIT_EXPORT bool allowStoredCredentials() const;
119     WEBKIT_EXPORT void setAllowStoredCredentials(bool);
120
121     WEBKIT_EXPORT CachePolicy cachePolicy() const;
122     WEBKIT_EXPORT void setCachePolicy(CachePolicy);
123
124     WEBKIT_EXPORT WebString httpMethod() const;
125     WEBKIT_EXPORT void setHTTPMethod(const WebString&);
126
127     WEBKIT_EXPORT WebString httpHeaderField(const WebString& name) const;
128     WEBKIT_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
129     WEBKIT_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
130     WEBKIT_EXPORT void clearHTTPHeaderField(const WebString& name);
131     WEBKIT_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
132
133     WEBKIT_EXPORT WebHTTPBody httpBody() const;
134     WEBKIT_EXPORT void setHTTPBody(const WebHTTPBody&);
135
136     // Controls whether upload progress events are generated when a request
137     // has a body.
138     WEBKIT_EXPORT bool reportUploadProgress() const;
139     WEBKIT_EXPORT void setReportUploadProgress(bool);
140
141     // Controls whether load timing info is collected for the request.
142     WEBKIT_EXPORT bool reportLoadTiming() const;
143     WEBKIT_EXPORT void setReportLoadTiming(bool);
144
145     // Controls whether actual headers sent and received for request are
146     // collected and reported.
147     WEBKIT_EXPORT bool reportRawHeaders() const;
148     WEBKIT_EXPORT void setReportRawHeaders(bool);
149
150     WEBKIT_EXPORT TargetType targetType() const;
151     WEBKIT_EXPORT void setTargetType(TargetType);
152
153     // True if the request was user initiated.
154     WEBKIT_EXPORT bool hasUserGesture() const;
155     WEBKIT_EXPORT void setHasUserGesture(bool);
156
157     // A consumer controlled value intended to be used to identify the
158     // requestor.
159     WEBKIT_EXPORT int requestorID() const;
160     WEBKIT_EXPORT void setRequestorID(int);
161
162     // A consumer controlled value intended to be used to identify the
163     // process of the requestor.
164     WEBKIT_EXPORT int requestorProcessID() const;
165     WEBKIT_EXPORT void setRequestorProcessID(int);
166
167     // Allows the request to be matched up with its app cache host.
168     WEBKIT_EXPORT int appCacheHostID() const;
169     WEBKIT_EXPORT void setAppCacheHostID(int);
170
171     // If true, the response body will be downloaded to a file managed by the
172     // WebURLLoader. See WebURLResponse::downloadedFilePath.
173     WEBKIT_EXPORT bool downloadToFile() const;
174     WEBKIT_EXPORT void setDownloadToFile(bool);
175
176     // Extra data associated with the underlying resource request. Resource
177     // requests can be copied. If non-null, each copy of a resource requests
178     // holds a pointer to the extra data, and the extra data pointer will be
179     // deleted when the last resource request is destroyed. Setting the extra
180     // data pointer will cause the underlying resource request to be
181     // dissociated from any existing non-null extra data pointer.
182     WEBKIT_EXPORT ExtraData* extraData() const;
183     WEBKIT_EXPORT void setExtraData(ExtraData*);
184
185 #if defined(WEBKIT_IMPLEMENTATION)
186     WebCore::ResourceRequest& toMutableResourceRequest();
187     const WebCore::ResourceRequest& toResourceRequest() const;
188 #endif
189
190 protected:
191     void assign(WebURLRequestPrivate*);
192
193 private:
194     WebURLRequestPrivate* m_private;
195 };
196
197 } // namespace WebKit
198
199 #endif