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