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=be460a1bbdf46dd4e317b39981878b3993675884$
13 //
14
15 #include "libcef_dll/ctocpp/request_handler_ctocpp.h"
16 #include "libcef_dll/cpptoc/auth_callback_cpptoc.h"
17 #include "libcef_dll/cpptoc/browser_cpptoc.h"
18 #include "libcef_dll/cpptoc/callback_cpptoc.h"
19 #include "libcef_dll/cpptoc/frame_cpptoc.h"
20 #include "libcef_dll/cpptoc/request_cpptoc.h"
21 #include "libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.h"
22 #include "libcef_dll/cpptoc/sslinfo_cpptoc.h"
23 #include "libcef_dll/cpptoc/x509certificate_cpptoc.h"
24 #include "libcef_dll/ctocpp/resource_request_handler_ctocpp.h"
25 #include "libcef_dll/shutdown_checker.h"
26
27 // VIRTUAL METHODS - Body may be edited by hand.
28
29 NO_SANITIZE("cfi-icall")
OnBeforeBrowse(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefRequest> request,bool user_gesture,bool is_redirect)30 bool CefRequestHandlerCToCpp::OnBeforeBrowse(CefRefPtr<CefBrowser> browser,
31 CefRefPtr<CefFrame> frame,
32 CefRefPtr<CefRequest> request,
33 bool user_gesture,
34 bool is_redirect) {
35 shutdown_checker::AssertNotShutdown();
36
37 cef_request_handler_t* _struct = GetStruct();
38 if (CEF_MEMBER_MISSING(_struct, on_before_browse))
39 return false;
40
41 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
42
43 // Verify param: browser; type: refptr_diff
44 DCHECK(browser.get());
45 if (!browser.get())
46 return false;
47 // Verify param: frame; type: refptr_diff
48 DCHECK(frame.get());
49 if (!frame.get())
50 return false;
51 // Verify param: request; type: refptr_diff
52 DCHECK(request.get());
53 if (!request.get())
54 return false;
55
56 // Execute
57 int _retval = _struct->on_before_browse(
58 _struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
59 CefRequestCppToC::Wrap(request), user_gesture, is_redirect);
60
61 // Return type: bool
62 return _retval ? true : false;
63 }
64
65 NO_SANITIZE("cfi-icall")
OnOpenURLFromTab(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,const CefString & target_url,WindowOpenDisposition target_disposition,bool user_gesture)66 bool CefRequestHandlerCToCpp::OnOpenURLFromTab(
67 CefRefPtr<CefBrowser> browser,
68 CefRefPtr<CefFrame> frame,
69 const CefString& target_url,
70 WindowOpenDisposition target_disposition,
71 bool user_gesture) {
72 shutdown_checker::AssertNotShutdown();
73
74 cef_request_handler_t* _struct = GetStruct();
75 if (CEF_MEMBER_MISSING(_struct, on_open_urlfrom_tab))
76 return false;
77
78 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
79
80 // Verify param: browser; type: refptr_diff
81 DCHECK(browser.get());
82 if (!browser.get())
83 return false;
84 // Verify param: frame; type: refptr_diff
85 DCHECK(frame.get());
86 if (!frame.get())
87 return false;
88 // Verify param: target_url; type: string_byref_const
89 DCHECK(!target_url.empty());
90 if (target_url.empty())
91 return false;
92
93 // Execute
94 int _retval = _struct->on_open_urlfrom_tab(
95 _struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
96 target_url.GetStruct(), target_disposition, user_gesture);
97
98 // Return type: bool
99 return _retval ? true : false;
100 }
101
102 NO_SANITIZE("cfi-icall")
103 CefRefPtr<CefResourceRequestHandler>
GetResourceRequestHandler(CefRefPtr<CefBrowser> browser,CefRefPtr<CefFrame> frame,CefRefPtr<CefRequest> request,bool is_navigation,bool is_download,const CefString & request_initiator,bool & disable_default_handling)104 CefRequestHandlerCToCpp::GetResourceRequestHandler(
105 CefRefPtr<CefBrowser> browser,
106 CefRefPtr<CefFrame> frame,
107 CefRefPtr<CefRequest> request,
108 bool is_navigation,
109 bool is_download,
110 const CefString& request_initiator,
111 bool& disable_default_handling) {
112 shutdown_checker::AssertNotShutdown();
113
114 cef_request_handler_t* _struct = GetStruct();
115 if (CEF_MEMBER_MISSING(_struct, get_resource_request_handler))
116 return nullptr;
117
118 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
119
120 // Verify param: browser; type: refptr_diff
121 DCHECK(browser.get());
122 if (!browser.get())
123 return nullptr;
124 // Verify param: frame; type: refptr_diff
125 DCHECK(frame.get());
126 if (!frame.get())
127 return nullptr;
128 // Verify param: request; type: refptr_diff
129 DCHECK(request.get());
130 if (!request.get())
131 return nullptr;
132 // Unverified params: request_initiator
133
134 // Translate param: disable_default_handling; type: bool_byref
135 int disable_default_handlingInt = disable_default_handling;
136
137 // Execute
138 cef_resource_request_handler_t* _retval =
139 _struct->get_resource_request_handler(
140 _struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
141 CefRequestCppToC::Wrap(request), is_navigation, is_download,
142 request_initiator.GetStruct(), &disable_default_handlingInt);
143
144 // Restore param:disable_default_handling; type: bool_byref
145 disable_default_handling = disable_default_handlingInt ? true : false;
146
147 // Return type: refptr_same
148 return CefResourceRequestHandlerCToCpp::Wrap(_retval);
149 }
150
151 NO_SANITIZE("cfi-icall")
GetAuthCredentials(CefRefPtr<CefBrowser> browser,const CefString & origin_url,bool isProxy,const CefString & host,int port,const CefString & realm,const CefString & scheme,CefRefPtr<CefAuthCallback> callback)152 bool CefRequestHandlerCToCpp::GetAuthCredentials(
153 CefRefPtr<CefBrowser> browser,
154 const CefString& origin_url,
155 bool isProxy,
156 const CefString& host,
157 int port,
158 const CefString& realm,
159 const CefString& scheme,
160 CefRefPtr<CefAuthCallback> callback) {
161 shutdown_checker::AssertNotShutdown();
162
163 cef_request_handler_t* _struct = GetStruct();
164 if (CEF_MEMBER_MISSING(_struct, get_auth_credentials))
165 return false;
166
167 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
168
169 // Verify param: browser; type: refptr_diff
170 DCHECK(browser.get());
171 if (!browser.get())
172 return false;
173 // Verify param: origin_url; type: string_byref_const
174 DCHECK(!origin_url.empty());
175 if (origin_url.empty())
176 return false;
177 // Verify param: host; type: string_byref_const
178 DCHECK(!host.empty());
179 if (host.empty())
180 return false;
181 // Verify param: callback; type: refptr_diff
182 DCHECK(callback.get());
183 if (!callback.get())
184 return false;
185 // Unverified params: realm, scheme
186
187 // Execute
188 int _retval = _struct->get_auth_credentials(
189 _struct, CefBrowserCppToC::Wrap(browser), origin_url.GetStruct(), isProxy,
190 host.GetStruct(), port, realm.GetStruct(), scheme.GetStruct(),
191 CefAuthCallbackCppToC::Wrap(callback));
192
193 // Return type: bool
194 return _retval ? true : false;
195 }
196
197 NO_SANITIZE("cfi-icall")
OnQuotaRequest(CefRefPtr<CefBrowser> browser,const CefString & origin_url,int64 new_size,CefRefPtr<CefCallback> callback)198 bool CefRequestHandlerCToCpp::OnQuotaRequest(CefRefPtr<CefBrowser> browser,
199 const CefString& origin_url,
200 int64 new_size,
201 CefRefPtr<CefCallback> callback) {
202 shutdown_checker::AssertNotShutdown();
203
204 cef_request_handler_t* _struct = GetStruct();
205 if (CEF_MEMBER_MISSING(_struct, on_quota_request))
206 return false;
207
208 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
209
210 // Verify param: browser; type: refptr_diff
211 DCHECK(browser.get());
212 if (!browser.get())
213 return false;
214 // Verify param: origin_url; type: string_byref_const
215 DCHECK(!origin_url.empty());
216 if (origin_url.empty())
217 return false;
218 // Verify param: callback; type: refptr_diff
219 DCHECK(callback.get());
220 if (!callback.get())
221 return false;
222
223 // Execute
224 int _retval = _struct->on_quota_request(
225 _struct, CefBrowserCppToC::Wrap(browser), origin_url.GetStruct(),
226 new_size, CefCallbackCppToC::Wrap(callback));
227
228 // Return type: bool
229 return _retval ? true : false;
230 }
231
232 NO_SANITIZE("cfi-icall")
OnCertificateError(CefRefPtr<CefBrowser> browser,cef_errorcode_t cert_error,const CefString & request_url,CefRefPtr<CefSSLInfo> ssl_info,CefRefPtr<CefCallback> callback)233 bool CefRequestHandlerCToCpp::OnCertificateError(
234 CefRefPtr<CefBrowser> browser,
235 cef_errorcode_t cert_error,
236 const CefString& request_url,
237 CefRefPtr<CefSSLInfo> ssl_info,
238 CefRefPtr<CefCallback> callback) {
239 shutdown_checker::AssertNotShutdown();
240
241 cef_request_handler_t* _struct = GetStruct();
242 if (CEF_MEMBER_MISSING(_struct, on_certificate_error))
243 return false;
244
245 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
246
247 // Verify param: browser; type: refptr_diff
248 DCHECK(browser.get());
249 if (!browser.get())
250 return false;
251 // Verify param: request_url; type: string_byref_const
252 DCHECK(!request_url.empty());
253 if (request_url.empty())
254 return false;
255 // Verify param: ssl_info; type: refptr_diff
256 DCHECK(ssl_info.get());
257 if (!ssl_info.get())
258 return false;
259 // Verify param: callback; type: refptr_diff
260 DCHECK(callback.get());
261 if (!callback.get())
262 return false;
263
264 // Execute
265 int _retval = _struct->on_certificate_error(
266 _struct, CefBrowserCppToC::Wrap(browser), cert_error,
267 request_url.GetStruct(), CefSSLInfoCppToC::Wrap(ssl_info),
268 CefCallbackCppToC::Wrap(callback));
269
270 // Return type: bool
271 return _retval ? true : false;
272 }
273
274 NO_SANITIZE("cfi-icall")
OnSelectClientCertificate(CefRefPtr<CefBrowser> browser,bool isProxy,const CefString & host,int port,const X509CertificateList & certificates,CefRefPtr<CefSelectClientCertificateCallback> callback)275 bool CefRequestHandlerCToCpp::OnSelectClientCertificate(
276 CefRefPtr<CefBrowser> browser,
277 bool isProxy,
278 const CefString& host,
279 int port,
280 const X509CertificateList& certificates,
281 CefRefPtr<CefSelectClientCertificateCallback> callback) {
282 shutdown_checker::AssertNotShutdown();
283
284 cef_request_handler_t* _struct = GetStruct();
285 if (CEF_MEMBER_MISSING(_struct, on_select_client_certificate))
286 return false;
287
288 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
289
290 // Verify param: browser; type: refptr_diff
291 DCHECK(browser.get());
292 if (!browser.get())
293 return false;
294 // Verify param: host; type: string_byref_const
295 DCHECK(!host.empty());
296 if (host.empty())
297 return false;
298 // Verify param: callback; type: refptr_diff
299 DCHECK(callback.get());
300 if (!callback.get())
301 return false;
302
303 // Translate param: certificates; type: refptr_vec_diff_byref_const
304 const size_t certificatesCount = certificates.size();
305 cef_x509certificate_t** certificatesList = NULL;
306 if (certificatesCount > 0) {
307 certificatesList = new cef_x509certificate_t*[certificatesCount];
308 DCHECK(certificatesList);
309 if (certificatesList) {
310 for (size_t i = 0; i < certificatesCount; ++i) {
311 certificatesList[i] = CefX509CertificateCppToC::Wrap(certificates[i]);
312 }
313 }
314 }
315
316 // Execute
317 int _retval = _struct->on_select_client_certificate(
318 _struct, CefBrowserCppToC::Wrap(browser), isProxy, host.GetStruct(), port,
319 certificatesCount, certificatesList,
320 CefSelectClientCertificateCallbackCppToC::Wrap(callback));
321
322 // Restore param:certificates; type: refptr_vec_diff_byref_const
323 if (certificatesList)
324 delete[] certificatesList;
325
326 // Return type: bool
327 return _retval ? true : false;
328 }
329
330 NO_SANITIZE("cfi-icall")
OnPluginCrashed(CefRefPtr<CefBrowser> browser,const CefString & plugin_path)331 void CefRequestHandlerCToCpp::OnPluginCrashed(CefRefPtr<CefBrowser> browser,
332 const CefString& plugin_path) {
333 shutdown_checker::AssertNotShutdown();
334
335 cef_request_handler_t* _struct = GetStruct();
336 if (CEF_MEMBER_MISSING(_struct, on_plugin_crashed))
337 return;
338
339 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
340
341 // Verify param: browser; type: refptr_diff
342 DCHECK(browser.get());
343 if (!browser.get())
344 return;
345 // Verify param: plugin_path; type: string_byref_const
346 DCHECK(!plugin_path.empty());
347 if (plugin_path.empty())
348 return;
349
350 // Execute
351 _struct->on_plugin_crashed(_struct, CefBrowserCppToC::Wrap(browser),
352 plugin_path.GetStruct());
353 }
354
355 NO_SANITIZE("cfi-icall")
OnRenderViewReady(CefRefPtr<CefBrowser> browser)356 void CefRequestHandlerCToCpp::OnRenderViewReady(CefRefPtr<CefBrowser> browser) {
357 shutdown_checker::AssertNotShutdown();
358
359 cef_request_handler_t* _struct = GetStruct();
360 if (CEF_MEMBER_MISSING(_struct, on_render_view_ready))
361 return;
362
363 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
364
365 // Verify param: browser; type: refptr_diff
366 DCHECK(browser.get());
367 if (!browser.get())
368 return;
369
370 // Execute
371 _struct->on_render_view_ready(_struct, CefBrowserCppToC::Wrap(browser));
372 }
373
374 NO_SANITIZE("cfi-icall")
OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,TerminationStatus status)375 void CefRequestHandlerCToCpp::OnRenderProcessTerminated(
376 CefRefPtr<CefBrowser> browser,
377 TerminationStatus status) {
378 shutdown_checker::AssertNotShutdown();
379
380 cef_request_handler_t* _struct = GetStruct();
381 if (CEF_MEMBER_MISSING(_struct, on_render_process_terminated))
382 return;
383
384 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
385
386 // Verify param: browser; type: refptr_diff
387 DCHECK(browser.get());
388 if (!browser.get())
389 return;
390
391 // Execute
392 _struct->on_render_process_terminated(
393 _struct, CefBrowserCppToC::Wrap(browser), status);
394 }
395
396 NO_SANITIZE("cfi-icall")
OnDocumentAvailableInMainFrame(CefRefPtr<CefBrowser> browser)397 void CefRequestHandlerCToCpp::OnDocumentAvailableInMainFrame(
398 CefRefPtr<CefBrowser> browser) {
399 shutdown_checker::AssertNotShutdown();
400
401 cef_request_handler_t* _struct = GetStruct();
402 if (CEF_MEMBER_MISSING(_struct, on_document_available_in_main_frame))
403 return;
404
405 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
406
407 // Verify param: browser; type: refptr_diff
408 DCHECK(browser.get());
409 if (!browser.get())
410 return;
411
412 // Execute
413 _struct->on_document_available_in_main_frame(_struct,
414 CefBrowserCppToC::Wrap(browser));
415 }
416
417 // CONSTRUCTOR - Do not edit by hand.
418
CefRequestHandlerCToCpp()419 CefRequestHandlerCToCpp::CefRequestHandlerCToCpp() {}
420
421 // DESTRUCTOR - Do not edit by hand.
422
~CefRequestHandlerCToCpp()423 CefRequestHandlerCToCpp::~CefRequestHandlerCToCpp() {
424 shutdown_checker::AssertNotShutdown();
425 }
426
427 template <>
428 cef_request_handler_t* CefCToCppRefCounted<
429 CefRequestHandlerCToCpp,
430 CefRequestHandler,
UnwrapDerived(CefWrapperType type,CefRequestHandler * c)431 cef_request_handler_t>::UnwrapDerived(CefWrapperType type,
432 CefRequestHandler* c) {
433 NOTREACHED() << "Unexpected class type: " << type;
434 return nullptr;
435 }
436
437 template <>
438 CefWrapperType CefCToCppRefCounted<CefRequestHandlerCToCpp,
439 CefRequestHandler,
440 cef_request_handler_t>::kWrapperType =
441 WT_REQUEST_HANDLER;
442