objc2_web_kit/generated/
WKWebView.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#[cfg(feature = "objc2-security")]
13use objc2_security::*;
14
15use crate::*;
16
17/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkmediaplaybackstate?language=objc)
18// NS_ENUM
19#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct WKMediaPlaybackState(pub NSInteger);
22impl WKMediaPlaybackState {
23    #[doc(alias = "WKMediaPlaybackStateNone")]
24    pub const None: Self = Self(0);
25    #[doc(alias = "WKMediaPlaybackStatePlaying")]
26    pub const Playing: Self = Self(1);
27    #[doc(alias = "WKMediaPlaybackStatePaused")]
28    pub const Paused: Self = Self(2);
29    #[doc(alias = "WKMediaPlaybackStateSuspended")]
30    pub const Suspended: Self = Self(3);
31}
32
33unsafe impl Encode for WKMediaPlaybackState {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for WKMediaPlaybackState {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkmediacapturestate?language=objc)
42// NS_ENUM
43#[repr(transparent)]
44#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
45pub struct WKMediaCaptureState(pub NSInteger);
46impl WKMediaCaptureState {
47    #[doc(alias = "WKMediaCaptureStateNone")]
48    pub const None: Self = Self(0);
49    #[doc(alias = "WKMediaCaptureStateActive")]
50    pub const Active: Self = Self(1);
51    #[doc(alias = "WKMediaCaptureStateMuted")]
52    pub const Muted: Self = Self(2);
53}
54
55unsafe impl Encode for WKMediaCaptureState {
56    const ENCODING: Encoding = NSInteger::ENCODING;
57}
58
59unsafe impl RefEncode for WKMediaCaptureState {
60    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
61}
62
63/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkfullscreenstate?language=objc)
64// NS_ENUM
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct WKFullscreenState(pub NSInteger);
68impl WKFullscreenState {
69    #[doc(alias = "WKFullscreenStateNotInFullscreen")]
70    pub const NotInFullscreen: Self = Self(0);
71    #[doc(alias = "WKFullscreenStateEnteringFullscreen")]
72    pub const EnteringFullscreen: Self = Self(1);
73    #[doc(alias = "WKFullscreenStateInFullscreen")]
74    pub const InFullscreen: Self = Self(2);
75    #[doc(alias = "WKFullscreenStateExitingFullscreen")]
76    pub const ExitingFullscreen: Self = Self(3);
77}
78
79unsafe impl Encode for WKFullscreenState {
80    const ENCODING: Encoding = NSInteger::ENCODING;
81}
82
83unsafe impl RefEncode for WKFullscreenState {
84    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
85}
86
87/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebviewdatatype?language=objc)
88// NS_OPTIONS
89#[repr(transparent)]
90#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
91pub struct WKWebViewDataType(pub NSUInteger);
92bitflags::bitflags! {
93    impl WKWebViewDataType: NSUInteger {
94        #[doc(alias = "WKWebViewDataTypeSessionStorage")]
95        const SessionStorage = 1<<0;
96    }
97}
98
99unsafe impl Encode for WKWebViewDataType {
100    const ENCODING: Encoding = NSUInteger::ENCODING;
101}
102
103unsafe impl RefEncode for WKWebViewDataType {
104    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
105}
106
107extern_class!(
108    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebview?language=objc)
109    #[unsafe(super(NSView, NSResponder, NSObject))]
110    #[thread_kind = MainThreadOnly]
111    #[derive(Debug, PartialEq, Eq, Hash)]
112    #[cfg(feature = "objc2-app-kit")]
113    #[cfg(target_os = "macos")]
114    pub struct WKWebView;
115);
116
117#[cfg(feature = "objc2-app-kit")]
118#[cfg(target_os = "macos")]
119extern_conformance!(
120    unsafe impl NSAccessibility for WKWebView {}
121);
122
123#[cfg(feature = "objc2-app-kit")]
124#[cfg(target_os = "macos")]
125extern_conformance!(
126    unsafe impl NSAccessibilityElementProtocol for WKWebView {}
127);
128
129#[cfg(feature = "objc2-app-kit")]
130#[cfg(target_os = "macos")]
131extern_conformance!(
132    unsafe impl NSAnimatablePropertyContainer for WKWebView {}
133);
134
135#[cfg(feature = "objc2-app-kit")]
136#[cfg(target_os = "macos")]
137extern_conformance!(
138    unsafe impl NSAppearanceCustomization for WKWebView {}
139);
140
141#[cfg(feature = "objc2-app-kit")]
142#[cfg(target_os = "macos")]
143extern_conformance!(
144    unsafe impl NSCoding for WKWebView {}
145);
146
147#[cfg(feature = "objc2-app-kit")]
148#[cfg(target_os = "macos")]
149extern_conformance!(
150    unsafe impl NSDraggingDestination for WKWebView {}
151);
152
153#[cfg(feature = "objc2-app-kit")]
154#[cfg(target_os = "macos")]
155extern_conformance!(
156    unsafe impl NSObjectProtocol for WKWebView {}
157);
158
159#[cfg(feature = "objc2-app-kit")]
160#[cfg(target_os = "macos")]
161extern_conformance!(
162    unsafe impl NSUserInterfaceItemIdentification for WKWebView {}
163);
164
165#[cfg(feature = "objc2-app-kit")]
166#[cfg(target_os = "macos")]
167impl WKWebView {
168    extern_methods!(
169        #[cfg(feature = "WKWebViewConfiguration")]
170        /// A copy of the configuration with which the web view was
171        /// initialized.
172        #[unsafe(method(configuration))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn configuration(&self) -> Retained<WKWebViewConfiguration>;
175
176        #[cfg(feature = "WKNavigationDelegate")]
177        /// The web view's navigation delegate.
178        #[unsafe(method(navigationDelegate))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn navigationDelegate(
181            &self,
182        ) -> Option<Retained<ProtocolObject<dyn WKNavigationDelegate>>>;
183
184        #[cfg(feature = "WKNavigationDelegate")]
185        /// Setter for [`navigationDelegate`][Self::navigationDelegate].
186        ///
187        /// This is a [weak property][objc2::topics::weak_property].
188        #[unsafe(method(setNavigationDelegate:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setNavigationDelegate(
191            &self,
192            navigation_delegate: Option<&ProtocolObject<dyn WKNavigationDelegate>>,
193        );
194
195        #[cfg(feature = "WKUIDelegate")]
196        /// The web view's user interface delegate.
197        #[unsafe(method(UIDelegate))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn UIDelegate(&self) -> Option<Retained<ProtocolObject<dyn WKUIDelegate>>>;
200
201        #[cfg(feature = "WKUIDelegate")]
202        /// Setter for [`UIDelegate`][Self::UIDelegate].
203        ///
204        /// This is a [weak property][objc2::topics::weak_property].
205        #[unsafe(method(setUIDelegate:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn setUIDelegate(&self, ui_delegate: Option<&ProtocolObject<dyn WKUIDelegate>>);
208
209        #[cfg(feature = "WKBackForwardList")]
210        /// The web view's back-forward list.
211        #[unsafe(method(backForwardList))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn backForwardList(&self) -> Retained<WKBackForwardList>;
214
215        #[cfg(all(feature = "WKWebViewConfiguration", feature = "objc2-core-foundation"))]
216        /// Returns a web view initialized with a specified frame and
217        /// configuration.
218        ///
219        /// Parameter `frame`: The frame for the new web view.
220        ///
221        /// Parameter `configuration`: The configuration for the new web view.
222        ///
223        /// Returns: An initialized web view, or nil if the object could not be
224        /// initialized.
225        ///
226        /// This is a designated initializer. You can use
227        ///
228        /// ```text
229        ///  -initWithFrame:
230        /// ```
231        ///
232        /// to initialize an instance with the default
233        /// configuration. The initializer copies the specified configuration, so
234        /// mutating the configuration after invoking the initializer has no effect
235        /// on the web view.
236        #[unsafe(method(initWithFrame:configuration:))]
237        #[unsafe(method_family = init)]
238        pub unsafe fn initWithFrame_configuration(
239            this: Allocated<Self>,
240            frame: CGRect,
241            configuration: &WKWebViewConfiguration,
242        ) -> Retained<Self>;
243
244        /// # Safety
245        ///
246        /// `coder` possibly has further requirements.
247        #[unsafe(method(initWithCoder:))]
248        #[unsafe(method_family = init)]
249        pub unsafe fn initWithCoder(
250            this: Allocated<Self>,
251            coder: &NSCoder,
252        ) -> Option<Retained<Self>>;
253
254        #[cfg(feature = "WKNavigation")]
255        /// Navigates to a requested URL.
256        ///
257        /// Parameter `request`: The request specifying the URL to which to navigate.
258        ///
259        /// Returns: A new navigation for the given request.
260        #[unsafe(method(loadRequest:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn loadRequest(&self, request: &NSURLRequest) -> Option<Retained<WKNavigation>>;
263
264        #[cfg(feature = "WKNavigation")]
265        /// Navigates to the requested file URL on the filesystem.
266        ///
267        /// Parameter `URL`: The file URL to which to navigate.
268        ///
269        /// Parameter `readAccessURL`: The URL to allow read access to.
270        ///
271        /// If readAccessURL references a single file, only that file may be loaded by WebKit.
272        /// If readAccessURL references a directory, files inside that file may be loaded by WebKit.
273        ///
274        /// Returns: A new navigation for the given file URL.
275        #[unsafe(method(loadFileURL:allowingReadAccessToURL:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn loadFileURL_allowingReadAccessToURL(
278            &self,
279            url: &NSURL,
280            read_access_url: &NSURL,
281        ) -> Option<Retained<WKNavigation>>;
282
283        #[cfg(feature = "WKNavigation")]
284        /// Sets the webpage contents and base URL.
285        ///
286        /// Parameter `string`: The string to use as the contents of the webpage.
287        ///
288        /// Parameter `baseURL`: A URL that is used to resolve relative URLs within the document.
289        ///
290        /// Returns: A new navigation.
291        #[unsafe(method(loadHTMLString:baseURL:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn loadHTMLString_baseURL(
294            &self,
295            string: &NSString,
296            base_url: Option<&NSURL>,
297        ) -> Option<Retained<WKNavigation>>;
298
299        #[cfg(feature = "WKNavigation")]
300        /// Sets the webpage contents and base URL.
301        ///
302        /// Parameter `data`: The data to use as the contents of the webpage.
303        ///
304        /// Parameter `MIMEType`: The MIME type of the data.
305        ///
306        /// Parameter `characterEncodingName`: The data's character encoding name.
307        ///
308        /// Parameter `baseURL`: A URL that is used to resolve relative URLs within the document.
309        ///
310        /// Returns: A new navigation.
311        #[unsafe(method(loadData:MIMEType:characterEncodingName:baseURL:))]
312        #[unsafe(method_family = none)]
313        pub unsafe fn loadData_MIMEType_characterEncodingName_baseURL(
314            &self,
315            data: &NSData,
316            mime_type: &NSString,
317            character_encoding_name: &NSString,
318            base_url: &NSURL,
319        ) -> Option<Retained<WKNavigation>>;
320
321        #[cfg(all(feature = "WKBackForwardListItem", feature = "WKNavigation"))]
322        /// Navigates to an item from the back-forward list and sets it
323        /// as the current item.
324        ///
325        /// Parameter `item`: The item to which to navigate. Must be one of the items in the
326        /// web view's back-forward list.
327        ///
328        /// Returns: A new navigation to the requested item, or nil if it is already
329        /// the current item or is not part of the web view's back-forward list.
330        ///
331        /// See also: backForwardList
332        #[unsafe(method(goToBackForwardListItem:))]
333        #[unsafe(method_family = none)]
334        pub unsafe fn goToBackForwardListItem(
335            &self,
336            item: &WKBackForwardListItem,
337        ) -> Option<Retained<WKNavigation>>;
338
339        /// The page title.
340        ///
341        ///
342        /// ```text
343        ///  WKWebView
344        /// ```
345        ///
346        /// is key-value observing (KVO) compliant
347        /// for this property.
348        #[unsafe(method(title))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
351
352        /// The active URL.
353        ///
354        /// This is the URL that should be reflected in the user
355        /// interface.
356        ///
357        /// ```text
358        ///  WKWebView
359        /// ```
360        ///
361        /// is key-value observing (KVO) compliant for this
362        /// property.
363        #[unsafe(method(URL))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn URL(&self) -> Option<Retained<NSURL>>;
366
367        /// A Boolean value indicating whether the view is currently
368        /// loading content.
369        ///
370        ///
371        /// ```text
372        ///  WKWebView
373        /// ```
374        ///
375        /// is key-value observing (KVO) compliant
376        /// for this property.
377        #[unsafe(method(isLoading))]
378        #[unsafe(method_family = none)]
379        pub unsafe fn isLoading(&self) -> bool;
380
381        /// An estimate of what fraction of the current navigation has been completed.
382        ///
383        /// This value ranges from 0.0 to 1.0 based on the total number of
384        /// bytes expected to be received, including the main document and all of its
385        /// potential subresources. After a navigation completes, the value remains at 1.0
386        /// until a new navigation starts, at which point it is reset to 0.0.
387        ///
388        /// ```text
389        ///  WKWebView
390        /// ```
391        ///
392        /// is key-value observing (KVO) compliant for this
393        /// property.
394        #[unsafe(method(estimatedProgress))]
395        #[unsafe(method_family = none)]
396        pub unsafe fn estimatedProgress(&self) -> c_double;
397
398        /// A Boolean value indicating whether all resources on the page
399        /// have been loaded over securely encrypted connections.
400        ///
401        ///
402        /// ```text
403        ///  WKWebView
404        /// ```
405        ///
406        /// is key-value observing (KVO) compliant
407        /// for this property.
408        #[unsafe(method(hasOnlySecureContent))]
409        #[unsafe(method_family = none)]
410        pub unsafe fn hasOnlySecureContent(&self) -> bool;
411
412        #[cfg(feature = "objc2-security")]
413        /// A SecTrustRef for the currently committed navigation.
414        ///
415        ///
416        /// ```text
417        ///  WKWebView
418        /// ```
419        ///
420        /// is key-value observing (KVO) compliant
421        /// for this property.
422        #[unsafe(method(serverTrust))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn serverTrust(&self) -> Option<Retained<SecTrust>>;
425
426        /// A Boolean value indicating whether there is a back item in
427        /// the back-forward list that can be navigated to.
428        ///
429        ///
430        /// ```text
431        ///  WKWebView
432        /// ```
433        ///
434        /// is key-value observing (KVO) compliant
435        /// for this property.
436        ///
437        /// See also: backForwardList.
438        #[unsafe(method(canGoBack))]
439        #[unsafe(method_family = none)]
440        pub unsafe fn canGoBack(&self) -> bool;
441
442        /// A Boolean value indicating whether there is a forward item in
443        /// the back-forward list that can be navigated to.
444        ///
445        ///
446        /// ```text
447        ///  WKWebView
448        /// ```
449        ///
450        /// is key-value observing (KVO) compliant
451        /// for this property.
452        ///
453        /// See also: backForwardList.
454        #[unsafe(method(canGoForward))]
455        #[unsafe(method_family = none)]
456        pub unsafe fn canGoForward(&self) -> bool;
457
458        #[cfg(feature = "WKNavigation")]
459        /// Navigates to the back item in the back-forward list.
460        ///
461        /// Returns: A new navigation to the requested item, or nil if there is no back
462        /// item in the back-forward list.
463        #[unsafe(method(goBack))]
464        #[unsafe(method_family = none)]
465        pub unsafe fn goBack(&self) -> Option<Retained<WKNavigation>>;
466
467        #[cfg(feature = "WKNavigation")]
468        /// Navigates to the forward item in the back-forward list.
469        ///
470        /// Returns: A new navigation to the requested item, or nil if there is no
471        /// forward item in the back-forward list.
472        #[unsafe(method(goForward))]
473        #[unsafe(method_family = none)]
474        pub unsafe fn goForward(&self) -> Option<Retained<WKNavigation>>;
475
476        #[cfg(feature = "WKNavigation")]
477        /// Reloads the current page.
478        ///
479        /// Returns: A new navigation representing the reload.
480        #[unsafe(method(reload))]
481        #[unsafe(method_family = none)]
482        pub unsafe fn reload(&self) -> Option<Retained<WKNavigation>>;
483
484        #[cfg(feature = "WKNavigation")]
485        /// Reloads the current page, performing end-to-end revalidation
486        /// using cache-validating conditionals if possible.
487        ///
488        /// Returns: A new navigation representing the reload.
489        #[unsafe(method(reloadFromOrigin))]
490        #[unsafe(method_family = none)]
491        pub unsafe fn reloadFromOrigin(&self) -> Option<Retained<WKNavigation>>;
492
493        /// Stops loading all resources on the current page.
494        #[unsafe(method(stopLoading))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn stopLoading(&self);
497
498        #[cfg(feature = "block2")]
499        #[unsafe(method(evaluateJavaScript:completionHandler:))]
500        #[unsafe(method_family = none)]
501        pub unsafe fn evaluateJavaScript_completionHandler(
502            &self,
503            java_script_string: &NSString,
504            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut AnyObject, *mut NSError)>>,
505        );
506
507        #[cfg(all(
508            feature = "WKContentWorld",
509            feature = "WKFrameInfo",
510            feature = "block2"
511        ))]
512        #[unsafe(method(evaluateJavaScript:inFrame:inContentWorld:completionHandler:))]
513        #[unsafe(method_family = none)]
514        pub unsafe fn evaluateJavaScript_inFrame_inContentWorld_completionHandler(
515            &self,
516            java_script_string: &NSString,
517            frame: Option<&WKFrameInfo>,
518            content_world: &WKContentWorld,
519            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut AnyObject, *mut NSError)>>,
520        );
521
522        #[cfg(all(
523            feature = "WKContentWorld",
524            feature = "WKFrameInfo",
525            feature = "block2"
526        ))]
527        /// # Safety
528        ///
529        /// `arguments` generic should be of the correct type.
530        #[unsafe(method(callAsyncJavaScript:arguments:inFrame:inContentWorld:completionHandler:))]
531        #[unsafe(method_family = none)]
532        pub unsafe fn callAsyncJavaScript_arguments_inFrame_inContentWorld_completionHandler(
533            &self,
534            function_body: &NSString,
535            arguments: Option<&NSDictionary<NSString, AnyObject>>,
536            frame: Option<&WKFrameInfo>,
537            content_world: &WKContentWorld,
538            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut AnyObject, *mut NSError)>>,
539        );
540
541        #[cfg(feature = "block2")]
542        /// Closes all out-of-window media presentations in a WKWebView.
543        ///
544        /// Includes picture-in-picture and fullscreen.
545        #[unsafe(method(closeAllMediaPresentationsWithCompletionHandler:))]
546        #[unsafe(method_family = none)]
547        pub unsafe fn closeAllMediaPresentationsWithCompletionHandler(
548            &self,
549            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
550        );
551
552        #[deprecated]
553        #[unsafe(method(closeAllMediaPresentations))]
554        #[unsafe(method_family = none)]
555        pub unsafe fn closeAllMediaPresentations(&self);
556
557        #[cfg(feature = "block2")]
558        /// Pauses media playback in WKWebView.
559        ///
560        /// Pauses media playback. Media in the page can be restarted by calling play() on a media element or resume() on an AudioContext in JavaScript. A user can also use media controls to play media content after it has been paused.
561        #[unsafe(method(pauseAllMediaPlaybackWithCompletionHandler:))]
562        #[unsafe(method_family = none)]
563        pub unsafe fn pauseAllMediaPlaybackWithCompletionHandler(
564            &self,
565            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
566        );
567
568        #[cfg(feature = "block2")]
569        #[deprecated]
570        #[unsafe(method(pauseAllMediaPlayback:))]
571        #[unsafe(method_family = none)]
572        pub unsafe fn pauseAllMediaPlayback(
573            &self,
574            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
575        );
576
577        #[cfg(feature = "block2")]
578        /// Suspends or resumes all media playback in WKWebView.
579        ///
580        /// Parameter `suspended`: Whether media playback should be suspended or resumed.
581        ///
582        /// If suspended is true, this pauses media playback and blocks all attempts by the page or the user to resume until setAllMediaPlaybackSuspended is called again with suspended set to false. Media playback should always be suspended and resumed in pairs.
583        #[unsafe(method(setAllMediaPlaybackSuspended:completionHandler:))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn setAllMediaPlaybackSuspended_completionHandler(
586            &self,
587            suspended: bool,
588            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
589        );
590
591        #[cfg(feature = "block2")]
592        #[deprecated]
593        #[unsafe(method(resumeAllMediaPlayback:))]
594        #[unsafe(method_family = none)]
595        pub unsafe fn resumeAllMediaPlayback(
596            &self,
597            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
598        );
599
600        #[cfg(feature = "block2")]
601        #[deprecated]
602        #[unsafe(method(suspendAllMediaPlayback:))]
603        #[unsafe(method_family = none)]
604        pub unsafe fn suspendAllMediaPlayback(
605            &self,
606            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
607        );
608
609        #[cfg(feature = "block2")]
610        /// Get the current media playback state of a WKWebView.
611        ///
612        /// Parameter `completionHandler`: A block to invoke with the return value of the function call.
613        ///
614        /// If media playback exists, WKMediaPlaybackState will be one of three
615        /// values: WKMediaPlaybackPaused, WKMediaPlaybackSuspended, or WKMediaPlaybackPlaying.
616        /// If no media playback exists in the current WKWebView, WKMediaPlaybackState will equal
617        /// WKMediaPlaybackStateNone.
618        #[unsafe(method(requestMediaPlaybackStateWithCompletionHandler:))]
619        #[unsafe(method_family = none)]
620        pub unsafe fn requestMediaPlaybackStateWithCompletionHandler(
621            &self,
622            completion_handler: &block2::DynBlock<dyn Fn(WKMediaPlaybackState)>,
623        );
624
625        #[cfg(feature = "block2")]
626        #[deprecated]
627        #[unsafe(method(requestMediaPlaybackState:))]
628        #[unsafe(method_family = none)]
629        pub unsafe fn requestMediaPlaybackState(
630            &self,
631            completion_handler: &block2::DynBlock<dyn Fn(WKMediaPlaybackState)>,
632        );
633
634        /// The state of camera capture on a web page.
635        ///
636        ///
637        /// ```text
638        ///  WKWebView
639        /// ```
640        ///
641        /// is key-value observing (KVO) compliant
642        /// for this property.
643        #[unsafe(method(cameraCaptureState))]
644        #[unsafe(method_family = none)]
645        pub unsafe fn cameraCaptureState(&self) -> WKMediaCaptureState;
646
647        /// The state of microphone capture on a web page.
648        ///
649        ///
650        /// ```text
651        ///  WKWebView
652        /// ```
653        ///
654        /// is key-value observing (KVO) compliant
655        /// for this property.
656        #[unsafe(method(microphoneCaptureState))]
657        #[unsafe(method_family = none)]
658        pub unsafe fn microphoneCaptureState(&self) -> WKMediaCaptureState;
659
660        #[cfg(feature = "block2")]
661        /// Set camera capture state of a WKWebView.
662        ///
663        /// Parameter `state`: State to apply for capture.
664        ///
665        /// Parameter `completionHandler`: A block to invoke after the camera state has been changed.
666        ///
667        /// If value is WKMediaCaptureStateNone, this will stop any camera capture.
668        /// If value is WKMediaCaptureStateMuted, any active camera capture will become muted.
669        /// If value is WKMediaCaptureStateActive, any muted camera capture will become active.
670        #[unsafe(method(setCameraCaptureState:completionHandler:))]
671        #[unsafe(method_family = none)]
672        pub unsafe fn setCameraCaptureState_completionHandler(
673            &self,
674            state: WKMediaCaptureState,
675            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
676        );
677
678        #[cfg(feature = "block2")]
679        /// Set microphone capture state of a WKWebView.
680        ///
681        /// Parameter `state`: state to apply for capture.
682        ///
683        /// Parameter `completionHandler`: A block to invoke after the microphone state has been changed.
684        ///
685        /// If value is WKMediaCaptureStateNone, this will stop any microphone capture.
686        /// If value is WKMediaCaptureStateMuted, any active microphone capture will become muted.
687        /// If value is WKMediaCaptureStateActive, any muted microphone capture will become active.
688        #[unsafe(method(setMicrophoneCaptureState:completionHandler:))]
689        #[unsafe(method_family = none)]
690        pub unsafe fn setMicrophoneCaptureState_completionHandler(
691            &self,
692            state: WKMediaCaptureState,
693            completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
694        );
695
696        #[cfg(all(feature = "WKSnapshotConfiguration", feature = "block2"))]
697        #[unsafe(method(takeSnapshotWithConfiguration:completionHandler:))]
698        #[unsafe(method_family = none)]
699        pub unsafe fn takeSnapshotWithConfiguration_completionHandler(
700            &self,
701            snapshot_configuration: Option<&WKSnapshotConfiguration>,
702            completion_handler: &block2::DynBlock<dyn Fn(*mut NSImage, *mut NSError)>,
703        );
704
705        #[cfg(all(feature = "WKPDFConfiguration", feature = "block2"))]
706        /// Create a PDF document representation from the web page currently displayed in the WKWebView
707        ///
708        /// Parameter `pdfConfiguration`: An object that specifies how the PDF capture is configured.
709        ///
710        /// Parameter `completionHandler`: A block to invoke when the pdf document data is ready.
711        ///
712        /// If the WKPDFConfiguration is nil, the method will create a PDF document representing the bounds of the currently displayed web page.
713        /// The completionHandler is passed the resulting PDF document data or an error.
714        /// The data can be used to create a PDFDocument object.
715        /// If the data is written to a file the resulting file is a valid PDF document.
716        #[unsafe(method(createPDFWithConfiguration:completionHandler:))]
717        #[unsafe(method_family = none)]
718        pub unsafe fn createPDFWithConfiguration_completionHandler(
719            &self,
720            pdf_configuration: Option<&WKPDFConfiguration>,
721            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
722        );
723
724        #[cfg(feature = "block2")]
725        #[unsafe(method(createWebArchiveDataWithCompletionHandler:))]
726        #[unsafe(method_family = none)]
727        pub unsafe fn createWebArchiveDataWithCompletionHandler(
728            &self,
729            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
730        );
731
732        /// A Boolean value indicating whether horizontal swipe gestures
733        /// will trigger back-forward list navigations.
734        ///
735        /// The default value is NO.
736        #[unsafe(method(allowsBackForwardNavigationGestures))]
737        #[unsafe(method_family = none)]
738        pub unsafe fn allowsBackForwardNavigationGestures(&self) -> bool;
739
740        /// Setter for [`allowsBackForwardNavigationGestures`][Self::allowsBackForwardNavigationGestures].
741        #[unsafe(method(setAllowsBackForwardNavigationGestures:))]
742        #[unsafe(method_family = none)]
743        pub unsafe fn setAllowsBackForwardNavigationGestures(
744            &self,
745            allows_back_forward_navigation_gestures: bool,
746        );
747
748        /// The custom user agent string or nil if no custom user agent string has been set.
749        #[unsafe(method(customUserAgent))]
750        #[unsafe(method_family = none)]
751        pub unsafe fn customUserAgent(&self) -> Option<Retained<NSString>>;
752
753        /// Setter for [`customUserAgent`][Self::customUserAgent].
754        ///
755        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
756        #[unsafe(method(setCustomUserAgent:))]
757        #[unsafe(method_family = none)]
758        pub unsafe fn setCustomUserAgent(&self, custom_user_agent: Option<&NSString>);
759
760        /// A Boolean value indicating whether link preview is allowed for any
761        /// links inside this WKWebView.
762        ///
763        /// The default value is YES on Mac and iOS.
764        #[unsafe(method(allowsLinkPreview))]
765        #[unsafe(method_family = none)]
766        pub unsafe fn allowsLinkPreview(&self) -> bool;
767
768        /// Setter for [`allowsLinkPreview`][Self::allowsLinkPreview].
769        #[unsafe(method(setAllowsLinkPreview:))]
770        #[unsafe(method_family = none)]
771        pub unsafe fn setAllowsLinkPreview(&self, allows_link_preview: bool);
772
773        #[unsafe(method(allowsMagnification))]
774        #[unsafe(method_family = none)]
775        pub unsafe fn allowsMagnification(&self) -> bool;
776
777        /// Setter for [`allowsMagnification`][Self::allowsMagnification].
778        #[unsafe(method(setAllowsMagnification:))]
779        #[unsafe(method_family = none)]
780        pub unsafe fn setAllowsMagnification(&self, allows_magnification: bool);
781
782        #[cfg(feature = "objc2-core-foundation")]
783        #[unsafe(method(magnification))]
784        #[unsafe(method_family = none)]
785        pub unsafe fn magnification(&self) -> CGFloat;
786
787        #[cfg(feature = "objc2-core-foundation")]
788        /// Setter for [`magnification`][Self::magnification].
789        #[unsafe(method(setMagnification:))]
790        #[unsafe(method_family = none)]
791        pub unsafe fn setMagnification(&self, magnification: CGFloat);
792
793        #[cfg(feature = "objc2-core-foundation")]
794        #[unsafe(method(setMagnification:centeredAtPoint:))]
795        #[unsafe(method_family = none)]
796        pub unsafe fn setMagnification_centeredAtPoint(
797            &self,
798            magnification: CGFloat,
799            point: CGPoint,
800        );
801
802        #[cfg(feature = "objc2-core-foundation")]
803        #[unsafe(method(pageZoom))]
804        #[unsafe(method_family = none)]
805        pub unsafe fn pageZoom(&self) -> CGFloat;
806
807        #[cfg(feature = "objc2-core-foundation")]
808        /// Setter for [`pageZoom`][Self::pageZoom].
809        #[unsafe(method(setPageZoom:))]
810        #[unsafe(method_family = none)]
811        pub unsafe fn setPageZoom(&self, page_zoom: CGFloat);
812
813        #[cfg(all(
814            feature = "WKFindConfiguration",
815            feature = "WKFindResult",
816            feature = "block2"
817        ))]
818        #[unsafe(method(findString:withConfiguration:completionHandler:))]
819        #[unsafe(method_family = none)]
820        pub unsafe fn findString_withConfiguration_completionHandler(
821            &self,
822            string: &NSString,
823            configuration: Option<&WKFindConfiguration>,
824            completion_handler: &block2::DynBlock<dyn Fn(NonNull<WKFindResult>)>,
825        );
826
827        #[unsafe(method(handlesURLScheme:))]
828        #[unsafe(method_family = none)]
829        pub unsafe fn handlesURLScheme(url_scheme: &NSString, mtm: MainThreadMarker) -> bool;
830
831        #[cfg(all(feature = "WKDownload", feature = "block2"))]
832        #[unsafe(method(startDownloadUsingRequest:completionHandler:))]
833        #[unsafe(method_family = none)]
834        pub unsafe fn startDownloadUsingRequest_completionHandler(
835            &self,
836            request: &NSURLRequest,
837            completion_handler: &block2::DynBlock<dyn Fn(NonNull<WKDownload>)>,
838        );
839
840        #[cfg(all(feature = "WKDownload", feature = "block2"))]
841        #[unsafe(method(resumeDownloadFromResumeData:completionHandler:))]
842        #[unsafe(method_family = none)]
843        pub unsafe fn resumeDownloadFromResumeData_completionHandler(
844            &self,
845            resume_data: &NSData,
846            completion_handler: &block2::DynBlock<dyn Fn(NonNull<WKDownload>)>,
847        );
848
849        #[unsafe(method(mediaType))]
850        #[unsafe(method_family = none)]
851        pub unsafe fn mediaType(&self) -> Option<Retained<NSString>>;
852
853        /// Setter for [`mediaType`][Self::mediaType].
854        ///
855        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
856        #[unsafe(method(setMediaType:))]
857        #[unsafe(method_family = none)]
858        pub unsafe fn setMediaType(&self, media_type: Option<&NSString>);
859
860        #[unsafe(method(interactionState))]
861        #[unsafe(method_family = none)]
862        pub unsafe fn interactionState(&self) -> Option<Retained<AnyObject>>;
863
864        /// Setter for [`interactionState`][Self::interactionState].
865        ///
866        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
867        ///
868        /// # Safety
869        ///
870        /// `interaction_state` should be of the correct type.
871        #[unsafe(method(setInteractionState:))]
872        #[unsafe(method_family = none)]
873        pub unsafe fn setInteractionState(&self, interaction_state: Option<&AnyObject>);
874
875        /// A Boolean value indicating whether Screen Time blocking has occurred.
876        #[unsafe(method(isBlockedByScreenTime))]
877        #[unsafe(method_family = none)]
878        pub unsafe fn isBlockedByScreenTime(&self) -> bool;
879
880        #[cfg(feature = "WKNavigation")]
881        /// Sets the webpage contents from the passed data as if it was the
882        /// response to the supplied request. The request is never actually sent to the
883        /// supplied URL, though loads of resources defined in the NSData object would
884        /// be performed.
885        ///
886        /// Parameter `request`: The request specifying the base URL and other loading details
887        /// to be used while interpreting the supplied data object.
888        ///
889        /// Parameter `response`: A response that is used to interpret the supplied data object.
890        ///
891        /// Parameter `data`: The data to use as the contents of the webpage.
892        ///
893        /// Returns: A new navigation.
894        #[unsafe(method(loadSimulatedRequest:response:responseData:))]
895        #[unsafe(method_family = none)]
896        pub unsafe fn loadSimulatedRequest_response_responseData(
897            &self,
898            request: &NSURLRequest,
899            response: &NSURLResponse,
900            data: &NSData,
901        ) -> Retained<WKNavigation>;
902
903        #[cfg(feature = "WKNavigation")]
904        #[deprecated]
905        #[unsafe(method(loadSimulatedRequest:withResponse:responseData:))]
906        #[unsafe(method_family = none)]
907        pub unsafe fn loadSimulatedRequest_withResponse_responseData(
908            &self,
909            request: &NSURLRequest,
910            response: &NSURLResponse,
911            data: &NSData,
912        ) -> Retained<WKNavigation>;
913
914        #[cfg(feature = "WKNavigation")]
915        /// Navigates to the requested file URL on the filesystem.
916        ///
917        /// Parameter `request`: The request specifying the file URL to which to navigate.
918        ///
919        /// Parameter `readAccessURL`: The URL to allow read access to.
920        ///
921        /// If readAccessURL references a single file, only that file may be
922        /// loaded by WebKit.
923        /// If readAccessURL references a directory, files inside that file may be loaded by WebKit.
924        ///
925        /// Returns: A new navigation for the given file URL.
926        #[unsafe(method(loadFileRequest:allowingReadAccessToURL:))]
927        #[unsafe(method_family = none)]
928        pub unsafe fn loadFileRequest_allowingReadAccessToURL(
929            &self,
930            request: &NSURLRequest,
931            read_access_url: &NSURL,
932        ) -> Retained<WKNavigation>;
933
934        #[cfg(feature = "WKNavigation")]
935        /// Sets the webpage contents from the passed HTML string as if it was
936        /// the response to the supplied request. The request is never actually sent to the
937        /// supplied URL, though loads of resources defined in the HTML string would be
938        /// performed.
939        ///
940        /// Parameter `request`: The request specifying the base URL and other loading details
941        /// to be used while interpreting the supplied data object.
942        ///
943        /// Parameter `string`: The data to use as the contents of the webpage.
944        ///
945        /// Returns: A new navigation.
946        #[unsafe(method(loadSimulatedRequest:responseHTMLString:))]
947        #[unsafe(method_family = none)]
948        pub unsafe fn loadSimulatedRequest_responseHTMLString(
949            &self,
950            request: &NSURLRequest,
951            string: &NSString,
952        ) -> Retained<WKNavigation>;
953
954        #[cfg(feature = "WKNavigation")]
955        #[deprecated]
956        #[unsafe(method(loadSimulatedRequest:withResponseHTMLString:))]
957        #[unsafe(method_family = none)]
958        pub unsafe fn loadSimulatedRequest_withResponseHTMLString(
959            &self,
960            request: &NSURLRequest,
961            string: &NSString,
962        ) -> Retained<WKNavigation>;
963
964        #[unsafe(method(printOperationWithPrintInfo:))]
965        #[unsafe(method_family = none)]
966        pub unsafe fn printOperationWithPrintInfo(
967            &self,
968            print_info: &NSPrintInfo,
969        ) -> Retained<NSPrintOperation>;
970
971        #[unsafe(method(themeColor))]
972        #[unsafe(method_family = none)]
973        pub unsafe fn themeColor(&self) -> Option<Retained<NSColor>>;
974
975        #[unsafe(method(underPageBackgroundColor))]
976        #[unsafe(method_family = none)]
977        pub unsafe fn underPageBackgroundColor(&self) -> Retained<NSColor>;
978
979        /// Setter for [`underPageBackgroundColor`][Self::underPageBackgroundColor].
980        ///
981        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
982        #[unsafe(method(setUnderPageBackgroundColor:))]
983        #[unsafe(method_family = none)]
984        pub unsafe fn setUnderPageBackgroundColor(
985            &self,
986            under_page_background_color: Option<&NSColor>,
987        );
988
989        /// A WKWebView's fullscreen state.
990        ///
991        ///
992        /// ```text
993        ///  WKWebView @link is key-value observing (KVO) compliant for this property. When an element
994        ///  in the WKWebView enters fullscreen, WebKit will replace the WKWebView in the application view hierarchy with
995        ///  a "placeholder" view, and move the WKWebView into a fullscreen window. When the element exits fullscreen later,
996        ///  the WKWebView will be moved back into the application view hierarchy. An application may need to adjust/restore
997        ///  its native UI components when the fullscreen state changes. The application should observe the fullscreenState
998        ///  property of WKWebView in order to receive notifications regarding the fullscreen state change.
999        ///  
1000        ///
1001        /// ```
1002        #[unsafe(method(fullscreenState))]
1003        #[unsafe(method_family = none)]
1004        pub unsafe fn fullscreenState(&self) -> WKFullscreenState;
1005
1006        #[unsafe(method(minimumViewportInset))]
1007        #[unsafe(method_family = none)]
1008        pub unsafe fn minimumViewportInset(&self) -> NSEdgeInsets;
1009
1010        #[unsafe(method(maximumViewportInset))]
1011        #[unsafe(method_family = none)]
1012        pub unsafe fn maximumViewportInset(&self) -> NSEdgeInsets;
1013
1014        #[unsafe(method(setMinimumViewportInset:maximumViewportInset:))]
1015        #[unsafe(method_family = none)]
1016        pub unsafe fn setMinimumViewportInset_maximumViewportInset(
1017            &self,
1018            minimum_viewport_inset: NSEdgeInsets,
1019            maximum_viewport_inset: NSEdgeInsets,
1020        );
1021
1022        /// Controls whether this
1023        ///
1024        /// ```text
1025        ///  WKWebView
1026        /// ```
1027        ///
1028        /// is inspectable in Web Inspector.
1029        ///
1030        /// The default value is NO.
1031        #[unsafe(method(isInspectable))]
1032        #[unsafe(method_family = none)]
1033        pub unsafe fn isInspectable(&self) -> bool;
1034
1035        /// Setter for [`isInspectable`][Self::isInspectable].
1036        #[unsafe(method(setInspectable:))]
1037        #[unsafe(method_family = none)]
1038        pub unsafe fn setInspectable(&self, inspectable: bool);
1039
1040        /// A Boolean value indicating whether Writing Tools is active for the view.
1041        ///
1042        ///
1043        /// ```text
1044        ///  WKWebView
1045        /// ```
1046        ///
1047        /// is key-value observing (KVO) compliant for this property.
1048        #[unsafe(method(isWritingToolsActive))]
1049        #[unsafe(method_family = none)]
1050        pub unsafe fn isWritingToolsActive(&self) -> bool;
1051
1052        #[cfg(feature = "block2")]
1053        #[unsafe(method(fetchDataOfTypes:completionHandler:))]
1054        #[unsafe(method_family = none)]
1055        pub unsafe fn fetchDataOfTypes_completionHandler(
1056            &self,
1057            data_types: WKWebViewDataType,
1058            completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
1059        );
1060
1061        #[cfg(feature = "block2")]
1062        #[unsafe(method(restoreData:completionHandler:))]
1063        #[unsafe(method_family = none)]
1064        pub unsafe fn restoreData_completionHandler(
1065            &self,
1066            data: &NSData,
1067            completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
1068        );
1069
1070        #[unsafe(method(obscuredContentInsets))]
1071        #[unsafe(method_family = none)]
1072        pub unsafe fn obscuredContentInsets(&self) -> NSEdgeInsets;
1073
1074        /// Setter for [`obscuredContentInsets`][Self::obscuredContentInsets].
1075        #[unsafe(method(setObscuredContentInsets:))]
1076        #[unsafe(method_family = none)]
1077        pub unsafe fn setObscuredContentInsets(&self, obscured_content_insets: NSEdgeInsets);
1078    );
1079}
1080
1081/// Methods declared on superclass `NSView`.
1082#[cfg(feature = "objc2-app-kit")]
1083#[cfg(target_os = "macos")]
1084impl WKWebView {
1085    extern_methods!(
1086        #[unsafe(method(initWithFrame:))]
1087        #[unsafe(method_family = init)]
1088        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
1089    );
1090}
1091
1092/// Methods declared on superclass `NSResponder`.
1093#[cfg(feature = "objc2-app-kit")]
1094#[cfg(target_os = "macos")]
1095impl WKWebView {
1096    extern_methods!(
1097        #[unsafe(method(init))]
1098        #[unsafe(method_family = init)]
1099        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
1100    );
1101}
1102
1103/// Methods declared on superclass `NSObject`.
1104#[cfg(feature = "objc2-app-kit")]
1105#[cfg(target_os = "macos")]
1106impl WKWebView {
1107    extern_methods!(
1108        #[unsafe(method(new))]
1109        #[unsafe(method_family = new)]
1110        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
1111    );
1112}
1113
1114/// WKIBActions.
1115#[cfg(feature = "objc2-app-kit")]
1116#[cfg(target_os = "macos")]
1117impl WKWebView {
1118    extern_methods!(
1119        /// Action method that navigates to the back item in the
1120        /// back-forward list.
1121        ///
1122        /// Parameter `sender`: The object that sent this message.
1123        ///
1124        /// # Safety
1125        ///
1126        /// `sender` should be of the correct type.
1127        #[unsafe(method(goBack:))]
1128        #[unsafe(method_family = none)]
1129        pub unsafe fn goBack_(&self, sender: Option<&AnyObject>);
1130
1131        /// Action method that navigates to the forward item in the
1132        /// back-forward list.
1133        ///
1134        /// Parameter `sender`: The object that sent this message.
1135        ///
1136        /// # Safety
1137        ///
1138        /// `sender` should be of the correct type.
1139        #[unsafe(method(goForward:))]
1140        #[unsafe(method_family = none)]
1141        pub unsafe fn goForward_(&self, sender: Option<&AnyObject>);
1142
1143        /// Action method that reloads the current page.
1144        ///
1145        /// Parameter `sender`: The object that sent this message.
1146        ///
1147        /// # Safety
1148        ///
1149        /// `sender` should be of the correct type.
1150        #[unsafe(method(reload:))]
1151        #[unsafe(method_family = none)]
1152        pub unsafe fn reload_(&self, sender: Option<&AnyObject>);
1153
1154        /// Action method that reloads the current page, performing
1155        /// end-to-end revalidation using cache-validating conditionals if possible.
1156        ///
1157        /// Parameter `sender`: The object that sent this message.
1158        ///
1159        /// # Safety
1160        ///
1161        /// `sender` should be of the correct type.
1162        #[unsafe(method(reloadFromOrigin:))]
1163        #[unsafe(method_family = none)]
1164        pub unsafe fn reloadFromOrigin_(&self, sender: Option<&AnyObject>);
1165
1166        /// Action method that stops loading all resources on the current
1167        /// page.
1168        ///
1169        /// Parameter `sender`: The object that sent this message.
1170        ///
1171        /// # Safety
1172        ///
1173        /// `sender` should be of the correct type.
1174        #[unsafe(method(stopLoading:))]
1175        #[unsafe(method_family = none)]
1176        pub unsafe fn stopLoading_(&self, sender: Option<&AnyObject>);
1177    );
1178}
1179
1180#[cfg(feature = "objc2-app-kit")]
1181#[cfg(target_os = "macos")]
1182extern_conformance!(
1183    unsafe impl NSUserInterfaceValidations for WKWebView {}
1184);
1185
1186/// WKNSTextFinderClient.
1187#[cfg(feature = "objc2-app-kit")]
1188#[cfg(target_os = "macos")]
1189impl WKWebView {
1190    extern_methods!();
1191}
1192
1193#[cfg(feature = "objc2-app-kit")]
1194#[cfg(target_os = "macos")]
1195extern_conformance!(
1196    unsafe impl NSTextFinderClient for WKWebView {}
1197);
1198
1199/// WKDeprecated.
1200#[cfg(feature = "objc2-app-kit")]
1201#[cfg(target_os = "macos")]
1202impl WKWebView {
1203    extern_methods!(
1204        #[deprecated]
1205        #[unsafe(method(certificateChain))]
1206        #[unsafe(method_family = none)]
1207        pub unsafe fn certificateChain(&self) -> Retained<NSArray>;
1208    );
1209}