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