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=befb9e9bd438e431bb55b7c67413d9d7a7b263f2$
13 //
14
15 #include "libcef_dll/ctocpp/extension_handler_ctocpp.h"
16 #include "libcef_dll/cpptoc/browser_cpptoc.h"
17 #include "libcef_dll/cpptoc/extension_cpptoc.h"
18 #include "libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h"
19 #include "libcef_dll/ctocpp/client_ctocpp.h"
20 #include "libcef_dll/shutdown_checker.h"
21
22 // VIRTUAL METHODS - Body may be edited by hand.
23
24 NO_SANITIZE("cfi-icall")
OnExtensionLoadFailed(cef_errorcode_t result)25 void CefExtensionHandlerCToCpp::OnExtensionLoadFailed(cef_errorcode_t result) {
26 shutdown_checker::AssertNotShutdown();
27
28 cef_extension_handler_t* _struct = GetStruct();
29 if (CEF_MEMBER_MISSING(_struct, on_extension_load_failed))
30 return;
31
32 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
33
34 // Execute
35 _struct->on_extension_load_failed(_struct, result);
36 }
37
38 NO_SANITIZE("cfi-icall")
OnExtensionLoaded(CefRefPtr<CefExtension> extension)39 void CefExtensionHandlerCToCpp::OnExtensionLoaded(
40 CefRefPtr<CefExtension> extension) {
41 shutdown_checker::AssertNotShutdown();
42
43 cef_extension_handler_t* _struct = GetStruct();
44 if (CEF_MEMBER_MISSING(_struct, on_extension_loaded))
45 return;
46
47 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
48
49 // Verify param: extension; type: refptr_diff
50 DCHECK(extension.get());
51 if (!extension.get())
52 return;
53
54 // Execute
55 _struct->on_extension_loaded(_struct, CefExtensionCppToC::Wrap(extension));
56 }
57
58 NO_SANITIZE("cfi-icall")
OnExtensionUnloaded(CefRefPtr<CefExtension> extension)59 void CefExtensionHandlerCToCpp::OnExtensionUnloaded(
60 CefRefPtr<CefExtension> extension) {
61 shutdown_checker::AssertNotShutdown();
62
63 cef_extension_handler_t* _struct = GetStruct();
64 if (CEF_MEMBER_MISSING(_struct, on_extension_unloaded))
65 return;
66
67 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
68
69 // Verify param: extension; type: refptr_diff
70 DCHECK(extension.get());
71 if (!extension.get())
72 return;
73
74 // Execute
75 _struct->on_extension_unloaded(_struct, CefExtensionCppToC::Wrap(extension));
76 }
77
78 NO_SANITIZE("cfi-icall")
OnBeforeBackgroundBrowser(CefRefPtr<CefExtension> extension,const CefString & url,CefRefPtr<CefClient> & client,CefBrowserSettings & settings)79 bool CefExtensionHandlerCToCpp::OnBeforeBackgroundBrowser(
80 CefRefPtr<CefExtension> extension,
81 const CefString& url,
82 CefRefPtr<CefClient>& client,
83 CefBrowserSettings& settings) {
84 shutdown_checker::AssertNotShutdown();
85
86 cef_extension_handler_t* _struct = GetStruct();
87 if (CEF_MEMBER_MISSING(_struct, on_before_background_browser))
88 return false;
89
90 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
91
92 // Verify param: extension; type: refptr_diff
93 DCHECK(extension.get());
94 if (!extension.get())
95 return false;
96 // Verify param: url; type: string_byref_const
97 DCHECK(!url.empty());
98 if (url.empty())
99 return false;
100
101 // Translate param: client; type: refptr_same_byref
102 cef_client_t* clientStruct = NULL;
103 if (client.get())
104 clientStruct = CefClientCToCpp::Unwrap(client);
105 cef_client_t* clientOrig = clientStruct;
106
107 // Execute
108 int _retval = _struct->on_before_background_browser(
109 _struct, CefExtensionCppToC::Wrap(extension), url.GetStruct(),
110 &clientStruct, &settings);
111
112 // Restore param:client; type: refptr_same_byref
113 if (clientStruct) {
114 if (clientStruct != clientOrig) {
115 client = CefClientCToCpp::Wrap(clientStruct);
116 }
117 } else {
118 client = nullptr;
119 }
120
121 // Return type: bool
122 return _retval ? true : false;
123 }
124
125 NO_SANITIZE("cfi-icall")
OnBeforeBrowser(CefRefPtr<CefExtension> extension,CefRefPtr<CefBrowser> browser,CefRefPtr<CefBrowser> active_browser,int index,const CefString & url,bool active,CefWindowInfo & windowInfo,CefRefPtr<CefClient> & client,CefBrowserSettings & settings)126 bool CefExtensionHandlerCToCpp::OnBeforeBrowser(
127 CefRefPtr<CefExtension> extension,
128 CefRefPtr<CefBrowser> browser,
129 CefRefPtr<CefBrowser> active_browser,
130 int index,
131 const CefString& url,
132 bool active,
133 CefWindowInfo& windowInfo,
134 CefRefPtr<CefClient>& client,
135 CefBrowserSettings& settings) {
136 shutdown_checker::AssertNotShutdown();
137
138 cef_extension_handler_t* _struct = GetStruct();
139 if (CEF_MEMBER_MISSING(_struct, on_before_browser))
140 return false;
141
142 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
143
144 // Verify param: extension; type: refptr_diff
145 DCHECK(extension.get());
146 if (!extension.get())
147 return false;
148 // Verify param: browser; type: refptr_diff
149 DCHECK(browser.get());
150 if (!browser.get())
151 return false;
152 // Verify param: active_browser; type: refptr_diff
153 DCHECK(active_browser.get());
154 if (!active_browser.get())
155 return false;
156 // Verify param: url; type: string_byref_const
157 DCHECK(!url.empty());
158 if (url.empty())
159 return false;
160
161 // Translate param: client; type: refptr_same_byref
162 cef_client_t* clientStruct = NULL;
163 if (client.get())
164 clientStruct = CefClientCToCpp::Unwrap(client);
165 cef_client_t* clientOrig = clientStruct;
166
167 // Execute
168 int _retval = _struct->on_before_browser(
169 _struct, CefExtensionCppToC::Wrap(extension),
170 CefBrowserCppToC::Wrap(browser), CefBrowserCppToC::Wrap(active_browser),
171 index, url.GetStruct(), active, &windowInfo, &clientStruct, &settings);
172
173 // Restore param:client; type: refptr_same_byref
174 if (clientStruct) {
175 if (clientStruct != clientOrig) {
176 client = CefClientCToCpp::Wrap(clientStruct);
177 }
178 } else {
179 client = nullptr;
180 }
181
182 // Return type: bool
183 return _retval ? true : false;
184 }
185
186 NO_SANITIZE("cfi-icall")
GetActiveBrowser(CefRefPtr<CefExtension> extension,CefRefPtr<CefBrowser> browser,bool include_incognito)187 CefRefPtr<CefBrowser> CefExtensionHandlerCToCpp::GetActiveBrowser(
188 CefRefPtr<CefExtension> extension,
189 CefRefPtr<CefBrowser> browser,
190 bool include_incognito) {
191 shutdown_checker::AssertNotShutdown();
192
193 cef_extension_handler_t* _struct = GetStruct();
194 if (CEF_MEMBER_MISSING(_struct, get_active_browser))
195 return nullptr;
196
197 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
198
199 // Verify param: extension; type: refptr_diff
200 DCHECK(extension.get());
201 if (!extension.get())
202 return nullptr;
203 // Verify param: browser; type: refptr_diff
204 DCHECK(browser.get());
205 if (!browser.get())
206 return nullptr;
207
208 // Execute
209 cef_browser_t* _retval = _struct->get_active_browser(
210 _struct, CefExtensionCppToC::Wrap(extension),
211 CefBrowserCppToC::Wrap(browser), include_incognito);
212
213 // Return type: refptr_diff
214 return CefBrowserCppToC::Unwrap(_retval);
215 }
216
217 NO_SANITIZE("cfi-icall")
CanAccessBrowser(CefRefPtr<CefExtension> extension,CefRefPtr<CefBrowser> browser,bool include_incognito,CefRefPtr<CefBrowser> target_browser)218 bool CefExtensionHandlerCToCpp::CanAccessBrowser(
219 CefRefPtr<CefExtension> extension,
220 CefRefPtr<CefBrowser> browser,
221 bool include_incognito,
222 CefRefPtr<CefBrowser> target_browser) {
223 shutdown_checker::AssertNotShutdown();
224
225 cef_extension_handler_t* _struct = GetStruct();
226 if (CEF_MEMBER_MISSING(_struct, can_access_browser))
227 return false;
228
229 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
230
231 // Verify param: extension; type: refptr_diff
232 DCHECK(extension.get());
233 if (!extension.get())
234 return false;
235 // Verify param: browser; type: refptr_diff
236 DCHECK(browser.get());
237 if (!browser.get())
238 return false;
239 // Verify param: target_browser; type: refptr_diff
240 DCHECK(target_browser.get());
241 if (!target_browser.get())
242 return false;
243
244 // Execute
245 int _retval = _struct->can_access_browser(
246 _struct, CefExtensionCppToC::Wrap(extension),
247 CefBrowserCppToC::Wrap(browser), include_incognito,
248 CefBrowserCppToC::Wrap(target_browser));
249
250 // Return type: bool
251 return _retval ? true : false;
252 }
253
254 NO_SANITIZE("cfi-icall")
GetExtensionResource(CefRefPtr<CefExtension> extension,CefRefPtr<CefBrowser> browser,const CefString & file,CefRefPtr<CefGetExtensionResourceCallback> callback)255 bool CefExtensionHandlerCToCpp::GetExtensionResource(
256 CefRefPtr<CefExtension> extension,
257 CefRefPtr<CefBrowser> browser,
258 const CefString& file,
259 CefRefPtr<CefGetExtensionResourceCallback> callback) {
260 shutdown_checker::AssertNotShutdown();
261
262 cef_extension_handler_t* _struct = GetStruct();
263 if (CEF_MEMBER_MISSING(_struct, get_extension_resource))
264 return false;
265
266 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
267
268 // Verify param: extension; type: refptr_diff
269 DCHECK(extension.get());
270 if (!extension.get())
271 return false;
272 // Verify param: browser; type: refptr_diff
273 DCHECK(browser.get());
274 if (!browser.get())
275 return false;
276 // Verify param: file; type: string_byref_const
277 DCHECK(!file.empty());
278 if (file.empty())
279 return false;
280 // Verify param: callback; type: refptr_diff
281 DCHECK(callback.get());
282 if (!callback.get())
283 return false;
284
285 // Execute
286 int _retval = _struct->get_extension_resource(
287 _struct, CefExtensionCppToC::Wrap(extension),
288 CefBrowserCppToC::Wrap(browser), file.GetStruct(),
289 CefGetExtensionResourceCallbackCppToC::Wrap(callback));
290
291 // Return type: bool
292 return _retval ? true : false;
293 }
294
295 // CONSTRUCTOR - Do not edit by hand.
296
CefExtensionHandlerCToCpp()297 CefExtensionHandlerCToCpp::CefExtensionHandlerCToCpp() {}
298
299 // DESTRUCTOR - Do not edit by hand.
300
~CefExtensionHandlerCToCpp()301 CefExtensionHandlerCToCpp::~CefExtensionHandlerCToCpp() {
302 shutdown_checker::AssertNotShutdown();
303 }
304
305 template <>
306 cef_extension_handler_t* CefCToCppRefCounted<
307 CefExtensionHandlerCToCpp,
308 CefExtensionHandler,
UnwrapDerived(CefWrapperType type,CefExtensionHandler * c)309 cef_extension_handler_t>::UnwrapDerived(CefWrapperType type,
310 CefExtensionHandler* c) {
311 NOTREACHED() << "Unexpected class type: " << type;
312 return nullptr;
313 }
314
315 template <>
316 CefWrapperType CefCToCppRefCounted<CefExtensionHandlerCToCpp,
317 CefExtensionHandler,
318 cef_extension_handler_t>::kWrapperType =
319 WT_EXTENSION_HANDLER;
320