objc2_web_kit/generated/
WKWebExtensionContext.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::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13extern "C" {
14    /// Indicates a ``WKWebExtensionContext`` error.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontexterrordomain?language=objc)
17    pub static WKWebExtensionContextErrorDomain: &'static NSErrorDomain;
18}
19
20/// Constants used by ``NSError`` to indicate errors in the ``WKWebExtensionContext`` domain.
21///
22/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontexterror?language=objc)
23// NS_ERROR_ENUM
24#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct WKWebExtensionContextError(pub NSInteger);
27impl WKWebExtensionContextError {
28    #[doc(alias = "WKWebExtensionContextErrorUnknown")]
29    pub const Unknown: Self = Self(1);
30    #[doc(alias = "WKWebExtensionContextErrorAlreadyLoaded")]
31    pub const AlreadyLoaded: Self = Self(2);
32    #[doc(alias = "WKWebExtensionContextErrorNotLoaded")]
33    pub const NotLoaded: Self = Self(3);
34    #[doc(alias = "WKWebExtensionContextErrorBaseURLAlreadyInUse")]
35    pub const BaseURLAlreadyInUse: Self = Self(4);
36    #[doc(alias = "WKWebExtensionContextErrorNoBackgroundContent")]
37    pub const NoBackgroundContent: Self = Self(5);
38    #[doc(alias = "WKWebExtensionContextErrorBackgroundContentFailedToLoad")]
39    pub const BackgroundContentFailedToLoad: Self = Self(6);
40}
41
42unsafe impl Encode for WKWebExtensionContextError {
43    const ENCODING: Encoding = NSInteger::ENCODING;
44}
45
46unsafe impl RefEncode for WKWebExtensionContextError {
47    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
48}
49
50extern "C" {
51    /// This notification is sent whenever a ``WKWebExtensionContext`` has new errors or errors were cleared.
52    ///
53    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontexterrorsdidupdatenotification?language=objc)
54    pub static WKWebExtensionContextErrorsDidUpdateNotification: &'static NSNotificationName;
55}
56
57/// Constants used to indicate permission status in ``WKWebExtensionContext``.
58///
59/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextpermissionstatus?language=objc)
60// NS_ENUM
61#[repr(transparent)]
62#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
63pub struct WKWebExtensionContextPermissionStatus(pub NSInteger);
64impl WKWebExtensionContextPermissionStatus {
65    #[doc(alias = "WKWebExtensionContextPermissionStatusDeniedExplicitly")]
66    pub const DeniedExplicitly: Self = Self(-3);
67    #[doc(alias = "WKWebExtensionContextPermissionStatusDeniedImplicitly")]
68    pub const DeniedImplicitly: Self = Self(-2);
69    #[doc(alias = "WKWebExtensionContextPermissionStatusRequestedImplicitly")]
70    pub const RequestedImplicitly: Self = Self(-1);
71    #[doc(alias = "WKWebExtensionContextPermissionStatusUnknown")]
72    pub const Unknown: Self = Self(0);
73    #[doc(alias = "WKWebExtensionContextPermissionStatusRequestedExplicitly")]
74    pub const RequestedExplicitly: Self = Self(1);
75    #[doc(alias = "WKWebExtensionContextPermissionStatusGrantedImplicitly")]
76    pub const GrantedImplicitly: Self = Self(2);
77    #[doc(alias = "WKWebExtensionContextPermissionStatusGrantedExplicitly")]
78    pub const GrantedExplicitly: Self = Self(3);
79}
80
81unsafe impl Encode for WKWebExtensionContextPermissionStatus {
82    const ENCODING: Encoding = NSInteger::ENCODING;
83}
84
85unsafe impl RefEncode for WKWebExtensionContextPermissionStatus {
86    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
87}
88
89extern "C" {
90    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly granted permissions.
91    ///
92    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextpermissionsweregrantednotification?language=objc)
93    pub static WKWebExtensionContextPermissionsWereGrantedNotification: &'static NSNotificationName;
94}
95
96extern "C" {
97    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly denied permissions.
98    ///
99    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextpermissionsweredeniednotification?language=objc)
100    pub static WKWebExtensionContextPermissionsWereDeniedNotification: &'static NSNotificationName;
101}
102
103extern "C" {
104    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly removed granted permissions.
105    ///
106    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextgrantedpermissionswereremovednotification?language=objc)
107    pub static WKWebExtensionContextGrantedPermissionsWereRemovedNotification:
108        &'static NSNotificationName;
109}
110
111extern "C" {
112    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly removed denied permissions.
113    ///
114    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextdeniedpermissionswereremovednotification?language=objc)
115    pub static WKWebExtensionContextDeniedPermissionsWereRemovedNotification:
116        &'static NSNotificationName;
117}
118
119extern "C" {
120    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly granted permission match patterns.
121    ///
122    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextpermissionmatchpatternsweregrantednotification?language=objc)
123    pub static WKWebExtensionContextPermissionMatchPatternsWereGrantedNotification:
124        &'static NSNotificationName;
125}
126
127extern "C" {
128    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly denied permission match patterns.
129    ///
130    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextpermissionmatchpatternsweredeniednotification?language=objc)
131    pub static WKWebExtensionContextPermissionMatchPatternsWereDeniedNotification:
132        &'static NSNotificationName;
133}
134
135extern "C" {
136    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly removed granted permission match patterns.
137    ///
138    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextgrantedpermissionmatchpatternswereremovednotification?language=objc)
139    pub static WKWebExtensionContextGrantedPermissionMatchPatternsWereRemovedNotification:
140        &'static NSNotificationName;
141}
142
143extern "C" {
144    /// This notification is sent whenever a ``WKWebExtensionContext`` has newly removed denied permission match patterns.
145    ///
146    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextdeniedpermissionmatchpatternswereremovednotification?language=objc)
147    pub static WKWebExtensionContextDeniedPermissionMatchPatternsWereRemovedNotification:
148        &'static NSNotificationName;
149}
150
151/// Constants for specifying ``WKWebExtensionContext`` information in notifications.
152///
153/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextnotificationuserinfokey?language=objc)
154// NS_TYPED_EXTENSIBLE_ENUM
155pub type WKWebExtensionContextNotificationUserInfoKey = NSString;
156
157extern "C" {
158    /// The corresponding value represents the affected permissions in ``WKWebExtensionContext`` notifications.
159    ///
160    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextnotificationuserinfokeypermissions?language=objc)
161    pub static WKWebExtensionContextNotificationUserInfoKeyPermissions:
162        &'static WKWebExtensionContextNotificationUserInfoKey;
163}
164
165extern "C" {
166    /// The corresponding value represents the affected permission match patterns in ``WKWebExtensionContext`` notifications.
167    ///
168    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontextnotificationuserinfokeymatchpatterns?language=objc)
169    pub static WKWebExtensionContextNotificationUserInfoKeyMatchPatterns:
170        &'static WKWebExtensionContextNotificationUserInfoKey;
171}
172
173extern_class!(
174    /// A ``WKWebExtensionContext`` object represents the runtime environment for a web extension.
175    ///
176    /// This class provides methods for managing the extension's permissions, allowing it to inject content, run
177    /// background logic, show popovers, and display other web-based UI to the user.
178    ///
179    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebextensioncontext?language=objc)
180    #[unsafe(super(NSObject))]
181    #[thread_kind = MainThreadOnly]
182    #[derive(Debug, PartialEq, Eq, Hash)]
183    pub struct WKWebExtensionContext;
184);
185
186extern_conformance!(
187    unsafe impl NSObjectProtocol for WKWebExtensionContext {}
188);
189
190impl WKWebExtensionContext {
191    extern_methods!(
192        #[unsafe(method(new))]
193        #[unsafe(method_family = new)]
194        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
195
196        #[unsafe(method(init))]
197        #[unsafe(method_family = init)]
198        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
199
200        #[cfg(feature = "WKWebExtension")]
201        /// Returns a web extension context initialized with the specified extension.
202        ///
203        /// Parameter `extension`: The extension to use for the new web extension context.
204        ///
205        /// Returns: An initialized web extension context.
206        #[unsafe(method(contextForExtension:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn contextForExtension(extension: &WKWebExtension) -> Retained<Self>;
209
210        #[cfg(feature = "WKWebExtension")]
211        /// Returns a web extension context initialized with a specified extension.
212        ///
213        /// Parameter `extension`: The extension to use for the new web extension context.
214        ///
215        /// Returns: An initialized web extension context.
216        ///
217        /// This is a designated initializer.
218        #[unsafe(method(initForExtension:))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn initForExtension(
221            this: Allocated<Self>,
222            extension: &WKWebExtension,
223        ) -> Retained<Self>;
224
225        #[cfg(feature = "WKWebExtension")]
226        /// The extension this context represents.
227        #[unsafe(method(webExtension))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn webExtension(&self) -> Retained<WKWebExtension>;
230
231        #[cfg(feature = "WKWebExtensionController")]
232        /// The extension controller this context is loaded in, otherwise `nil` if it isn't loaded.
233        #[unsafe(method(webExtensionController))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn webExtensionController(&self) -> Option<Retained<WKWebExtensionController>>;
236
237        /// A Boolean value indicating if this context is loaded in an extension controller.
238        #[unsafe(method(isLoaded))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn isLoaded(&self) -> bool;
241
242        /// All errors that occurred in the extension context.
243        ///
244        /// Provides an array of all parse-time and runtime errors for the extension and extension context, with repeat errors
245        /// consolidated into a single entry for the original occurrence. If no errors occurred, an empty array is returned.
246        #[unsafe(method(errors))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn errors(&self) -> Retained<NSArray<NSError>>;
249
250        /// The base URL the context uses for loading extension resources or injecting content into webpages.
251        ///
252        /// The default value is a unique URL using the `webkit-extension` scheme.
253        /// The base URL can be set to any URL, but only the scheme and host will be used. The scheme cannot be a scheme that is
254        /// already supported by ``WKWebView`` (e.g. http, https, etc.) Setting is only allowed when the context is not loaded.
255        #[unsafe(method(baseURL))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn baseURL(&self) -> Retained<NSURL>;
258
259        /// Setter for [`baseURL`][Self::baseURL].
260        #[unsafe(method(setBaseURL:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn setBaseURL(&self, base_url: &NSURL);
263
264        /// A unique identifier used to distinguish the extension from other extensions and target it for messages.
265        ///
266        /// The default value is a unique value that matches the host in the default base URL. The identifier can be any
267        /// value that is unique. Setting is only allowed when the context is not loaded. This value is accessible by the extension via
268        /// `browser.runtime.id` and is used for messaging the extension via `browser.runtime.sendMessage()`.
269        #[unsafe(method(uniqueIdentifier))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn uniqueIdentifier(&self) -> Retained<NSString>;
272
273        /// Setter for [`uniqueIdentifier`][Self::uniqueIdentifier].
274        #[unsafe(method(setUniqueIdentifier:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setUniqueIdentifier(&self, unique_identifier: &NSString);
277
278        /// Determines whether Web Inspector can inspect the ``WKWebView`` instances for this context.
279        ///
280        /// A context can control multiple ``WKWebView`` instances, from the background content, to the popover.
281        /// You should set this to `YES` when needed for debugging purposes. The default value is `NO`.
282        #[unsafe(method(isInspectable))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn isInspectable(&self) -> bool;
285
286        /// Setter for [`isInspectable`][Self::isInspectable].
287        #[unsafe(method(setInspectable:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn setInspectable(&self, inspectable: bool);
290
291        /// The name shown when inspecting the background web view.
292        ///
293        /// This is the text that will appear when inspecting the background web view.
294        #[unsafe(method(inspectionName))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn inspectionName(&self) -> Option<Retained<NSString>>;
297
298        /// Setter for [`inspectionName`][Self::inspectionName].
299        #[unsafe(method(setInspectionName:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn setInspectionName(&self, inspection_name: Option<&NSString>);
302
303        /// Specifies unsupported APIs for this extension, making them `undefined` in JavaScript.
304        ///
305        /// This property allows the app to specify a subset of web extension APIs that it chooses not to support, effectively making
306        /// these APIs `undefined` within the extension's JavaScript contexts. This enables extensions to employ feature detection techniques
307        /// for unsupported APIs, allowing them to adapt their behavior based on the APIs actually supported by the app. Setting is only allowed when
308        /// the context is not loaded. Only certain APIs can be specified here, particularly those within the `browser` namespace and other dynamic
309        /// functions and properties, anything else will be silently ignored.
310        ///
311        /// Note: For example, specifying `"browser.windows.create"` and `"browser.storage"` in this set will result in the
312        /// `browser.windows.create()` function and `browser.storage` property being `undefined`.
313        #[unsafe(method(unsupportedAPIs))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn unsupportedAPIs(&self) -> Retained<NSSet<NSString>>;
316
317        /// Setter for [`unsupportedAPIs`][Self::unsupportedAPIs].
318        #[unsafe(method(setUnsupportedAPIs:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setUnsupportedAPIs(&self, unsupported_ap_is: Option<&NSSet<NSString>>);
321
322        #[cfg(feature = "WKWebViewConfiguration")]
323        /// The web view configuration to use for web views that load pages from this extension.
324        ///
325        /// Returns a customized copy of the configuration, originally set in the web extension controller configuration, for this extension.
326        /// The app must use this configuration when initializing web views intended to navigate to a URL originating from this extension's base URL.
327        /// The app must also swap web views in tabs when navigating to and from web extension URLs. This property returns `nil` if the context isn't
328        /// associated with a web extension controller. The returned configuration copy can be customized prior to web view initialization.
329        ///
330        /// Note: Navigations will fail if a web view using this configuration attempts to navigate to a URL that doesn't originate from this extension's
331        /// base URL. Similarly, navigations will be canceled if a web view not configured with this configuration attempts to navigate to a URL that does
332        /// originate from this extension's base URL.
333        #[unsafe(method(webViewConfiguration))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn webViewConfiguration(&self) -> Option<Retained<WKWebViewConfiguration>>;
336
337        /// The URL of the extension's options page, if the extension has one.
338        ///
339        /// Provides the URL for the dedicated options page, if provided by the extension; otherwise `nil` if no page is defined.
340        /// The app should provide access to this page through a user interface element.
341        ///
342        /// Note: Navigation to the options page is only possible after this extension has been loaded.
343        ///
344        /// See also: webViewConfiguration
345        #[unsafe(method(optionsPageURL))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn optionsPageURL(&self) -> Option<Retained<NSURL>>;
348
349        /// The URL to use as an alternative to the default new tab page, if the extension has one.
350        ///
351        /// Provides the URL for a new tab page, if provided by the extension; otherwise `nil` if no page is defined.
352        /// The app should prompt the user for permission to use the extension's new tab page as the default.
353        ///
354        /// Note: Navigation to the override new tab page is only possible after this extension has been loaded.
355        ///
356        /// See also: webViewConfiguration
357        #[unsafe(method(overrideNewTabPageURL))]
358        #[unsafe(method_family = none)]
359        pub unsafe fn overrideNewTabPageURL(&self) -> Option<Retained<NSURL>>;
360
361        #[cfg(feature = "WKWebExtensionPermission")]
362        /// The currently granted permissions and their expiration dates.
363        ///
364        /// Permissions that don't expire will have a distant future date. This will never include expired entries at time of access.
365        /// Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.
366        /// Permissions in this dictionary should be explicitly granted by the user before being added. Any permissions in this collection will not be
367        /// presented for approval again until they expire. This value should be saved and restored as needed by the app.
368        ///
369        /// See also: setPermissionStatus:forPermission:
370        ///
371        /// See also: setPermissionStatus:forPermission:expirationDate:
372        #[unsafe(method(grantedPermissions))]
373        #[unsafe(method_family = none)]
374        pub unsafe fn grantedPermissions(
375            &self,
376        ) -> Retained<NSDictionary<WKWebExtensionPermission, NSDate>>;
377
378        #[cfg(feature = "WKWebExtensionPermission")]
379        /// Setter for [`grantedPermissions`][Self::grantedPermissions].
380        #[unsafe(method(setGrantedPermissions:))]
381        #[unsafe(method_family = none)]
382        pub unsafe fn setGrantedPermissions(
383            &self,
384            granted_permissions: &NSDictionary<WKWebExtensionPermission, NSDate>,
385        );
386
387        #[cfg(feature = "WKWebExtensionMatchPattern")]
388        /// The currently granted permission match patterns and their expiration dates.
389        ///
390        /// Match patterns that don't expire will have a distant future date. This will never include expired entries at time of access.
391        /// Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.
392        /// Match patterns in this dictionary should be explicitly granted by the user before being added. Any match pattern in this collection will not be
393        /// presented for approval again until they expire. This value should be saved and restored as needed by the app.
394        ///
395        /// See also: setPermissionStatus:forMatchPattern:
396        ///
397        /// See also: setPermissionStatus:forMatchPattern:expirationDate:
398        #[unsafe(method(grantedPermissionMatchPatterns))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn grantedPermissionMatchPatterns(
401            &self,
402        ) -> Retained<NSDictionary<WKWebExtensionMatchPattern, NSDate>>;
403
404        #[cfg(feature = "WKWebExtensionMatchPattern")]
405        /// Setter for [`grantedPermissionMatchPatterns`][Self::grantedPermissionMatchPatterns].
406        #[unsafe(method(setGrantedPermissionMatchPatterns:))]
407        #[unsafe(method_family = none)]
408        pub unsafe fn setGrantedPermissionMatchPatterns(
409            &self,
410            granted_permission_match_patterns: &NSDictionary<WKWebExtensionMatchPattern, NSDate>,
411        );
412
413        #[cfg(feature = "WKWebExtensionPermission")]
414        /// The currently denied permissions and their expiration dates.
415        ///
416        /// Permissions that don't expire will have a distant future date. This will never include expired entries at time of access.
417        /// Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.
418        /// Permissions in this dictionary should be explicitly denied by the user before being added. Any match pattern in this collection will not be
419        /// presented for approval again until they expire. This value should be saved and restored as needed by the app.
420        ///
421        /// See also: setPermissionStatus:forPermission:
422        ///
423        /// See also: setPermissionStatus:forPermission:expirationDate:
424        #[unsafe(method(deniedPermissions))]
425        #[unsafe(method_family = none)]
426        pub unsafe fn deniedPermissions(
427            &self,
428        ) -> Retained<NSDictionary<WKWebExtensionPermission, NSDate>>;
429
430        #[cfg(feature = "WKWebExtensionPermission")]
431        /// Setter for [`deniedPermissions`][Self::deniedPermissions].
432        #[unsafe(method(setDeniedPermissions:))]
433        #[unsafe(method_family = none)]
434        pub unsafe fn setDeniedPermissions(
435            &self,
436            denied_permissions: &NSDictionary<WKWebExtensionPermission, NSDate>,
437        );
438
439        #[cfg(feature = "WKWebExtensionMatchPattern")]
440        /// The currently denied permission match patterns and their expiration dates.
441        ///
442        /// Match patterns that don't expire will have a distant future date. This will never include expired entries at time of access.
443        /// Setting this property will replace all existing entries. Use this property for saving and restoring permission status in bulk.
444        /// Match patterns in this dictionary should be explicitly denied by the user before being added. Any match pattern in this collection will not be
445        /// presented for approval again until they expire. This value should be saved and restored as needed by the app.
446        ///
447        /// See also: setPermissionStatus:forMatchPattern:
448        ///
449        /// See also: setPermissionStatus:forMatchPattern:expirationDate:
450        #[unsafe(method(deniedPermissionMatchPatterns))]
451        #[unsafe(method_family = none)]
452        pub unsafe fn deniedPermissionMatchPatterns(
453            &self,
454        ) -> Retained<NSDictionary<WKWebExtensionMatchPattern, NSDate>>;
455
456        #[cfg(feature = "WKWebExtensionMatchPattern")]
457        /// Setter for [`deniedPermissionMatchPatterns`][Self::deniedPermissionMatchPatterns].
458        #[unsafe(method(setDeniedPermissionMatchPatterns:))]
459        #[unsafe(method_family = none)]
460        pub unsafe fn setDeniedPermissionMatchPatterns(
461            &self,
462            denied_permission_match_patterns: &NSDictionary<WKWebExtensionMatchPattern, NSDate>,
463        );
464
465        /// A Boolean value indicating if the extension has requested optional access to all hosts.
466        ///
467        /// If this property is `YES`, the extension has asked for access to all hosts in a call to `browser.runtime.permissions.request()`,
468        /// and future permission checks will present discrete hosts for approval as being implicitly requested. This value should be saved and restored as needed by the app.
469        #[unsafe(method(hasRequestedOptionalAccessToAllHosts))]
470        #[unsafe(method_family = none)]
471        pub unsafe fn hasRequestedOptionalAccessToAllHosts(&self) -> bool;
472
473        /// Setter for [`hasRequestedOptionalAccessToAllHosts`][Self::hasRequestedOptionalAccessToAllHosts].
474        #[unsafe(method(setHasRequestedOptionalAccessToAllHosts:))]
475        #[unsafe(method_family = none)]
476        pub unsafe fn setHasRequestedOptionalAccessToAllHosts(
477            &self,
478            has_requested_optional_access_to_all_hosts: bool,
479        );
480
481        /// A Boolean value indicating if the extension has access to private data.
482        ///
483        /// If this property is `YES`, the extension is granted permission to interact with private windows, tabs, and cookies. Access to private data
484        /// should be explicitly allowed by the user before setting this property. This value should be saved and restored as needed by the app.
485        ///
486        /// Note: To ensure proper isolation between private and non-private data, web views associated with private data must use a
487        /// different ``WKUserContentController``. Likewise, to be identified as a private web view and to ensure that cookies and other
488        /// website data is not shared, private web views must be configured to use a non-persistent ``WKWebsiteDataStore``.
489        #[unsafe(method(hasAccessToPrivateData))]
490        #[unsafe(method_family = none)]
491        pub unsafe fn hasAccessToPrivateData(&self) -> bool;
492
493        /// Setter for [`hasAccessToPrivateData`][Self::hasAccessToPrivateData].
494        #[unsafe(method(setHasAccessToPrivateData:))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn setHasAccessToPrivateData(&self, has_access_to_private_data: bool);
497
498        #[cfg(feature = "WKWebExtensionPermission")]
499        /// The currently granted permissions that have not expired.
500        ///
501        /// See also: grantedPermissions
502        #[unsafe(method(currentPermissions))]
503        #[unsafe(method_family = none)]
504        pub unsafe fn currentPermissions(&self) -> Retained<NSSet<WKWebExtensionPermission>>;
505
506        #[cfg(feature = "WKWebExtensionMatchPattern")]
507        /// The currently granted permission match patterns that have not expired.
508        ///
509        /// See also: grantedPermissionMatchPatterns
510        #[unsafe(method(currentPermissionMatchPatterns))]
511        #[unsafe(method_family = none)]
512        pub unsafe fn currentPermissionMatchPatterns(
513            &self,
514        ) -> Retained<NSSet<WKWebExtensionMatchPattern>>;
515
516        #[cfg(feature = "WKWebExtensionPermission")]
517        /// Checks the specified permission against the currently granted permissions.
518        ///
519        /// Parameter `permission`: The permission for which to return the status.
520        ///
521        /// See also: currentPermissions
522        ///
523        /// See also: hasPermission:inTab:
524        ///
525        /// See also: permissionStatusForPermission:
526        ///
527        /// See also: permissionStatusForPermission:inTab:
528        #[unsafe(method(hasPermission:))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn hasPermission(&self, permission: &WKWebExtensionPermission) -> bool;
531
532        #[cfg(all(feature = "WKWebExtensionPermission", feature = "WKWebExtensionTab"))]
533        /// Checks the specified permission against the currently granted permissions in a specific tab.
534        ///
535        /// Parameter `permission`: The permission for which to return the status.
536        ///
537        /// Parameter `tab`: The tab in which to return the permission status, or
538        /// `nil`if the tab is not known or the global status is desired.
539        ///
540        /// Permissions can be granted on a per-tab basis. When the tab is known, permission checks should always use this method.
541        ///
542        /// See also: currentPermissions
543        ///
544        /// See also: hasPermission:
545        ///
546        /// See also: permissionStatusForPermission:
547        ///
548        /// See also: permissionStatusForPermission:inTab:
549        #[unsafe(method(hasPermission:inTab:))]
550        #[unsafe(method_family = none)]
551        pub unsafe fn hasPermission_inTab(
552            &self,
553            permission: &WKWebExtensionPermission,
554            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
555        ) -> bool;
556
557        /// Checks the specified URL against the currently granted permission match patterns.
558        ///
559        /// Parameter `url`: The URL for which to return the status.
560        ///
561        /// See also: currentPermissionMatchPatterns
562        ///
563        /// See also: hasAccessToURL:inTab:
564        ///
565        /// See also: permissionStatusForURL:
566        ///
567        /// See also: permissionStatusForURL:inTab:
568        ///
569        /// See also: permissionStatusForMatchPattern:
570        ///
571        /// See also: permissionStatusForMatchPattern:inTab:
572        #[unsafe(method(hasAccessToURL:))]
573        #[unsafe(method_family = none)]
574        pub unsafe fn hasAccessToURL(&self, url: &NSURL) -> bool;
575
576        #[cfg(feature = "WKWebExtensionTab")]
577        /// Checks the specified URL against the currently granted permission match patterns in a specific tab.
578        ///
579        /// Parameter `url`: The URL for which to return the status.
580        ///
581        /// Parameter `tab`: The tab in which to return the permission status, or
582        /// `nil`if the tab is not known or the global status is desired.
583        ///
584        /// Some match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.
585        ///
586        /// See also: currentPermissionMatchPatterns
587        ///
588        /// See also: hasAccessToURL:
589        ///
590        /// See also: permissionStatusForURL:
591        ///
592        /// See also: permissionStatusForURL:inTab:
593        ///
594        /// See also: permissionStatusForMatchPattern:
595        ///
596        /// See also: permissionStatusForMatchPattern:inTab:
597        #[unsafe(method(hasAccessToURL:inTab:))]
598        #[unsafe(method_family = none)]
599        pub unsafe fn hasAccessToURL_inTab(
600            &self,
601            url: &NSURL,
602            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
603        ) -> bool;
604
605        /// A Boolean value indicating if the currently granted permission match patterns set contains the `
606        /// <all
607        /// _urls>` pattern.
608        ///
609        /// This does not check for any `*` host patterns. In most cases you should use the broader ``hasAccessToAllHosts``.
610        ///
611        /// See also: currentPermissionMatchPatterns
612        ///
613        /// See also: hasAccessToAllHosts
614        #[unsafe(method(hasAccessToAllURLs))]
615        #[unsafe(method_family = none)]
616        pub unsafe fn hasAccessToAllURLs(&self) -> bool;
617
618        /// A Boolean value indicating if the currently granted permission match patterns set contains the `
619        /// <all
620        /// _urls>` pattern or any `*` host patterns.
621        ///
622        /// See also: currentPermissionMatchPatterns
623        ///
624        /// See also: hasAccessToAllURLs
625        #[unsafe(method(hasAccessToAllHosts))]
626        #[unsafe(method_family = none)]
627        pub unsafe fn hasAccessToAllHosts(&self) -> bool;
628
629        /// A Boolean value indicating whether the extension has script or stylesheet content that can be injected into webpages.
630        ///
631        /// If this property is `YES`, the extension has content that can be injected by matching against the extension's requested match patterns.
632        ///
633        /// See also: hasInjectedContentForURL:
634        #[unsafe(method(hasInjectedContent))]
635        #[unsafe(method_family = none)]
636        pub unsafe fn hasInjectedContent(&self) -> bool;
637
638        /// Checks if the extension has script or stylesheet content that can be injected into the specified URL.
639        ///
640        /// Parameter `url`: The webpage URL to check.
641        ///
642        /// Returns: Returns `YES` if the extension has content that can be injected by matching the URL against the extension's requested match patterns.
643        ///
644        /// The extension context will still need to be loaded and have granted website permissions for its content to actually be injected.
645        #[unsafe(method(hasInjectedContentForURL:))]
646        #[unsafe(method_family = none)]
647        pub unsafe fn hasInjectedContentForURL(&self, url: &NSURL) -> bool;
648
649        /// A boolean value indicating whether the extension includes rules used for content modification or blocking.
650        ///
651        /// This includes both static rules available in the extension's manifest and dynamic rules applied during a browsing session.
652        #[unsafe(method(hasContentModificationRules))]
653        #[unsafe(method_family = none)]
654        pub unsafe fn hasContentModificationRules(&self) -> bool;
655
656        #[cfg(feature = "WKWebExtensionPermission")]
657        /// Checks the specified permission against the currently denied, granted, and requested permissions.
658        ///
659        /// Parameter `permission`: The permission for which to return the status.
660        ///
661        /// Permissions can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.
662        ///
663        /// See also: permissionStatusForPermission:inTab:
664        ///
665        /// See also: hasPermission:
666        #[unsafe(method(permissionStatusForPermission:))]
667        #[unsafe(method_family = none)]
668        pub unsafe fn permissionStatusForPermission(
669            &self,
670            permission: &WKWebExtensionPermission,
671        ) -> WKWebExtensionContextPermissionStatus;
672
673        #[cfg(all(feature = "WKWebExtensionPermission", feature = "WKWebExtensionTab"))]
674        /// Checks the specified permission against the currently denied, granted, and requested permissions.
675        ///
676        /// Parameter `permission`: The permission for which to return the status.
677        ///
678        /// Parameter `tab`: The tab in which to return the permission status, or
679        /// `nil`if the tab is not known or the global status is desired.
680        ///
681        /// Permissions can be granted on a per-tab basis. When the tab is known, access checks should always specify the tab.
682        ///
683        /// See also: permissionStatusForPermission:
684        ///
685        /// See also: hasPermission:inTab:
686        #[unsafe(method(permissionStatusForPermission:inTab:))]
687        #[unsafe(method_family = none)]
688        pub unsafe fn permissionStatusForPermission_inTab(
689            &self,
690            permission: &WKWebExtensionPermission,
691            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
692        ) -> WKWebExtensionContextPermissionStatus;
693
694        #[cfg(feature = "WKWebExtensionPermission")]
695        /// Sets the status of a permission with a distant future expiration date.
696        ///
697        /// Parameter `status`: The new permission status to set for the given permission.
698        ///
699        /// Parameter `permission`: The permission for which to set the status.
700        ///
701        /// This method will update ``grantedPermissions`` and ``deniedPermissions``. Use this method for changing a single permission's status.
702        /// Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``, and ``WKWebExtensionContextPermissionStatusGrantedExplicitly``
703        /// states are allowed to be set using this method.
704        ///
705        /// See also: setPermissionStatus:forPermission:expirationDate:
706        ///
707        /// See also: setPermissionStatus:forPermission:inTab:
708        #[unsafe(method(setPermissionStatus:forPermission:))]
709        #[unsafe(method_family = none)]
710        pub unsafe fn setPermissionStatus_forPermission(
711            &self,
712            status: WKWebExtensionContextPermissionStatus,
713            permission: &WKWebExtensionPermission,
714        );
715
716        #[cfg(feature = "WKWebExtensionPermission")]
717        /// Sets the status of a permission with a specific expiration date.
718        ///
719        /// Parameter `status`: The new permission status to set for the given permission.
720        ///
721        /// Parameter `permission`: The permission for which to set the status.
722        ///
723        /// Parameter `expirationDate`: The expiration date for the new permission status, or
724        /// `nil`for distant future.
725        ///
726        /// This method will update ``grantedPermissions`` and ``deniedPermissions``. Use this method for changing a single permission's status.
727        /// Passing a `nil` expiration date will be treated as a distant future date. Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``,
728        /// and ``WKWebExtensionContextPermissionStatusGrantedExplicitly`` states are allowed to be set using this method.
729        ///
730        /// See also: setPermissionStatus:forPermission:
731        ///
732        /// See also: setPermissionStatus:forPermission:inTab:
733        #[unsafe(method(setPermissionStatus:forPermission:expirationDate:))]
734        #[unsafe(method_family = none)]
735        pub unsafe fn setPermissionStatus_forPermission_expirationDate(
736            &self,
737            status: WKWebExtensionContextPermissionStatus,
738            permission: &WKWebExtensionPermission,
739            expiration_date: Option<&NSDate>,
740        );
741
742        /// Checks the specified URL against the currently denied, granted, and requested permission match patterns.
743        ///
744        /// Parameter `url`: The URL for which to return the status.
745        ///
746        /// URLs and match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.
747        ///
748        /// See also: permissionStatusForURL:inTab:
749        ///
750        /// See also: hasAccessToURL:
751        #[unsafe(method(permissionStatusForURL:))]
752        #[unsafe(method_family = none)]
753        pub unsafe fn permissionStatusForURL(
754            &self,
755            url: &NSURL,
756        ) -> WKWebExtensionContextPermissionStatus;
757
758        #[cfg(feature = "WKWebExtensionTab")]
759        /// Checks the specified URL against the currently denied, granted, and requested permission match patterns.
760        ///
761        /// Parameter `url`: The URL for which to return the status.
762        ///
763        /// Parameter `tab`: The tab in which to return the permission status, or
764        /// `nil`if the tab is not known or the global status is desired.
765        ///
766        /// URLs and match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.
767        ///
768        /// See also: permissionStatusForURL:
769        ///
770        /// See also: hasAccessToURL:inTab:
771        #[unsafe(method(permissionStatusForURL:inTab:))]
772        #[unsafe(method_family = none)]
773        pub unsafe fn permissionStatusForURL_inTab(
774            &self,
775            url: &NSURL,
776            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
777        ) -> WKWebExtensionContextPermissionStatus;
778
779        /// Sets the permission status of a URL with a distant future expiration date.
780        ///
781        /// Parameter `status`: The new permission status to set for the given URL.
782        ///
783        /// Parameter `url`: The URL for which to set the status.
784        ///
785        /// The URL is converted into a match pattern and will update ``grantedPermissionMatchPatterns`` and ``deniedPermissionMatchPatterns``. Use this method for changing a single URL's status.
786        /// Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``, and ``WKWebExtensionContextPermissionStatusGrantedExplicitly``
787        /// states are allowed to be set using this method.
788        ///
789        /// See also: setPermissionStatus:forURL:expirationDate:
790        ///
791        /// See also: setPermissionStatus:forURL:inTab:
792        #[unsafe(method(setPermissionStatus:forURL:))]
793        #[unsafe(method_family = none)]
794        pub unsafe fn setPermissionStatus_forURL(
795            &self,
796            status: WKWebExtensionContextPermissionStatus,
797            url: &NSURL,
798        );
799
800        /// Sets the permission status of a URL with a distant future expiration date.
801        ///
802        /// Parameter `status`: The new permission status to set for the given URL.
803        ///
804        /// Parameter `url`: The URL for which to set the status.
805        ///
806        /// Parameter `expirationDate`: The expiration date for the new permission status, or
807        /// `nil`for distant future.
808        ///
809        /// The URL is converted into a match pattern and will update ``grantedPermissionMatchPatterns`` and ``deniedPermissionMatchPatterns``. Use this method for changing a single URL's status.
810        /// Passing a `nil` expiration date will be treated as a distant future date. Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``,
811        /// and ``WKWebExtensionContextPermissionStatusGrantedExplicitly`` states are allowed to be set using this method.
812        ///
813        /// See also: setPermissionStatus:forURL:
814        ///
815        /// See also: setPermissionStatus:forURL:inTab:
816        #[unsafe(method(setPermissionStatus:forURL:expirationDate:))]
817        #[unsafe(method_family = none)]
818        pub unsafe fn setPermissionStatus_forURL_expirationDate(
819            &self,
820            status: WKWebExtensionContextPermissionStatus,
821            url: &NSURL,
822            expiration_date: Option<&NSDate>,
823        );
824
825        #[cfg(feature = "WKWebExtensionMatchPattern")]
826        /// Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
827        ///
828        /// Parameter `pattern`: The pattern for which to return the status.
829        ///
830        /// Match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use the method that checks in a tab.
831        ///
832        /// See also: permissionStatusForMatchPattern:inTab:
833        ///
834        /// See also: hasAccessToURL:inTab:
835        #[unsafe(method(permissionStatusForMatchPattern:))]
836        #[unsafe(method_family = none)]
837        pub unsafe fn permissionStatusForMatchPattern(
838            &self,
839            pattern: &WKWebExtensionMatchPattern,
840        ) -> WKWebExtensionContextPermissionStatus;
841
842        #[cfg(all(feature = "WKWebExtensionMatchPattern", feature = "WKWebExtensionTab"))]
843        /// Checks the specified match pattern against the currently denied, granted, and requested permission match patterns.
844        ///
845        /// Parameter `pattern`: The pattern for which to return the status.
846        ///
847        /// Parameter `tab`: The tab in which to return the permission status, or
848        /// `nil`if the tab is not known or the global status is desired.
849        ///
850        /// Match patterns can be granted on a per-tab basis. When the tab is known, access checks should always use this method.
851        ///
852        /// See also: permissionStatusForMatchPattern:
853        ///
854        /// See also: hasAccessToURL:inTab:
855        #[unsafe(method(permissionStatusForMatchPattern:inTab:))]
856        #[unsafe(method_family = none)]
857        pub unsafe fn permissionStatusForMatchPattern_inTab(
858            &self,
859            pattern: &WKWebExtensionMatchPattern,
860            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
861        ) -> WKWebExtensionContextPermissionStatus;
862
863        #[cfg(feature = "WKWebExtensionMatchPattern")]
864        /// Sets the status of a match pattern with a distant future expiration date.
865        ///
866        /// Parameter `status`: The new permission status to set for the given match pattern.
867        ///
868        /// Parameter `pattern`: The match pattern for which to set the status.
869        ///
870        /// This method will update ``grantedPermissionMatchPatterns`` and ``deniedPermissionMatchPatterns``. Use this method for changing a single match pattern's status.
871        /// Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``, and ``WKWebExtensionContextPermissionStatusGrantedExplicitly``
872        /// states are allowed to be set using this method.
873        ///
874        /// See also: setPermissionStatus:forMatchPattern:expirationDate:
875        ///
876        /// See also: setPermissionStatus:forMatchPattern:inTab:
877        #[unsafe(method(setPermissionStatus:forMatchPattern:))]
878        #[unsafe(method_family = none)]
879        pub unsafe fn setPermissionStatus_forMatchPattern(
880            &self,
881            status: WKWebExtensionContextPermissionStatus,
882            pattern: &WKWebExtensionMatchPattern,
883        );
884
885        #[cfg(feature = "WKWebExtensionMatchPattern")]
886        /// Sets the status of a match pattern with a specific expiration date.
887        ///
888        /// Parameter `status`: The new permission status to set for the given match pattern.
889        ///
890        /// Parameter `pattern`: The match pattern for which to set the status.
891        ///
892        /// Parameter `expirationDate`: The expiration date for the new permission status, or
893        /// `nil`for distant future.
894        ///
895        /// This method will update ``grantedPermissionMatchPatterns`` and ``deniedPermissionMatchPatterns``. Use this method for changing a single match pattern's status.
896        /// Passing a `nil` expiration date will be treated as a distant future date. Only ``WKWebExtensionContextPermissionStatusDeniedExplicitly``, ``WKWebExtensionContextPermissionStatusUnknown``,
897        /// and ``WKWebExtensionContextPermissionStatusGrantedExplicitly`` states are allowed to be set using this method.
898        ///
899        /// See also: setPermissionStatus:forMatchPattern:
900        ///
901        /// See also: setPermissionStatus:forMatchPattern:inTab:
902        #[unsafe(method(setPermissionStatus:forMatchPattern:expirationDate:))]
903        #[unsafe(method_family = none)]
904        pub unsafe fn setPermissionStatus_forMatchPattern_expirationDate(
905            &self,
906            status: WKWebExtensionContextPermissionStatus,
907            pattern: &WKWebExtensionMatchPattern,
908            expiration_date: Option<&NSDate>,
909        );
910
911        #[cfg(feature = "block2")]
912        /// Loads the background content if needed for the extension.
913        ///
914        /// Parameter `completionHandler`: A block to be called upon completion of the loading process, with an optional error.
915        ///
916        /// This method forces the loading of the background content for the extension that will otherwise be loaded on-demand during specific events.
917        /// It is useful when the app requires the background content to be loaded for other reasons. If the background content is already loaded, the completion handler
918        /// will be called immediately. An error will occur if the extension does not have any background content to load or loading fails.
919        #[unsafe(method(loadBackgroundContentWithCompletionHandler:))]
920        #[unsafe(method_family = none)]
921        pub unsafe fn loadBackgroundContentWithCompletionHandler(
922            &self,
923            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
924        );
925
926        #[cfg(all(feature = "WKWebExtensionAction", feature = "WKWebExtensionTab"))]
927        /// Retrieves the extension action for a given tab, or the default action if `nil` is passed.
928        ///
929        /// Parameter `tab`: The tab for which to retrieve the extension action, or `nil` to get the default action.
930        ///
931        /// The returned object represents the action specific to the tab when provided; otherwise, it returns the default action. The default
932        /// action is useful when the context is unrelated to a specific tab. When possible, specify the tab to get the most context-relevant action.
933        ///
934        /// See also: performActionForTab:
935        #[unsafe(method(actionForTab:))]
936        #[unsafe(method_family = none)]
937        pub unsafe fn actionForTab(
938            &self,
939            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
940        ) -> Option<Retained<WKWebExtensionAction>>;
941
942        #[cfg(feature = "WKWebExtensionTab")]
943        /// Performs the extension action associated with the specified tab or performs the default action if `nil` is passed.
944        ///
945        /// Parameter `tab`: The tab for which to perform the extension action, or `nil` to perform the default action.
946        ///
947        /// Performing the action will mark the tab, if specified, as having an active user gesture. When the ``tab`` parameter is `nil`,
948        /// the default action is performed. The action can either trigger an event or display a popup, depending on how the extension is configured.
949        /// If the action is configured to display a popup, implementing the appropriate web extension controller delegate method is required; otherwise,
950        /// no action is performed for popup actions.
951        #[unsafe(method(performActionForTab:))]
952        #[unsafe(method_family = none)]
953        pub unsafe fn performActionForTab(
954            &self,
955            tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
956        );
957
958        #[cfg(feature = "WKWebExtensionCommand")]
959        /// The commands associated with the extension.
960        ///
961        /// Provides all commands registered within the extension. Each command represents an action or behavior available for the web extension.
962        ///
963        /// See also: performCommand:
964        #[unsafe(method(commands))]
965        #[unsafe(method_family = none)]
966        pub unsafe fn commands(&self) -> Retained<NSArray<WKWebExtensionCommand>>;
967
968        #[cfg(feature = "WKWebExtensionCommand")]
969        /// Performs the specified command, triggering events specific to this extension.
970        ///
971        /// Parameter `command`: The command to be performed.
972        ///
973        /// This method performs the given command as if it was triggered by a user gesture within the context of the focused window and active tab.
974        #[unsafe(method(performCommand:))]
975        #[unsafe(method_family = none)]
976        pub unsafe fn performCommand(&self, command: &WKWebExtensionCommand);
977
978        #[cfg(feature = "objc2-app-kit")]
979        #[cfg(target_os = "macos")]
980        /// Performs the command associated with the given event.
981        ///
982        /// This method checks for a command corresponding to the provided event and performs it, if available. The app should use this method to perform
983        /// any extension commands at an appropriate time in the app's event handling, like in ``sendEvent:`` of ``NSApplication`` or ``NSWindow`` subclasses.
984        ///
985        /// Parameter `event`: The event representing the user input.
986        ///
987        /// Returns: Returns `YES` if a command corresponding to the event was found and performed, `NO` otherwise.
988        #[unsafe(method(performCommandForEvent:))]
989        #[unsafe(method_family = none)]
990        pub unsafe fn performCommandForEvent(&self, event: &NSEvent) -> bool;
991
992        #[cfg(all(feature = "WKWebExtensionCommand", feature = "objc2-app-kit"))]
993        #[cfg(target_os = "macos")]
994        /// Retrieves the command associated with the given event without performing it.
995        ///
996        /// Returns the command that corresponds to the provided event, if such a command exists. This provides a way to programmatically
997        /// determine what action would occur for a given event, without triggering the command.
998        ///
999        /// Parameter `event`: The event for which to retrieve the corresponding command.
1000        ///
1001        /// Returns: The command associated with the event, or `nil` if there is no such command.
1002        #[unsafe(method(commandForEvent:))]
1003        #[unsafe(method_family = none)]
1004        pub unsafe fn commandForEvent(
1005            &self,
1006            event: &NSEvent,
1007        ) -> Option<Retained<WKWebExtensionCommand>>;
1008
1009        #[cfg(all(feature = "WKWebExtensionTab", feature = "objc2-app-kit"))]
1010        #[cfg(target_os = "macos")]
1011        #[unsafe(method(menuItemsForTab:))]
1012        #[unsafe(method_family = none)]
1013        pub unsafe fn menuItemsForTab(
1014            &self,
1015            tab: &ProtocolObject<dyn WKWebExtensionTab>,
1016        ) -> Retained<NSArray<NSMenuItem>>;
1017
1018        #[cfg(feature = "WKWebExtensionTab")]
1019        /// Should be called by the app when a user gesture is performed in a specific tab.
1020        ///
1021        /// Parameter `tab`: The tab in which the user gesture was performed.
1022        ///
1023        /// When a user gesture is performed in a tab, this method should be called to update the extension context.
1024        /// This enables the extension to be aware of the user gesture, potentially granting it access to features that require user interaction,
1025        /// such as `activeTab`. Not required if using ``performActionForTab:``.
1026        ///
1027        /// See also: hasActiveUserGestureInTab:
1028        #[unsafe(method(userGesturePerformedInTab:))]
1029        #[unsafe(method_family = none)]
1030        pub unsafe fn userGesturePerformedInTab(&self, tab: &ProtocolObject<dyn WKWebExtensionTab>);
1031
1032        #[cfg(feature = "WKWebExtensionTab")]
1033        /// Indicates if a user gesture is currently active in the specified tab.
1034        ///
1035        /// Parameter `tab`: The tab for which to check for an active user gesture.
1036        ///
1037        /// An active user gesture may influence the availability of certain permissions, such as `activeTab`. User gestures can
1038        /// be triggered by various user interactions with the web extension, including clicking on extension menu items, executing extension commands,
1039        /// or interacting with extension actions. A tab as having an active user gesture enables the extension to access features that require user interaction.
1040        ///
1041        /// See also: userGesturePerformedInTab:
1042        #[unsafe(method(hasActiveUserGestureInTab:))]
1043        #[unsafe(method_family = none)]
1044        pub unsafe fn hasActiveUserGestureInTab(
1045            &self,
1046            tab: &ProtocolObject<dyn WKWebExtensionTab>,
1047        ) -> bool;
1048
1049        #[cfg(feature = "WKWebExtensionTab")]
1050        /// Should be called by the app to clear a user gesture in a specific tab.
1051        ///
1052        /// Parameter `tab`: The tab from which the user gesture should be cleared.
1053        ///
1054        /// When a user gesture is no longer relevant in a tab, this method should be called to update the extension context.
1055        /// This will revoke the extension's access to features that require active user interaction, such as `activeTab`. User gestures are
1056        /// automatically cleared during navigation in certain scenarios; this method is needed if the app intends to clear the gesture more aggressively.
1057        ///
1058        /// See also: userGesturePerformedInTab:
1059        #[unsafe(method(clearUserGestureInTab:))]
1060        #[unsafe(method_family = none)]
1061        pub unsafe fn clearUserGestureInTab(&self, tab: &ProtocolObject<dyn WKWebExtensionTab>);
1062
1063        #[cfg(feature = "WKWebExtensionWindow")]
1064        /// The open windows that are exposed to this extension.
1065        ///
1066        /// Provides the windows that are open and visible to the extension, as updated by the ``didOpenWindow:`` and ``didCloseWindow:`` methods.
1067        /// Initially populated by the windows returned by the extension controller delegate method ``webExtensionController:openWindowsForExtensionContext:``.
1068        ///
1069        /// See also: didOpenWindow:
1070        ///
1071        /// See also: didCloseWindow:
1072        #[unsafe(method(openWindows))]
1073        #[unsafe(method_family = none)]
1074        pub unsafe fn openWindows(
1075            &self,
1076        ) -> Retained<NSArray<ProtocolObject<dyn WKWebExtensionWindow>>>;
1077
1078        #[cfg(feature = "WKWebExtensionWindow")]
1079        /// The window that currently has focus for this extension.
1080        ///
1081        /// Provides the window that currently has focus, as set by the ``didFocusWindow:`` method.
1082        /// It will be `nil` if no window has focus or if a window has focus that is not visible to the extension. Initially populated by the window
1083        /// returned by the extension controller delegate method ``webExtensionController:focusedWindowForExtensionContext:``.
1084        ///
1085        /// See also: didFocusWindow:
1086        #[unsafe(method(focusedWindow))]
1087        #[unsafe(method_family = none)]
1088        pub unsafe fn focusedWindow(
1089            &self,
1090        ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionWindow>>>;
1091
1092        #[cfg(feature = "WKWebExtensionTab")]
1093        /// A set of open tabs in all open windows that are exposed to this extension.
1094        ///
1095        /// Provides a set of tabs in all open windows that are visible to the extension, as updated by the ``didOpenTab:`` and ``didCloseTab:`` methods.
1096        /// Initially populated by the tabs in the windows returned by the extension controller delegate method ``webExtensionController:openWindowsForExtensionContext:``.
1097        ///
1098        /// See also: didOpenTab:
1099        ///
1100        /// See also: didCloseTab:
1101        #[unsafe(method(openTabs))]
1102        #[unsafe(method_family = none)]
1103        pub unsafe fn openTabs(&self) -> Retained<NSSet<ProtocolObject<dyn WKWebExtensionTab>>>;
1104
1105        #[cfg(feature = "WKWebExtensionWindow")]
1106        /// Should be called by the app when a new window is opened to fire appropriate events with only this extension.
1107        ///
1108        /// Parameter `newWindow`: The newly opened window.
1109        ///
1110        /// This method informs only the specific extension of the opening of a new window. If the intention is to inform all loaded
1111        /// extensions consistently, you should use the respective method on the extension controller instead.
1112        ///
1113        /// See also: didCloseWindow:
1114        ///
1115        /// See also: openWindows
1116        #[unsafe(method(didOpenWindow:))]
1117        #[unsafe(method_family = none)]
1118        pub unsafe fn didOpenWindow(&self, new_window: &ProtocolObject<dyn WKWebExtensionWindow>);
1119
1120        #[cfg(feature = "WKWebExtensionWindow")]
1121        /// Should be called by the app when a window is closed to fire appropriate events with only this extension.
1122        ///
1123        /// Parameter `newWindow`: The window that was closed.
1124        ///
1125        /// This method informs only the specific extension of the closure of a window. If the intention is to inform all loaded
1126        /// extensions consistently, you should use the respective method on the extension controller instead.
1127        ///
1128        /// See also: didOpenWindow:
1129        ///
1130        /// See also: openWindows
1131        #[unsafe(method(didCloseWindow:))]
1132        #[unsafe(method_family = none)]
1133        pub unsafe fn didCloseWindow(
1134            &self,
1135            closed_window: &ProtocolObject<dyn WKWebExtensionWindow>,
1136        );
1137
1138        #[cfg(feature = "WKWebExtensionWindow")]
1139        /// Should be called by the app when a window gains focus to fire appropriate events with only this extension.
1140        ///
1141        /// Parameter `focusedWindow`: The window that gained focus, or
1142        /// `nil`if no window has focus or a window has focus that is not visible to this extension.
1143        ///
1144        /// This method informs only the specific extension that a window has gained focus. If the intention is to inform all loaded
1145        /// extensions consistently, you should use the respective method on the extension controller instead.
1146        #[unsafe(method(didFocusWindow:))]
1147        #[unsafe(method_family = none)]
1148        pub unsafe fn didFocusWindow(
1149            &self,
1150            focused_window: Option<&ProtocolObject<dyn WKWebExtensionWindow>>,
1151        );
1152
1153        #[cfg(feature = "WKWebExtensionTab")]
1154        /// Should be called by the app when a new tab is opened to fire appropriate events with only this extension.
1155        ///
1156        /// Parameter `newTab`: The newly opened tab.
1157        ///
1158        /// This method informs only the specific extension of the opening of a new tab. If the intention is to inform all loaded
1159        /// extensions consistently, you should use the respective method on the extension controller instead.
1160        ///
1161        /// See also: didCloseTab:
1162        ///
1163        /// See also: openTabs
1164        #[unsafe(method(didOpenTab:))]
1165        #[unsafe(method_family = none)]
1166        pub unsafe fn didOpenTab(&self, new_tab: &ProtocolObject<dyn WKWebExtensionTab>);
1167
1168        #[cfg(feature = "WKWebExtensionTab")]
1169        /// Should be called by the app when a tab is closed to fire appropriate events with only this extension.
1170        ///
1171        /// Parameter `closedTab`: The tab that was closed.
1172        ///
1173        /// Parameter `windowIsClosing`: A boolean value indicating whether the window containing the tab is also closing.
1174        ///
1175        /// This method informs only the specific extension of the closure of a tab. If the intention is to inform all loaded
1176        /// extensions consistently, you should use the respective method on the extension controller instead.
1177        ///
1178        /// See also: didOpenTab:
1179        ///
1180        /// See also: openTabs
1181        #[unsafe(method(didCloseTab:windowIsClosing:))]
1182        #[unsafe(method_family = none)]
1183        pub unsafe fn didCloseTab_windowIsClosing(
1184            &self,
1185            closed_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1186            window_is_closing: bool,
1187        );
1188
1189        #[cfg(feature = "WKWebExtensionTab")]
1190        /// Should be called by the app when a tab is activated to notify only this specific extension.
1191        ///
1192        /// Parameter `activatedTab`: The tab that has become active.
1193        ///
1194        /// Parameter `previousTab`: The tab that was active before. This parameter can be
1195        /// `nil`if there was no previously active tab.
1196        ///
1197        /// This method informs only the specific extension of the tab activation. If the intention is to inform all loaded
1198        /// extensions consistently, you should use the respective method on the extension controller instead.
1199        #[unsafe(method(didActivateTab:previousActiveTab:))]
1200        #[unsafe(method_family = none)]
1201        pub unsafe fn didActivateTab_previousActiveTab(
1202            &self,
1203            activated_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1204            previous_tab: Option<&ProtocolObject<dyn WKWebExtensionTab>>,
1205        );
1206
1207        #[cfg(feature = "WKWebExtensionTab")]
1208        /// Should be called by the app when tabs are selected to fire appropriate events with only this extension.
1209        ///
1210        /// Parameter `selectedTabs`: The set of tabs that were selected.
1211        ///
1212        /// This method informs only the specific extension that tabs have been selected. If the intention is to inform all loaded
1213        /// extensions consistently, you should use the respective method on the extension controller instead.
1214        #[unsafe(method(didSelectTabs:))]
1215        #[unsafe(method_family = none)]
1216        pub unsafe fn didSelectTabs(
1217            &self,
1218            selected_tabs: &NSArray<ProtocolObject<dyn WKWebExtensionTab>>,
1219        );
1220
1221        #[cfg(feature = "WKWebExtensionTab")]
1222        /// Should be called by the app when tabs are deselected to fire appropriate events with only this extension.
1223        ///
1224        /// Parameter `deselectedTabs`: The set of tabs that were deselected.
1225        ///
1226        /// This method informs only the specific extension that tabs have been deselected. If the intention is to inform all loaded
1227        /// extensions consistently, you should use the respective method on the extension controller instead.
1228        #[unsafe(method(didDeselectTabs:))]
1229        #[unsafe(method_family = none)]
1230        pub unsafe fn didDeselectTabs(
1231            &self,
1232            deselected_tabs: &NSArray<ProtocolObject<dyn WKWebExtensionTab>>,
1233        );
1234
1235        #[cfg(all(feature = "WKWebExtensionTab", feature = "WKWebExtensionWindow"))]
1236        /// Should be called by the app when a tab is moved to fire appropriate events with only this extension.
1237        ///
1238        /// Parameter `movedTab`: The tab that was moved.
1239        ///
1240        /// Parameter `index`: The old index of the tab within the window.
1241        ///
1242        /// Parameter `oldWindow`: The window that the tab was moved from, or
1243        /// `nil`if the tab is moving from no open window.
1244        ///
1245        /// If the window is staying the same, the current window should be specified. This method informs only the specific extension
1246        /// that a tab has been moved. If the intention is to inform all loaded extensions consistently, you should use the respective method on
1247        /// the extension controller instead.
1248        #[unsafe(method(didMoveTab:fromIndex:inWindow:))]
1249        #[unsafe(method_family = none)]
1250        pub unsafe fn didMoveTab_fromIndex_inWindow(
1251            &self,
1252            moved_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1253            index: NSUInteger,
1254            old_window: Option<&ProtocolObject<dyn WKWebExtensionWindow>>,
1255        );
1256
1257        #[cfg(feature = "WKWebExtensionTab")]
1258        /// Should be called by the app when a tab is replaced by another tab to fire appropriate events with only this extension.
1259        ///
1260        /// Parameter `oldTab`: The tab that was replaced.
1261        ///
1262        /// Parameter `newTab`: The tab that replaced the old tab.
1263        ///
1264        /// This method informs only the specific extension that a tab has been replaced. If the intention is to inform all loaded
1265        /// extensions consistently, you should use the respective method on the extension controller instead.
1266        #[unsafe(method(didReplaceTab:withTab:))]
1267        #[unsafe(method_family = none)]
1268        pub unsafe fn didReplaceTab_withTab(
1269            &self,
1270            old_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1271            new_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1272        );
1273
1274        #[cfg(feature = "WKWebExtensionTab")]
1275        /// Should be called by the app when the properties of a tab are changed to fire appropriate events with only this extension.
1276        ///
1277        /// Parameter `properties`: The properties of the tab that were changed.
1278        ///
1279        /// Parameter `changedTab`: The tab whose properties were changed.
1280        ///
1281        /// This method informs only the specific extension of the changes to a tab's properties. If the intention is to inform all loaded
1282        /// extensions consistently, you should use the respective method on the extension controller instead.
1283        #[unsafe(method(didChangeTabProperties:forTab:))]
1284        #[unsafe(method_family = none)]
1285        pub unsafe fn didChangeTabProperties_forTab(
1286            &self,
1287            properties: WKWebExtensionTabChangedProperties,
1288            changed_tab: &ProtocolObject<dyn WKWebExtensionTab>,
1289        );
1290    );
1291}