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
//! 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::*;
/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkcookiepolicy?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct WKCookiePolicy(pub NSInteger);
impl WKCookiePolicy {
#[doc(alias = "WKCookiePolicyAllow")]
pub const Allow: Self = Self(0);
#[doc(alias = "WKCookiePolicyDisallow")]
pub const Disallow: Self = Self(1);
}
unsafe impl Encode for WKCookiePolicy {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for WKCookiePolicy {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// [Apple's documentation](https://developer.apple.com/documentation/webkit/wkhttpcookiestoreobserver?language=objc)
pub unsafe trait WKHTTPCookieStoreObserver: NSObjectProtocol + MainThreadOnly {
#[optional]
#[unsafe(method(cookiesDidChangeInCookieStore:))]
#[unsafe(method_family = none)]
unsafe fn cookiesDidChangeInCookieStore(&self, cookie_store: &WKHTTPCookieStore);
}
);
extern_class!(
/// A WKHTTPCookieStore object allows managing the HTTP cookies associated with a particular WKWebsiteDataStore.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkhttpcookiestore?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct WKHTTPCookieStore;
);
extern_conformance!(
unsafe impl NSObjectProtocol for WKHTTPCookieStore {}
);
impl WKHTTPCookieStore {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "block2")]
/// Fetches all stored cookies.
///
/// Parameter `completionHandler`: A block to invoke with the fetched cookies.
#[unsafe(method(getAllCookies:))]
#[unsafe(method_family = none)]
pub unsafe fn getAllCookies(
&self,
completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<NSHTTPCookie>>)>,
);
#[cfg(feature = "block2")]
/// Set a cookie.
///
/// Parameter `cookie`: The cookie to set.
///
/// Parameter `completionHandler`: A block to invoke once the cookie has been stored.
#[unsafe(method(setCookie:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setCookie_completionHandler(
&self,
cookie: &NSHTTPCookie,
completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
);
#[cfg(feature = "block2")]
/// Delete the specified cookie.
///
/// Parameter `completionHandler`: A block to invoke once the cookie has been deleted.
#[unsafe(method(deleteCookie:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn deleteCookie_completionHandler(
&self,
cookie: &NSHTTPCookie,
completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
);
/// Adds a WKHTTPCookieStoreObserver object with the cookie store.
///
/// Parameter `observer`: The observer object to add.
///
/// The observer is not retained by the receiver. It is your responsibility
/// to unregister the observer before it becomes invalid.
#[unsafe(method(addObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn addObserver(&self, observer: &ProtocolObject<dyn WKHTTPCookieStoreObserver>);
/// Removes a WKHTTPCookieStoreObserver object from the cookie store.
///
/// Parameter `observer`: The observer to remove.
#[unsafe(method(removeObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn removeObserver(
&self,
observer: &ProtocolObject<dyn WKHTTPCookieStoreObserver>,
);
#[cfg(feature = "block2")]
/// Set whether cookies are allowed.
///
/// Parameter `policy`: A value indicating whether cookies are allowed. The default value is WKCookiePolicyAllow.
///
/// Parameter `completionHandler`: A block to invoke once the cookie policy has been set.
#[unsafe(method(setCookiePolicy:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setCookiePolicy_completionHandler(
&self,
policy: WKCookiePolicy,
completion_handler: Option<&block2::DynBlock<dyn Fn()>>,
);
#[cfg(feature = "block2")]
/// Get whether cookies are allowed.
///
/// Parameter `completionHandler`: A block to invoke with the value of whether cookies are allowed.
#[unsafe(method(getCookiePolicy:))]
#[unsafe(method_family = none)]
pub unsafe fn getCookiePolicy(
&self,
completion_handler: &block2::DynBlock<dyn Fn(WKCookiePolicy)>,
);
);
}
/// Methods declared on superclass `NSObject`.
impl WKHTTPCookieStore {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}