1 // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the name Chromium Embedded
14 // Framework nor the names of its contributors may be used to endorse
15 // or promote products derived from this software without specific prior
16 // written permission.
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.
30 // ---------------------------------------------------------------------------
32 // The contents of this file must follow a specific format in order to
33 // support the CEF translator tool. See the translator.README.txt file in the
34 // tools directory for more information.
37 #ifndef CEF_INCLUDE_CEF_REQUEST_H_
38 #define CEF_INCLUDE_CEF_REQUEST_H_
41 #include "include/cef_base.h"
46 class CefPostDataElement;
49 // Class used to represent a web request. The methods of this class may be
50 // called on any thread.
52 /*--cef(source=library,no_debugct_check)--*/
53 class CefRequest : public virtual CefBase {
55 typedef std::multimap<CefString, CefString> HeaderMap;
56 typedef cef_resource_type_t ResourceType;
57 typedef cef_transition_type_t TransitionType;
60 // Create a new CefRequest object.
63 static CefRefPtr<CefRequest> Create();
66 // Returns true if this object is read-only.
69 virtual bool IsReadOnly() =0;
72 // Get the fully qualified URL.
75 virtual CefString GetURL() =0;
78 // Set the fully qualified URL.
81 virtual void SetURL(const CefString& url) =0;
84 // Get the request method type. The value will default to POST if post data
85 // is provided and GET otherwise.
88 virtual CefString GetMethod() =0;
91 // Set the request method type.
94 virtual void SetMethod(const CefString& method) =0;
100 virtual CefRefPtr<CefPostData> GetPostData() =0;
103 // Set the post data.
106 virtual void SetPostData(CefRefPtr<CefPostData> postData) =0;
109 // Get the header values.
112 virtual void GetHeaderMap(HeaderMap& headerMap) =0;
115 // Set the header values.
118 virtual void SetHeaderMap(const HeaderMap& headerMap) =0;
121 // Set all values at one time.
123 /*--cef(optional_param=postData)--*/
124 virtual void Set(const CefString& url,
125 const CefString& method,
126 CefRefPtr<CefPostData> postData,
127 const HeaderMap& headerMap) =0;
130 // Get the flags used in combination with CefURLRequest. See
131 // cef_urlrequest_flags_t for supported values.
133 /*--cef(default_retval=UR_FLAG_NONE)--*/
134 virtual int GetFlags() =0;
137 // Set the flags used in combination with CefURLRequest. See
138 // cef_urlrequest_flags_t for supported values.
141 virtual void SetFlags(int flags) =0;
144 // Set the URL to the first party for cookies used in combination with
148 virtual CefString GetFirstPartyForCookies() =0;
151 // Get the URL to the first party for cookies used in combination with
155 virtual void SetFirstPartyForCookies(const CefString& url) =0;
158 // Get the resource type for this request. Only available in the browser
161 /*--cef(default_retval=RT_SUB_RESOURCE)--*/
162 virtual ResourceType GetResourceType() =0;
165 // Get the transition type for this request. Only available in the browser
166 // process and only applies to requests that represent a main frame or
167 // sub-frame navigation.
169 /*--cef(default_retval=TT_EXPLICIT)--*/
170 virtual TransitionType GetTransitionType() =0;
173 // Returns the globally unique identifier for this request or 0 if not
174 // specified. Can be used by CefRequestHandler implementations in the browser
175 // process to track a single request across multiple callbacks.
178 virtual uint64 GetIdentifier() =0;
183 // Class used to represent post data for a web request. The methods of this
184 // class may be called on any thread.
186 /*--cef(source=library,no_debugct_check)--*/
187 class CefPostData : public virtual CefBase {
189 typedef std::vector<CefRefPtr<CefPostDataElement> > ElementVector;
192 // Create a new CefPostData object.
195 static CefRefPtr<CefPostData> Create();
198 // Returns true if this object is read-only.
201 virtual bool IsReadOnly() =0;
204 // Returns the number of existing post data elements.
207 virtual size_t GetElementCount() =0;
210 // Retrieve the post data elements.
212 /*--cef(count_func=elements:GetElementCount)--*/
213 virtual void GetElements(ElementVector& elements) =0;
216 // Remove the specified post data element. Returns true if the removal
220 virtual bool RemoveElement(CefRefPtr<CefPostDataElement> element) =0;
223 // Add the specified post data element. Returns true if the add succeeds.
226 virtual bool AddElement(CefRefPtr<CefPostDataElement> element) =0;
229 // Remove all existing post data elements.
232 virtual void RemoveElements() =0;
237 // Class used to represent a single element in the request post data. The
238 // methods of this class may be called on any thread.
240 /*--cef(source=library,no_debugct_check)--*/
241 class CefPostDataElement : public virtual CefBase {
244 // Post data elements may represent either bytes or files.
246 typedef cef_postdataelement_type_t Type;
249 // Create a new CefPostDataElement object.
252 static CefRefPtr<CefPostDataElement> Create();
255 // Returns true if this object is read-only.
258 virtual bool IsReadOnly() =0;
261 // Remove all contents from the post data element.
264 virtual void SetToEmpty() =0;
267 // The post data element will represent a file.
270 virtual void SetToFile(const CefString& fileName) =0;
273 // The post data element will represent bytes. The bytes passed
274 // in will be copied.
277 virtual void SetToBytes(size_t size, const void* bytes) =0;
280 // Return the type of this post data element.
282 /*--cef(default_retval=PDE_TYPE_EMPTY)--*/
283 virtual Type GetType() =0;
286 // Return the file name.
289 virtual CefString GetFile() =0;
292 // Return the number of bytes.
295 virtual size_t GetBytesCount() =0;
298 // Read up to |size| bytes into |bytes| and return the number of bytes
302 virtual size_t GetBytes(size_t size, void* bytes) =0;
305 #endif // CEF_INCLUDE_CEF_REQUEST_H_