objc2_web_kit/generated/
WKWebExtensionTab.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::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// Constants used by ``WKWebExtensionController
16/// @
17/// /link and
18///
19/// ```text
20///  WKWebExtensionContext`` to indicate tab changes.
21///  @constant WKWebExtensionTabChangedPropertiesNone  Indicates nothing changed.
22///  @constant WKWebExtensionTabChangedPropertiesLoading  Indicates the loading state changed.
23///  @constant WKWebExtensionTabChangedPropertiesMuted  Indicates the muted state changed.
24///  @constant WKWebExtensionTabChangedPropertiesPinned  Indicates the pinned state changed.
25///  @constant WKWebExtensionTabChangedPropertiesPlayingAudio Indicates the audio playback state changed.
26///  @constant WKWebExtensionTabChangedPropertiesReaderMode  Indicates the reader mode state changed.
27///  @constant WKWebExtensionTabChangedPropertiesSize  Indicates the size changed.
28///  @constant WKWebExtensionTabChangedPropertiesTitle  Indicates the title changed.
29///  @constant WKWebExtensionTabChangedPropertiesURL  Indicates the URL changed.
30///  @constant WKWebExtensionTabChangedPropertiesZoomFactor  Indicates the zoom factor changed.
31///  
32///
33/// ```
34///
35/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensiontabchangedproperties?language=objc)
36// NS_OPTIONS
37#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct WKWebExtensionTabChangedProperties(pub NSUInteger);
40bitflags::bitflags! {
41    impl WKWebExtensionTabChangedProperties: NSUInteger {
42        #[doc(alias = "WKWebExtensionTabChangedPropertiesNone")]
43        const None = 0;
44        #[doc(alias = "WKWebExtensionTabChangedPropertiesLoading")]
45        const Loading = 1<<1;
46        #[doc(alias = "WKWebExtensionTabChangedPropertiesMuted")]
47        const Muted = 1<<2;
48        #[doc(alias = "WKWebExtensionTabChangedPropertiesPinned")]
49        const Pinned = 1<<3;
50        #[doc(alias = "WKWebExtensionTabChangedPropertiesPlayingAudio")]
51        const PlayingAudio = 1<<4;
52        #[doc(alias = "WKWebExtensionTabChangedPropertiesReaderMode")]
53        const ReaderMode = 1<<5;
54        #[doc(alias = "WKWebExtensionTabChangedPropertiesSize")]
55        const Size = 1<<6;
56        #[doc(alias = "WKWebExtensionTabChangedPropertiesTitle")]
57        const Title = 1<<7;
58        #[doc(alias = "WKWebExtensionTabChangedPropertiesURL")]
59        const URL = 1<<8;
60        #[doc(alias = "WKWebExtensionTabChangedPropertiesZoomFactor")]
61        const ZoomFactor = 1<<9;
62    }
63}
64
65unsafe impl Encode for WKWebExtensionTabChangedProperties {
66    const ENCODING: Encoding = NSUInteger::ENCODING;
67}
68
69unsafe impl RefEncode for WKWebExtensionTabChangedProperties {
70    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
71}
72
73extern_protocol!(
74    /// A class conforming to the ``WKWebExtensionTab`` protocol represents a tab to web extensions.
75    ///
76    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensiontab?language=objc)
77    pub unsafe trait WKWebExtensionTab: NSObjectProtocol + MainThreadOnly {
78        #[cfg(all(feature = "WKWebExtensionContext", feature = "WKWebExtensionWindow"))]
79        /// Called when the window containing the tab is needed.
80        ///
81        /// Parameter `context`: The context in which the web extension is running.
82        ///
83        /// Returns: The window containing the tab.
84        ///
85        /// Defaults to `nil` if not implemented.
86        #[optional]
87        #[unsafe(method(windowForWebExtensionContext:))]
88        #[unsafe(method_family = none)]
89        unsafe fn windowForWebExtensionContext(
90            &self,
91            context: &WKWebExtensionContext,
92        ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionWindow>>>;
93
94        #[cfg(feature = "WKWebExtensionContext")]
95        /// Called when the index of the tab in the window is needed.
96        ///
97        /// Parameter `context`: The context in which the web extension is running.
98        ///
99        /// Returns: The index of the tab in the window, or ``NSNotFound`` if the tab is not currently in a window.
100        ///
101        /// This method should be implemented for better performance. Defaults to the window's
102        /// ``tabsForWebExtensionContext:`` method to find the index if not implemented.
103        #[optional]
104        #[unsafe(method(indexInWindowForWebExtensionContext:))]
105        #[unsafe(method_family = none)]
106        unsafe fn indexInWindowForWebExtensionContext(
107            &self,
108            context: &WKWebExtensionContext,
109        ) -> NSUInteger;
110
111        #[cfg(feature = "WKWebExtensionContext")]
112        /// Called when the parent tab for the tab is needed.
113        ///
114        /// Parameter `context`: The context in which the web extension is running.
115        ///
116        /// Returns: The parent tab of the tab, if the tab was opened from another tab.
117        ///
118        /// Defaults to `nil` if not implemented.
119        ///
120        /// See also: setParentTab:forWebExtensionContext:completionHandler:
121        #[optional]
122        #[unsafe(method(parentTabForWebExtensionContext:))]
123        #[unsafe(method_family = none)]
124        unsafe fn parentTabForWebExtensionContext(
125            &self,
126            context: &WKWebExtensionContext,
127        ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionTab>>>;
128
129        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
130        /// Called to set or clear the parent tab for the tab.
131        ///
132        /// Parameter `parentTab`: The tab that should be set as the parent of the tab. If
133        /// `nil`is provided, the current
134        /// parent tab should be cleared.
135        ///
136        /// Parameter `context`: The context in which the web extension is running.
137        ///
138        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
139        /// which should be provided if any errors occurred.
140        ///
141        /// No action is performed if not implemented.
142        ///
143        /// See also: parentTabForWebExtensionContext:
144        #[optional]
145        #[unsafe(method(setParentTab:forWebExtensionContext:completionHandler:))]
146        #[unsafe(method_family = none)]
147        unsafe fn setParentTab_forWebExtensionContext_completionHandler(
148            &self,
149            parent_tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
150            context: &WKWebExtensionContext,
151            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
152        );
153
154        #[cfg(all(
155            feature = "WKWebExtensionContext",
156            feature = "WKWebView",
157            feature = "objc2-app-kit"
158        ))]
159        #[cfg(target_os = "macos")]
160        /// Called when the web view for the tab is needed.
161        ///
162        /// Parameter `context`: The context in which the web extension is running.
163        ///
164        /// Returns: The web view for the tab.
165        ///
166        /// The web view's ``WKWebViewConfiguration`` must have its ``webExtensionController`` property set to match
167        /// the controller of the given context; otherwise `nil` will be used. Defaults to `nil` if not implemented. If `nil`, some critical features
168        /// will not be available for this tab, such as content injection or modification.
169        #[optional]
170        #[unsafe(method(webViewForWebExtensionContext:))]
171        #[unsafe(method_family = none)]
172        unsafe fn webViewForWebExtensionContext(
173            &self,
174            context: &WKWebExtensionContext,
175        ) -> Option<Retained<WKWebView>>;
176
177        #[cfg(feature = "WKWebExtensionContext")]
178        /// Called when the title of the tab is needed.
179        ///
180        /// Parameter `context`: The context in which the web extension is running.
181        ///
182        /// Returns: The title of the tab.
183        ///
184        /// Defaults to ``title`` of the tab's web view if not implemented.
185        #[optional]
186        #[unsafe(method(titleForWebExtensionContext:))]
187        #[unsafe(method_family = none)]
188        unsafe fn titleForWebExtensionContext(
189            &self,
190            context: &WKWebExtensionContext,
191        ) -> Option<Retained<NSString>>;
192
193        #[cfg(feature = "WKWebExtensionContext")]
194        /// Called when the pinned state of the tab is needed.
195        ///
196        /// Parameter `context`: The context in which the web extension is running.
197        ///
198        /// Returns: `YES` if the tab is pinned, `NO` otherwise.
199        ///
200        /// Defaults to `NO` if not implemented.
201        ///
202        /// See also: setPinned:forWebExtensionContext:completionHandler:
203        #[optional]
204        #[unsafe(method(isPinnedForWebExtensionContext:))]
205        #[unsafe(method_family = none)]
206        unsafe fn isPinnedForWebExtensionContext(&self, context: &WKWebExtensionContext) -> bool;
207
208        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
209        /// Called to set the pinned state of the tab.
210        ///
211        /// Parameter `pinned`: A boolean value indicating whether to pin the tab.
212        ///
213        /// Parameter `context`: The context in which the web extension is running.
214        ///
215        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
216        /// which should be provided if any errors occurred.
217        ///
218        /// This is equivalent to the user selecting to pin or unpin the tab through a menu item. When a tab is pinned,
219        /// it should be moved to the front of the tab bar and usually reduced in size. When a tab is unpinned, it should be restored
220        /// to a normal size and position in the tab bar. No action is performed if not implemented.
221        ///
222        /// See also: isPinnedForWebExtensionContext:
223        #[optional]
224        #[unsafe(method(setPinned:forWebExtensionContext:completionHandler:))]
225        #[unsafe(method_family = none)]
226        unsafe fn setPinned_forWebExtensionContext_completionHandler(
227            &self,
228            pinned: bool,
229            context: &WKWebExtensionContext,
230            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
231        );
232
233        #[cfg(feature = "WKWebExtensionContext")]
234        /// Called to check if reader mode is available for the tab.
235        ///
236        /// Parameter `context`: The context in which the web extension is running.
237        ///
238        /// Returns: `YES` if reader mode is available for the tab, `NO` otherwise.
239        ///
240        /// Defaults to `NO` if not implemented.
241        ///
242        /// See also: isReaderModeActiveForWebExtensionContext:
243        #[optional]
244        #[unsafe(method(isReaderModeAvailableForWebExtensionContext:))]
245        #[unsafe(method_family = none)]
246        unsafe fn isReaderModeAvailableForWebExtensionContext(
247            &self,
248            context: &WKWebExtensionContext,
249        ) -> bool;
250
251        #[cfg(feature = "WKWebExtensionContext")]
252        /// Called to check if the tab is currently showing reader mode.
253        ///
254        /// Parameter `context`: The context in which the web extension is running.
255        ///
256        /// Returns: `YES` if the tab is showing reader mode, `NO` otherwise.
257        ///
258        /// Defaults to `NO` if not implemented.
259        ///
260        /// See also: isReaderModeAvailableForWebExtensionContext:
261        #[optional]
262        #[unsafe(method(isReaderModeActiveForWebExtensionContext:))]
263        #[unsafe(method_family = none)]
264        unsafe fn isReaderModeActiveForWebExtensionContext(
265            &self,
266            context: &WKWebExtensionContext,
267        ) -> bool;
268
269        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
270        /// Called to set the reader mode for the tab.
271        ///
272        /// Parameter `active`: A boolean value indicating whether to activate reader mode.
273        ///
274        /// Parameter `context`: The context in which the web extension is running.
275        ///
276        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
277        /// which should be provided if any errors occurred.
278        ///
279        /// No action is performed if not implemented.
280        ///
281        /// See also: isReaderModeAvailableForWebExtensionContext:
282        ///
283        /// See also: isReaderModeActiveForWebExtensionContext:
284        #[optional]
285        #[unsafe(method(setReaderModeActive:forWebExtensionContext:completionHandler:))]
286        #[unsafe(method_family = none)]
287        unsafe fn setReaderModeActive_forWebExtensionContext_completionHandler(
288            &self,
289            active: bool,
290            context: &WKWebExtensionContext,
291            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
292        );
293
294        #[cfg(feature = "WKWebExtensionContext")]
295        /// Called to check if the tab is currently playing audio.
296        ///
297        /// Parameter `context`: The context in which the web extension is running.
298        ///
299        /// Returns: `YES` if the tab is playing audio, `NO` otherwise.
300        ///
301        /// Defaults to `NO` if not implemented.
302        #[optional]
303        #[unsafe(method(isPlayingAudioForWebExtensionContext:))]
304        #[unsafe(method_family = none)]
305        unsafe fn isPlayingAudioForWebExtensionContext(
306            &self,
307            context: &WKWebExtensionContext,
308        ) -> bool;
309
310        #[cfg(feature = "WKWebExtensionContext")]
311        /// Called to check if the tab is currently muted.
312        ///
313        /// Parameter `context`: The context in which the web extension is running.
314        ///
315        /// Returns: `YES` if the tab is muted, `NO` otherwise.
316        ///
317        /// Defaults to `NO` if not implemented.
318        ///
319        /// See also: setMuted:forWebExtensionContext:completionHandler:
320        #[optional]
321        #[unsafe(method(isMutedForWebExtensionContext:))]
322        #[unsafe(method_family = none)]
323        unsafe fn isMutedForWebExtensionContext(&self, context: &WKWebExtensionContext) -> bool;
324
325        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
326        /// Called to set the mute state of the tab.
327        ///
328        /// Parameter `muted`: A boolean indicating whether the tab should be muted.
329        ///
330        /// Parameter `context`: The context in which the web extension is running.
331        ///
332        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
333        /// which should be provided if any errors occurred.
334        ///
335        /// No action is performed if not implemented.
336        ///
337        /// See also: isMutedForWebExtensionContext:
338        #[optional]
339        #[unsafe(method(setMuted:forWebExtensionContext:completionHandler:))]
340        #[unsafe(method_family = none)]
341        unsafe fn setMuted_forWebExtensionContext_completionHandler(
342            &self,
343            muted: bool,
344            context: &WKWebExtensionContext,
345            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
346        );
347
348        #[cfg(all(feature = "WKWebExtensionContext", feature = "objc2-core-foundation"))]
349        /// Called when the size of the tab is needed.
350        ///
351        /// Parameter `context`: The context in which the web extension is running.
352        ///
353        /// Returns: The size of the tab.
354        ///
355        /// Defaults to size of the tab's web view if not implemented.
356        #[optional]
357        #[unsafe(method(sizeForWebExtensionContext:))]
358        #[unsafe(method_family = none)]
359        unsafe fn sizeForWebExtensionContext(&self, context: &WKWebExtensionContext) -> CGSize;
360
361        #[cfg(feature = "WKWebExtensionContext")]
362        /// Called when the zoom factor of the tab is needed.
363        ///
364        /// Parameter `context`: The context in which the web extension is running.
365        ///
366        /// Returns: The zoom factor of the tab.
367        ///
368        /// Defaults to ``pageZoom`` of the tab's web view if not implemented.
369        ///
370        /// See also: setZoomFactor:forWebExtensionContext:completionHandler:
371        #[optional]
372        #[unsafe(method(zoomFactorForWebExtensionContext:))]
373        #[unsafe(method_family = none)]
374        unsafe fn zoomFactorForWebExtensionContext(
375            &self,
376            context: &WKWebExtensionContext,
377        ) -> c_double;
378
379        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
380        /// Called to set the zoom factor of the tab.
381        ///
382        /// Parameter `zoomFactor`: The desired zoom factor for the tab.
383        ///
384        /// Parameter `context`: The context in which the web extension is running.
385        ///
386        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
387        /// which should be provided if any errors occurred.
388        ///
389        /// Sets ``pageZoom`` of the tab's web view if not implemented.
390        ///
391        /// See also: zoomFactorForWebExtensionContext:
392        #[optional]
393        #[unsafe(method(setZoomFactor:forWebExtensionContext:completionHandler:))]
394        #[unsafe(method_family = none)]
395        unsafe fn setZoomFactor_forWebExtensionContext_completionHandler(
396            &self,
397            zoom_factor: c_double,
398            context: &WKWebExtensionContext,
399            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
400        );
401
402        #[cfg(feature = "WKWebExtensionContext")]
403        /// Called when the URL of the tab is needed.
404        ///
405        /// Parameter `context`: The context in which the web extension is running.
406        ///
407        /// Returns: The URL of the tab.
408        ///
409        /// Defaults to `URL` of the tab's web view if not implemented.
410        #[optional]
411        #[unsafe(method(urlForWebExtensionContext:))]
412        #[unsafe(method_family = none)]
413        unsafe fn urlForWebExtensionContext(
414            &self,
415            context: &WKWebExtensionContext,
416        ) -> Option<Retained<NSURL>>;
417
418        #[cfg(feature = "WKWebExtensionContext")]
419        /// Called when the pending URL of the tab is needed.
420        ///
421        /// Parameter `context`: The context in which the web extension is running.
422        ///
423        /// Returns: The pending URL of the tab.
424        ///
425        /// The pending URL is the URL of a page that is in the process of loading. If there is no pending URL, return `nil`.
426        /// Defaults to `nil` if not implemented.
427        #[optional]
428        #[unsafe(method(pendingURLForWebExtensionContext:))]
429        #[unsafe(method_family = none)]
430        unsafe fn pendingURLForWebExtensionContext(
431            &self,
432            context: &WKWebExtensionContext,
433        ) -> Option<Retained<NSURL>>;
434
435        #[cfg(feature = "WKWebExtensionContext")]
436        /// Called to check if the tab has finished loading.
437        ///
438        /// Parameter `context`: The context in which the web extension is running.
439        ///
440        /// Returns: `YES` if the tab has finished loading, `NO` otherwise.
441        ///
442        /// Defaults to ``isLoading`` of the tab's web view if not implemented.
443        #[optional]
444        #[unsafe(method(isLoadingCompleteForWebExtensionContext:))]
445        #[unsafe(method_family = none)]
446        unsafe fn isLoadingCompleteForWebExtensionContext(
447            &self,
448            context: &WKWebExtensionContext,
449        ) -> bool;
450
451        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
452        /// Called to detect the locale of the webpage currently loaded in the tab.
453        ///
454        /// Parameter `context`: The context in which the web extension is running.
455        ///
456        /// Parameter `completionHandler`: A block that must be called upon completion. The block takes two arguments:
457        /// the detected locale (or
458        /// `nil`if the locale is unknown) and an error, which should be provided if any errors occurred.
459        ///
460        /// No action is performed if not implemented.
461        #[optional]
462        #[unsafe(method(detectWebpageLocaleForWebExtensionContext:completionHandler:))]
463        #[unsafe(method_family = none)]
464        unsafe fn detectWebpageLocaleForWebExtensionContext_completionHandler(
465            &self,
466            context: &WKWebExtensionContext,
467            completion_handler: &block2::DynBlock<dyn Fn(*mut NSLocale, *mut NSError)>,
468        );
469
470        #[cfg(all(
471            feature = "WKSnapshotConfiguration",
472            feature = "WKWebExtensionContext",
473            feature = "block2",
474            feature = "objc2-app-kit"
475        ))]
476        #[cfg(target_os = "macos")]
477        #[optional]
478        #[unsafe(method(takeSnapshotUsingConfiguration:forWebExtensionContext:completionHandler:))]
479        #[unsafe(method_family = none)]
480        unsafe fn takeSnapshotUsingConfiguration_forWebExtensionContext_completionHandler(
481            &self,
482            configuration: &WKSnapshotConfiguration,
483            context: &WKWebExtensionContext,
484            completion_handler: &block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>,
485        );
486
487        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
488        /// Called to load a URL in the tab.
489        ///
490        /// Parameter `url`: The URL to be loaded in the tab.
491        ///
492        /// Parameter `context`: The context in which the web extension is running.
493        ///
494        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
495        /// which should be provided if any errors occurred.
496        ///
497        /// If the tab is already loading a page, calling this method should stop the current page from loading and start
498        /// loading the new URL. Loads the URL in the tab's web view via ``loadRequest:`` if not implemented.
499        #[optional]
500        #[unsafe(method(loadURL:forWebExtensionContext:completionHandler:))]
501        #[unsafe(method_family = none)]
502        unsafe fn loadURL_forWebExtensionContext_completionHandler(
503            &self,
504            url: &NSURL,
505            context: &WKWebExtensionContext,
506            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
507        );
508
509        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
510        /// Called to reload the current page in the tab.
511        ///
512        /// Parameter `fromOrigin`: A boolean value indicating whether to reload the tab from the origin, bypassing the cache.
513        ///
514        /// Parameter `context`: The context in which the web extension is running.
515        ///
516        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
517        /// which should be provided if any errors occurred.
518        ///
519        /// Reloads the tab's web view via ``reload`` or ``reloadFromOrigin`` if not implemented.
520        #[optional]
521        #[unsafe(method(reloadFromOrigin:forWebExtensionContext:completionHandler:))]
522        #[unsafe(method_family = none)]
523        unsafe fn reloadFromOrigin_forWebExtensionContext_completionHandler(
524            &self,
525            from_origin: bool,
526            context: &WKWebExtensionContext,
527            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
528        );
529
530        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
531        /// Called to navigate the tab to the previous page in its history.
532        ///
533        /// Parameter `context`: The context in which the web extension is running.
534        ///
535        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
536        /// which should be provided if any errors occurred.
537        ///
538        /// Navigates to the previous page in the tab's web view via ``goBack`` if not implemented.
539        #[optional]
540        #[unsafe(method(goBackForWebExtensionContext:completionHandler:))]
541        #[unsafe(method_family = none)]
542        unsafe fn goBackForWebExtensionContext_completionHandler(
543            &self,
544            context: &WKWebExtensionContext,
545            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
546        );
547
548        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
549        /// Called to navigate the tab to the next page in its history.
550        ///
551        /// Parameter `context`: The context in which the web extension is running.
552        ///
553        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
554        /// which should be provided if any errors occurred.
555        ///
556        /// Navigates to the next page in the tab's web view via ``goForward`` if not implemented.
557        #[optional]
558        #[unsafe(method(goForwardForWebExtensionContext:completionHandler:))]
559        #[unsafe(method_family = none)]
560        unsafe fn goForwardForWebExtensionContext_completionHandler(
561            &self,
562            context: &WKWebExtensionContext,
563            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
564        );
565
566        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
567        /// Called to activate the tab, making it frontmost.
568        ///
569        /// Parameter `context`: The context in which the web extension is running.
570        ///
571        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
572        /// which should be provided if any errors occurred.
573        ///
574        /// Upon activation, the tab should become the frontmost and either be the sole selected tab or
575        /// be included among the selected tabs. No action is performed if not implemented.
576        ///
577        /// See also: setSelected:forWebExtensionContext:completionHandler:
578        #[optional]
579        #[unsafe(method(activateForWebExtensionContext:completionHandler:))]
580        #[unsafe(method_family = none)]
581        unsafe fn activateForWebExtensionContext_completionHandler(
582            &self,
583            context: &WKWebExtensionContext,
584            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
585        );
586
587        #[cfg(feature = "WKWebExtensionContext")]
588        /// Called when the selected state of the tab is needed.
589        ///
590        /// Parameter `context`: The context in which the web extension is running.
591        ///
592        /// Returns: `YES` if the tab is selected, `NO` otherwise.
593        ///
594        /// Defaults to `YES` for the active tab and `NO` for other tabs if not implemented.
595        #[optional]
596        #[unsafe(method(isSelectedForWebExtensionContext:))]
597        #[unsafe(method_family = none)]
598        unsafe fn isSelectedForWebExtensionContext(&self, context: &WKWebExtensionContext) -> bool;
599
600        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
601        /// Called to set the selected state of the tab.
602        ///
603        /// Parameter `selected`: A boolean value indicating whether to select the tab.
604        ///
605        /// Parameter `context`: The context in which the web extension is running.
606        ///
607        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
608        /// which should be provided if any errors occurred.
609        ///
610        /// This is equivalent to the user command-clicking on the tab to add it to or remove it from a selection.
611        /// The method should update the tab's selection state without changing the active tab. No action is performed if not implemented.
612        ///
613        /// See also: isSelectedForWebExtensionContext:
614        #[optional]
615        #[unsafe(method(setSelected:forWebExtensionContext:completionHandler:))]
616        #[unsafe(method_family = none)]
617        unsafe fn setSelected_forWebExtensionContext_completionHandler(
618            &self,
619            selected: bool,
620            context: &WKWebExtensionContext,
621            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
622        );
623
624        #[cfg(all(
625            feature = "WKWebExtensionContext",
626            feature = "WKWebExtensionTabConfiguration",
627            feature = "block2"
628        ))]
629        /// Called to duplicate the tab.
630        ///
631        /// Parameter `configuration`: The tab configuration influencing the duplicated tab's properties.
632        ///
633        /// Parameter `context`: The context in which the web extension is running.
634        ///
635        /// Parameter `completionHandler`: A block that must be called upon completion. It takes two arguments:
636        /// the duplicated tab (or
637        /// `nil`if no tab was created) and an error, which should be provided if any errors occurred.
638        ///
639        /// This is equivalent to the user selecting to duplicate the tab through a menu item, with the specified configuration.
640        /// No action is performed if not implemented.
641        #[optional]
642        #[unsafe(method(duplicateUsingConfiguration:forWebExtensionContext:completionHandler:))]
643        #[unsafe(method_family = none)]
644        unsafe fn duplicateUsingConfiguration_forWebExtensionContext_completionHandler(
645            &self,
646            configuration: &WKWebExtensionTabConfiguration,
647            context: &WKWebExtensionContext,
648            completion_handler: &block2::DynBlock<
649                dyn Fn(*mut ProtocolObject<dyn WKWebExtensionTab>, *mut NSError),
650            >,
651        );
652
653        #[cfg(all(feature = "WKWebExtensionContext", feature = "block2"))]
654        /// Called to close the tab.
655        ///
656        /// Parameter `context`: The context in which the web extension is running.
657        ///
658        /// Parameter `completionHandler`: A block that must be called upon completion. It takes a single error argument,
659        /// which should be provided if any errors occurred.
660        ///
661        /// No action is performed if not implemented.
662        #[optional]
663        #[unsafe(method(closeForWebExtensionContext:completionHandler:))]
664        #[unsafe(method_family = none)]
665        unsafe fn closeForWebExtensionContext_completionHandler(
666            &self,
667            context: &WKWebExtensionContext,
668            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
669        );
670
671        #[cfg(feature = "WKWebExtensionContext")]
672        /// Called to determine if permissions should be granted for the tab on user gesture.
673        ///
674        /// Parameter `context`: The context in which the web extension is running.
675        ///
676        /// Returns: `YES` if permissions should be granted to the tab, `NO` otherwise.
677        ///
678        /// This method allows the app to control granting of permissions on a per-tab basis when triggered by a user
679        /// gesture. Implementing this method enables the app to dynamically manage `activeTab` permissions based on the tab's
680        /// current state, the content being accessed, or other custom criteria.
681        #[optional]
682        #[unsafe(method(shouldGrantPermissionsOnUserGestureForWebExtensionContext:))]
683        #[unsafe(method_family = none)]
684        unsafe fn shouldGrantPermissionsOnUserGestureForWebExtensionContext(
685            &self,
686            context: &WKWebExtensionContext,
687        ) -> bool;
688
689        #[cfg(feature = "WKWebExtensionContext")]
690        /// Called to determine if the tab should bypass host permission checks.
691        ///
692        /// Parameter `context`: The context in which the web extension is running.
693        ///
694        /// Returns: `YES` to bypass host permission checks, `NO` to enforce them.
695        ///
696        /// This method allows the app to dynamically control whether a tab can bypass standard host permission checks.
697        #[optional]
698        #[unsafe(method(shouldBypassPermissionsForWebExtensionContext:))]
699        #[unsafe(method_family = none)]
700        unsafe fn shouldBypassPermissionsForWebExtensionContext(
701            &self,
702            context: &WKWebExtensionContext,
703        ) -> bool;
704    }
705);