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=7cdd0564d9b129bf9f068764d4d1588645445d5b$
13 //
14
15 #include "libcef_dll/cpptoc/extension_handler_cpptoc.h"
16 #include "libcef_dll/cpptoc/client_cpptoc.h"
17 #include "libcef_dll/ctocpp/browser_ctocpp.h"
18 #include "libcef_dll/ctocpp/extension_ctocpp.h"
19 #include "libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h"
20 #include "libcef_dll/shutdown_checker.h"
21
22 namespace {
23
24 // MEMBER FUNCTIONS - Body may be edited by hand.
25
extension_handler_on_extension_load_failed(struct _cef_extension_handler_t * self,cef_errorcode_t result)26 void CEF_CALLBACK extension_handler_on_extension_load_failed(
27 struct _cef_extension_handler_t* self,
28 cef_errorcode_t result) {
29 shutdown_checker::AssertNotShutdown();
30
31 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
32
33 DCHECK(self);
34 if (!self)
35 return;
36
37 // Execute
38 CefExtensionHandlerCppToC::Get(self)->OnExtensionLoadFailed(result);
39 }
40
41 void CEF_CALLBACK
extension_handler_on_extension_loaded(struct _cef_extension_handler_t * self,cef_extension_t * extension)42 extension_handler_on_extension_loaded(struct _cef_extension_handler_t* self,
43 cef_extension_t* extension) {
44 shutdown_checker::AssertNotShutdown();
45
46 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
47
48 DCHECK(self);
49 if (!self)
50 return;
51 // Verify param: extension; type: refptr_diff
52 DCHECK(extension);
53 if (!extension)
54 return;
55
56 // Execute
57 CefExtensionHandlerCppToC::Get(self)->OnExtensionLoaded(
58 CefExtensionCToCpp::Wrap(extension));
59 }
60
61 void CEF_CALLBACK
extension_handler_on_extension_unloaded(struct _cef_extension_handler_t * self,cef_extension_t * extension)62 extension_handler_on_extension_unloaded(struct _cef_extension_handler_t* self,
63 cef_extension_t* extension) {
64 shutdown_checker::AssertNotShutdown();
65
66 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
67
68 DCHECK(self);
69 if (!self)
70 return;
71 // Verify param: extension; type: refptr_diff
72 DCHECK(extension);
73 if (!extension)
74 return;
75
76 // Execute
77 CefExtensionHandlerCppToC::Get(self)->OnExtensionUnloaded(
78 CefExtensionCToCpp::Wrap(extension));
79 }
80
extension_handler_on_before_background_browser(struct _cef_extension_handler_t * self,cef_extension_t * extension,const cef_string_t * url,cef_client_t ** client,struct _cef_browser_settings_t * settings)81 int CEF_CALLBACK extension_handler_on_before_background_browser(
82 struct _cef_extension_handler_t* self,
83 cef_extension_t* extension,
84 const cef_string_t* url,
85 cef_client_t** client,
86 struct _cef_browser_settings_t* settings) {
87 shutdown_checker::AssertNotShutdown();
88
89 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
90
91 DCHECK(self);
92 if (!self)
93 return 0;
94 // Verify param: extension; type: refptr_diff
95 DCHECK(extension);
96 if (!extension)
97 return 0;
98 // Verify param: url; type: string_byref_const
99 DCHECK(url);
100 if (!url)
101 return 0;
102 // Verify param: client; type: refptr_same_byref
103 DCHECK(client);
104 if (!client)
105 return 0;
106 // Verify param: settings; type: struct_byref
107 DCHECK(settings);
108 if (!settings)
109 return 0;
110
111 // Translate param: client; type: refptr_same_byref
112 CefRefPtr<CefClient> clientPtr;
113 if (client && *client)
114 clientPtr = CefClientCppToC::Unwrap(*client);
115 CefClient* clientOrig = clientPtr.get();
116 // Translate param: settings; type: struct_byref
117 CefBrowserSettings settingsObj;
118 if (settings)
119 settingsObj.AttachTo(*settings);
120
121 // Execute
122 bool _retval =
123 CefExtensionHandlerCppToC::Get(self)->OnBeforeBackgroundBrowser(
124 CefExtensionCToCpp::Wrap(extension), CefString(url), clientPtr,
125 settingsObj);
126
127 // Restore param: client; type: refptr_same_byref
128 if (client) {
129 if (clientPtr.get()) {
130 if (clientPtr.get() != clientOrig) {
131 *client = CefClientCppToC::Wrap(clientPtr);
132 }
133 } else {
134 *client = nullptr;
135 }
136 }
137 // Restore param: settings; type: struct_byref
138 if (settings)
139 settingsObj.DetachTo(*settings);
140
141 // Return type: bool
142 return _retval;
143 }
144
145 int CEF_CALLBACK
extension_handler_on_before_browser(struct _cef_extension_handler_t * self,cef_extension_t * extension,cef_browser_t * browser,cef_browser_t * active_browser,int index,const cef_string_t * url,int active,cef_window_info_t * windowInfo,cef_client_t ** client,struct _cef_browser_settings_t * settings)146 extension_handler_on_before_browser(struct _cef_extension_handler_t* self,
147 cef_extension_t* extension,
148 cef_browser_t* browser,
149 cef_browser_t* active_browser,
150 int index,
151 const cef_string_t* url,
152 int active,
153 cef_window_info_t* windowInfo,
154 cef_client_t** client,
155 struct _cef_browser_settings_t* settings) {
156 shutdown_checker::AssertNotShutdown();
157
158 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
159
160 DCHECK(self);
161 if (!self)
162 return 0;
163 // Verify param: extension; type: refptr_diff
164 DCHECK(extension);
165 if (!extension)
166 return 0;
167 // Verify param: browser; type: refptr_diff
168 DCHECK(browser);
169 if (!browser)
170 return 0;
171 // Verify param: active_browser; type: refptr_diff
172 DCHECK(active_browser);
173 if (!active_browser)
174 return 0;
175 // Verify param: url; type: string_byref_const
176 DCHECK(url);
177 if (!url)
178 return 0;
179 // Verify param: windowInfo; type: struct_byref
180 DCHECK(windowInfo);
181 if (!windowInfo)
182 return 0;
183 // Verify param: client; type: refptr_same_byref
184 DCHECK(client);
185 if (!client)
186 return 0;
187 // Verify param: settings; type: struct_byref
188 DCHECK(settings);
189 if (!settings)
190 return 0;
191
192 // Translate param: windowInfo; type: struct_byref
193 CefWindowInfo windowInfoObj;
194 if (windowInfo)
195 windowInfoObj.AttachTo(*windowInfo);
196 // Translate param: client; type: refptr_same_byref
197 CefRefPtr<CefClient> clientPtr;
198 if (client && *client)
199 clientPtr = CefClientCppToC::Unwrap(*client);
200 CefClient* clientOrig = clientPtr.get();
201 // Translate param: settings; type: struct_byref
202 CefBrowserSettings settingsObj;
203 if (settings)
204 settingsObj.AttachTo(*settings);
205
206 // Execute
207 bool _retval = CefExtensionHandlerCppToC::Get(self)->OnBeforeBrowser(
208 CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
209 CefBrowserCToCpp::Wrap(active_browser), index, CefString(url),
210 active ? true : false, windowInfoObj, clientPtr, settingsObj);
211
212 // Restore param: windowInfo; type: struct_byref
213 if (windowInfo)
214 windowInfoObj.DetachTo(*windowInfo);
215 // Restore param: client; type: refptr_same_byref
216 if (client) {
217 if (clientPtr.get()) {
218 if (clientPtr.get() != clientOrig) {
219 *client = CefClientCppToC::Wrap(clientPtr);
220 }
221 } else {
222 *client = nullptr;
223 }
224 }
225 // Restore param: settings; type: struct_byref
226 if (settings)
227 settingsObj.DetachTo(*settings);
228
229 // Return type: bool
230 return _retval;
231 }
232
233 cef_browser_t* CEF_CALLBACK
extension_handler_get_active_browser(struct _cef_extension_handler_t * self,cef_extension_t * extension,cef_browser_t * browser,int include_incognito)234 extension_handler_get_active_browser(struct _cef_extension_handler_t* self,
235 cef_extension_t* extension,
236 cef_browser_t* browser,
237 int include_incognito) {
238 shutdown_checker::AssertNotShutdown();
239
240 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
241
242 DCHECK(self);
243 if (!self)
244 return NULL;
245 // Verify param: extension; type: refptr_diff
246 DCHECK(extension);
247 if (!extension)
248 return NULL;
249 // Verify param: browser; type: refptr_diff
250 DCHECK(browser);
251 if (!browser)
252 return NULL;
253
254 // Execute
255 CefRefPtr<CefBrowser> _retval =
256 CefExtensionHandlerCppToC::Get(self)->GetActiveBrowser(
257 CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
258 include_incognito ? true : false);
259
260 // Return type: refptr_diff
261 return CefBrowserCToCpp::Unwrap(_retval);
262 }
263
264 int CEF_CALLBACK
extension_handler_can_access_browser(struct _cef_extension_handler_t * self,cef_extension_t * extension,cef_browser_t * browser,int include_incognito,cef_browser_t * target_browser)265 extension_handler_can_access_browser(struct _cef_extension_handler_t* self,
266 cef_extension_t* extension,
267 cef_browser_t* browser,
268 int include_incognito,
269 cef_browser_t* target_browser) {
270 shutdown_checker::AssertNotShutdown();
271
272 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
273
274 DCHECK(self);
275 if (!self)
276 return 0;
277 // Verify param: extension; type: refptr_diff
278 DCHECK(extension);
279 if (!extension)
280 return 0;
281 // Verify param: browser; type: refptr_diff
282 DCHECK(browser);
283 if (!browser)
284 return 0;
285 // Verify param: target_browser; type: refptr_diff
286 DCHECK(target_browser);
287 if (!target_browser)
288 return 0;
289
290 // Execute
291 bool _retval = CefExtensionHandlerCppToC::Get(self)->CanAccessBrowser(
292 CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
293 include_incognito ? true : false, CefBrowserCToCpp::Wrap(target_browser));
294
295 // Return type: bool
296 return _retval;
297 }
298
extension_handler_get_extension_resource(struct _cef_extension_handler_t * self,cef_extension_t * extension,cef_browser_t * browser,const cef_string_t * file,cef_get_extension_resource_callback_t * callback)299 int CEF_CALLBACK extension_handler_get_extension_resource(
300 struct _cef_extension_handler_t* self,
301 cef_extension_t* extension,
302 cef_browser_t* browser,
303 const cef_string_t* file,
304 cef_get_extension_resource_callback_t* callback) {
305 shutdown_checker::AssertNotShutdown();
306
307 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
308
309 DCHECK(self);
310 if (!self)
311 return 0;
312 // Verify param: extension; type: refptr_diff
313 DCHECK(extension);
314 if (!extension)
315 return 0;
316 // Verify param: browser; type: refptr_diff
317 DCHECK(browser);
318 if (!browser)
319 return 0;
320 // Verify param: file; type: string_byref_const
321 DCHECK(file);
322 if (!file)
323 return 0;
324 // Verify param: callback; type: refptr_diff
325 DCHECK(callback);
326 if (!callback)
327 return 0;
328
329 // Execute
330 bool _retval = CefExtensionHandlerCppToC::Get(self)->GetExtensionResource(
331 CefExtensionCToCpp::Wrap(extension), CefBrowserCToCpp::Wrap(browser),
332 CefString(file), CefGetExtensionResourceCallbackCToCpp::Wrap(callback));
333
334 // Return type: bool
335 return _retval;
336 }
337
338 } // namespace
339
340 // CONSTRUCTOR - Do not edit by hand.
341
CefExtensionHandlerCppToC()342 CefExtensionHandlerCppToC::CefExtensionHandlerCppToC() {
343 GetStruct()->on_extension_load_failed =
344 extension_handler_on_extension_load_failed;
345 GetStruct()->on_extension_loaded = extension_handler_on_extension_loaded;
346 GetStruct()->on_extension_unloaded = extension_handler_on_extension_unloaded;
347 GetStruct()->on_before_background_browser =
348 extension_handler_on_before_background_browser;
349 GetStruct()->on_before_browser = extension_handler_on_before_browser;
350 GetStruct()->get_active_browser = extension_handler_get_active_browser;
351 GetStruct()->can_access_browser = extension_handler_can_access_browser;
352 GetStruct()->get_extension_resource =
353 extension_handler_get_extension_resource;
354 }
355
356 // DESTRUCTOR - Do not edit by hand.
357
~CefExtensionHandlerCppToC()358 CefExtensionHandlerCppToC::~CefExtensionHandlerCppToC() {
359 shutdown_checker::AssertNotShutdown();
360 }
361
362 template <>
363 CefRefPtr<CefExtensionHandler> CefCppToCRefCounted<
364 CefExtensionHandlerCppToC,
365 CefExtensionHandler,
UnwrapDerived(CefWrapperType type,cef_extension_handler_t * s)366 cef_extension_handler_t>::UnwrapDerived(CefWrapperType type,
367 cef_extension_handler_t* s) {
368 NOTREACHED() << "Unexpected class type: " << type;
369 return nullptr;
370 }
371
372 template <>
373 CefWrapperType CefCppToCRefCounted<CefExtensionHandlerCppToC,
374 CefExtensionHandler,
375 cef_extension_handler_t>::kWrapperType =
376 WT_EXTENSION_HANDLER;
377