1643ca7872b450ea4efacab6188849e5aac2ba161Steve Block/*
2643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * Copyright (C) 2009 Google Inc. All rights reserved.
3643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *
4643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * Redistribution and use in source and binary forms, with or without
5643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * modification, are permitted provided that the following conditions are
6643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * met:
7643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *
8643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *     * Redistributions of source code must retain the above copyright
9643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * notice, this list of conditions and the following disclaimer.
10643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *     * Redistributions in binary form must reproduce the above
11643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * copyright notice, this list of conditions and the following disclaimer
12643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * in the documentation and/or other materials provided with the
13643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * distribution.
14643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *     * Neither the name of Google Inc. nor the names of its
15643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * contributors may be used to endorse or promote products derived from
16643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * this software without specific prior written permission.
17643ca7872b450ea4efacab6188849e5aac2ba161Steve Block *
18643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28643ca7872b450ea4efacab6188849e5aac2ba161Steve Block * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29643ca7872b450ea4efacab6188849e5aac2ba161Steve Block */
30643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
31643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#ifndef WebURLRequest_h
32643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#define WebURLRequest_h
33643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
34643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "WebCommon.h"
35643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#include "WebHTTPBody.h"
36643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
37643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#if defined(WEBKIT_IMPLEMENTATION)
38643ca7872b450ea4efacab6188849e5aac2ba161Steve Blocknamespace WebCore { class ResourceRequest; }
39643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#endif
40643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
41643ca7872b450ea4efacab6188849e5aac2ba161Steve Blocknamespace WebKit {
42643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
43643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebCString;
44643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebHTTPBody;
45643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebHTTPHeaderVisitor;
46643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebString;
47643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebURL;
48643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebURLRequestPrivate;
49643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
50643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockclass WebURLRequest {
51643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockpublic:
52643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    enum CachePolicy {
53643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        UseProtocolCachePolicy,  // normal load
54643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        ReloadIgnoringCacheData, // reload
55643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        ReturnCacheDataElseLoad, // back/forward or encoding change - allow stale data
56643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        ReturnCacheDataDontLoad, // results of a post - allow stale data and only use cache
57643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    };
58643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
59643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    enum TargetType {
60643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsMainFrame = 0,
61643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsSubFrame = 1,   // Temporary for backward compatibility.
62643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsSubframe = 1,
63643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsSubResource = 2,  // Temporary for backward comptibility.
64643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsSubresource = 2,
65643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsStyleSheet = 3,
66643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsScript = 4,
67643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsFontResource = 5,
68643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsImage = 6,
69643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsObject = 7,
70643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        TargetIsMedia = 8
71643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    };
72643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
73643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    ~WebURLRequest() { reset(); }
74643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
75643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WebURLRequest() : m_private(0) { }
76643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
77643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WebURLRequest& operator=(const WebURLRequest& r)
78643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    {
79643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        assign(r);
80643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        return *this;
81643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    }
82643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
83643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    explicit WebURLRequest(const WebURL& url) : m_private(0)
84643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    {
85643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        initialize();
86643ca7872b450ea4efacab6188849e5aac2ba161Steve Block        setURL(url);
87643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    }
88643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
89643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void initialize();
90643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void reset();
91643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void assign(const WebURLRequest&);
92643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
93643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API bool isNull() const;
94643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
95643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API WebURL url() const;
96643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setURL(const WebURL&);
97643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
98643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // Used to implement third-party cookie blocking.
99643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API WebURL firstPartyForCookies() const;
100643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setFirstPartyForCookies(const WebURL&);
101643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
102643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API bool allowCookies() const;
103643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setAllowCookies(bool allowCookies);
104643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
105643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // Controls whether user name, password, and cookies may be sent with the
106643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // request. (If false, this overrides allowCookies.)
107643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API bool allowStoredCredentials() const;
108643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setAllowStoredCredentials(bool allowStoredCredentials);
109643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
110643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API CachePolicy cachePolicy() const;
111643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setCachePolicy(CachePolicy);
112643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
113643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API WebString httpMethod() const;
114643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setHTTPMethod(const WebString&);
115643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
116643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API WebString httpHeaderField(const WebString& name) const;
117643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setHTTPHeaderField(const WebString& name, const WebString& value);
118643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void addHTTPHeaderField(const WebString& name, const WebString& value);
119643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void clearHTTPHeaderField(const WebString& name);
120643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
121643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
122643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API WebHTTPBody httpBody() const;
123643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setHTTPBody(const WebHTTPBody&);
124643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
125643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // Controls whether upload progress events are generated when a request
126643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // has a body.
127643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API bool reportUploadProgress() const;
128643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setReportUploadProgress(bool);
129643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
130643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API TargetType targetType() const;
131643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setTargetType(TargetType);
132643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
133643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // A consumer controlled value intended to be used to identify the
134643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // requestor.
135643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API int requestorID() const;
136643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setRequestorID(int);
137643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
138643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // A consumer controlled value intended to be used to identify the
139643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // process of the requestor.
140643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API int requestorProcessID() const;
141643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setRequestorProcessID(int);
142643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
143643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    // Allows the request to be matched up with its app cache host.
144643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API int appCacheHostID() const;
145643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WEBKIT_API void setAppCacheHostID(int id);
146643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
147643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#if defined(WEBKIT_IMPLEMENTATION)
148643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WebCore::ResourceRequest& toMutableResourceRequest();
149643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    const WebCore::ResourceRequest& toResourceRequest() const;
150643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#endif
151643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
152643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockprotected:
153643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    void assign(WebURLRequestPrivate*);
154643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
155643ca7872b450ea4efacab6188849e5aac2ba161Steve Blockprivate:
156643ca7872b450ea4efacab6188849e5aac2ba161Steve Block    WebURLRequestPrivate* m_private;
157643ca7872b450ea4efacab6188849e5aac2ba161Steve Block};
158643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
159643ca7872b450ea4efacab6188849e5aac2ba161Steve Block} // namespace WebKit
160643ca7872b450ea4efacab6188849e5aac2ba161Steve Block
161643ca7872b450ea4efacab6188849e5aac2ba161Steve Block#endif
162