• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
2 // reserved. Use of this source code is governed by a BSD-style license that
3 // can be found in the LICENSE file.
4 //
5 // ---------------------------------------------------------------------------
6 //
7 // This file was generated by the CEF translator tool. If making changes by
8 // hand only do so within the body of existing method and function
9 // implementations. See the translator.README.txt file in the tools directory
10 // for more information.
11 //
12 // $hash=fa45e2603966fc7a6c93c930dd4c03692cf10fd2$
13 //
14 
15 #include "libcef_dll/cpptoc/request_handler_cpptoc.h"
16 #include "libcef_dll/cpptoc/resource_request_handler_cpptoc.h"
17 #include "libcef_dll/ctocpp/auth_callback_ctocpp.h"
18 #include "libcef_dll/ctocpp/browser_ctocpp.h"
19 #include "libcef_dll/ctocpp/callback_ctocpp.h"
20 #include "libcef_dll/ctocpp/frame_ctocpp.h"
21 #include "libcef_dll/ctocpp/request_ctocpp.h"
22 #include "libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.h"
23 #include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
24 #include "libcef_dll/ctocpp/x509certificate_ctocpp.h"
25 #include "libcef_dll/shutdown_checker.h"
26 
27 namespace {
28 
29 // MEMBER FUNCTIONS - Body may be edited by hand.
30 
31 int CEF_CALLBACK
request_handler_on_before_browse(struct _cef_request_handler_t * self,cef_browser_t * browser,cef_frame_t * frame,cef_request_t * request,int user_gesture,int is_redirect)32 request_handler_on_before_browse(struct _cef_request_handler_t* self,
33                                  cef_browser_t* browser,
34                                  cef_frame_t* frame,
35                                  cef_request_t* request,
36                                  int user_gesture,
37                                  int is_redirect) {
38   shutdown_checker::AssertNotShutdown();
39 
40   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
41 
42   DCHECK(self);
43   if (!self)
44     return 0;
45   // Verify param: browser; type: refptr_diff
46   DCHECK(browser);
47   if (!browser)
48     return 0;
49   // Verify param: frame; type: refptr_diff
50   DCHECK(frame);
51   if (!frame)
52     return 0;
53   // Verify param: request; type: refptr_diff
54   DCHECK(request);
55   if (!request)
56     return 0;
57 
58   // Execute
59   bool _retval = CefRequestHandlerCppToC::Get(self)->OnBeforeBrowse(
60       CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
61       CefRequestCToCpp::Wrap(request), user_gesture ? true : false,
62       is_redirect ? true : false);
63 
64   // Return type: bool
65   return _retval;
66 }
67 
request_handler_on_open_urlfrom_tab(struct _cef_request_handler_t * self,cef_browser_t * browser,cef_frame_t * frame,const cef_string_t * target_url,cef_window_open_disposition_t target_disposition,int user_gesture)68 int CEF_CALLBACK request_handler_on_open_urlfrom_tab(
69     struct _cef_request_handler_t* self,
70     cef_browser_t* browser,
71     cef_frame_t* frame,
72     const cef_string_t* target_url,
73     cef_window_open_disposition_t target_disposition,
74     int user_gesture) {
75   shutdown_checker::AssertNotShutdown();
76 
77   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
78 
79   DCHECK(self);
80   if (!self)
81     return 0;
82   // Verify param: browser; type: refptr_diff
83   DCHECK(browser);
84   if (!browser)
85     return 0;
86   // Verify param: frame; type: refptr_diff
87   DCHECK(frame);
88   if (!frame)
89     return 0;
90   // Verify param: target_url; type: string_byref_const
91   DCHECK(target_url);
92   if (!target_url)
93     return 0;
94 
95   // Execute
96   bool _retval = CefRequestHandlerCppToC::Get(self)->OnOpenURLFromTab(
97       CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
98       CefString(target_url), target_disposition, user_gesture ? true : false);
99 
100   // Return type: bool
101   return _retval;
102 }
103 
104 struct _cef_resource_request_handler_t* CEF_CALLBACK
request_handler_get_resource_request_handler(struct _cef_request_handler_t * self,cef_browser_t * browser,cef_frame_t * frame,cef_request_t * request,int is_navigation,int is_download,const cef_string_t * request_initiator,int * disable_default_handling)105 request_handler_get_resource_request_handler(
106     struct _cef_request_handler_t* self,
107     cef_browser_t* browser,
108     cef_frame_t* frame,
109     cef_request_t* request,
110     int is_navigation,
111     int is_download,
112     const cef_string_t* request_initiator,
113     int* disable_default_handling) {
114   shutdown_checker::AssertNotShutdown();
115 
116   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
117 
118   DCHECK(self);
119   if (!self)
120     return NULL;
121   // Verify param: browser; type: refptr_diff
122   DCHECK(browser);
123   if (!browser)
124     return NULL;
125   // Verify param: frame; type: refptr_diff
126   DCHECK(frame);
127   if (!frame)
128     return NULL;
129   // Verify param: request; type: refptr_diff
130   DCHECK(request);
131   if (!request)
132     return NULL;
133   // Verify param: disable_default_handling; type: bool_byref
134   DCHECK(disable_default_handling);
135   if (!disable_default_handling)
136     return NULL;
137   // Unverified params: request_initiator
138 
139   // Translate param: disable_default_handling; type: bool_byref
140   bool disable_default_handlingBool =
141       (disable_default_handling && *disable_default_handling) ? true : false;
142 
143   // Execute
144   CefRefPtr<CefResourceRequestHandler> _retval =
145       CefRequestHandlerCppToC::Get(self)->GetResourceRequestHandler(
146           CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
147           CefRequestCToCpp::Wrap(request), is_navigation ? true : false,
148           is_download ? true : false, CefString(request_initiator),
149           disable_default_handlingBool);
150 
151   // Restore param: disable_default_handling; type: bool_byref
152   if (disable_default_handling)
153     *disable_default_handling = disable_default_handlingBool ? true : false;
154 
155   // Return type: refptr_same
156   return CefResourceRequestHandlerCppToC::Wrap(_retval);
157 }
158 
159 int CEF_CALLBACK
request_handler_get_auth_credentials(struct _cef_request_handler_t * self,cef_browser_t * browser,const cef_string_t * origin_url,int isProxy,const cef_string_t * host,int port,const cef_string_t * realm,const cef_string_t * scheme,cef_auth_callback_t * callback)160 request_handler_get_auth_credentials(struct _cef_request_handler_t* self,
161                                      cef_browser_t* browser,
162                                      const cef_string_t* origin_url,
163                                      int isProxy,
164                                      const cef_string_t* host,
165                                      int port,
166                                      const cef_string_t* realm,
167                                      const cef_string_t* scheme,
168                                      cef_auth_callback_t* callback) {
169   shutdown_checker::AssertNotShutdown();
170 
171   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
172 
173   DCHECK(self);
174   if (!self)
175     return 0;
176   // Verify param: browser; type: refptr_diff
177   DCHECK(browser);
178   if (!browser)
179     return 0;
180   // Verify param: origin_url; type: string_byref_const
181   DCHECK(origin_url);
182   if (!origin_url)
183     return 0;
184   // Verify param: host; type: string_byref_const
185   DCHECK(host);
186   if (!host)
187     return 0;
188   // Verify param: callback; type: refptr_diff
189   DCHECK(callback);
190   if (!callback)
191     return 0;
192   // Unverified params: realm, scheme
193 
194   // Execute
195   bool _retval = CefRequestHandlerCppToC::Get(self)->GetAuthCredentials(
196       CefBrowserCToCpp::Wrap(browser), CefString(origin_url),
197       isProxy ? true : false, CefString(host), port, CefString(realm),
198       CefString(scheme), CefAuthCallbackCToCpp::Wrap(callback));
199 
200   // Return type: bool
201   return _retval;
202 }
203 
204 int CEF_CALLBACK
request_handler_on_quota_request(struct _cef_request_handler_t * self,cef_browser_t * browser,const cef_string_t * origin_url,int64 new_size,cef_callback_t * callback)205 request_handler_on_quota_request(struct _cef_request_handler_t* self,
206                                  cef_browser_t* browser,
207                                  const cef_string_t* origin_url,
208                                  int64 new_size,
209                                  cef_callback_t* callback) {
210   shutdown_checker::AssertNotShutdown();
211 
212   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
213 
214   DCHECK(self);
215   if (!self)
216     return 0;
217   // Verify param: browser; type: refptr_diff
218   DCHECK(browser);
219   if (!browser)
220     return 0;
221   // Verify param: origin_url; type: string_byref_const
222   DCHECK(origin_url);
223   if (!origin_url)
224     return 0;
225   // Verify param: callback; type: refptr_diff
226   DCHECK(callback);
227   if (!callback)
228     return 0;
229 
230   // Execute
231   bool _retval = CefRequestHandlerCppToC::Get(self)->OnQuotaRequest(
232       CefBrowserCToCpp::Wrap(browser), CefString(origin_url), new_size,
233       CefCallbackCToCpp::Wrap(callback));
234 
235   // Return type: bool
236   return _retval;
237 }
238 
239 int CEF_CALLBACK
request_handler_on_certificate_error(struct _cef_request_handler_t * self,cef_browser_t * browser,cef_errorcode_t cert_error,const cef_string_t * request_url,struct _cef_sslinfo_t * ssl_info,cef_callback_t * callback)240 request_handler_on_certificate_error(struct _cef_request_handler_t* self,
241                                      cef_browser_t* browser,
242                                      cef_errorcode_t cert_error,
243                                      const cef_string_t* request_url,
244                                      struct _cef_sslinfo_t* ssl_info,
245                                      cef_callback_t* callback) {
246   shutdown_checker::AssertNotShutdown();
247 
248   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
249 
250   DCHECK(self);
251   if (!self)
252     return 0;
253   // Verify param: browser; type: refptr_diff
254   DCHECK(browser);
255   if (!browser)
256     return 0;
257   // Verify param: request_url; type: string_byref_const
258   DCHECK(request_url);
259   if (!request_url)
260     return 0;
261   // Verify param: ssl_info; type: refptr_diff
262   DCHECK(ssl_info);
263   if (!ssl_info)
264     return 0;
265   // Verify param: callback; type: refptr_diff
266   DCHECK(callback);
267   if (!callback)
268     return 0;
269 
270   // Execute
271   bool _retval = CefRequestHandlerCppToC::Get(self)->OnCertificateError(
272       CefBrowserCToCpp::Wrap(browser), cert_error, CefString(request_url),
273       CefSSLInfoCToCpp::Wrap(ssl_info), CefCallbackCToCpp::Wrap(callback));
274 
275   // Return type: bool
276   return _retval;
277 }
278 
request_handler_on_select_client_certificate(struct _cef_request_handler_t * self,cef_browser_t * browser,int isProxy,const cef_string_t * host,int port,size_t certificatesCount,struct _cef_x509certificate_t * const * certificates,cef_select_client_certificate_callback_t * callback)279 int CEF_CALLBACK request_handler_on_select_client_certificate(
280     struct _cef_request_handler_t* self,
281     cef_browser_t* browser,
282     int isProxy,
283     const cef_string_t* host,
284     int port,
285     size_t certificatesCount,
286     struct _cef_x509certificate_t* const* certificates,
287     cef_select_client_certificate_callback_t* callback) {
288   shutdown_checker::AssertNotShutdown();
289 
290   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
291 
292   DCHECK(self);
293   if (!self)
294     return 0;
295   // Verify param: browser; type: refptr_diff
296   DCHECK(browser);
297   if (!browser)
298     return 0;
299   // Verify param: host; type: string_byref_const
300   DCHECK(host);
301   if (!host)
302     return 0;
303   // Verify param: certificates; type: refptr_vec_diff_byref_const
304   DCHECK(certificatesCount == 0 || certificates);
305   if (certificatesCount > 0 && !certificates)
306     return 0;
307   // Verify param: callback; type: refptr_diff
308   DCHECK(callback);
309   if (!callback)
310     return 0;
311 
312   // Translate param: certificates; type: refptr_vec_diff_byref_const
313   std::vector<CefRefPtr<CefX509Certificate>> certificatesList;
314   if (certificatesCount > 0) {
315     for (size_t i = 0; i < certificatesCount; ++i) {
316       CefRefPtr<CefX509Certificate> certificatesVal =
317           CefX509CertificateCToCpp::Wrap(certificates[i]);
318       certificatesList.push_back(certificatesVal);
319     }
320   }
321 
322   // Execute
323   bool _retval = CefRequestHandlerCppToC::Get(self)->OnSelectClientCertificate(
324       CefBrowserCToCpp::Wrap(browser), isProxy ? true : false, CefString(host),
325       port, certificatesList,
326       CefSelectClientCertificateCallbackCToCpp::Wrap(callback));
327 
328   // Return type: bool
329   return _retval;
330 }
331 
332 void CEF_CALLBACK
request_handler_on_plugin_crashed(struct _cef_request_handler_t * self,cef_browser_t * browser,const cef_string_t * plugin_path)333 request_handler_on_plugin_crashed(struct _cef_request_handler_t* self,
334                                   cef_browser_t* browser,
335                                   const cef_string_t* plugin_path) {
336   shutdown_checker::AssertNotShutdown();
337 
338   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
339 
340   DCHECK(self);
341   if (!self)
342     return;
343   // Verify param: browser; type: refptr_diff
344   DCHECK(browser);
345   if (!browser)
346     return;
347   // Verify param: plugin_path; type: string_byref_const
348   DCHECK(plugin_path);
349   if (!plugin_path)
350     return;
351 
352   // Execute
353   CefRequestHandlerCppToC::Get(self)->OnPluginCrashed(
354       CefBrowserCToCpp::Wrap(browser), CefString(plugin_path));
355 }
356 
357 void CEF_CALLBACK
request_handler_on_render_view_ready(struct _cef_request_handler_t * self,cef_browser_t * browser)358 request_handler_on_render_view_ready(struct _cef_request_handler_t* self,
359                                      cef_browser_t* browser) {
360   shutdown_checker::AssertNotShutdown();
361 
362   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
363 
364   DCHECK(self);
365   if (!self)
366     return;
367   // Verify param: browser; type: refptr_diff
368   DCHECK(browser);
369   if (!browser)
370     return;
371 
372   // Execute
373   CefRequestHandlerCppToC::Get(self)->OnRenderViewReady(
374       CefBrowserCToCpp::Wrap(browser));
375 }
376 
request_handler_on_render_process_terminated(struct _cef_request_handler_t * self,cef_browser_t * browser,cef_termination_status_t status)377 void CEF_CALLBACK request_handler_on_render_process_terminated(
378     struct _cef_request_handler_t* self,
379     cef_browser_t* browser,
380     cef_termination_status_t status) {
381   shutdown_checker::AssertNotShutdown();
382 
383   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
384 
385   DCHECK(self);
386   if (!self)
387     return;
388   // Verify param: browser; type: refptr_diff
389   DCHECK(browser);
390   if (!browser)
391     return;
392 
393   // Execute
394   CefRequestHandlerCppToC::Get(self)->OnRenderProcessTerminated(
395       CefBrowserCToCpp::Wrap(browser), status);
396 }
397 
request_handler_on_document_available_in_main_frame(struct _cef_request_handler_t * self,cef_browser_t * browser)398 void CEF_CALLBACK request_handler_on_document_available_in_main_frame(
399     struct _cef_request_handler_t* self,
400     cef_browser_t* browser) {
401   shutdown_checker::AssertNotShutdown();
402 
403   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
404 
405   DCHECK(self);
406   if (!self)
407     return;
408   // Verify param: browser; type: refptr_diff
409   DCHECK(browser);
410   if (!browser)
411     return;
412 
413   // Execute
414   CefRequestHandlerCppToC::Get(self)->OnDocumentAvailableInMainFrame(
415       CefBrowserCToCpp::Wrap(browser));
416 }
417 
418 }  // namespace
419 
420 // CONSTRUCTOR - Do not edit by hand.
421 
CefRequestHandlerCppToC()422 CefRequestHandlerCppToC::CefRequestHandlerCppToC() {
423   GetStruct()->on_before_browse = request_handler_on_before_browse;
424   GetStruct()->on_open_urlfrom_tab = request_handler_on_open_urlfrom_tab;
425   GetStruct()->get_resource_request_handler =
426       request_handler_get_resource_request_handler;
427   GetStruct()->get_auth_credentials = request_handler_get_auth_credentials;
428   GetStruct()->on_quota_request = request_handler_on_quota_request;
429   GetStruct()->on_certificate_error = request_handler_on_certificate_error;
430   GetStruct()->on_select_client_certificate =
431       request_handler_on_select_client_certificate;
432   GetStruct()->on_plugin_crashed = request_handler_on_plugin_crashed;
433   GetStruct()->on_render_view_ready = request_handler_on_render_view_ready;
434   GetStruct()->on_render_process_terminated =
435       request_handler_on_render_process_terminated;
436   GetStruct()->on_document_available_in_main_frame =
437       request_handler_on_document_available_in_main_frame;
438 }
439 
440 // DESTRUCTOR - Do not edit by hand.
441 
~CefRequestHandlerCppToC()442 CefRequestHandlerCppToC::~CefRequestHandlerCppToC() {
443   shutdown_checker::AssertNotShutdown();
444 }
445 
446 template <>
447 CefRefPtr<CefRequestHandler> CefCppToCRefCounted<
448     CefRequestHandlerCppToC,
449     CefRequestHandler,
UnwrapDerived(CefWrapperType type,cef_request_handler_t * s)450     cef_request_handler_t>::UnwrapDerived(CefWrapperType type,
451                                           cef_request_handler_t* s) {
452   NOTREACHED() << "Unexpected class type: " << type;
453   return nullptr;
454 }
455 
456 template <>
457 CefWrapperType CefCppToCRefCounted<CefRequestHandlerCppToC,
458                                    CefRequestHandler,
459                                    cef_request_handler_t>::kWrapperType =
460     WT_REQUEST_HANDLER;
461