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