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