objc2_web_kit/generated/WKWebExtensionController.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_class!(
11 /// A ``WKWebExtensionController`` object manages a set of loaded extension contexts.
12 ///
13 /// You can have one or more extension controller instances, allowing different parts of the app to use different sets of extensions.
14 /// A controller is associated with ``WKWebView`` via the ``webExtensionController`` property on ``WKWebViewConfiguration``.
15 ///
16 /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontroller?language=objc)
17 #[unsafe(super(NSObject))]
18 #[thread_kind = MainThreadOnly]
19 #[derive(Debug, PartialEq, Eq, Hash)]
20 pub struct WKWebExtensionController;
21);
22
23extern_conformance!(
24 unsafe impl NSObjectProtocol for WKWebExtensionController {}
25);
26
27impl WKWebExtensionController {
28 extern_methods!(
29 /// Returns a web extension controller initialized with the default configuration.
30 ///
31 /// Returns: An initialized web extension controller, or nil if the object could not be initialized.
32 ///
33 /// This is a designated initializer. You can use ``initWithConfiguration:`` to
34 /// initialize an instance with a configuration.
35 ///
36 /// See also: initWithConfiguration:
37 #[unsafe(method(init))]
38 #[unsafe(method_family = init)]
39 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
40
41 #[cfg(feature = "WKWebExtensionControllerConfiguration")]
42 /// Returns a web extension controller initialized with the specified configuration.
43 ///
44 /// Parameter `configuration`: The configuration for the new web extension controller.
45 ///
46 /// Returns: An initialized web extension controller, or nil if the object could not be initialized.
47 ///
48 /// This is a designated initializer. You can use ``init:`` to initialize an
49 /// instance with the default configuration. The initializer copies the specified configuration, so mutating
50 /// the configuration after invoking the initializer has no effect on the web extension controller.
51 ///
52 /// See also: init
53 #[unsafe(method(initWithConfiguration:))]
54 #[unsafe(method_family = init)]
55 pub unsafe fn initWithConfiguration(
56 this: Allocated<Self>,
57 configuration: &WKWebExtensionControllerConfiguration,
58 ) -> Retained<Self>;
59
60 #[cfg(feature = "WKWebExtensionControllerDelegate")]
61 /// The extension controller delegate.
62 #[unsafe(method(delegate))]
63 #[unsafe(method_family = none)]
64 pub unsafe fn delegate(
65 &self,
66 ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionControllerDelegate>>>;
67
68 #[cfg(feature = "WKWebExtensionControllerDelegate")]
69 /// This is a [weak property][objc2::topics::weak_property].
70 /// Setter for [`delegate`][Self::delegate].
71 #[unsafe(method(setDelegate:))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn setDelegate(
74 &self,
75 delegate: Option<&ProtocolObject<dyn WKWebExtensionControllerDelegate>>,
76 );
77
78 #[cfg(feature = "WKWebExtensionControllerConfiguration")]
79 /// A copy of the configuration with which the web extension controller was initialized.
80 ///
81 /// Mutating the configuration has no effect on the web extension controller.
82 #[unsafe(method(configuration))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn configuration(&self) -> Retained<WKWebExtensionControllerConfiguration>;
85
86 #[cfg(feature = "WKWebExtensionContext")]
87 /// Loads the specified extension context.
88 ///
89 /// Causes the context to start, loading any background content, and injecting any content into relevant tabs.
90 ///
91 /// Parameter `error`: Set to
92 /// `nil`or an
93 /// `NSError`instance if an error occurred.
94 ///
95 /// Returns: A Boolean value indicating if the context was successfully loaded.
96 ///
97 /// See also: loadExtensionContext:
98 #[unsafe(method(loadExtensionContext:error:_))]
99 #[unsafe(method_family = none)]
100 pub unsafe fn loadExtensionContext_error(
101 &self,
102 extension_context: &WKWebExtensionContext,
103 ) -> Result<(), Retained<NSError>>;
104
105 #[cfg(feature = "WKWebExtensionContext")]
106 /// Unloads the specified extension context.
107 ///
108 /// Causes the context to stop running.
109 ///
110 /// Parameter `error`: Set to
111 /// `nil`or an
112 /// `NSError`instance if an error occurred.
113 ///
114 /// Returns: A Boolean value indicating if the context was successfully unloaded.
115 ///
116 /// See also: unloadExtensionContext:
117 #[unsafe(method(unloadExtensionContext:error:_))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn unloadExtensionContext_error(
120 &self,
121 extension_context: &WKWebExtensionContext,
122 ) -> Result<(), Retained<NSError>>;
123
124 #[cfg(all(feature = "WKWebExtension", feature = "WKWebExtensionContext"))]
125 /// Returns a loaded extension context for the specified extension.
126 ///
127 /// Parameter `extension`: An extension to lookup.
128 ///
129 /// Returns: An extension context or `nil` if no match was found.
130 ///
131 /// See also: extensions
132 #[unsafe(method(extensionContextForExtension:))]
133 #[unsafe(method_family = none)]
134 pub unsafe fn extensionContextForExtension(
135 &self,
136 extension: &WKWebExtension,
137 ) -> Option<Retained<WKWebExtensionContext>>;
138
139 #[cfg(feature = "WKWebExtensionContext")]
140 /// Returns a loaded extension context matching the specified URL.
141 ///
142 /// Parameter `URL`: The URL to lookup.
143 ///
144 /// Returns: An extension context or `nil` if no match was found.
145 ///
146 /// This method is useful for determining the extension context to use when about to navigate to an extension URL. For example,
147 /// you could use this method to retrieve the appropriate extension context and then use its ``webViewConfiguration`` property to configure a
148 /// web view for loading that URL.
149 #[unsafe(method(extensionContextForURL:))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn extensionContextForURL(
152 &self,
153 url: &NSURL,
154 ) -> Option<Retained<WKWebExtensionContext>>;
155
156 #[cfg(feature = "WKWebExtension")]
157 /// A set of all the currently loaded extensions.
158 ///
159 /// See also: extensionContexts
160 #[unsafe(method(extensions))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn extensions(&self) -> Retained<NSSet<WKWebExtension>>;
163
164 #[cfg(feature = "WKWebExtensionContext")]
165 /// A set of all the currently loaded extension contexts.
166 ///
167 /// See also: extensions
168 #[unsafe(method(extensionContexts))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn extensionContexts(&self) -> Retained<NSSet<WKWebExtensionContext>>;
171
172 #[cfg(feature = "WKWebExtensionDataType")]
173 /// Returns a set of all available extension data types.
174 #[unsafe(method(allExtensionDataTypes))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn allExtensionDataTypes(
177 mtm: MainThreadMarker,
178 ) -> Retained<NSSet<WKWebExtensionDataType>>;
179
180 #[cfg(all(
181 feature = "WKWebExtensionDataRecord",
182 feature = "WKWebExtensionDataType",
183 feature = "block2"
184 ))]
185 /// Fetches data records containing the given extension data types for all known extensions.
186 ///
187 /// Parameter `dataTypes`: The extension data types to fetch records for.
188 ///
189 /// Parameter `completionHandler`: A block to invoke when the data records have been fetched.
190 ///
191 /// Note: The extension does not need to be loaded to be included in the result.
192 #[unsafe(method(fetchDataRecordsOfTypes:completionHandler:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn fetchDataRecordsOfTypes_completionHandler(
195 &self,
196 data_types: &NSSet<WKWebExtensionDataType>,
197 completion_handler: &block2::DynBlock<
198 dyn Fn(NonNull<NSArray<WKWebExtensionDataRecord>>),
199 >,
200 );
201
202 #[cfg(all(
203 feature = "WKWebExtensionContext",
204 feature = "WKWebExtensionDataRecord",
205 feature = "WKWebExtensionDataType",
206 feature = "block2"
207 ))]
208 /// Fetches a data record containing the given extension data types for a specific known web extension context.
209 ///
210 /// Parameter `dataTypes`: The extension data types to fetch records for.
211 ///
212 /// Parameter `extensionContext`: The specific web extension context to fetch records for.
213 ///
214 /// Parameter `completionHandler`: A block to invoke when the data record has been fetched.
215 ///
216 /// Note: The extension does not need to be loaded to be included in the result.
217 #[unsafe(method(fetchDataRecordOfTypes:forExtensionContext:completionHandler:))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn fetchDataRecordOfTypes_forExtensionContext_completionHandler(
220 &self,
221 data_types: &NSSet<WKWebExtensionDataType>,
222 extension_context: &WKWebExtensionContext,
223 completion_handler: &block2::DynBlock<dyn Fn(*mut WKWebExtensionDataRecord)>,
224 );
225
226 #[cfg(all(
227 feature = "WKWebExtensionDataRecord",
228 feature = "WKWebExtensionDataType",
229 feature = "block2"
230 ))]
231 /// Removes extension data of the given types for the given data records.
232 ///
233 /// Parameter `dataTypes`: The extension data types that should be removed.
234 ///
235 /// Parameter `dataRecords`: The extension data records to delete data from.
236 ///
237 /// Parameter `completionHandler`: A block to invoke when the data has been removed.
238 #[unsafe(method(removeDataOfTypes:fromDataRecords:completionHandler:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn removeDataOfTypes_fromDataRecords_completionHandler(
241 &self,
242 data_types: &NSSet<WKWebExtensionDataType>,
243 data_records: &NSArray<WKWebExtensionDataRecord>,
244 completion_handler: &block2::DynBlock<dyn Fn()>,
245 );
246
247 #[cfg(feature = "WKWebExtensionWindow")]
248 /// Should be called by the app when a new window is opened to fire appropriate events with all loaded web extensions.
249 ///
250 /// Parameter `newWindow`: The newly opened window.
251 ///
252 /// This method informs all loaded extensions of the opening of a new window, ensuring consistent understanding across extensions.
253 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
254 ///
255 /// See also: didCloseWindow:
256 #[unsafe(method(didOpenWindow:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn didOpenWindow(&self, new_window: &ProtocolObject<dyn WKWebExtensionWindow>);
259
260 #[cfg(feature = "WKWebExtensionWindow")]
261 /// Should be called by the app when a window is closed to fire appropriate events with all loaded web extensions.
262 ///
263 /// Parameter `newWindow`: The window that was closed.
264 ///
265 /// This method informs all loaded extensions of the closure of a window, ensuring consistent understanding across extensions.
266 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
267 ///
268 /// See also: didOpenWindow:
269 #[unsafe(method(didCloseWindow:))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn didCloseWindow(
272 &self,
273 closed_window: &ProtocolObject<dyn WKWebExtensionWindow>,
274 );
275
276 #[cfg(feature = "WKWebExtensionWindow")]
277 /// Should be called by the app when a window gains focus to fire appropriate events with all loaded web extensions.
278 ///
279 /// Parameter `focusedWindow`: The window that gained focus, or
280 /// `nil`if no window has focus or a window has focus that is not visible to extensions.
281 ///
282 /// This method informs all loaded extensions of the focused window, ensuring consistent understanding across extensions.
283 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
284 #[unsafe(method(didFocusWindow:))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn didFocusWindow(
287 &self,
288 focused_window: Option<&ProtocolObject<dyn WKWebExtensionWindow>>,
289 );
290
291 #[cfg(feature = "WKWebExtensionTab")]
292 /// Should be called by the app when a new tab is opened to fire appropriate events with all loaded web extensions.
293 ///
294 /// Parameter `newTab`: The newly opened tab.
295 ///
296 /// This method informs all loaded extensions of the opening of a new tab, ensuring consistent understanding across extensions.
297 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
298 ///
299 /// See also: didCloseTab:
300 #[unsafe(method(didOpenTab:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn didOpenTab(&self, new_tab: &ProtocolObject<dyn WKWebExtensionTab>);
303
304 #[cfg(feature = "WKWebExtensionTab")]
305 /// Should be called by the app when a tab is closed to fire appropriate events with all loaded web extensions.
306 ///
307 /// Parameter `closedTab`: The tab that was closed.
308 ///
309 /// Parameter `windowIsClosing`: A boolean value indicating whether the window containing the tab is also closing.
310 ///
311 /// This method informs all loaded extensions of the closing of a tab, ensuring consistent understanding across extensions.
312 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
313 ///
314 /// See also: didOpenTab:
315 #[unsafe(method(didCloseTab:windowIsClosing:))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn didCloseTab_windowIsClosing(
318 &self,
319 closed_tab: &ProtocolObject<dyn WKWebExtensionTab>,
320 window_is_closing: bool,
321 );
322
323 #[cfg(feature = "WKWebExtensionTab")]
324 /// Should be called by the app when a tab is activated to notify all loaded web extensions.
325 ///
326 /// Parameter `activatedTab`: The tab that has become active.
327 ///
328 /// Parameter `previousTab`: The tab that was active before. This parameter can be
329 /// `nil`if there was no previously active tab.
330 ///
331 /// This method informs all loaded extensions of the tab activation, ensuring consistent state awareness across extensions.
332 /// If the intention is to inform only a specific extension, use the respective method on that extension's context instead.
333 #[unsafe(method(didActivateTab:previousActiveTab:))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn didActivateTab_previousActiveTab(
336 &self,
337 activated_tab: &ProtocolObject<dyn WKWebExtensionTab>,
338 previous_tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
339 );
340
341 #[cfg(feature = "WKWebExtensionTab")]
342 /// Should be called by the app when tabs are selected to fire appropriate events with all loaded web extensions.
343 ///
344 /// Parameter `selectedTabs`: The set of tabs that were selected.
345 ///
346 /// This method informs all loaded extensions that tabs have been selected, ensuring consistent understanding across extensions.
347 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
348 #[unsafe(method(didSelectTabs:))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn didSelectTabs(
351 &self,
352 selected_tabs: &NSArray<ProtocolObject<dyn WKWebExtensionTab>>,
353 );
354
355 #[cfg(feature = "WKWebExtensionTab")]
356 /// Should be called by the app when tabs are deselected to fire appropriate events with all loaded web extensions.
357 ///
358 /// Parameter `deselectedTabs`: The set of tabs that were deselected.
359 ///
360 /// This method informs all loaded extensions that tabs have been deselected, ensuring consistent understanding across extensions.
361 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
362 #[unsafe(method(didDeselectTabs:))]
363 #[unsafe(method_family = none)]
364 pub unsafe fn didDeselectTabs(
365 &self,
366 deselected_tabs: &NSArray<ProtocolObject<dyn WKWebExtensionTab>>,
367 );
368
369 #[cfg(all(feature = "WKWebExtensionTab", feature = "WKWebExtensionWindow"))]
370 /// Should be called by the app when a tab is moved to fire appropriate events with all loaded web extensions.
371 ///
372 /// Parameter `movedTab`: The tab that was moved.
373 ///
374 /// Parameter `index`: The old index of the tab within the window.
375 ///
376 /// Parameter `oldWindow`: The window that the tab was moved from, or
377 /// `nil`if the tab is moving from no open window.
378 ///
379 /// This method informs all loaded extensions of the movement of a tab, ensuring consistent understanding across extensions.
380 /// If the window is staying the same, the current window should be specified. If the intention is to inform only a specific extension,
381 /// use the respective method on that extension's context instead.
382 #[unsafe(method(didMoveTab:fromIndex:inWindow:))]
383 #[unsafe(method_family = none)]
384 pub unsafe fn didMoveTab_fromIndex_inWindow(
385 &self,
386 moved_tab: &ProtocolObject<dyn WKWebExtensionTab>,
387 index: NSUInteger,
388 old_window: Option<&ProtocolObject<dyn WKWebExtensionWindow>>,
389 );
390
391 #[cfg(feature = "WKWebExtensionTab")]
392 /// Should be called by the app when a tab is replaced by another tab to fire appropriate events with all loaded web extensions.
393 ///
394 /// Parameter `oldTab`: The tab that was replaced.
395 ///
396 /// Parameter `newTab`: The tab that replaced the old tab.
397 ///
398 /// This method informs all loaded extensions of the replacement of a tab, ensuring consistent understanding across extensions.
399 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
400 #[unsafe(method(didReplaceTab:withTab:))]
401 #[unsafe(method_family = none)]
402 pub unsafe fn didReplaceTab_withTab(
403 &self,
404 old_tab: &ProtocolObject<dyn WKWebExtensionTab>,
405 new_tab: &ProtocolObject<dyn WKWebExtensionTab>,
406 );
407
408 #[cfg(feature = "WKWebExtensionTab")]
409 /// Should be called by the app when the properties of a tab are changed to fire appropriate events with all loaded web extensions.
410 ///
411 /// Parameter `properties`: The properties of the tab that were changed.
412 ///
413 /// Parameter `changedTab`: The tab whose properties were changed.
414 ///
415 /// This method informs all loaded extensions of changes to tab properties, ensuring a unified understanding across extensions.
416 /// If the intention is to inform only a specific extension, you should use the respective method on that extension's context instead.
417 #[unsafe(method(didChangeTabProperties:forTab:))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn didChangeTabProperties_forTab(
420 &self,
421 properties: WKWebExtensionTabChangedProperties,
422 changed_tab: &ProtocolObject<dyn WKWebExtensionTab>,
423 );
424 );
425}
426
427/// Methods declared on superclass `NSObject`.
428impl WKWebExtensionController {
429 extern_methods!(
430 #[unsafe(method(new))]
431 #[unsafe(method_family = new)]
432 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
433 );
434}