objc2_web_kit/generated/WKWebExtensionControllerDelegate.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_protocol!(
11 /// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontrollerdelegate?language=objc)
12 pub unsafe trait WKWebExtensionControllerDelegate:
13 NSObjectProtocol + MainThreadOnly
14 {
15 #[cfg(all(
16 feature = "WKWebExtensionContext",
17 feature = "WKWebExtensionController",
18 feature = "WKWebExtensionWindow"
19 ))]
20 /// Called when an extension context requests the list of ordered open windows.
21 ///
22 /// Parameter `controller`: The web extension controller that is managing the extension.
23 ///
24 /// Parameter `extensionContext`: The context in which the web extension is running.
25 ///
26 /// Returns: The array of ordered open windows.
27 ///
28 /// This method should be implemented by the app to provide the extension with the ordered open windows. Depending on your
29 /// app's requirements, you may return different windows for each extension or the same windows for all extensions. The first window in the returned
30 /// array must correspond to the currently focused window and match the result of ``webExtensionController:focusedWindowForExtensionContext:``.
31 /// If ``webExtensionController:focusedWindowForExtensionContext:`` returns `nil`, indicating that no window has focus or the focused
32 /// window is not visible to the extension, the first window in the list returned by this method will be considered the presumed focused window. An empty result
33 /// indicates no open windows are available for the extension. Defaults to an empty array if not implemented.
34 ///
35 /// See also: webExtensionController:focusedWindowForExtensionContext:
36 #[optional]
37 #[unsafe(method(webExtensionController:openWindowsForExtensionContext:))]
38 #[unsafe(method_family = none)]
39 unsafe fn webExtensionController_openWindowsForExtensionContext(
40 &self,
41 controller: &WKWebExtensionController,
42 extension_context: &WKWebExtensionContext,
43 ) -> Retained<NSArray<ProtocolObject<dyn WKWebExtensionWindow>>>;
44
45 #[cfg(all(
46 feature = "WKWebExtensionContext",
47 feature = "WKWebExtensionController",
48 feature = "WKWebExtensionWindow"
49 ))]
50 /// Called when an extension context requests the currently focused window.
51 ///
52 /// Parameter `controller`: The web extension controller that is managing the extension.
53 ///
54 /// Parameter `extensionContext`: The context in which the web extension is running.
55 ///
56 /// Returns: The window that is currently focused, or `nil` if no window is focused or the focused window is not visible to the extension.
57 ///
58 /// This method can be optionally implemented by the app to designate the window currently in focus to the extension.
59 /// If not implemented, the first window in the result of ``webExtensionController:openWindowsForExtensionContext:`` is used.
60 ///
61 /// See also: webExtensionController:openWindowsForExtensionContext:
62 #[optional]
63 #[unsafe(method(webExtensionController:focusedWindowForExtensionContext:))]
64 #[unsafe(method_family = none)]
65 unsafe fn webExtensionController_focusedWindowForExtensionContext(
66 &self,
67 controller: &WKWebExtensionController,
68 extension_context: &WKWebExtensionContext,
69 ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionWindow>>>;
70
71 #[cfg(all(
72 feature = "WKWebExtensionContext",
73 feature = "WKWebExtensionController",
74 feature = "WKWebExtensionWindow",
75 feature = "WKWebExtensionWindowConfiguration",
76 feature = "block2"
77 ))]
78 /// Called when an extension context requests a new window to be opened.
79 ///
80 /// Parameter `controller`: The web extension controller that is managing the extension.
81 ///
82 /// Parameter `configuration`: The configuration specifying how the new window should be created.
83 ///
84 /// Parameter `extensionContext`: The context in which the web extension is running.
85 ///
86 /// Parameter `completionHandler`: A block to be called with the newly created window or
87 /// `nil`if the window wasn't created. An error should be
88 /// provided if any errors occurred.
89 ///
90 /// This method should be implemented by the app to handle requests to open new windows. The app can decide how to handle the
91 /// process based on the provided configuration and existing windows. Once handled, the app should call the completion handler with the opened window
92 /// or `nil` if the request was declined or failed. If not implemented, the extension will be unable to open new windows.
93 #[optional]
94 #[unsafe(method(webExtensionController:openNewWindowUsingConfiguration:forExtensionContext:completionHandler:))]
95 #[unsafe(method_family = none)]
96 unsafe fn webExtensionController_openNewWindowUsingConfiguration_forExtensionContext_completionHandler(
97 &self,
98 controller: &WKWebExtensionController,
99 configuration: &WKWebExtensionWindowConfiguration,
100 extension_context: &WKWebExtensionContext,
101 completion_handler: &block2::DynBlock<
102 dyn Fn(*mut ProtocolObject<dyn WKWebExtensionWindow>, *mut NSError),
103 >,
104 );
105
106 #[cfg(all(
107 feature = "WKWebExtensionContext",
108 feature = "WKWebExtensionController",
109 feature = "WKWebExtensionTab",
110 feature = "WKWebExtensionTabConfiguration",
111 feature = "block2"
112 ))]
113 /// Called when an extension context requests a new tab to be opened.
114 ///
115 /// Parameter `controller`: The web extension controller that is managing the extension.
116 ///
117 /// Parameter `configuration`: The configuration specifying how the new tab should be created.
118 ///
119 /// Parameter `extensionContext`: The context in which the web extension is running.
120 ///
121 /// Parameter `completionHandler`: A block to be called with the newly created tab or
122 /// `nil`if the tab wasn't created. An error should be
123 /// provided if any errors occurred.
124 ///
125 /// This method should be implemented by the app to handle requests to open new tabs. The app can decide how to handle the
126 /// process based on the provided configuration and existing tabs. Once handled, the app should call the completion handler with the opened tab
127 /// or `nil` if the request was declined or failed. If not implemented, the extension will be unable to open new tabs.
128 #[optional]
129 #[unsafe(method(webExtensionController:openNewTabUsingConfiguration:forExtensionContext:completionHandler:))]
130 #[unsafe(method_family = none)]
131 unsafe fn webExtensionController_openNewTabUsingConfiguration_forExtensionContext_completionHandler(
132 &self,
133 controller: &WKWebExtensionController,
134 configuration: &WKWebExtensionTabConfiguration,
135 extension_context: &WKWebExtensionContext,
136 completion_handler: &block2::DynBlock<
137 dyn Fn(*mut ProtocolObject<dyn WKWebExtensionTab>, *mut NSError),
138 >,
139 );
140
141 #[cfg(all(
142 feature = "WKWebExtensionContext",
143 feature = "WKWebExtensionController",
144 feature = "block2"
145 ))]
146 /// Called when an extension context requests its options page to be opened.
147 ///
148 /// Parameter `controller`: The web extension controller that is managing the extension.
149 ///
150 /// Parameter `extensionContext`: The context in which the web extension is running.
151 ///
152 /// Parameter `completionHandler`: A block to be called once the options page has been displayed or with an error if the page could not be shown.
153 ///
154 /// This method should be implemented by the app to handle requests to display the extension's options page. The app can decide
155 /// how and where to display the options page (e.g., in a new tab or a separate window). The app should call the completion handler once the options
156 /// page is visible to the user, or with an error if the operation was declined or failed. If not implemented, the options page will be opened in a new tab
157 /// using the ``webExtensionController:openNewTabUsingConfiguration:forExtensionContext:completionHandler:`` delegate method.
158 #[optional]
159 #[unsafe(method(webExtensionController:openOptionsPageForExtensionContext:completionHandler:))]
160 #[unsafe(method_family = none)]
161 unsafe fn webExtensionController_openOptionsPageForExtensionContext_completionHandler(
162 &self,
163 controller: &WKWebExtensionController,
164 extension_context: &WKWebExtensionContext,
165 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
166 );
167
168 #[cfg(all(
169 feature = "WKWebExtensionContext",
170 feature = "WKWebExtensionController",
171 feature = "WKWebExtensionPermission",
172 feature = "WKWebExtensionTab",
173 feature = "block2"
174 ))]
175 /// Called when an extension context requests permissions.
176 ///
177 /// Parameter `controller`: The web extension controller that is managing the extension.
178 ///
179 /// Parameter `permissions`: The set of permissions being requested by the extension.
180 ///
181 /// Parameter `tab`: The tab in which the extension is running, or
182 /// `nil`if the request is not specific to a tab.
183 ///
184 /// Parameter `extensionContext`: The context in which the web extension is running.
185 ///
186 /// Parameter `completionHandler`: A block to be called with the set of allowed permissions and an optional expiration date.
187 ///
188 /// This method should be implemented by the app to prompt the user for permission and call the completion handler with the
189 /// set of permissions that were granted and an optional expiration date. If not implemented or the completion handler is not called within a reasonable
190 /// amount of time, the request is assumed to have been denied. The expiration date can be used to specify when the permissions expire. If `nil`,
191 /// permissions are assumed to not expire.
192 #[optional]
193 #[unsafe(method(webExtensionController:promptForPermissions:inTab:forExtensionContext:completionHandler:))]
194 #[unsafe(method_family = none)]
195 unsafe fn webExtensionController_promptForPermissions_inTab_forExtensionContext_completionHandler(
196 &self,
197 controller: &WKWebExtensionController,
198 permissions: &NSSet<WKWebExtensionPermission>,
199 tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
200 extension_context: &WKWebExtensionContext,
201 completion_handler: &block2::DynBlock<
202 dyn Fn(NonNull<NSSet<WKWebExtensionPermission>>, *mut NSDate),
203 >,
204 );
205
206 #[cfg(all(
207 feature = "WKWebExtensionContext",
208 feature = "WKWebExtensionController",
209 feature = "WKWebExtensionTab",
210 feature = "block2"
211 ))]
212 /// Called when an extension context requests access to a set of URLs.
213 ///
214 /// Parameter `controller`: The web extension controller that is managing the extension.
215 ///
216 /// Parameter `urls`: The set of URLs that the extension is requesting access to.
217 ///
218 /// Parameter `tab`: The tab in which the extension is running, or
219 /// `nil`if the request is not specific to a tab.
220 ///
221 /// Parameter `extensionContext`: The context in which the web extension is running.
222 ///
223 /// Parameter `completionHandler`: A block to be called with the set of allowed URLs and an optional expiration date.
224 ///
225 /// This method should be implemented by the app to prompt the user for permission and call the completion handler with the
226 /// set of URLs that were granted access to and an optional expiration date. If not implemented or the completion handler is not called within a
227 /// reasonable amount of time, the request is assumed to have been denied. The expiration date can be used to specify when the URLs expire.
228 /// If `nil`, URLs are assumed to not expire.
229 #[optional]
230 #[unsafe(method(webExtensionController:promptForPermissionToAccessURLs:inTab:forExtensionContext:completionHandler:))]
231 #[unsafe(method_family = none)]
232 unsafe fn webExtensionController_promptForPermissionToAccessURLs_inTab_forExtensionContext_completionHandler(
233 &self,
234 controller: &WKWebExtensionController,
235 urls: &NSSet<NSURL>,
236 tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
237 extension_context: &WKWebExtensionContext,
238 completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSSet<NSURL>>, *mut NSDate)>,
239 );
240
241 #[cfg(all(
242 feature = "WKWebExtensionContext",
243 feature = "WKWebExtensionController",
244 feature = "WKWebExtensionMatchPattern",
245 feature = "WKWebExtensionTab",
246 feature = "block2"
247 ))]
248 /// Called when an extension context requests access to a set of match patterns.
249 ///
250 /// Parameter `controller`: The web extension controller that is managing the extension.
251 ///
252 /// Parameter `matchPatterns`: The set of match patterns that the extension is requesting access to.
253 ///
254 /// Parameter `tab`: The tab in which the extension is running, or
255 /// `nil`if the request is not specific to a tab.
256 ///
257 /// Parameter `extensionContext`: The context in which the web extension is running.
258 ///
259 /// Parameter `completionHandler`: A block to be called with the set of allowed match patterns and an optional expiration date.
260 ///
261 /// This method should be implemented by the app to prompt the user for permission and call the completion handler with the
262 /// set of match patterns that were granted access to and an optional expiration date. If not implemented or the completion handler is not called
263 /// within a reasonable amount of time, the request is assumed to have been denied. The expiration date can be used to specify when the match
264 /// patterns expire. If `nil`, match patterns are assumed to not expire.
265 #[optional]
266 #[unsafe(method(webExtensionController:promptForPermissionMatchPatterns:inTab:forExtensionContext:completionHandler:))]
267 #[unsafe(method_family = none)]
268 unsafe fn webExtensionController_promptForPermissionMatchPatterns_inTab_forExtensionContext_completionHandler(
269 &self,
270 controller: &WKWebExtensionController,
271 match_patterns: &NSSet<WKWebExtensionMatchPattern>,
272 tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
273 extension_context: &WKWebExtensionContext,
274 completion_handler: &block2::DynBlock<
275 dyn Fn(NonNull<NSSet<WKWebExtensionMatchPattern>>, *mut NSDate),
276 >,
277 );
278
279 #[cfg(all(
280 feature = "WKWebExtensionAction",
281 feature = "WKWebExtensionContext",
282 feature = "WKWebExtensionController"
283 ))]
284 /// Called when an action's properties are updated.
285 ///
286 /// Parameter `controller`: The web extension controller initiating the request.
287 ///
288 /// Parameter `action`: The web extension action whose properties are updated.
289 ///
290 /// Parameter `context`: The context within which the web extension is running.
291 ///
292 /// This method is called when an action's properties are updated and should be reflected in the app's user interface.
293 /// The app should ensure that any visible changes, such as icons and labels, are updated accordingly.
294 #[optional]
295 #[unsafe(method(webExtensionController:didUpdateAction:forExtensionContext:))]
296 #[unsafe(method_family = none)]
297 unsafe fn webExtensionController_didUpdateAction_forExtensionContext(
298 &self,
299 controller: &WKWebExtensionController,
300 action: &WKWebExtensionAction,
301 context: &WKWebExtensionContext,
302 );
303
304 #[cfg(all(
305 feature = "WKWebExtensionAction",
306 feature = "WKWebExtensionContext",
307 feature = "WKWebExtensionController",
308 feature = "block2"
309 ))]
310 /// Called when a popup is requested to be displayed for a specific action.
311 ///
312 /// Parameter `controller`: The web extension controller initiating the request.
313 ///
314 /// Parameter `action`: The action for which the popup is requested.
315 ///
316 /// Parameter `context`: The context within which the web extension is running.
317 ///
318 /// Parameter `completionHandler`: A block to be called once the popup display operation is completed.
319 ///
320 /// This method is called in response to the extension's scripts or when invoking ``performActionForTab:`` if the action has a popup.
321 /// The associated tab, if applicable, can be located through the ``associatedTab`` property of the ``action`` parameter. This delegate method is
322 /// called when the web view for the popup is fully loaded and ready to display. Implementing this method is needed if the app intends to support
323 /// programmatically showing the popup by the extension, although it is recommended for handling both programmatic and user-initiated cases.
324 #[optional]
325 #[unsafe(method(webExtensionController:presentPopupForAction:forExtensionContext:completionHandler:))]
326 #[unsafe(method_family = none)]
327 unsafe fn webExtensionController_presentPopupForAction_forExtensionContext_completionHandler(
328 &self,
329 controller: &WKWebExtensionController,
330 action: &WKWebExtensionAction,
331 context: &WKWebExtensionContext,
332 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
333 );
334
335 #[cfg(all(
336 feature = "WKWebExtensionContext",
337 feature = "WKWebExtensionController",
338 feature = "block2"
339 ))]
340 /// Called when an extension context wants to send a one-time message to an application.
341 ///
342 /// Parameter `controller`: The web extension controller that is managing the extension.
343 ///
344 /// Parameter `message`: The message to be sent.
345 ///
346 /// Parameter `applicationIdentifier`: The unique identifier for the application, or
347 /// `nil`if none was specified.
348 ///
349 /// Parameter `extensionContext`: The context in which the web extension is running.
350 ///
351 /// Parameter `replyHandler`: A block to be called with a JSON-serializable reply message or an error.
352 ///
353 /// This method should be implemented by the app to handle one-off messages to applications.
354 /// If not implemented, the default behavior is to pass the message to the app extension handler within the extension's bundle,
355 /// if the extension was loaded from an app extension bundle; otherwise, no action is performed if not implemented.
356 ///
357 /// Note: The reply message must be JSON-serializable according to ``NSJSONSerialization``.
358 ///
359 /// # Safety
360 ///
361 /// `message` should be of the correct type.
362 #[optional]
363 #[unsafe(method(webExtensionController:sendMessage:toApplicationWithIdentifier:forExtensionContext:replyHandler:))]
364 #[unsafe(method_family = none)]
365 unsafe fn webExtensionController_sendMessage_toApplicationWithIdentifier_forExtensionContext_replyHandler(
366 &self,
367 controller: &WKWebExtensionController,
368 message: &AnyObject,
369 application_identifier: Option<&NSString>,
370 extension_context: &WKWebExtensionContext,
371 reply_handler: &block2::DynBlock<dyn Fn(*mut AnyObject, *mut NSError)>,
372 );
373
374 #[cfg(all(
375 feature = "WKWebExtensionContext",
376 feature = "WKWebExtensionController",
377 feature = "WKWebExtensionMessagePort",
378 feature = "block2"
379 ))]
380 /// Called when an extension context wants to establish a persistent connection to an application.
381 ///
382 /// Parameter `controller`: The web extension controller that is managing the extension.
383 ///
384 /// Parameter `extensionContext`: The context in which the web extension is running.
385 ///
386 /// Parameter `port`: A port object for handling the message exchange.
387 ///
388 /// Parameter `completionHandler`: A block to be called when the connection is ready to use, taking an optional error.
389 /// If the connection is successfully established, the error should be
390 /// `nil.`
391 /// This method should be implemented by the app to handle establishing connections to applications.
392 /// The provided ``WKWebExtensionPort`` object can be used to handle message sending, receiving, and disconnection.
393 /// You should retain the port object for as long as the connection remains active. Releasing the port will disconnect it.
394 /// If not implemented, the default behavior is to pass the messages to the app extension handler within the extension's bundle,
395 /// if the extension was loaded from an app extension bundle; otherwise, no action is performed if not implemented.
396 #[optional]
397 #[unsafe(method(webExtensionController:connectUsingMessagePort:forExtensionContext:completionHandler:))]
398 #[unsafe(method_family = none)]
399 unsafe fn webExtensionController_connectUsingMessagePort_forExtensionContext_completionHandler(
400 &self,
401 controller: &WKWebExtensionController,
402 port: &WKWebExtensionMessagePort,
403 extension_context: &WKWebExtensionContext,
404 completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
405 );
406 }
407);