OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef FetchRequestData_h |
| 6 #define FetchRequestData_h |
| 7 |
| 8 #include "platform/weborigin/KURL.h" |
| 9 #include "platform/weborigin/Referrer.h" |
| 10 #include "wtf/PassOwnPtr.h" |
| 11 #include "wtf/PassRefPtr.h" |
| 12 #include "wtf/RefCounted.h" |
| 13 #include "wtf/text/AtomicString.h" |
| 14 #include "wtf/text/WTFString.h" |
| 15 |
| 16 namespace blink { |
| 17 class WebServiceWorkerRequest; |
| 18 } |
| 19 |
| 20 namespace WebCore { |
| 21 |
| 22 class ExecutionContext; |
| 23 class FetchHeaderList; |
| 24 struct ResourceLoaderOptions; |
| 25 class ResourceRequest; |
| 26 class SecurityOrigin; |
| 27 struct ThreadableLoaderOptions; |
| 28 |
| 29 class FetchRequestData : public RefCounted<FetchRequestData> { |
| 30 WTF_MAKE_NONCOPYABLE(FetchRequestData); |
| 31 public: |
| 32 enum Mode { SameOriginMode, NoCORSMode, CORSMode, CORSWithForcedPreflight }; |
| 33 enum Credentials { OmitCredentials, SameOriginCredentials, IncludeCredential
s }; |
| 34 enum Context { ChildContext, ConnectContext, DownloadContext, FontContext, F
ormContext, ImageContext, ManifestContext, MediaContext, NavigateContext, Object
Context, PingContext, PopupContext, PrefetchContext, ScriptContext, ServiceWorke
rContext, SharedWorkerContext, StyleContext, WorkerContext, NullContext }; |
| 35 enum Tainting { BasicTainting, CORSTainting, OpaqueTainting }; |
| 36 |
| 37 class Referrer { |
| 38 WTF_MAKE_NONCOPYABLE(Referrer); |
| 39 public: |
| 40 Referrer() : m_type(ClientReferrer) { } |
| 41 ~Referrer() { } |
| 42 bool isNone() const { return m_type == NoneReferrer; } |
| 43 bool isClient() const { return m_type == ClientReferrer; } |
| 44 bool isURL() const { return m_type == URLReferrer; } |
| 45 void setNone() |
| 46 { |
| 47 m_referrer = WebCore::Referrer(); |
| 48 m_type = NoneReferrer; |
| 49 } |
| 50 void setClient(const WebCore::Referrer& referrer) |
| 51 { |
| 52 m_referrer = referrer; |
| 53 m_type = ClientReferrer; |
| 54 } |
| 55 void setURL(const WebCore::Referrer& referrer) |
| 56 { |
| 57 m_referrer = referrer; |
| 58 m_type = URLReferrer; |
| 59 } |
| 60 WebCore::Referrer referrer() const { return m_referrer; } |
| 61 private: |
| 62 enum Type { NoneReferrer, ClientReferrer, URLReferrer }; |
| 63 Type m_type; |
| 64 WebCore::Referrer m_referrer; |
| 65 }; |
| 66 |
| 67 static PassRefPtr<FetchRequestData> create(ExecutionContext*); |
| 68 static PassRefPtr<FetchRequestData> create(const blink::WebServiceWorkerRequ
est&); |
| 69 PassRefPtr<FetchRequestData> createRestrictedCopy(ExecutionContext*, PassRef
Ptr<SecurityOrigin>) const; |
| 70 ~FetchRequestData(); |
| 71 |
| 72 void setMethod(AtomicString method) { m_method = method; } |
| 73 const AtomicString method() const { return m_method; } |
| 74 void setURL(const KURL& url) { m_url = url; } |
| 75 const KURL& url() const { return m_url; } |
| 76 bool unsafeRequestFlag() const { return m_unsafeRequestFlag; } |
| 77 PassRefPtr<SecurityOrigin> origin() { return m_origin; } |
| 78 bool sameOriginDataURLFlag() { return m_sameOriginDataURLFlag; } |
| 79 const Referrer& referrer() const { return m_referrer; } |
| 80 void setMode(Mode mode) { m_mode = mode; } |
| 81 Mode mode() const { return m_mode; } |
| 82 void setCredentials(Credentials credentials) { m_credentials = credentials;
} |
| 83 Credentials credentials() const { return m_credentials; } |
| 84 void setResponseTainting(Tainting tainting) { m_responseTainting = tainting;
} |
| 85 Tainting tainting() const { return m_responseTainting; } |
| 86 FetchHeaderList* headerList() { return m_headerList.get(); } |
| 87 |
| 88 private: |
| 89 FetchRequestData(); |
| 90 |
| 91 AtomicString m_method; |
| 92 KURL m_url; |
| 93 RefPtr<FetchHeaderList> m_headerList; |
| 94 bool m_unsafeRequestFlag; |
| 95 // FIXME: Support body. |
| 96 // FIXME: Support m_skipServiceWorkerFlag; |
| 97 Context m_context; |
| 98 RefPtr<SecurityOrigin> m_origin; |
| 99 // FIXME: Support m_forceOriginHeaderFlag; |
| 100 bool m_sameOriginDataURLFlag; |
| 101 Referrer m_referrer; |
| 102 // FIXME: Support m_authenticationFlag; |
| 103 // FIXME: Support m_synchronousFlag; |
| 104 Mode m_mode; |
| 105 Credentials m_credentials; |
| 106 // FIXME: Support m_useURLCredentialsFlag; |
| 107 // FIXME: Support m_manualRedirectFlag; |
| 108 // FIXME: Support m_redirectCount; |
| 109 Tainting m_responseTainting; |
| 110 }; |
| 111 |
| 112 } // namespace WebCore |
| 113 |
| 114 #endif // FetchRequestData_h |
OLD | NEW |