objc2_web_kit/generated/
WebPolicyDelegate.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9/// The type of action that triggered a possible navigation.
10///
11/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/webnavigationtype?language=objc)
12// NS_ENUM
13#[deprecated]
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct WebNavigationType(pub NSInteger);
17impl WebNavigationType {
18    #[doc(alias = "WebNavigationTypeLinkClicked")]
19    #[deprecated]
20    pub const LinkClicked: Self = Self(0);
21    #[doc(alias = "WebNavigationTypeFormSubmitted")]
22    #[deprecated]
23    pub const FormSubmitted: Self = Self(1);
24    #[doc(alias = "WebNavigationTypeBackForward")]
25    #[deprecated]
26    pub const BackForward: Self = Self(2);
27    #[doc(alias = "WebNavigationTypeReload")]
28    #[deprecated]
29    pub const Reload: Self = Self(3);
30    #[doc(alias = "WebNavigationTypeFormResubmitted")]
31    #[deprecated]
32    pub const FormResubmitted: Self = Self(4);
33    #[doc(alias = "WebNavigationTypeOther")]
34    #[deprecated]
35    pub const Other: Self = Self(5);
36}
37
38unsafe impl Encode for WebNavigationType {
39    const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for WebNavigationType {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46extern "C" {
47    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/webactionnavigationtypekey?language=objc)
48    #[deprecated]
49    pub static WebActionNavigationTypeKey: Option<&'static NSString>;
50}
51
52extern "C" {
53    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/webactionelementkey?language=objc)
54    #[deprecated]
55    pub static WebActionElementKey: Option<&'static NSString>;
56}
57
58extern "C" {
59    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/webactionbuttonkey?language=objc)
60    #[deprecated]
61    pub static WebActionButtonKey: Option<&'static NSString>;
62}
63
64extern "C" {
65    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/webactionmodifierflagskey?language=objc)
66    #[deprecated]
67    pub static WebActionModifierFlagsKey: Option<&'static NSString>;
68}
69
70extern "C" {
71    /// [Apple's documentation](https://developer.apple.com/documentation/webkit/webactionoriginalurlkey?language=objc)
72    #[deprecated]
73    pub static WebActionOriginalURLKey: Option<&'static NSString>;
74}
75
76extern_protocol!(
77    /// This protocol is used to call back with the results of a
78    /// policy decision. This provides the ability to make these decisions
79    /// asyncrhonously, which means the decision can be made by prompting
80    /// with a sheet, for example.
81    ///
82    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/webpolicydecisionlistener?language=objc)
83    #[deprecated]
84    pub unsafe trait WebPolicyDecisionListener: NSObjectProtocol {
85        /// Use the resource
86        ///
87        /// If there remain more policy decisions to be made, then
88        /// the next policy delegate method gets to decide. This will be
89        /// either the next navigation policy delegate if there is a redirect,
90        /// or the content policy delegate. If there are no more policy
91        /// decisions to be made, the resource will be displayed inline if
92        /// possible. If there is no view available to display the resource
93        /// inline, then unableToImplementPolicyWithError:frame: will be
94        /// called with an appropriate error.
95        ///
96        /// <p>
97        /// If a new window is going to be created for this navigation as a
98        /// result of frame targeting, then it will be created once you call
99        /// this method.
100        #[deprecated]
101        #[unsafe(method(use))]
102        #[unsafe(method_family = none)]
103        unsafe fn r#use(&self);
104
105        /// Download the resource instead of displaying it.
106        ///
107        /// This method is more than just a convenience because it
108        /// allows an in-progress navigation to be converted to a download
109        /// based on content type, without having to stop and restart the
110        /// load.
111        #[deprecated]
112        #[unsafe(method(download))]
113        #[unsafe(method_family = none)]
114        unsafe fn download(&self);
115
116        /// Do nothing (but the client may choose to handle the request itself)
117        ///
118        /// A policy of ignore prevents WebKit from doing anything
119        /// further with the load, however, the client is still free to handle
120        /// the request in some other way, such as opening a new window,
121        /// opening a new window behind the current one, opening the URL in an
122        /// external app, revealing the location in Finder if a file URL, etc.
123        #[deprecated]
124        #[unsafe(method(ignore))]
125        #[unsafe(method_family = none)]
126        unsafe fn ignore(&self);
127    }
128);
129
130extern_protocol!(
131    /// While loading a URL, WebKit asks the WebPolicyDelegate for
132    /// policies that determine the action of what to do with the URL or the data that
133    /// the URL represents. Typically, the policy handler methods are called in this order:
134    ///
135    /// decidePolicyForNewWindowAction:request:newFrameName:decisionListener: (at most once)
136    /// <BR
137    /// >
138    /// decidePolicyForNavigationAction:request:frame:decisionListener: (zero or more times)
139    /// <BR
140    /// >
141    /// decidePolicyForMIMEType:request:frame: (zero or more times)
142    /// <BR
143    /// >
144    ///
145    /// New window policy is always checked. Navigation policy is checked
146    /// for the initial load and every redirect unless blocked by an
147    /// earlier policy. Content policy is checked once the content type is
148    /// known, unless an earlier policy prevented it.
149    ///
150    /// In rare cases, content policy might be checked more than
151    /// once. This occurs when loading a "multipart/x-mixed-replace"
152    /// document, also known as "server push". In this case, multiple
153    /// documents come in one navigation, with each replacing the last. In
154    /// this case, conent policy will be checked for each one.
155    ///
156    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/webpolicydelegate?language=objc)
157    #[deprecated]
158    pub unsafe trait WebPolicyDelegate: NSObjectProtocol {
159        #[cfg(all(feature = "WebFrame", feature = "WebView", feature = "objc2-app-kit"))]
160        #[cfg(target_os = "macos")]
161        /// This method is called to decide what to do with a proposed navigation.
162        ///
163        /// Parameter `actionInformation`: Dictionary that describes the action that triggered this navigation.
164        ///
165        /// Parameter `request`: The request for the proposed navigation
166        ///
167        /// Parameter `frame`: The WebFrame in which the navigation is happening
168        ///
169        /// Parameter `listener`: The object to call when the decision is made
170        ///
171        /// This method will be called before loading starts, and
172        /// on every redirect.
173        ///
174        /// # Safety
175        ///
176        /// - `web_view` might not allow `None`.
177        /// - `action_information` generic should be of the correct type.
178        /// - `action_information` might not allow `None`.
179        /// - `request` might not allow `None`.
180        /// - `frame` might not allow `None`.
181        /// - `listener` might not allow `None`.
182        #[deprecated]
183        #[optional]
184        #[unsafe(method(webView:decidePolicyForNavigationAction:request:frame:decisionListener:))]
185        #[unsafe(method_family = none)]
186        unsafe fn webView_decidePolicyForNavigationAction_request_frame_decisionListener(
187            &self,
188            web_view: Option<&WebView>,
189            action_information: Option<&NSDictionary>,
190            request: Option<&NSURLRequest>,
191            frame: Option<&WebFrame>,
192            listener: Option<&ProtocolObject<dyn WebPolicyDecisionListener>>,
193        );
194
195        #[cfg(all(feature = "WebView", feature = "objc2-app-kit"))]
196        #[cfg(target_os = "macos")]
197        /// This method is called to decide what to do with an targetted nagivation that would open a new window.
198        ///
199        /// Parameter `actionInformation`: Dictionary that describes the action that triggered this navigation.
200        ///
201        /// Parameter `request`: The request for the proposed navigation
202        ///
203        /// Parameter `frameName`: The frame in which the navigation is taking place
204        ///
205        /// Parameter `listener`: The object to call when the decision is made
206        ///
207        /// This method is provided so that modified clicks on a targetted link which
208        /// opens a new frame can prevent the new window from being opened if they decide to
209        /// do something else, like download or present the new frame in a specialized way.
210        ///
211        /// <p>
212        /// If this method picks a policy of Use, the new window will be
213        /// opened, and decidePolicyForNavigationAction:request:frame:decisionListner:
214        /// will be called with a WebNavigationType of WebNavigationTypeOther
215        /// in its action. This is to avoid possible confusion about the modifiers.
216        ///
217        /// # Safety
218        ///
219        /// - `web_view` might not allow `None`.
220        /// - `action_information` generic should be of the correct type.
221        /// - `action_information` might not allow `None`.
222        /// - `request` might not allow `None`.
223        /// - `frame_name` might not allow `None`.
224        /// - `listener` might not allow `None`.
225        #[deprecated]
226        #[optional]
227        #[unsafe(method(webView:decidePolicyForNewWindowAction:request:newFrameName:decisionListener:))]
228        #[unsafe(method_family = none)]
229        unsafe fn webView_decidePolicyForNewWindowAction_request_newFrameName_decisionListener(
230            &self,
231            web_view: Option<&WebView>,
232            action_information: Option<&NSDictionary>,
233            request: Option<&NSURLRequest>,
234            frame_name: Option<&NSString>,
235            listener: Option<&ProtocolObject<dyn WebPolicyDecisionListener>>,
236        );
237
238        #[cfg(all(feature = "WebFrame", feature = "WebView", feature = "objc2-app-kit"))]
239        #[cfg(target_os = "macos")]
240        /// Returns the policy for content which has been partially loaded.
241        /// Sent after webView:didStartProvisionalLoadForFrame: is sent on the WebFrameLoadDelegate.
242        ///
243        /// Parameter `type`: MIME type for the resource.
244        ///
245        /// Parameter `request`: A NSURLRequest for the partially loaded content.
246        ///
247        /// Parameter `frame`: The frame which is loading the URL.
248        ///
249        /// Parameter `listener`: The object to call when the decision is made
250        ///
251        /// # Safety
252        ///
253        /// - `web_view` might not allow `None`.
254        /// - `type` might not allow `None`.
255        /// - `request` might not allow `None`.
256        /// - `frame` might not allow `None`.
257        /// - `listener` might not allow `None`.
258        #[deprecated]
259        #[optional]
260        #[unsafe(method(webView:decidePolicyForMIMEType:request:frame:decisionListener:))]
261        #[unsafe(method_family = none)]
262        unsafe fn webView_decidePolicyForMIMEType_request_frame_decisionListener(
263            &self,
264            web_view: Option<&WebView>,
265            r#type: Option<&NSString>,
266            request: Option<&NSURLRequest>,
267            frame: Option<&WebFrame>,
268            listener: Option<&ProtocolObject<dyn WebPolicyDecisionListener>>,
269        );
270
271        #[cfg(all(feature = "WebFrame", feature = "WebView", feature = "objc2-app-kit"))]
272        #[cfg(target_os = "macos")]
273        /// Called when a WebPolicy could not be implemented. It is up to the client to display appropriate feedback.
274        ///
275        /// Parameter `error`: The error that caused the policy to not be implemented.
276        ///
277        /// Parameter `frame`: The frame in which the policy could not be implemented.
278        ///
279        /// # Safety
280        ///
281        /// - `web_view` might not allow `None`.
282        /// - `error` might not allow `None`.
283        /// - `frame` might not allow `None`.
284        #[deprecated]
285        #[optional]
286        #[unsafe(method(webView:unableToImplementPolicyWithError:frame:))]
287        #[unsafe(method_family = none)]
288        unsafe fn webView_unableToImplementPolicyWithError_frame(
289            &self,
290            web_view: Option<&WebView>,
291            error: Option<&NSError>,
292            frame: Option<&WebFrame>,
293        );
294    }
295);