• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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=3d5c3c54c9f7eedc5cd1dd61c0f69edcd6a1143a$
37 //
38 
39 #ifndef CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_
40 #define CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_
41 #pragma once
42 
43 #include "include/capi/cef_base_capi.h"
44 #include "include/capi/cef_browser_capi.h"
45 #include "include/capi/cef_callback_capi.h"
46 #include "include/capi/cef_frame_capi.h"
47 #include "include/capi/cef_request_capi.h"
48 #include "include/capi/cef_resource_handler_capi.h"
49 #include "include/capi/cef_response_capi.h"
50 #include "include/capi/cef_response_filter_capi.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 struct _cef_cookie_access_filter_t;
57 
58 ///
59 // Implement this structure to handle events related to browser requests. The
60 // functions of this structure will be called on the IO thread unless otherwise
61 // indicated.
62 ///
63 typedef struct _cef_resource_request_handler_t {
64   ///
65   // Base structure.
66   ///
67   cef_base_ref_counted_t base;
68 
69   ///
70   // Called on the IO thread before a resource request is loaded. The |browser|
71   // and |frame| values represent the source of the request, and may be NULL for
72   // requests originating from service workers or cef_urlrequest_t. To
73   // optionally filter cookies for the request return a
74   // cef_cookie_access_filter_t object. The |request| object cannot not be
75   // modified in this callback.
76   ///
77   struct _cef_cookie_access_filter_t*(CEF_CALLBACK* get_cookie_access_filter)(
78       struct _cef_resource_request_handler_t* self,
79       struct _cef_browser_t* browser,
80       struct _cef_frame_t* frame,
81       struct _cef_request_t* request);
82 
83   ///
84   // Called on the IO thread before a resource request is loaded. The |browser|
85   // and |frame| values represent the source of the request, and may be NULL for
86   // requests originating from service workers or cef_urlrequest_t. To redirect
87   // or change the resource load optionally modify |request|. Modification of
88   // the request URL will be treated as a redirect. Return RV_CONTINUE to
89   // continue the request immediately. Return RV_CONTINUE_ASYNC and call
90   // cef_callback_t functions at a later time to continue or cancel the request
91   // asynchronously. Return RV_CANCEL to cancel the request immediately.
92   //
93   ///
94   cef_return_value_t(CEF_CALLBACK* on_before_resource_load)(
95       struct _cef_resource_request_handler_t* self,
96       struct _cef_browser_t* browser,
97       struct _cef_frame_t* frame,
98       struct _cef_request_t* request,
99       struct _cef_callback_t* callback);
100 
101   ///
102   // Called on the IO thread before a resource is loaded. The |browser| and
103   // |frame| values represent the source of the request, and may be NULL for
104   // requests originating from service workers or cef_urlrequest_t. To allow the
105   // resource to load using the default network loader return NULL. To specify a
106   // handler for the resource return a cef_resource_handler_t object. The
107   // |request| object cannot not be modified in this callback.
108   ///
109   struct _cef_resource_handler_t*(CEF_CALLBACK* get_resource_handler)(
110       struct _cef_resource_request_handler_t* self,
111       struct _cef_browser_t* browser,
112       struct _cef_frame_t* frame,
113       struct _cef_request_t* request);
114 
115   ///
116   // Called on the IO thread when a resource load is redirected. The |browser|
117   // and |frame| values represent the source of the request, and may be NULL for
118   // requests originating from service workers or cef_urlrequest_t. The
119   // |request| parameter will contain the old URL and other request-related
120   // information. The |response| parameter will contain the response that
121   // resulted in the redirect. The |new_url| parameter will contain the new URL
122   // and can be changed if desired. The |request| and |response| objects cannot
123   // be modified in this callback.
124   ///
125   void(CEF_CALLBACK* on_resource_redirect)(
126       struct _cef_resource_request_handler_t* self,
127       struct _cef_browser_t* browser,
128       struct _cef_frame_t* frame,
129       struct _cef_request_t* request,
130       struct _cef_response_t* response,
131       cef_string_t* new_url);
132 
133   ///
134   // Called on the IO thread when a resource response is received. The |browser|
135   // and |frame| values represent the source of the request, and may be NULL for
136   // requests originating from service workers or cef_urlrequest_t. To allow the
137   // resource load to proceed without modification return false (0). To redirect
138   // or retry the resource load optionally modify |request| and return true (1).
139   // Modification of the request URL will be treated as a redirect. Requests
140   // handled using the default network loader cannot be redirected in this
141   // callback. The |response| object cannot be modified in this callback.
142   //
143   // WARNING: Redirecting using this function is deprecated. Use
144   // OnBeforeResourceLoad or GetResourceHandler to perform redirects.
145   ///
146   int(CEF_CALLBACK* on_resource_response)(
147       struct _cef_resource_request_handler_t* self,
148       struct _cef_browser_t* browser,
149       struct _cef_frame_t* frame,
150       struct _cef_request_t* request,
151       struct _cef_response_t* response);
152 
153   ///
154   // Called on the IO thread to optionally filter resource response content. The
155   // |browser| and |frame| values represent the source of the request, and may
156   // be NULL for requests originating from service workers or cef_urlrequest_t.
157   // |request| and |response| represent the request and response respectively
158   // and cannot be modified in this callback.
159   ///
160   struct _cef_response_filter_t*(CEF_CALLBACK* get_resource_response_filter)(
161       struct _cef_resource_request_handler_t* self,
162       struct _cef_browser_t* browser,
163       struct _cef_frame_t* frame,
164       struct _cef_request_t* request,
165       struct _cef_response_t* response);
166 
167   ///
168   // Called on the IO thread when a resource load has completed. The |browser|
169   // and |frame| values represent the source of the request, and may be NULL for
170   // requests originating from service workers or cef_urlrequest_t. |request|
171   // and |response| represent the request and response respectively and cannot
172   // be modified in this callback. |status| indicates the load completion
173   // status. |received_content_length| is the number of response bytes actually
174   // read. This function will be called for all requests, including requests
175   // that are aborted due to CEF shutdown or destruction of the associated
176   // browser. In cases where the associated browser is destroyed this callback
177   // may arrive after the cef_life_span_handler_t::OnBeforeClose callback for
178   // that browser. The cef_frame_t::IsValid function can be used to test for
179   // this situation, and care should be taken not to call |browser| or |frame|
180   // functions that modify state (like LoadURL, SendProcessMessage, etc.) if the
181   // frame is invalid.
182   ///
183   void(CEF_CALLBACK* on_resource_load_complete)(
184       struct _cef_resource_request_handler_t* self,
185       struct _cef_browser_t* browser,
186       struct _cef_frame_t* frame,
187       struct _cef_request_t* request,
188       struct _cef_response_t* response,
189       cef_urlrequest_status_t status,
190       int64 received_content_length);
191 
192   ///
193   // Called on the IO thread to handle requests for URLs with an unknown
194   // protocol component. The |browser| and |frame| values represent the source
195   // of the request, and may be NULL for requests originating from service
196   // workers or cef_urlrequest_t. |request| cannot be modified in this callback.
197   // Set |allow_os_execution| to true (1) to attempt execution via the
198   // registered OS protocol handler, if any. SECURITY WARNING: YOU SHOULD USE
199   // THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL
200   // ANALYSIS BEFORE ALLOWING OS EXECUTION.
201   ///
202   void(CEF_CALLBACK* on_protocol_execution)(
203       struct _cef_resource_request_handler_t* self,
204       struct _cef_browser_t* browser,
205       struct _cef_frame_t* frame,
206       struct _cef_request_t* request,
207       int* allow_os_execution);
208 } cef_resource_request_handler_t;
209 
210 ///
211 // Implement this structure to filter cookies that may be sent or received from
212 // resource requests. The functions of this structure will be called on the IO
213 // thread unless otherwise indicated.
214 ///
215 typedef struct _cef_cookie_access_filter_t {
216   ///
217   // Base structure.
218   ///
219   cef_base_ref_counted_t base;
220 
221   ///
222   // Called on the IO thread before a resource request is sent. The |browser|
223   // and |frame| values represent the source of the request, and may be NULL for
224   // requests originating from service workers or cef_urlrequest_t. |request|
225   // cannot be modified in this callback. Return true (1) if the specified
226   // cookie can be sent with the request or false (0) otherwise.
227   ///
228   int(CEF_CALLBACK* can_send_cookie)(struct _cef_cookie_access_filter_t* self,
229                                      struct _cef_browser_t* browser,
230                                      struct _cef_frame_t* frame,
231                                      struct _cef_request_t* request,
232                                      const struct _cef_cookie_t* cookie);
233 
234   ///
235   // Called on the IO thread after a resource response is received. The
236   // |browser| and |frame| values represent the source of the request, and may
237   // be NULL for requests originating from service workers or cef_urlrequest_t.
238   // |request| cannot be modified in this callback. Return true (1) if the
239   // specified cookie returned with the response can be saved or false (0)
240   // otherwise.
241   ///
242   int(CEF_CALLBACK* can_save_cookie)(struct _cef_cookie_access_filter_t* self,
243                                      struct _cef_browser_t* browser,
244                                      struct _cef_frame_t* frame,
245                                      struct _cef_request_t* request,
246                                      struct _cef_response_t* response,
247                                      const struct _cef_cookie_t* cookie);
248 } cef_cookie_access_filter_t;
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 
254 #endif  // CEF_INCLUDE_CAPI_CEF_RESOURCE_REQUEST_HANDLER_CAPI_H_
255