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
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
use objc2_foundation::*;

use crate::*;

// 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);
}

// 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!(
    pub unsafe trait WKNavigationDelegate: NSObjectProtocol {
        #[cfg(all(
            feature = "WKNavigationAction",
            feature = "WKWebView",
            feature = "block2",
            feature = "objc2-app-kit"
        ))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:decidePolicyForNavigationAction:decisionHandler:)]
        unsafe fn webView_decidePolicyForNavigationAction_decisionHandler(
            &self,
            web_view: &WKWebView,
            navigation_action: &WKNavigationAction,
            decision_handler: &block2::Block<dyn Fn(WKNavigationActionPolicy)>,
        );

        #[cfg(all(
            feature = "WKNavigationAction",
            feature = "WKWebView",
            feature = "WKWebpagePreferences",
            feature = "block2",
            feature = "objc2-app-kit"
        ))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:decidePolicyForNavigationAction:preferences:decisionHandler:)]
        unsafe fn webView_decidePolicyForNavigationAction_preferences_decisionHandler(
            &self,
            web_view: &WKWebView,
            navigation_action: &WKNavigationAction,
            preferences: &WKWebpagePreferences,
            decision_handler: &block2::Block<
                dyn Fn(WKNavigationActionPolicy, NonNull<WKWebpagePreferences>),
            >,
        );

        #[cfg(all(
            feature = "WKNavigationResponse",
            feature = "WKWebView",
            feature = "block2",
            feature = "objc2-app-kit"
        ))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:decidePolicyForNavigationResponse:decisionHandler:)]
        unsafe fn webView_decidePolicyForNavigationResponse_decisionHandler(
            &self,
            web_view: &WKWebView,
            navigation_response: &WKNavigationResponse,
            decision_handler: &block2::Block<dyn Fn(WKNavigationResponsePolicy)>,
        );

        #[cfg(all(
            feature = "WKNavigation",
            feature = "WKWebView",
            feature = "objc2-app-kit"
        ))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:didStartProvisionalNavigation:)]
        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")]
        #[optional]
        #[method(webView:didReceiveServerRedirectForProvisionalNavigation:)]
        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")]
        #[optional]
        #[method(webView:didFailProvisionalNavigation:withError:)]
        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")]
        #[optional]
        #[method(webView:didCommitNavigation:)]
        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")]
        #[optional]
        #[method(webView:didFinishNavigation:)]
        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")]
        #[optional]
        #[method(webView:didFailNavigation:withError:)]
        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")]
        #[optional]
        #[method(webView:didReceiveAuthenticationChallenge:completionHandler:)]
        unsafe fn webView_didReceiveAuthenticationChallenge_completionHandler(
            &self,
            web_view: &WKWebView,
            challenge: &NSURLAuthenticationChallenge,
            completion_handler: &block2::Block<
                dyn Fn(NSURLSessionAuthChallengeDisposition, *mut NSURLCredential),
            >,
        );

        #[cfg(all(feature = "WKWebView", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webViewWebContentProcessDidTerminate:)]
        unsafe fn webViewWebContentProcessDidTerminate(&self, web_view: &WKWebView);

        #[cfg(all(feature = "WKWebView", feature = "block2", feature = "objc2-app-kit"))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:authenticationChallenge:shouldAllowDeprecatedTLS:)]
        unsafe fn webView_authenticationChallenge_shouldAllowDeprecatedTLS(
            &self,
            web_view: &WKWebView,
            challenge: &NSURLAuthenticationChallenge,
            decision_handler: &block2::Block<dyn Fn(Bool)>,
        );

        #[cfg(all(
            feature = "WKDownload",
            feature = "WKNavigationAction",
            feature = "WKWebView",
            feature = "objc2-app-kit"
        ))]
        #[cfg(target_os = "macos")]
        #[optional]
        #[method(webView:navigationAction:didBecomeDownload:)]
        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]
        #[method(webView:navigationResponse:didBecomeDownload:)]
        unsafe fn webView_navigationResponse_didBecomeDownload(
            &self,
            web_view: &WKWebView,
            navigation_response: &WKNavigationResponse,
            download: &WKDownload,
        );
    }

    unsafe impl ProtocolType for dyn WKNavigationDelegate {}
);