#ifndef WebURLRequest_h
#define WebURLRequest_h
#include "WebCommon.h"
#include "WebHTTPBody.h"
#include "WebReferrerPolicy.h"
#if INSIDE_BLINK
namespace WebCore { class ResourceRequest; }
#endif
namespace blink {
class WebCString;
class WebHTTPBody;
class WebHTTPHeaderVisitor;
class WebString;
class WebURL;
class WebURLRequestPrivate;
class WebURLRequest {
public:
enum CachePolicy {
UseProtocolCachePolicy,
ReloadIgnoringCacheData,
ReturnCacheDataElseLoad,
ReturnCacheDataDontLoad,
};
enum Priority {
PriorityUnresolved = -1,
PriorityVeryLow,
PriorityLow,
PriorityMedium,
PriorityHigh,
PriorityVeryHigh,
};
enum TargetType {
TargetIsMainFrame = 0,
TargetIsSubframe = 1,
TargetIsSubresource = 2,
TargetIsStyleSheet = 3,
TargetIsScript = 4,
TargetIsFontResource = 5,
TargetIsImage = 6,
TargetIsObject = 7,
TargetIsMedia = 8,
TargetIsWorker = 9,
TargetIsSharedWorker = 10,
TargetIsPrefetch = 11,
TargetIsFavicon = 12,
TargetIsXHR = 13,
TargetIsTextTrack = 14,
TargetIsPing = 15,
TargetIsServiceWorker = 16,
TargetIsUnspecified = 17,
};
class ExtraData {
public:
virtual ~ExtraData() { }
};
~WebURLRequest() { reset(); }
WebURLRequest() : m_private(0) { }
WebURLRequest(const WebURLRequest& r) : m_private(0) { assign(r); }
WebURLRequest& operator=(const WebURLRequest& r)
{
assign(r);
return *this;
}
explicit WebURLRequest(const WebURL& url) : m_private(0)
{
initialize();
setURL(url);
}
BLINK_PLATFORM_EXPORT void initialize();
BLINK_PLATFORM_EXPORT void reset();
BLINK_PLATFORM_EXPORT void assign(const WebURLRequest&);
BLINK_PLATFORM_EXPORT bool isNull() const;
BLINK_PLATFORM_EXPORT WebURL url() const;
BLINK_PLATFORM_EXPORT void setURL(const WebURL&);
BLINK_PLATFORM_EXPORT WebURL firstPartyForCookies() const;
BLINK_PLATFORM_EXPORT void setFirstPartyForCookies(const WebURL&);
BLINK_PLATFORM_EXPORT bool allowCookies() const;
BLINK_PLATFORM_EXPORT void setAllowCookies(bool);
BLINK_PLATFORM_EXPORT bool allowStoredCredentials() const;
BLINK_PLATFORM_EXPORT void setAllowStoredCredentials(bool);
BLINK_PLATFORM_EXPORT CachePolicy cachePolicy() const;
BLINK_PLATFORM_EXPORT void setCachePolicy(CachePolicy);
BLINK_PLATFORM_EXPORT WebString httpMethod() const;
BLINK_PLATFORM_EXPORT void setHTTPMethod(const WebString&);
BLINK_PLATFORM_EXPORT WebString httpHeaderField(const WebString& name) const;
BLINK_PLATFORM_EXPORT void setHTTPHeaderField(const WebString& name, const WebString& value);
BLINK_PLATFORM_EXPORT void setHTTPReferrer(const WebString& referrer, WebReferrerPolicy);
BLINK_PLATFORM_EXPORT void addHTTPHeaderField(const WebString& name, const WebString& value);
BLINK_PLATFORM_EXPORT void clearHTTPHeaderField(const WebString& name);
BLINK_PLATFORM_EXPORT void visitHTTPHeaderFields(WebHTTPHeaderVisitor*) const;
BLINK_PLATFORM_EXPORT WebHTTPBody httpBody() const;
BLINK_PLATFORM_EXPORT void setHTTPBody(const WebHTTPBody&);
BLINK_PLATFORM_EXPORT bool reportUploadProgress() const;
BLINK_PLATFORM_EXPORT void setReportUploadProgress(bool);
BLINK_PLATFORM_EXPORT bool reportLoadTiming() const;
BLINK_PLATFORM_EXPORT void setReportLoadTiming(bool);
BLINK_PLATFORM_EXPORT bool reportRawHeaders() const;
BLINK_PLATFORM_EXPORT void setReportRawHeaders(bool);
BLINK_PLATFORM_EXPORT TargetType targetType() const;
BLINK_PLATFORM_EXPORT void setTargetType(TargetType);
BLINK_PLATFORM_EXPORT WebReferrerPolicy referrerPolicy() const;
BLINK_PLATFORM_EXPORT bool hasUserGesture() const;
BLINK_PLATFORM_EXPORT void setHasUserGesture(bool);
BLINK_PLATFORM_EXPORT int requestorID() const;
BLINK_PLATFORM_EXPORT void setRequestorID(int);
BLINK_PLATFORM_EXPORT int requestorProcessID() const;
BLINK_PLATFORM_EXPORT void setRequestorProcessID(int);
BLINK_PLATFORM_EXPORT int appCacheHostID() const;
BLINK_PLATFORM_EXPORT void setAppCacheHostID(int);
BLINK_PLATFORM_EXPORT bool downloadToFile() const;
BLINK_PLATFORM_EXPORT void setDownloadToFile(bool);
BLINK_PLATFORM_EXPORT ExtraData* extraData() const;
BLINK_PLATFORM_EXPORT void setExtraData(ExtraData*);
BLINK_PLATFORM_EXPORT Priority priority() const;
#if INSIDE_BLINK
BLINK_PLATFORM_EXPORT WebCore::ResourceRequest& toMutableResourceRequest();
BLINK_PLATFORM_EXPORT const WebCore::ResourceRequest& toResourceRequest() const;
#endif
protected:
BLINK_PLATFORM_EXPORT void assign(WebURLRequestPrivate*);
private:
WebURLRequestPrivate* m_private;
};
}
#endif