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