objc2_web_kit/generated/
WKUIDelegate.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkpermissiondecision?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct WKPermissionDecision(pub NSInteger);
15impl WKPermissionDecision {
16    #[doc(alias = "WKPermissionDecisionPrompt")]
17    pub const Prompt: Self = Self(0);
18    #[doc(alias = "WKPermissionDecisionGrant")]
19    pub const Grant: Self = Self(1);
20    #[doc(alias = "WKPermissionDecisionDeny")]
21    pub const Deny: Self = Self(2);
22}
23
24unsafe impl Encode for WKPermissionDecision {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for WKPermissionDecision {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkmediacapturetype?language=objc)
33// NS_ENUM
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct WKMediaCaptureType(pub NSInteger);
37impl WKMediaCaptureType {
38    #[doc(alias = "WKMediaCaptureTypeCamera")]
39    pub const Camera: Self = Self(0);
40    #[doc(alias = "WKMediaCaptureTypeMicrophone")]
41    pub const Microphone: Self = Self(1);
42    #[doc(alias = "WKMediaCaptureTypeCameraAndMicrophone")]
43    pub const CameraAndMicrophone: Self = Self(2);
44}
45
46unsafe impl Encode for WKMediaCaptureType {
47    const ENCODING: Encoding = NSInteger::ENCODING;
48}
49
50unsafe impl RefEncode for WKMediaCaptureType {
51    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54/// Constants returned by showLockdownModeFirstUseMessage to indicate how WebKit should treat first use.
55///
56/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkdialogresult?language=objc)
57// NS_ENUM
58#[repr(transparent)]
59#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
60pub struct WKDialogResult(pub NSInteger);
61impl WKDialogResult {
62    #[doc(alias = "WKDialogResultShowDefault")]
63    pub const ShowDefault: Self = Self(1);
64    #[doc(alias = "WKDialogResultAskAgain")]
65    pub const AskAgain: Self = Self(2);
66    #[doc(alias = "WKDialogResultHandled")]
67    pub const Handled: Self = Self(3);
68}
69
70unsafe impl Encode for WKDialogResult {
71    const ENCODING: Encoding = NSInteger::ENCODING;
72}
73
74unsafe impl RefEncode for WKDialogResult {
75    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
76}
77
78extern_protocol!(
79    /// A class conforming to the WKUIDelegate protocol provides methods for
80    /// presenting native UI on behalf of a webpage.
81    ///
82    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkuidelegate?language=objc)
83    pub unsafe trait WKUIDelegate: NSObjectProtocol + MainThreadOnly {
84        #[cfg(all(
85            feature = "WKNavigationAction",
86            feature = "WKWebView",
87            feature = "WKWebViewConfiguration",
88            feature = "WKWindowFeatures",
89            feature = "objc2-app-kit"
90        ))]
91        #[cfg(target_os = "macos")]
92        /// Creates a new web view.
93        ///
94        /// Parameter `webView`: The web view invoking the delegate method.
95        ///
96        /// Parameter `configuration`: The configuration to use when creating the new web
97        /// view. This configuration is a copy of webView.configuration.
98        ///
99        /// Parameter `navigationAction`: The navigation action causing the new web view to
100        /// be created.
101        ///
102        /// Parameter `windowFeatures`: Window features requested by the webpage.
103        ///
104        /// Returns: A new web view or nil.
105        ///
106        /// The web view returned must be created with the specified configuration. WebKit will load the request in the returned web view.
107        ///
108        /// If you do not implement this method, the web view will cancel the navigation.
109        #[optional]
110        #[unsafe(method(webView:createWebViewWithConfiguration:forNavigationAction:windowFeatures:))]
111        #[unsafe(method_family = none)]
112        unsafe fn webView_createWebViewWithConfiguration_forNavigationAction_windowFeatures(
113            &self,
114            web_view: &WKWebView,
115            configuration: &WKWebViewConfiguration,
116            navigation_action: &WKNavigationAction,
117            window_features: &WKWindowFeatures,
118        ) -> Option<Retained<WKWebView>>;
119
120        #[cfg(all(feature = "WKWebView", feature = "objc2-app-kit"))]
121        #[cfg(target_os = "macos")]
122        /// Notifies your app that the DOM window object's close() method completed successfully.
123        ///
124        /// Parameter `webView`: The web view invoking the delegate method.
125        ///
126        /// Your app should remove the web view from the view hierarchy and update
127        /// the UI as needed, such as by closing the containing browser tab or window.
128        #[optional]
129        #[unsafe(method(webViewDidClose:))]
130        #[unsafe(method_family = none)]
131        unsafe fn webViewDidClose(&self, web_view: &WKWebView);
132
133        #[cfg(all(
134            feature = "WKFrameInfo",
135            feature = "WKWebView",
136            feature = "block2",
137            feature = "objc2-app-kit"
138        ))]
139        #[cfg(target_os = "macos")]
140        /// Displays a JavaScript alert panel.
141        ///
142        /// Parameter `webView`: The web view invoking the delegate method.
143        ///
144        /// Parameter `message`: The message to display.
145        ///
146        /// Parameter `frame`: Information about the frame whose JavaScript initiated this
147        /// call.
148        ///
149        /// Parameter `completionHandler`: The completion handler to call after the alert
150        /// panel has been dismissed.
151        ///
152        /// For user security, your app should call attention to the fact
153        /// that a specific website controls the content in this panel. A simple forumla
154        /// for identifying the controlling website is frame.request.URL.host.
155        /// The panel should have a single OK button.
156        ///
157        /// If you do not implement this method, the web view will behave as if the user selected the OK button.
158        #[optional]
159        #[unsafe(method(webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:))]
160        #[unsafe(method_family = none)]
161        unsafe fn webView_runJavaScriptAlertPanelWithMessage_initiatedByFrame_completionHandler(
162            &self,
163            web_view: &WKWebView,
164            message: &NSString,
165            frame: &WKFrameInfo,
166            completion_handler: &block2::Block<dyn Fn()>,
167        );
168
169        #[cfg(all(
170            feature = "WKFrameInfo",
171            feature = "WKWebView",
172            feature = "block2",
173            feature = "objc2-app-kit"
174        ))]
175        #[cfg(target_os = "macos")]
176        /// Displays a JavaScript confirm panel.
177        ///
178        /// Parameter `webView`: The web view invoking the delegate method.
179        ///
180        /// Parameter `message`: The message to display.
181        ///
182        /// Parameter `frame`: Information about the frame whose JavaScript initiated this call.
183        ///
184        /// Parameter `completionHandler`: The completion handler to call after the confirm
185        /// panel has been dismissed. Pass YES if the user chose OK, NO if the user
186        /// chose Cancel.
187        ///
188        /// For user security, your app should call attention to the fact
189        /// that a specific website controls the content in this panel. A simple forumla
190        /// for identifying the controlling website is frame.request.URL.host.
191        /// The panel should have two buttons, such as OK and Cancel.
192        ///
193        /// If you do not implement this method, the web view will behave as if the user selected the Cancel button.
194        #[optional]
195        #[unsafe(method(webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:))]
196        #[unsafe(method_family = none)]
197        unsafe fn webView_runJavaScriptConfirmPanelWithMessage_initiatedByFrame_completionHandler(
198            &self,
199            web_view: &WKWebView,
200            message: &NSString,
201            frame: &WKFrameInfo,
202            completion_handler: &block2::Block<dyn Fn(Bool)>,
203        );
204
205        #[cfg(all(
206            feature = "WKFrameInfo",
207            feature = "WKWebView",
208            feature = "block2",
209            feature = "objc2-app-kit"
210        ))]
211        #[cfg(target_os = "macos")]
212        /// Displays a JavaScript text input panel.
213        ///
214        /// Parameter `webView`: The web view invoking the delegate method.
215        ///
216        /// Parameter `prompt`: The prompt to display.
217        ///
218        /// Parameter `defaultText`: The initial text to display in the text entry field.
219        ///
220        /// Parameter `frame`: Information about the frame whose JavaScript initiated this call.
221        ///
222        /// Parameter `completionHandler`: The completion handler to call after the text
223        /// input panel has been dismissed. Pass the entered text if the user chose
224        /// OK, otherwise nil.
225        ///
226        /// For user security, your app should call attention to the fact
227        /// that a specific website controls the content in this panel. A simple forumla
228        /// for identifying the controlling website is frame.request.URL.host.
229        /// The panel should have two buttons, such as OK and Cancel, and a field in
230        /// which to enter text.
231        ///
232        /// If you do not implement this method, the web view will behave as if the user selected the Cancel button.
233        #[optional]
234        #[unsafe(method(webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:))]
235        #[unsafe(method_family = none)]
236        unsafe fn webView_runJavaScriptTextInputPanelWithPrompt_defaultText_initiatedByFrame_completionHandler(
237            &self,
238            web_view: &WKWebView,
239            prompt: &NSString,
240            default_text: Option<&NSString>,
241            frame: &WKFrameInfo,
242            completion_handler: &block2::Block<dyn Fn(*mut NSString)>,
243        );
244
245        #[cfg(all(
246            feature = "WKFrameInfo",
247            feature = "WKSecurityOrigin",
248            feature = "WKWebView",
249            feature = "block2",
250            feature = "objc2-app-kit"
251        ))]
252        #[cfg(target_os = "macos")]
253        /// A delegate to request permission for microphone audio and camera video access.
254        ///
255        /// Parameter `webView`: The web view invoking the delegate method.
256        ///
257        /// Parameter `origin`: The origin of the page.
258        ///
259        /// Parameter `frame`: Information about the frame whose JavaScript initiated this call.
260        ///
261        /// Parameter `type`: The type of capture (camera, microphone).
262        ///
263        /// Parameter `decisionHandler`: The completion handler to call once the decision is made
264        ///
265        /// If not implemented, the result is the same as calling the decisionHandler with WKPermissionDecisionPrompt.
266        #[optional]
267        #[unsafe(method(webView:requestMediaCapturePermissionForOrigin:initiatedByFrame:type:decisionHandler:))]
268        #[unsafe(method_family = none)]
269        unsafe fn webView_requestMediaCapturePermissionForOrigin_initiatedByFrame_type_decisionHandler(
270            &self,
271            web_view: &WKWebView,
272            origin: &WKSecurityOrigin,
273            frame: &WKFrameInfo,
274            r#type: WKMediaCaptureType,
275            decision_handler: &block2::Block<dyn Fn(WKPermissionDecision)>,
276        );
277
278        #[cfg(all(
279            feature = "WKFrameInfo",
280            feature = "WKSecurityOrigin",
281            feature = "WKWebView",
282            feature = "block2",
283            feature = "objc2-app-kit"
284        ))]
285        #[cfg(target_os = "macos")]
286        /// Allows your app to determine whether or not the given security origin should have access to the device's orientation and motion.
287        ///
288        /// Parameter `securityOrigin`: The security origin which requested access to the device's orientation and motion.
289        ///
290        /// Parameter `frame`: The frame that initiated the request.
291        ///
292        /// Parameter `decisionHandler`: The decision handler to call once the app has made its decision.
293        #[optional]
294        #[unsafe(method(webView:requestDeviceOrientationAndMotionPermissionForOrigin:initiatedByFrame:decisionHandler:))]
295        #[unsafe(method_family = none)]
296        unsafe fn webView_requestDeviceOrientationAndMotionPermissionForOrigin_initiatedByFrame_decisionHandler(
297            &self,
298            web_view: &WKWebView,
299            origin: &WKSecurityOrigin,
300            frame: &WKFrameInfo,
301            decision_handler: &block2::Block<dyn Fn(WKPermissionDecision)>,
302        );
303
304        #[cfg(all(
305            feature = "WKFrameInfo",
306            feature = "WKOpenPanelParameters",
307            feature = "WKWebView",
308            feature = "block2",
309            feature = "objc2-app-kit"
310        ))]
311        #[cfg(target_os = "macos")]
312        /// Displays a file upload panel.
313        ///
314        /// Parameter `webView`: The web view invoking the delegate method.
315        ///
316        /// Parameter `parameters`: Parameters describing the file upload control.
317        ///
318        /// Parameter `frame`: Information about the frame whose file upload control initiated this call.
319        ///
320        /// Parameter `completionHandler`: The completion handler to call after open panel has been dismissed. Pass the selected URLs if the user chose OK, otherwise nil.
321        ///
322        /// If you do not implement this method, the web view will behave as if the user selected the Cancel button.
323        #[optional]
324        #[unsafe(method(webView:runOpenPanelWithParameters:initiatedByFrame:completionHandler:))]
325        #[unsafe(method_family = none)]
326        unsafe fn webView_runOpenPanelWithParameters_initiatedByFrame_completionHandler(
327            &self,
328            web_view: &WKWebView,
329            parameters: &WKOpenPanelParameters,
330            frame: &WKFrameInfo,
331            completion_handler: &block2::Block<dyn Fn(*mut NSArray<NSURL>)>,
332        );
333    }
334);