objc2_web_kit/generated/
WKWebViewConfiguration.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::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9use objc2_foundation::*;
10
11use crate::*;
12
13/// The policy used to determine the directionality of user interface elements inside a web view.
14///
15/// specifications.
16///
17/// userInterfaceLayoutDirection property
18///
19/// When WKUserInterfaceDirectionPolicyContent is specified, the directionality of user interface
20/// elements is affected by the "dir" attribute or the "direction" CSS property. When
21/// WKUserInterfaceDirectionPolicySystem is specified, the directionality of user interface elements is
22/// affected by the direction of the view.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkuserinterfacedirectionpolicy?language=objc)
25// NS_ENUM
26#[repr(transparent)]
27#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
28pub struct WKUserInterfaceDirectionPolicy(pub NSInteger);
29impl WKUserInterfaceDirectionPolicy {
30    #[doc(alias = "WKUserInterfaceDirectionPolicyContent")]
31    pub const Content: Self = Self(0);
32    #[doc(alias = "WKUserInterfaceDirectionPolicySystem")]
33    pub const System: Self = Self(1);
34}
35
36unsafe impl Encode for WKUserInterfaceDirectionPolicy {
37    const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for WKUserInterfaceDirectionPolicy {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// The types of audiovisual media which will require a user gesture to begin playing.
45///
46/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkaudiovisualmediatypes?language=objc)
47// NS_OPTIONS
48#[repr(transparent)]
49#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
50pub struct WKAudiovisualMediaTypes(pub NSUInteger);
51bitflags::bitflags! {
52    impl WKAudiovisualMediaTypes: NSUInteger {
53        #[doc(alias = "WKAudiovisualMediaTypeNone")]
54        const None = 0;
55        #[doc(alias = "WKAudiovisualMediaTypeAudio")]
56        const Audio = 1<<0;
57        #[doc(alias = "WKAudiovisualMediaTypeVideo")]
58        const Video = 1<<1;
59        #[doc(alias = "WKAudiovisualMediaTypeAll")]
60        const All = NSUIntegerMax as _;
61    }
62}
63
64unsafe impl Encode for WKAudiovisualMediaTypes {
65    const ENCODING: Encoding = NSUInteger::ENCODING;
66}
67
68unsafe impl RefEncode for WKAudiovisualMediaTypes {
69    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
70}
71
72extern_class!(
73    /// A WKWebViewConfiguration object is a collection of properties with
74    /// which to initialize a web view.
75    ///
76    /// Contains properties used to configure a
77    ///
78    /// ```text
79    ///  WKWebView
80    /// ```
81    ///
82    /// .
83    ///
84    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebviewconfiguration?language=objc)
85    #[unsafe(super(NSObject))]
86    #[thread_kind = MainThreadOnly]
87    #[derive(Debug, PartialEq, Eq, Hash)]
88    pub struct WKWebViewConfiguration;
89);
90
91extern_conformance!(
92    unsafe impl NSCoding for WKWebViewConfiguration {}
93);
94
95extern_conformance!(
96    unsafe impl NSCopying for WKWebViewConfiguration {}
97);
98
99unsafe impl CopyingHelper for WKWebViewConfiguration {
100    type Result = Self;
101}
102
103extern_conformance!(
104    unsafe impl NSObjectProtocol for WKWebViewConfiguration {}
105);
106
107extern_conformance!(
108    unsafe impl NSSecureCoding for WKWebViewConfiguration {}
109);
110
111impl WKWebViewConfiguration {
112    extern_methods!(
113        #[cfg(feature = "WKProcessPool")]
114        /// The process pool from which to obtain the view's web content
115        /// process.
116        ///
117        /// When a web view is initialized, a new web content process
118        /// will be created for it from the specified pool, or an existing process in
119        /// that pool will be used.
120        #[unsafe(method(processPool))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn processPool(&self) -> Retained<WKProcessPool>;
123
124        #[cfg(feature = "WKProcessPool")]
125        /// Setter for [`processPool`][Self::processPool].
126        #[unsafe(method(setProcessPool:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn setProcessPool(&self, process_pool: &WKProcessPool);
129
130        #[cfg(feature = "WKPreferences")]
131        /// The preference settings to be used by the web view.
132        #[unsafe(method(preferences))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn preferences(&self) -> Retained<WKPreferences>;
135
136        #[cfg(feature = "WKPreferences")]
137        /// Setter for [`preferences`][Self::preferences].
138        #[unsafe(method(setPreferences:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setPreferences(&self, preferences: &WKPreferences);
141
142        #[cfg(feature = "WKUserContentController")]
143        /// The user content controller to associate with the web view.
144        #[unsafe(method(userContentController))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn userContentController(&self) -> Retained<WKUserContentController>;
147
148        #[cfg(feature = "WKUserContentController")]
149        /// Setter for [`userContentController`][Self::userContentController].
150        #[unsafe(method(setUserContentController:))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn setUserContentController(
153            &self,
154            user_content_controller: &WKUserContentController,
155        );
156
157        #[cfg(feature = "WKWebExtensionController")]
158        /// The web extension controller to associate with the web view.
159        #[unsafe(method(webExtensionController))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn webExtensionController(&self) -> Option<Retained<WKWebExtensionController>>;
162
163        #[cfg(feature = "WKWebExtensionController")]
164        /// Setter for [`webExtensionController`][Self::webExtensionController].
165        #[unsafe(method(setWebExtensionController:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setWebExtensionController(
168            &self,
169            web_extension_controller: Option<&WKWebExtensionController>,
170        );
171
172        #[cfg(feature = "WKWebsiteDataStore")]
173        /// The website data store to be used by the web view.
174        #[unsafe(method(websiteDataStore))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn websiteDataStore(&self) -> Retained<WKWebsiteDataStore>;
177
178        #[cfg(feature = "WKWebsiteDataStore")]
179        /// Setter for [`websiteDataStore`][Self::websiteDataStore].
180        #[unsafe(method(setWebsiteDataStore:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn setWebsiteDataStore(&self, website_data_store: &WKWebsiteDataStore);
183
184        /// A Boolean value indicating whether the web view suppresses
185        /// content rendering until it is fully loaded into memory.
186        ///
187        /// The default value is NO.
188        #[unsafe(method(suppressesIncrementalRendering))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn suppressesIncrementalRendering(&self) -> bool;
191
192        /// Setter for [`suppressesIncrementalRendering`][Self::suppressesIncrementalRendering].
193        #[unsafe(method(setSuppressesIncrementalRendering:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setSuppressesIncrementalRendering(
196            &self,
197            suppresses_incremental_rendering: bool,
198        );
199
200        /// The name of the application as used in the user agent string.
201        #[unsafe(method(applicationNameForUserAgent))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn applicationNameForUserAgent(&self) -> Option<Retained<NSString>>;
204
205        /// Setter for [`applicationNameForUserAgent`][Self::applicationNameForUserAgent].
206        #[unsafe(method(setApplicationNameForUserAgent:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn setApplicationNameForUserAgent(
209            &self,
210            application_name_for_user_agent: Option<&NSString>,
211        );
212
213        /// A Boolean value indicating whether AirPlay is allowed.
214        ///
215        /// The default value is YES.
216        #[unsafe(method(allowsAirPlayForMediaPlayback))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn allowsAirPlayForMediaPlayback(&self) -> bool;
219
220        /// Setter for [`allowsAirPlayForMediaPlayback`][Self::allowsAirPlayForMediaPlayback].
221        #[unsafe(method(setAllowsAirPlayForMediaPlayback:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn setAllowsAirPlayForMediaPlayback(
224            &self,
225            allows_air_play_for_media_playback: bool,
226        );
227
228        /// A Boolean value indicating whether HTTP requests to servers known to support HTTPS should be automatically upgraded to HTTPS requests.
229        ///
230        /// The default value is YES.
231        #[unsafe(method(upgradeKnownHostsToHTTPS))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn upgradeKnownHostsToHTTPS(&self) -> bool;
234
235        /// Setter for [`upgradeKnownHostsToHTTPS`][Self::upgradeKnownHostsToHTTPS].
236        #[unsafe(method(setUpgradeKnownHostsToHTTPS:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setUpgradeKnownHostsToHTTPS(&self, upgrade_known_hosts_to_https: bool);
239
240        #[unsafe(method(mediaTypesRequiringUserActionForPlayback))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn mediaTypesRequiringUserActionForPlayback(&self) -> WKAudiovisualMediaTypes;
243
244        /// Setter for [`mediaTypesRequiringUserActionForPlayback`][Self::mediaTypesRequiringUserActionForPlayback].
245        #[unsafe(method(setMediaTypesRequiringUserActionForPlayback:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setMediaTypesRequiringUserActionForPlayback(
248            &self,
249            media_types_requiring_user_action_for_playback: WKAudiovisualMediaTypes,
250        );
251
252        #[cfg(feature = "WKWebpagePreferences")]
253        /// The set of default webpage preferences to use when loading and rendering content.
254        ///
255        /// These default webpage preferences are additionally passed to the navigation delegate
256        /// in -webView:decidePolicyForNavigationAction:preferences:decisionHandler:.
257        #[unsafe(method(defaultWebpagePreferences))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn defaultWebpagePreferences(&self) -> Retained<WKWebpagePreferences>;
260
261        #[cfg(feature = "WKWebpagePreferences")]
262        /// Setter for [`defaultWebpagePreferences`][Self::defaultWebpagePreferences].
263        #[unsafe(method(setDefaultWebpagePreferences:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn setDefaultWebpagePreferences(
266            &self,
267            default_webpage_preferences: Option<&WKWebpagePreferences>,
268        );
269
270        #[unsafe(method(limitsNavigationsToAppBoundDomains))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn limitsNavigationsToAppBoundDomains(&self) -> bool;
273
274        /// Setter for [`limitsNavigationsToAppBoundDomains`][Self::limitsNavigationsToAppBoundDomains].
275        #[unsafe(method(setLimitsNavigationsToAppBoundDomains:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn setLimitsNavigationsToAppBoundDomains(
278            &self,
279            limits_navigations_to_app_bound_domains: bool,
280        );
281
282        /// A Boolean value indicating whether inline predictions are allowed.
283        ///
284        /// The default value is `NO`. If false, inline predictions
285        /// are disabled regardless of the system setting. If true, they are enabled based
286        /// on the system setting.
287        #[unsafe(method(allowsInlinePredictions))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn allowsInlinePredictions(&self) -> bool;
290
291        /// Setter for [`allowsInlinePredictions`][Self::allowsInlinePredictions].
292        #[unsafe(method(setAllowsInlinePredictions:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn setAllowsInlinePredictions(&self, allows_inline_predictions: bool);
295
296        /// The directionality of user interface elements.
297        ///
298        /// Possible values are described in WKUserInterfaceDirectionPolicy.
299        /// The default value is WKUserInterfaceDirectionPolicyContent.
300        #[unsafe(method(userInterfaceDirectionPolicy))]
301        #[unsafe(method_family = none)]
302        pub unsafe fn userInterfaceDirectionPolicy(&self) -> WKUserInterfaceDirectionPolicy;
303
304        /// Setter for [`userInterfaceDirectionPolicy`][Self::userInterfaceDirectionPolicy].
305        #[unsafe(method(setUserInterfaceDirectionPolicy:))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn setUserInterfaceDirectionPolicy(
308            &self,
309            user_interface_direction_policy: WKUserInterfaceDirectionPolicy,
310        );
311
312        #[cfg(feature = "WKURLSchemeHandler")]
313        #[unsafe(method(setURLSchemeHandler:forURLScheme:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn setURLSchemeHandler_forURLScheme(
316            &self,
317            url_scheme_handler: Option<&ProtocolObject<dyn WKURLSchemeHandler>>,
318            url_scheme: &NSString,
319        );
320
321        #[cfg(feature = "WKURLSchemeHandler")]
322        #[unsafe(method(urlSchemeHandlerForURLScheme:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn urlSchemeHandlerForURLScheme(
325            &self,
326            url_scheme: &NSString,
327        ) -> Option<Retained<ProtocolObject<dyn WKURLSchemeHandler>>>;
328
329        /// A Boolean value indicating whether insertion of adaptive image glyphs is allowed.
330        ///
331        /// The default value is `NO`. If `NO`, adaptive image glyphs are inserted as regular
332        /// images. If `YES`, they are inserted with the full adaptive sizing behavior.
333        #[unsafe(method(supportsAdaptiveImageGlyph))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn supportsAdaptiveImageGlyph(&self) -> bool;
336
337        /// Setter for [`supportsAdaptiveImageGlyph`][Self::supportsAdaptiveImageGlyph].
338        #[unsafe(method(setSupportsAdaptiveImageGlyph:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn setSupportsAdaptiveImageGlyph(&self, supports_adaptive_image_glyph: bool);
341
342        #[cfg(feature = "objc2-app-kit")]
343        #[cfg(target_os = "macos")]
344        /// The preferred behavior of Writing Tools.
345        ///
346        /// The default behavior is equivalent to `NSWritingToolsBehaviorLimited`.
347        #[unsafe(method(writingToolsBehavior))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn writingToolsBehavior(&self) -> NSWritingToolsBehavior;
350
351        #[cfg(feature = "objc2-app-kit")]
352        #[cfg(target_os = "macos")]
353        /// Setter for [`writingToolsBehavior`][Self::writingToolsBehavior].
354        #[unsafe(method(setWritingToolsBehavior:))]
355        #[unsafe(method_family = none)]
356        pub unsafe fn setWritingToolsBehavior(
357            &self,
358            writing_tools_behavior: NSWritingToolsBehavior,
359        );
360    );
361}
362
363/// Methods declared on superclass `NSObject`.
364impl WKWebViewConfiguration {
365    extern_methods!(
366        #[unsafe(method(init))]
367        #[unsafe(method_family = init)]
368        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
369
370        #[unsafe(method(new))]
371        #[unsafe(method_family = new)]
372        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
373    );
374}