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