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
91unsafe impl NSCoding for WKWebViewConfiguration {}
92
93unsafe impl NSCopying for WKWebViewConfiguration {}
94
95unsafe impl CopyingHelper for WKWebViewConfiguration {
96    type Result = Self;
97}
98
99unsafe impl NSObjectProtocol for WKWebViewConfiguration {}
100
101unsafe impl NSSecureCoding for WKWebViewConfiguration {}
102
103impl WKWebViewConfiguration {
104    extern_methods!(
105        #[cfg(feature = "WKProcessPool")]
106        /// The process pool from which to obtain the view's web content
107        /// process.
108        ///
109        /// When a web view is initialized, a new web content process
110        /// will be created for it from the specified pool, or an existing process in
111        /// that pool will be used.
112        #[unsafe(method(processPool))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn processPool(&self) -> Retained<WKProcessPool>;
115
116        #[cfg(feature = "WKProcessPool")]
117        /// Setter for [`processPool`][Self::processPool].
118        #[unsafe(method(setProcessPool:))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn setProcessPool(&self, process_pool: &WKProcessPool);
121
122        #[cfg(feature = "WKPreferences")]
123        /// The preference settings to be used by the web view.
124        #[unsafe(method(preferences))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn preferences(&self) -> Retained<WKPreferences>;
127
128        #[cfg(feature = "WKPreferences")]
129        /// Setter for [`preferences`][Self::preferences].
130        #[unsafe(method(setPreferences:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn setPreferences(&self, preferences: &WKPreferences);
133
134        #[cfg(feature = "WKUserContentController")]
135        /// The user content controller to associate with the web view.
136        #[unsafe(method(userContentController))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn userContentController(&self) -> Retained<WKUserContentController>;
139
140        #[cfg(feature = "WKUserContentController")]
141        /// Setter for [`userContentController`][Self::userContentController].
142        #[unsafe(method(setUserContentController:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setUserContentController(
145            &self,
146            user_content_controller: &WKUserContentController,
147        );
148
149        #[cfg(feature = "WKWebsiteDataStore")]
150        /// The website data store to be used by the web view.
151        #[unsafe(method(websiteDataStore))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn websiteDataStore(&self) -> Retained<WKWebsiteDataStore>;
154
155        #[cfg(feature = "WKWebsiteDataStore")]
156        /// Setter for [`websiteDataStore`][Self::websiteDataStore].
157        #[unsafe(method(setWebsiteDataStore:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setWebsiteDataStore(&self, website_data_store: &WKWebsiteDataStore);
160
161        /// A Boolean value indicating whether the web view suppresses
162        /// content rendering until it is fully loaded into memory.
163        ///
164        /// The default value is NO.
165        #[unsafe(method(suppressesIncrementalRendering))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn suppressesIncrementalRendering(&self) -> bool;
168
169        /// Setter for [`suppressesIncrementalRendering`][Self::suppressesIncrementalRendering].
170        #[unsafe(method(setSuppressesIncrementalRendering:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setSuppressesIncrementalRendering(
173            &self,
174            suppresses_incremental_rendering: bool,
175        );
176
177        /// The name of the application as used in the user agent string.
178        #[unsafe(method(applicationNameForUserAgent))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn applicationNameForUserAgent(&self) -> Option<Retained<NSString>>;
181
182        /// Setter for [`applicationNameForUserAgent`][Self::applicationNameForUserAgent].
183        #[unsafe(method(setApplicationNameForUserAgent:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setApplicationNameForUserAgent(
186            &self,
187            application_name_for_user_agent: Option<&NSString>,
188        );
189
190        /// A Boolean value indicating whether AirPlay is allowed.
191        ///
192        /// The default value is YES.
193        #[unsafe(method(allowsAirPlayForMediaPlayback))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn allowsAirPlayForMediaPlayback(&self) -> bool;
196
197        /// Setter for [`allowsAirPlayForMediaPlayback`][Self::allowsAirPlayForMediaPlayback].
198        #[unsafe(method(setAllowsAirPlayForMediaPlayback:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn setAllowsAirPlayForMediaPlayback(
201            &self,
202            allows_air_play_for_media_playback: bool,
203        );
204
205        /// A Boolean value indicating whether HTTP requests to servers known to support HTTPS should be automatically upgraded to HTTPS requests.
206        ///
207        /// The default value is YES.
208        #[unsafe(method(upgradeKnownHostsToHTTPS))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn upgradeKnownHostsToHTTPS(&self) -> bool;
211
212        /// Setter for [`upgradeKnownHostsToHTTPS`][Self::upgradeKnownHostsToHTTPS].
213        #[unsafe(method(setUpgradeKnownHostsToHTTPS:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setUpgradeKnownHostsToHTTPS(&self, upgrade_known_hosts_to_https: bool);
216
217        #[unsafe(method(mediaTypesRequiringUserActionForPlayback))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn mediaTypesRequiringUserActionForPlayback(&self) -> WKAudiovisualMediaTypes;
220
221        /// Setter for [`mediaTypesRequiringUserActionForPlayback`][Self::mediaTypesRequiringUserActionForPlayback].
222        #[unsafe(method(setMediaTypesRequiringUserActionForPlayback:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setMediaTypesRequiringUserActionForPlayback(
225            &self,
226            media_types_requiring_user_action_for_playback: WKAudiovisualMediaTypes,
227        );
228
229        #[cfg(feature = "WKWebpagePreferences")]
230        /// The set of default webpage preferences to use when loading and rendering content.
231        ///
232        /// These default webpage preferences are additionally passed to the navigation delegate
233        /// in -webView:decidePolicyForNavigationAction:preferences:decisionHandler:.
234        #[unsafe(method(defaultWebpagePreferences))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn defaultWebpagePreferences(&self) -> Retained<WKWebpagePreferences>;
237
238        #[cfg(feature = "WKWebpagePreferences")]
239        /// Setter for [`defaultWebpagePreferences`][Self::defaultWebpagePreferences].
240        #[unsafe(method(setDefaultWebpagePreferences:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn setDefaultWebpagePreferences(
243            &self,
244            default_webpage_preferences: Option<&WKWebpagePreferences>,
245        );
246
247        #[unsafe(method(limitsNavigationsToAppBoundDomains))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn limitsNavigationsToAppBoundDomains(&self) -> bool;
250
251        /// Setter for [`limitsNavigationsToAppBoundDomains`][Self::limitsNavigationsToAppBoundDomains].
252        #[unsafe(method(setLimitsNavigationsToAppBoundDomains:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setLimitsNavigationsToAppBoundDomains(
255            &self,
256            limits_navigations_to_app_bound_domains: bool,
257        );
258
259        /// A Boolean value indicating whether inline predictions are allowed.
260        ///
261        /// The default value is `NO`. If false, inline predictions
262        /// are disabled regardless of the system setting. If true, they are enabled based
263        /// on the system setting.
264        #[unsafe(method(allowsInlinePredictions))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn allowsInlinePredictions(&self) -> bool;
267
268        /// Setter for [`allowsInlinePredictions`][Self::allowsInlinePredictions].
269        #[unsafe(method(setAllowsInlinePredictions:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn setAllowsInlinePredictions(&self, allows_inline_predictions: bool);
272
273        /// The directionality of user interface elements.
274        ///
275        /// Possible values are described in WKUserInterfaceDirectionPolicy.
276        /// The default value is WKUserInterfaceDirectionPolicyContent.
277        #[unsafe(method(userInterfaceDirectionPolicy))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn userInterfaceDirectionPolicy(&self) -> WKUserInterfaceDirectionPolicy;
280
281        /// Setter for [`userInterfaceDirectionPolicy`][Self::userInterfaceDirectionPolicy].
282        #[unsafe(method(setUserInterfaceDirectionPolicy:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn setUserInterfaceDirectionPolicy(
285            &self,
286            user_interface_direction_policy: WKUserInterfaceDirectionPolicy,
287        );
288
289        #[cfg(feature = "WKURLSchemeHandler")]
290        #[unsafe(method(setURLSchemeHandler:forURLScheme:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setURLSchemeHandler_forURLScheme(
293            &self,
294            url_scheme_handler: Option<&ProtocolObject<dyn WKURLSchemeHandler>>,
295            url_scheme: &NSString,
296        );
297
298        #[cfg(feature = "WKURLSchemeHandler")]
299        #[unsafe(method(urlSchemeHandlerForURLScheme:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn urlSchemeHandlerForURLScheme(
302            &self,
303            url_scheme: &NSString,
304        ) -> Option<Retained<ProtocolObject<dyn WKURLSchemeHandler>>>;
305
306        /// A Boolean value indicating whether insertion of adaptive image glyphs is allowed.
307        ///
308        /// The default value is `NO`. If `NO`, adaptive image glyphs are inserted as regular
309        /// images. If `YES`, they are inserted with the full adaptive sizing behavior.
310        #[unsafe(method(supportsAdaptiveImageGlyph))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn supportsAdaptiveImageGlyph(&self) -> bool;
313
314        /// Setter for [`supportsAdaptiveImageGlyph`][Self::supportsAdaptiveImageGlyph].
315        #[unsafe(method(setSupportsAdaptiveImageGlyph:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn setSupportsAdaptiveImageGlyph(&self, supports_adaptive_image_glyph: bool);
318
319        #[cfg(feature = "objc2-app-kit")]
320        #[cfg(target_os = "macos")]
321        /// The preferred behavior of Writing Tools.
322        ///
323        /// The default behavior is equivalent to `NSWritingToolsBehaviorLimited`.
324        #[unsafe(method(writingToolsBehavior))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn writingToolsBehavior(&self) -> NSWritingToolsBehavior;
327
328        #[cfg(feature = "objc2-app-kit")]
329        #[cfg(target_os = "macos")]
330        /// Setter for [`writingToolsBehavior`][Self::writingToolsBehavior].
331        #[unsafe(method(setWritingToolsBehavior:))]
332        #[unsafe(method_family = none)]
333        pub unsafe fn setWritingToolsBehavior(
334            &self,
335            writing_tools_behavior: NSWritingToolsBehavior,
336        );
337    );
338}
339
340/// Methods declared on superclass `NSObject`.
341impl WKWebViewConfiguration {
342    extern_methods!(
343        #[unsafe(method(init))]
344        #[unsafe(method_family = init)]
345        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
346
347        #[unsafe(method(new))]
348        #[unsafe(method_family = new)]
349        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
350    );
351}