objc2_web_kit/generated/WKNavigationDelegate.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/// The policy to pass back to the decision handler from the
11/// webView:decidePolicyForNavigationAction:decisionHandler: method.
12///
13/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationactionpolicy?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct WKNavigationActionPolicy(pub NSInteger);
18impl WKNavigationActionPolicy {
19 #[doc(alias = "WKNavigationActionPolicyCancel")]
20 pub const Cancel: Self = Self(0);
21 #[doc(alias = "WKNavigationActionPolicyAllow")]
22 pub const Allow: Self = Self(1);
23 #[doc(alias = "WKNavigationActionPolicyDownload")]
24 pub const Download: Self = Self(2);
25}
26
27unsafe impl Encode for WKNavigationActionPolicy {
28 const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for WKNavigationActionPolicy {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35/// The policy to pass back to the decision handler from the webView:decidePolicyForNavigationResponse:decisionHandler: method.
36///
37/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationresponsepolicy?language=objc)
38// NS_ENUM
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct WKNavigationResponsePolicy(pub NSInteger);
42impl WKNavigationResponsePolicy {
43 #[doc(alias = "WKNavigationResponsePolicyCancel")]
44 pub const Cancel: Self = Self(0);
45 #[doc(alias = "WKNavigationResponsePolicyAllow")]
46 pub const Allow: Self = Self(1);
47 #[doc(alias = "WKNavigationResponsePolicyDownload")]
48 pub const Download: Self = Self(2);
49}
50
51unsafe impl Encode for WKNavigationResponsePolicy {
52 const ENCODING: Encoding = NSInteger::ENCODING;
53}
54
55unsafe impl RefEncode for WKNavigationResponsePolicy {
56 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59extern_protocol!(
60 /// A class conforming to the WKNavigationDelegate protocol can provide
61 /// methods for tracking progress for main frame navigations and for deciding
62 /// policy for main frame and subframe navigations.
63 ///
64 /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationdelegate?language=objc)
65 pub unsafe trait WKNavigationDelegate: NSObjectProtocol + MainThreadOnly {
66 #[cfg(all(
67 feature = "WKNavigationAction",
68 feature = "WKWebView",
69 feature = "block2",
70 feature = "objc2-app-kit"
71 ))]
72 #[cfg(target_os = "macos")]
73 /// Decides whether to allow or cancel a navigation.
74 ///
75 /// Parameter `webView`: The web view invoking the delegate method.
76 ///
77 /// Parameter `navigationAction`: Descriptive information about the action
78 /// triggering the navigation request.
79 ///
80 /// Parameter `decisionHandler`: The decision handler to call to allow or cancel the
81 /// navigation. The argument is one of the constants of the enumerated type WKNavigationActionPolicy.
82 ///
83 /// If you do not implement this method, the web view will load the request or, if appropriate, forward it to another application.
84 #[optional]
85 #[unsafe(method(webView:decidePolicyForNavigationAction:decisionHandler:))]
86 #[unsafe(method_family = none)]
87 unsafe fn webView_decidePolicyForNavigationAction_decisionHandler(
88 &self,
89 web_view: &WKWebView,
90 navigation_action: &WKNavigationAction,
91 decision_handler: &block2::Block<dyn Fn(WKNavigationActionPolicy)>,
92 );
93
94 #[cfg(all(
95 feature = "WKNavigationAction",
96 feature = "WKWebView",
97 feature = "WKWebpagePreferences",
98 feature = "block2",
99 feature = "objc2-app-kit"
100 ))]
101 #[cfg(target_os = "macos")]
102 /// Decides whether to allow or cancel a navigation.
103 ///
104 /// Parameter `webView`: The web view invoking the delegate method.
105 ///
106 /// Parameter `navigationAction`: Descriptive information about the action
107 /// triggering the navigation request.
108 ///
109 /// Parameter `preferences`: The default set of webpage preferences. This may be
110 /// changed by setting defaultWebpagePreferences on WKWebViewConfiguration.
111 ///
112 /// Parameter `decisionHandler`: The policy decision handler to call to allow or cancel
113 /// the navigation. The arguments are one of the constants of the enumerated type
114 /// WKNavigationActionPolicy, as well as an instance of WKWebpagePreferences.
115 ///
116 /// If you implement this method,
117 /// -webView:decidePolicyForNavigationAction:decisionHandler: will not be called.
118 #[optional]
119 #[unsafe(method(webView:decidePolicyForNavigationAction:preferences:decisionHandler:))]
120 #[unsafe(method_family = none)]
121 unsafe fn webView_decidePolicyForNavigationAction_preferences_decisionHandler(
122 &self,
123 web_view: &WKWebView,
124 navigation_action: &WKNavigationAction,
125 preferences: &WKWebpagePreferences,
126 decision_handler: &block2::Block<
127 dyn Fn(WKNavigationActionPolicy, NonNull<WKWebpagePreferences>),
128 >,
129 );
130
131 #[cfg(all(
132 feature = "WKNavigationResponse",
133 feature = "WKWebView",
134 feature = "block2",
135 feature = "objc2-app-kit"
136 ))]
137 #[cfg(target_os = "macos")]
138 /// Decides whether to allow or cancel a navigation after its
139 /// response is known.
140 ///
141 /// Parameter `webView`: The web view invoking the delegate method.
142 ///
143 /// Parameter `navigationResponse`: Descriptive information about the navigation
144 /// response.
145 ///
146 /// Parameter `decisionHandler`: The decision handler to call to allow or cancel the
147 /// navigation. The argument is one of the constants of the enumerated type WKNavigationResponsePolicy.
148 ///
149 /// If you do not implement this method, the web view will allow the response, if the web view can show it.
150 #[optional]
151 #[unsafe(method(webView:decidePolicyForNavigationResponse:decisionHandler:))]
152 #[unsafe(method_family = none)]
153 unsafe fn webView_decidePolicyForNavigationResponse_decisionHandler(
154 &self,
155 web_view: &WKWebView,
156 navigation_response: &WKNavigationResponse,
157 decision_handler: &block2::Block<dyn Fn(WKNavigationResponsePolicy)>,
158 );
159
160 #[cfg(all(
161 feature = "WKNavigation",
162 feature = "WKWebView",
163 feature = "objc2-app-kit"
164 ))]
165 #[cfg(target_os = "macos")]
166 /// Invoked when a main frame navigation starts.
167 ///
168 /// Parameter `webView`: The web view invoking the delegate method.
169 ///
170 /// Parameter `navigation`: The navigation.
171 #[optional]
172 #[unsafe(method(webView:didStartProvisionalNavigation:))]
173 #[unsafe(method_family = none)]
174 unsafe fn webView_didStartProvisionalNavigation(
175 &self,
176 web_view: &WKWebView,
177 navigation: Option<&WKNavigation>,
178 );
179
180 #[cfg(all(
181 feature = "WKNavigation",
182 feature = "WKWebView",
183 feature = "objc2-app-kit"
184 ))]
185 #[cfg(target_os = "macos")]
186 /// Invoked when a server redirect is received for the main
187 /// frame.
188 ///
189 /// Parameter `webView`: The web view invoking the delegate method.
190 ///
191 /// Parameter `navigation`: The navigation.
192 #[optional]
193 #[unsafe(method(webView:didReceiveServerRedirectForProvisionalNavigation:))]
194 #[unsafe(method_family = none)]
195 unsafe fn webView_didReceiveServerRedirectForProvisionalNavigation(
196 &self,
197 web_view: &WKWebView,
198 navigation: Option<&WKNavigation>,
199 );
200
201 #[cfg(all(
202 feature = "WKNavigation",
203 feature = "WKWebView",
204 feature = "objc2-app-kit"
205 ))]
206 #[cfg(target_os = "macos")]
207 /// Invoked when an error occurs while starting to load data for
208 /// the main frame.
209 ///
210 /// Parameter `webView`: The web view invoking the delegate method.
211 ///
212 /// Parameter `navigation`: The navigation.
213 ///
214 /// Parameter `error`: The error that occurred.
215 #[optional]
216 #[unsafe(method(webView:didFailProvisionalNavigation:withError:))]
217 #[unsafe(method_family = none)]
218 unsafe fn webView_didFailProvisionalNavigation_withError(
219 &self,
220 web_view: &WKWebView,
221 navigation: Option<&WKNavigation>,
222 error: &NSError,
223 );
224
225 #[cfg(all(
226 feature = "WKNavigation",
227 feature = "WKWebView",
228 feature = "objc2-app-kit"
229 ))]
230 #[cfg(target_os = "macos")]
231 /// Invoked when content starts arriving for the main frame.
232 ///
233 /// Parameter `webView`: The web view invoking the delegate method.
234 ///
235 /// Parameter `navigation`: The navigation.
236 #[optional]
237 #[unsafe(method(webView:didCommitNavigation:))]
238 #[unsafe(method_family = none)]
239 unsafe fn webView_didCommitNavigation(
240 &self,
241 web_view: &WKWebView,
242 navigation: Option<&WKNavigation>,
243 );
244
245 #[cfg(all(
246 feature = "WKNavigation",
247 feature = "WKWebView",
248 feature = "objc2-app-kit"
249 ))]
250 #[cfg(target_os = "macos")]
251 /// Invoked when a main frame navigation completes.
252 ///
253 /// Parameter `webView`: The web view invoking the delegate method.
254 ///
255 /// Parameter `navigation`: The navigation.
256 #[optional]
257 #[unsafe(method(webView:didFinishNavigation:))]
258 #[unsafe(method_family = none)]
259 unsafe fn webView_didFinishNavigation(
260 &self,
261 web_view: &WKWebView,
262 navigation: Option<&WKNavigation>,
263 );
264
265 #[cfg(all(
266 feature = "WKNavigation",
267 feature = "WKWebView",
268 feature = "objc2-app-kit"
269 ))]
270 #[cfg(target_os = "macos")]
271 /// Invoked when an error occurs during a committed main frame
272 /// navigation.
273 ///
274 /// Parameter `webView`: The web view invoking the delegate method.
275 ///
276 /// Parameter `navigation`: The navigation.
277 ///
278 /// Parameter `error`: The error that occurred.
279 #[optional]
280 #[unsafe(method(webView:didFailNavigation:withError:))]
281 #[unsafe(method_family = none)]
282 unsafe fn webView_didFailNavigation_withError(
283 &self,
284 web_view: &WKWebView,
285 navigation: Option<&WKNavigation>,
286 error: &NSError,
287 );
288
289 #[cfg(all(feature = "WKWebView", feature = "block2", feature = "objc2-app-kit"))]
290 #[cfg(target_os = "macos")]
291 /// Invoked when the web view needs to respond to an authentication challenge.
292 ///
293 /// Parameter `webView`: The web view that received the authentication challenge.
294 ///
295 /// Parameter `challenge`: The authentication challenge.
296 ///
297 /// Parameter `completionHandler`: The completion handler you must invoke to respond to the challenge. The
298 /// disposition argument is one of the constants of the enumerated type
299 /// NSURLSessionAuthChallengeDisposition. When disposition is NSURLSessionAuthChallengeUseCredential,
300 /// the credential argument is the credential to use, or nil to indicate continuing without a
301 /// credential.
302 ///
303 /// If you do not implement this method, the web view will respond to the authentication challenge with the NSURLSessionAuthChallengeRejectProtectionSpace disposition.
304 #[optional]
305 #[unsafe(method(webView:didReceiveAuthenticationChallenge:completionHandler:))]
306 #[unsafe(method_family = none)]
307 unsafe fn webView_didReceiveAuthenticationChallenge_completionHandler(
308 &self,
309 web_view: &WKWebView,
310 challenge: &NSURLAuthenticationChallenge,
311 completion_handler: &block2::Block<
312 dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
313 >,
314 );
315
316 #[cfg(all(feature = "WKWebView", feature = "objc2-app-kit"))]
317 #[cfg(target_os = "macos")]
318 /// Invoked when the web view's web content process is terminated.
319 ///
320 /// Parameter `webView`: The web view whose underlying web content process was terminated.
321 #[optional]
322 #[unsafe(method(webViewWebContentProcessDidTerminate:))]
323 #[unsafe(method_family = none)]
324 unsafe fn webViewWebContentProcessDidTerminate(&self, web_view: &WKWebView);
325
326 #[cfg(all(feature = "WKWebView", feature = "block2", feature = "objc2-app-kit"))]
327 #[cfg(target_os = "macos")]
328 /// Invoked when the web view is establishing a network connection using a deprecated version of TLS.
329 ///
330 /// Parameter `webView`: The web view initiating the connection.
331 ///
332 /// Parameter `challenge`: The authentication challenge.
333 ///
334 /// Parameter `decisionHandler`: The decision handler you must invoke to respond to indicate whether or not to continue with the connection establishment.
335 #[optional]
336 #[unsafe(method(webView:authenticationChallenge:shouldAllowDeprecatedTLS:))]
337 #[unsafe(method_family = none)]
338 unsafe fn webView_authenticationChallenge_shouldAllowDeprecatedTLS(
339 &self,
340 web_view: &WKWebView,
341 challenge: &NSURLAuthenticationChallenge,
342 decision_handler: &block2::Block<dyn Fn(Bool)>,
343 );
344
345 #[cfg(all(
346 feature = "WKDownload",
347 feature = "WKNavigationAction",
348 feature = "WKWebView",
349 feature = "objc2-app-kit"
350 ))]
351 #[cfg(target_os = "macos")]
352 #[optional]
353 #[unsafe(method(webView:navigationAction:didBecomeDownload:))]
354 #[unsafe(method_family = none)]
355 unsafe fn webView_navigationAction_didBecomeDownload(
356 &self,
357 web_view: &WKWebView,
358 navigation_action: &WKNavigationAction,
359 download: &WKDownload,
360 );
361
362 #[cfg(all(
363 feature = "WKDownload",
364 feature = "WKNavigationResponse",
365 feature = "WKWebView",
366 feature = "objc2-app-kit"
367 ))]
368 #[cfg(target_os = "macos")]
369 #[optional]
370 #[unsafe(method(webView:navigationResponse:didBecomeDownload:))]
371 #[unsafe(method_family = none)]
372 unsafe fn webView_navigationResponse_didBecomeDownload(
373 &self,
374 web_view: &WKWebView,
375 navigation_response: &WKNavigationResponse,
376 download: &WKDownload,
377 );
378 }
379);