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=f9e1fa4fa79e3b66d9d147fd0cdb14da459de85b$
13 //
14
15 #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
16 #include "libcef_dll/cpptoc/client_cpptoc.h"
17 #include "libcef_dll/ctocpp/browser_ctocpp.h"
18 #include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
19 #include "libcef_dll/ctocpp/frame_ctocpp.h"
20 #include "libcef_dll/shutdown_checker.h"
21
22 namespace {
23
24 // MEMBER FUNCTIONS - Body may be edited by hand.
25
life_span_handler_on_before_popup(struct _cef_life_span_handler_t * self,cef_browser_t * browser,cef_frame_t * frame,const cef_string_t * target_url,const cef_string_t * target_frame_name,cef_window_open_disposition_t target_disposition,int user_gesture,const struct _cef_popup_features_t * popupFeatures,cef_window_info_t * windowInfo,cef_client_t ** client,struct _cef_browser_settings_t * settings,struct _cef_dictionary_value_t ** extra_info,int * no_javascript_access)26 int CEF_CALLBACK life_span_handler_on_before_popup(
27 struct _cef_life_span_handler_t* self,
28 cef_browser_t* browser,
29 cef_frame_t* frame,
30 const cef_string_t* target_url,
31 const cef_string_t* target_frame_name,
32 cef_window_open_disposition_t target_disposition,
33 int user_gesture,
34 const struct _cef_popup_features_t* popupFeatures,
35 cef_window_info_t* windowInfo,
36 cef_client_t** client,
37 struct _cef_browser_settings_t* settings,
38 struct _cef_dictionary_value_t** extra_info,
39 int* no_javascript_access) {
40 shutdown_checker::AssertNotShutdown();
41
42 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
43
44 DCHECK(self);
45 if (!self)
46 return 0;
47 // Verify param: browser; type: refptr_diff
48 DCHECK(browser);
49 if (!browser)
50 return 0;
51 // Verify param: frame; type: refptr_diff
52 DCHECK(frame);
53 if (!frame)
54 return 0;
55 // Verify param: popupFeatures; type: struct_byref_const
56 DCHECK(popupFeatures);
57 if (!popupFeatures)
58 return 0;
59 // Verify param: windowInfo; type: struct_byref
60 DCHECK(windowInfo);
61 if (!windowInfo)
62 return 0;
63 // Verify param: client; type: refptr_same_byref
64 DCHECK(client);
65 if (!client)
66 return 0;
67 // Verify param: settings; type: struct_byref
68 DCHECK(settings);
69 if (!settings)
70 return 0;
71 // Verify param: extra_info; type: refptr_diff_byref
72 DCHECK(extra_info);
73 if (!extra_info)
74 return 0;
75 // Verify param: no_javascript_access; type: bool_byaddr
76 DCHECK(no_javascript_access);
77 if (!no_javascript_access)
78 return 0;
79 // Unverified params: target_url, target_frame_name
80
81 // Translate param: popupFeatures; type: struct_byref_const
82 CefPopupFeatures popupFeaturesObj;
83 if (popupFeatures)
84 popupFeaturesObj.Set(*popupFeatures, false);
85 // Translate param: windowInfo; type: struct_byref
86 CefWindowInfo windowInfoObj;
87 if (windowInfo)
88 windowInfoObj.AttachTo(*windowInfo);
89 // Translate param: client; type: refptr_same_byref
90 CefRefPtr<CefClient> clientPtr;
91 if (client && *client)
92 clientPtr = CefClientCppToC::Unwrap(*client);
93 CefClient* clientOrig = clientPtr.get();
94 // Translate param: settings; type: struct_byref
95 CefBrowserSettings settingsObj;
96 if (settings)
97 settingsObj.AttachTo(*settings);
98 // Translate param: extra_info; type: refptr_diff_byref
99 CefRefPtr<CefDictionaryValue> extra_infoPtr;
100 if (extra_info && *extra_info)
101 extra_infoPtr = CefDictionaryValueCToCpp::Wrap(*extra_info);
102 CefDictionaryValue* extra_infoOrig = extra_infoPtr.get();
103 // Translate param: no_javascript_access; type: bool_byaddr
104 bool no_javascript_accessBool =
105 (no_javascript_access && *no_javascript_access) ? true : false;
106
107 // Execute
108 bool _retval = CefLifeSpanHandlerCppToC::Get(self)->OnBeforePopup(
109 CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
110 CefString(target_url), CefString(target_frame_name), target_disposition,
111 user_gesture ? true : false, popupFeaturesObj, windowInfoObj, clientPtr,
112 settingsObj, extra_infoPtr, &no_javascript_accessBool);
113
114 // Restore param: windowInfo; type: struct_byref
115 if (windowInfo)
116 windowInfoObj.DetachTo(*windowInfo);
117 // Restore param: client; type: refptr_same_byref
118 if (client) {
119 if (clientPtr.get()) {
120 if (clientPtr.get() != clientOrig) {
121 *client = CefClientCppToC::Wrap(clientPtr);
122 }
123 } else {
124 *client = nullptr;
125 }
126 }
127 // Restore param: settings; type: struct_byref
128 if (settings)
129 settingsObj.DetachTo(*settings);
130 // Restore param: extra_info; type: refptr_diff_byref
131 if (extra_info) {
132 if (extra_infoPtr.get()) {
133 if (extra_infoPtr.get() != extra_infoOrig) {
134 *extra_info = CefDictionaryValueCToCpp::Unwrap(extra_infoPtr);
135 }
136 } else {
137 *extra_info = nullptr;
138 }
139 }
140 // Restore param: no_javascript_access; type: bool_byaddr
141 if (no_javascript_access)
142 *no_javascript_access = no_javascript_accessBool ? true : false;
143
144 // Return type: bool
145 return _retval;
146 }
147
148 void CEF_CALLBACK
life_span_handler_on_after_created(struct _cef_life_span_handler_t * self,cef_browser_t * browser)149 life_span_handler_on_after_created(struct _cef_life_span_handler_t* self,
150 cef_browser_t* browser) {
151 shutdown_checker::AssertNotShutdown();
152
153 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
154
155 DCHECK(self);
156 if (!self)
157 return;
158 // Verify param: browser; type: refptr_diff
159 DCHECK(browser);
160 if (!browser)
161 return;
162
163 // Execute
164 CefLifeSpanHandlerCppToC::Get(self)->OnAfterCreated(
165 CefBrowserCToCpp::Wrap(browser));
166 }
167
168 int CEF_CALLBACK
life_span_handler_do_close(struct _cef_life_span_handler_t * self,cef_browser_t * browser)169 life_span_handler_do_close(struct _cef_life_span_handler_t* self,
170 cef_browser_t* browser) {
171 shutdown_checker::AssertNotShutdown();
172
173 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
174
175 DCHECK(self);
176 if (!self)
177 return 0;
178 // Verify param: browser; type: refptr_diff
179 DCHECK(browser);
180 if (!browser)
181 return 0;
182
183 // Execute
184 bool _retval = CefLifeSpanHandlerCppToC::Get(self)->DoClose(
185 CefBrowserCToCpp::Wrap(browser));
186
187 // Return type: bool
188 return _retval;
189 }
190
191 void CEF_CALLBACK
life_span_handler_on_before_close(struct _cef_life_span_handler_t * self,cef_browser_t * browser)192 life_span_handler_on_before_close(struct _cef_life_span_handler_t* self,
193 cef_browser_t* browser) {
194 shutdown_checker::AssertNotShutdown();
195
196 // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
197
198 DCHECK(self);
199 if (!self)
200 return;
201 // Verify param: browser; type: refptr_diff
202 DCHECK(browser);
203 if (!browser)
204 return;
205
206 // Execute
207 CefLifeSpanHandlerCppToC::Get(self)->OnBeforeClose(
208 CefBrowserCToCpp::Wrap(browser));
209 }
210
211 } // namespace
212
213 // CONSTRUCTOR - Do not edit by hand.
214
CefLifeSpanHandlerCppToC()215 CefLifeSpanHandlerCppToC::CefLifeSpanHandlerCppToC() {
216 GetStruct()->on_before_popup = life_span_handler_on_before_popup;
217 GetStruct()->on_after_created = life_span_handler_on_after_created;
218 GetStruct()->do_close = life_span_handler_do_close;
219 GetStruct()->on_before_close = life_span_handler_on_before_close;
220 }
221
222 // DESTRUCTOR - Do not edit by hand.
223
~CefLifeSpanHandlerCppToC()224 CefLifeSpanHandlerCppToC::~CefLifeSpanHandlerCppToC() {
225 shutdown_checker::AssertNotShutdown();
226 }
227
228 template <>
229 CefRefPtr<CefLifeSpanHandler> CefCppToCRefCounted<
230 CefLifeSpanHandlerCppToC,
231 CefLifeSpanHandler,
UnwrapDerived(CefWrapperType type,cef_life_span_handler_t * s)232 cef_life_span_handler_t>::UnwrapDerived(CefWrapperType type,
233 cef_life_span_handler_t* s) {
234 NOTREACHED() << "Unexpected class type: " << type;
235 return nullptr;
236 }
237
238 template <>
239 CefWrapperType CefCppToCRefCounted<CefLifeSpanHandlerCppToC,
240 CefLifeSpanHandler,
241 cef_life_span_handler_t>::kWrapperType =
242 WT_LIFE_SPAN_HANDLER;
243