1 // Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved. 2 // 3 // Redistribution and use in source and binary forms, with or without 4 // modification, are permitted provided that the following conditions are 5 // met: 6 // 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 12 // distribution. 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. 17 // 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. 29 // 30 // --------------------------------------------------------------------------- 31 // 32 // This file was generated by the CEF translator tool and should not edited 33 // by hand. See the translator.README.txt file in the tools directory for 34 // more information. 35 // 36 // $hash=a14d77cd7756797afb4db3d28a2359da53011bfa$ 37 // 38 39 #ifndef CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ 40 #define CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ 41 #pragma once 42 43 #include "include/capi/cef_auth_callback_capi.h" 44 #include "include/capi/cef_base_capi.h" 45 #include "include/capi/cef_request_capi.h" 46 #include "include/capi/cef_request_context_capi.h" 47 #include "include/capi/cef_response_capi.h" 48 49 #ifdef __cplusplus 50 extern "C" { 51 #endif 52 53 struct _cef_urlrequest_client_t; 54 55 /// 56 // Structure used to make a URL request. URL requests are not associated with a 57 // browser instance so no cef_client_t callbacks will be executed. URL requests 58 // can be created on any valid CEF thread in either the browser or render 59 // process. Once created the functions of the URL request object must be 60 // accessed on the same thread that created it. 61 /// 62 typedef struct _cef_urlrequest_t { 63 /// 64 // Base structure. 65 /// 66 cef_base_ref_counted_t base; 67 68 /// 69 // Returns the request object used to create this URL request. The returned 70 // object is read-only and should not be modified. 71 /// 72 struct _cef_request_t*(CEF_CALLBACK* get_request)( 73 struct _cef_urlrequest_t* self); 74 75 /// 76 // Returns the client. 77 /// 78 struct _cef_urlrequest_client_t*(CEF_CALLBACK* get_client)( 79 struct _cef_urlrequest_t* self); 80 81 /// 82 // Returns the request status. 83 /// 84 cef_urlrequest_status_t(CEF_CALLBACK* get_request_status)( 85 struct _cef_urlrequest_t* self); 86 87 /// 88 // Returns the request error if status is UR_CANCELED or UR_FAILED, or 0 89 // otherwise. 90 /// 91 cef_errorcode_t(CEF_CALLBACK* get_request_error)( 92 struct _cef_urlrequest_t* self); 93 94 /// 95 // Returns the response, or NULL if no response information is available. 96 // Response information will only be available after the upload has completed. 97 // The returned object is read-only and should not be modified. 98 /// 99 struct _cef_response_t*(CEF_CALLBACK* get_response)( 100 struct _cef_urlrequest_t* self); 101 102 /// 103 // Returns true (1) if the response body was served from the cache. This 104 // includes responses for which revalidation was required. 105 /// 106 int(CEF_CALLBACK* response_was_cached)(struct _cef_urlrequest_t* self); 107 108 /// 109 // Cancel the request. 110 /// 111 void(CEF_CALLBACK* cancel)(struct _cef_urlrequest_t* self); 112 } cef_urlrequest_t; 113 114 /// 115 // Create a new URL request that is not associated with a specific browser or 116 // frame. Use cef_frame_t::CreateURLRequest instead if you want the request to 117 // have this association, in which case it may be handled differently (see 118 // documentation on that function). A request created with this function may 119 // only originate from the browser process, and will behave as follows: 120 // - It may be intercepted by the client via CefResourceRequestHandler or 121 // CefSchemeHandlerFactory. 122 // - POST data may only contain only a single element of type PDE_TYPE_FILE 123 // or PDE_TYPE_BYTES. 124 // - If |request_context| is empty the global request context will be used. 125 // 126 // The |request| object will be marked as read-only after calling this function. 127 /// 128 CEF_EXPORT cef_urlrequest_t* cef_urlrequest_create( 129 struct _cef_request_t* request, 130 struct _cef_urlrequest_client_t* client, 131 struct _cef_request_context_t* request_context); 132 133 /// 134 // Structure that should be implemented by the cef_urlrequest_t client. The 135 // functions of this structure will be called on the same thread that created 136 // the request unless otherwise documented. 137 /// 138 typedef struct _cef_urlrequest_client_t { 139 /// 140 // Base structure. 141 /// 142 cef_base_ref_counted_t base; 143 144 /// 145 // Notifies the client that the request has completed. Use the 146 // cef_urlrequest_t::GetRequestStatus function to determine if the request was 147 // successful or not. 148 /// 149 void(CEF_CALLBACK* on_request_complete)(struct _cef_urlrequest_client_t* self, 150 struct _cef_urlrequest_t* request); 151 152 /// 153 // Notifies the client of upload progress. |current| denotes the number of 154 // bytes sent so far and |total| is the total size of uploading data (or -1 if 155 // chunked upload is enabled). This function will only be called if the 156 // UR_FLAG_REPORT_UPLOAD_PROGRESS flag is set on the request. 157 /// 158 void(CEF_CALLBACK* on_upload_progress)(struct _cef_urlrequest_client_t* self, 159 struct _cef_urlrequest_t* request, 160 int64 current, 161 int64 total); 162 163 /// 164 // Notifies the client of download progress. |current| denotes the number of 165 // bytes received up to the call and |total| is the expected total size of the 166 // response (or -1 if not determined). 167 /// 168 void(CEF_CALLBACK* on_download_progress)( 169 struct _cef_urlrequest_client_t* self, 170 struct _cef_urlrequest_t* request, 171 int64 current, 172 int64 total); 173 174 /// 175 // Called when some part of the response is read. |data| contains the current 176 // bytes received since the last call. This function will not be called if the 177 // UR_FLAG_NO_DOWNLOAD_DATA flag is set on the request. 178 /// 179 void(CEF_CALLBACK* on_download_data)(struct _cef_urlrequest_client_t* self, 180 struct _cef_urlrequest_t* request, 181 const void* data, 182 size_t data_length); 183 184 /// 185 // Called on the IO thread when the browser needs credentials from the user. 186 // |isProxy| indicates whether the host is a proxy server. |host| contains the 187 // hostname and |port| contains the port number. Return true (1) to continue 188 // the request and call cef_auth_callback_t::cont() when the authentication 189 // information is available. If the request has an associated browser/frame 190 // then returning false (0) will result in a call to GetAuthCredentials on the 191 // cef_request_handler_t associated with that browser, if any. Otherwise, 192 // returning false (0) will cancel the request immediately. This function will 193 // only be called for requests initiated from the browser process. 194 /// 195 int(CEF_CALLBACK* get_auth_credentials)( 196 struct _cef_urlrequest_client_t* self, 197 int isProxy, 198 const cef_string_t* host, 199 int port, 200 const cef_string_t* realm, 201 const cef_string_t* scheme, 202 struct _cef_auth_callback_t* callback); 203 } cef_urlrequest_client_t; 204 205 #ifdef __cplusplus 206 } 207 #endif 208 209 #endif // CEF_INCLUDE_CAPI_CEF_URLREQUEST_CAPI_H_ 210