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
//! 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::*;
extern_class!(
/// A WKUserContentController object provides a way for JavaScript to post
/// messages to a web view.
/// The user content controller associated with a web view is specified by its
/// web view configuration.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkusercontentcontroller?language=objc)
#[unsafe(super(NSObject))]
#[thread_kind = MainThreadOnly]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct WKUserContentController;
);
extern_conformance!(
unsafe impl NSCoding for WKUserContentController {}
);
extern_conformance!(
unsafe impl NSObjectProtocol for WKUserContentController {}
);
extern_conformance!(
unsafe impl NSSecureCoding for WKUserContentController {}
);
impl WKUserContentController {
extern_methods!(
#[cfg(feature = "WKUserScript")]
/// The user scripts associated with this user content
/// controller.
#[unsafe(method(userScripts))]
#[unsafe(method_family = none)]
pub unsafe fn userScripts(&self) -> Retained<NSArray<WKUserScript>>;
#[cfg(feature = "WKUserScript")]
/// Adds a user script.
///
/// Parameter `userScript`: The user script to add.
#[unsafe(method(addUserScript:))]
#[unsafe(method_family = none)]
pub unsafe fn addUserScript(&self, user_script: &WKUserScript);
/// Removes all associated user scripts.
#[unsafe(method(removeAllUserScripts))]
#[unsafe(method_family = none)]
pub unsafe fn removeAllUserScripts(&self);
#[cfg(all(feature = "WKContentWorld", feature = "WKScriptMessageHandler"))]
/// Adds a script message handler.
///
/// Parameter `scriptMessageHandler`: The script message handler to add.
///
/// Parameter `contentWorld`: The WKContentWorld in which to add the script message handler.
///
/// Parameter `name`: The name of the message handler.
///
/// Adding a script message handler adds a function
/// window.webkit.messageHandlers.
/// <name
/// >.postMessage(
/// <messageBody
/// >) to all frames, available in the given WKContentWorld.
///
/// The name argument must be a non-empty string.
///
/// Each WKContentWorld can have any number of script message handlers, but only one per unique name.
///
/// Once any script message handler has been added to a WKContentWorld for a given name, it is an error to add another
/// script message handler to that WKContentWorld for that same name without first removing the previous script message handler.
///
/// The above restriction applies to any type of script message handler - WKScriptMessageHandler and WKScriptMessageHandlerWithReply
/// objects will conflict with each other if you try to add them to the same WKContentWorld with the same name.
#[unsafe(method(addScriptMessageHandler:contentWorld:name:))]
#[unsafe(method_family = none)]
pub unsafe fn addScriptMessageHandler_contentWorld_name(
&self,
script_message_handler: &ProtocolObject<dyn WKScriptMessageHandler>,
world: &WKContentWorld,
name: &NSString,
);
#[cfg(all(
feature = "WKContentWorld",
feature = "WKScriptMessageHandlerWithReply"
))]
/// Adds a script message handler.
///
/// Parameter `scriptMessageHandlerWithReply`: The script message handler to add.
///
/// Parameter `contentWorld`: The WKContentWorld in which to add the script message handler.
///
/// Parameter `name`: The name of the message handler.
///
/// Adding a script message handler adds a function
/// window.webkit.messageHandlers.
/// <name
/// >.postMessage(
/// <messageBody
/// >) to all frames, available in the given WKContentWorld.
///
/// The name argument must be a non-empty string.
///
/// Each WKContentWorld can have any number of script message handlers, but only one per unique name.
///
/// Once any script message handler has been added to a WKContentWorld for a given name, it is an error to add another
/// script message handler to that WKContentWorld for that same name without first removing the previous script message handler.
///
/// The above restriction applies to any type of script message handler - WKScriptMessageHandlerWithReply and WKScriptMessageHandler
/// objects will conflict with each other if you try to add them to the same WKContentWorld with the same name.
///
/// Refer to the WKScriptMessageHandlerWithReply documentation for examples of how it is more flexible than WKScriptMessageHandler.
#[unsafe(method(addScriptMessageHandlerWithReply:contentWorld:name:))]
#[unsafe(method_family = none)]
pub unsafe fn addScriptMessageHandlerWithReply_contentWorld_name(
&self,
script_message_handler_with_reply: &ProtocolObject<dyn WKScriptMessageHandlerWithReply>,
content_world: &WKContentWorld,
name: &NSString,
);
#[cfg(feature = "WKScriptMessageHandler")]
/// Adds a script message handler to the main world used by page content itself.
///
/// Parameter `scriptMessageHandler`: The script message handler to add.
///
/// Parameter `name`: The name of the message handler.
///
/// Calling this method is equivalent to calling addScriptMessageHandler:contentWorld:name:
/// with [WKContentWorld pageWorld] as the contentWorld argument.
#[unsafe(method(addScriptMessageHandler:name:))]
#[unsafe(method_family = none)]
pub unsafe fn addScriptMessageHandler_name(
&self,
script_message_handler: &ProtocolObject<dyn WKScriptMessageHandler>,
name: &NSString,
);
#[cfg(feature = "WKContentWorld")]
/// Removes a script message handler.
///
/// Parameter `name`: The name of the message handler to remove.
///
/// Parameter `contentWorld`: The WKContentWorld from which to remove the script message handler.
#[unsafe(method(removeScriptMessageHandlerForName:contentWorld:))]
#[unsafe(method_family = none)]
pub unsafe fn removeScriptMessageHandlerForName_contentWorld(
&self,
name: &NSString,
content_world: &WKContentWorld,
);
/// Removes a script message handler.
///
/// Parameter `name`: The name of the message handler to remove.
///
/// Calling this method is equivalent to calling removeScriptMessageHandlerForName:contentWorld:
/// with [WKContentWorld pageWorld] as the contentWorld argument.
#[unsafe(method(removeScriptMessageHandlerForName:))]
#[unsafe(method_family = none)]
pub unsafe fn removeScriptMessageHandlerForName(&self, name: &NSString);
#[cfg(feature = "WKContentWorld")]
/// Removes all script message handlers from a given WKContentWorld.
///
/// Parameter `contentWorld`: The WKContentWorld from which to remove all script message handlers.
#[unsafe(method(removeAllScriptMessageHandlersFromContentWorld:))]
#[unsafe(method_family = none)]
pub unsafe fn removeAllScriptMessageHandlersFromContentWorld(
&self,
content_world: &WKContentWorld,
);
/// Removes all associated script message handlers.
#[unsafe(method(removeAllScriptMessageHandlers))]
#[unsafe(method_family = none)]
pub unsafe fn removeAllScriptMessageHandlers(&self);
#[cfg(feature = "WKContentRuleList")]
/// Adds a content rule list.
///
/// Parameter `contentRuleList`: The content rule list to add.
#[unsafe(method(addContentRuleList:))]
#[unsafe(method_family = none)]
pub unsafe fn addContentRuleList(&self, content_rule_list: &WKContentRuleList);
#[cfg(feature = "WKContentRuleList")]
/// Removes a content rule list.
///
/// Parameter `contentRuleList`: The content rule list to remove.
#[unsafe(method(removeContentRuleList:))]
#[unsafe(method_family = none)]
pub unsafe fn removeContentRuleList(&self, content_rule_list: &WKContentRuleList);
/// Removes all associated content rule lists.
#[unsafe(method(removeAllContentRuleLists))]
#[unsafe(method_family = none)]
pub unsafe fn removeAllContentRuleLists(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl WKUserContentController {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
);
}