objc2_web_kit/generated/
WKWebpagePreferences.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
7use crate::*;
8
9/// A content mode represents the type of content to load, as well as
10/// additional layout and rendering adaptations that are applied as a result of
11/// loading the content
12///
13///
14///
15///
16/// WKContentModeRecommended behaves like WKContentModeMobile on iPhone and iPad mini
17/// and WKContentModeDesktop on other iPad models as well as Mac.
18///
19/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkcontentmode?language=objc)
20// NS_ENUM
21#[repr(transparent)]
22#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
23pub struct WKContentMode(pub NSInteger);
24impl WKContentMode {
25    #[doc(alias = "WKContentModeRecommended")]
26    pub const Recommended: Self = Self(0);
27    #[doc(alias = "WKContentModeMobile")]
28    pub const Mobile: Self = Self(1);
29    #[doc(alias = "WKContentModeDesktop")]
30    pub const Desktop: Self = Self(2);
31}
32
33unsafe impl Encode for WKContentMode {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for WKContentMode {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41/// A secure navigation policy represents whether or not there is a
42/// preference for loading a webpage with https, and how failures should be
43/// handled.
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebpagepreferencesupgradetohttpspolicy?language=objc)
46// NS_ENUM
47#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct WKWebpagePreferencesUpgradeToHTTPSPolicy(pub NSInteger);
50impl WKWebpagePreferencesUpgradeToHTTPSPolicy {
51    #[doc(alias = "WKWebpagePreferencesUpgradeToHTTPSPolicyKeepAsRequested")]
52    pub const KeepAsRequested: Self = Self(0);
53    #[doc(alias = "WKWebpagePreferencesUpgradeToHTTPSPolicyAutomaticFallbackToHTTP")]
54    pub const AutomaticFallbackToHTTP: Self = Self(1);
55    #[doc(alias = "WKWebpagePreferencesUpgradeToHTTPSPolicyUserMediatedFallbackToHTTP")]
56    pub const UserMediatedFallbackToHTTP: Self = Self(2);
57    #[doc(alias = "WKWebpagePreferencesUpgradeToHTTPSPolicyErrorOnFailure")]
58    pub const ErrorOnFailure: Self = Self(3);
59}
60
61unsafe impl Encode for WKWebpagePreferencesUpgradeToHTTPSPolicy {
62    const ENCODING: Encoding = NSInteger::ENCODING;
63}
64
65unsafe impl RefEncode for WKWebpagePreferencesUpgradeToHTTPSPolicy {
66    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69extern_class!(
70    /// A WKWebpagePreferences object is a collection of properties that
71    /// determine the preferences to use when loading and rendering a page.
72    ///
73    /// Contains properties used to determine webpage preferences.
74    ///
75    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wkwebpagepreferences?language=objc)
76    #[unsafe(super(NSObject))]
77    #[thread_kind = MainThreadOnly]
78    #[derive(Debug, PartialEq, Eq, Hash)]
79    pub struct WKWebpagePreferences;
80);
81
82extern_conformance!(
83    unsafe impl NSObjectProtocol for WKWebpagePreferences {}
84);
85
86impl WKWebpagePreferences {
87    extern_methods!(
88        /// A WKContentMode indicating the content mode to prefer
89        /// when loading and rendering a webpage.
90        ///
91        /// The default value is WKContentModeRecommended. The stated
92        /// preference is ignored on subframe navigation
93        #[unsafe(method(preferredContentMode))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn preferredContentMode(&self) -> WKContentMode;
96
97        /// Setter for [`preferredContentMode`][Self::preferredContentMode].
98        #[unsafe(method(setPreferredContentMode:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn setPreferredContentMode(&self, preferred_content_mode: WKContentMode);
101
102        #[unsafe(method(allowsContentJavaScript))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn allowsContentJavaScript(&self) -> bool;
105
106        /// Setter for [`allowsContentJavaScript`][Self::allowsContentJavaScript].
107        #[unsafe(method(setAllowsContentJavaScript:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setAllowsContentJavaScript(&self, allows_content_java_script: bool);
110
111        /// A boolean indicating whether lockdown mode is enabled.
112        ///
113        /// This mode trades off performance and compatibility in favor of security.
114        /// The default value depends on the system setting.
115        #[unsafe(method(isLockdownModeEnabled))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn isLockdownModeEnabled(&self) -> bool;
118
119        /// Setter for [`isLockdownModeEnabled`][Self::isLockdownModeEnabled].
120        #[unsafe(method(setLockdownModeEnabled:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setLockdownModeEnabled(&self, lockdown_mode_enabled: bool);
123
124        /// A WKWebpagePreferencesUpgradeToHTTPSPolicy indicating the desired mode
125        /// used when performing a top-level navigation to a webpage.
126        ///
127        /// The default value is WKWebpagePreferencesUpgradeToHTTPSPolicyKeepAsRequested.
128        /// The stated preference is ignored on subframe navigation, and it may be ignored based on
129        /// system configuration. The upgradeKnownHostsToHTTPS property on WKWebViewConfiguration
130        /// supercedes this policy for known hosts.
131        #[unsafe(method(preferredHTTPSNavigationPolicy))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn preferredHTTPSNavigationPolicy(
134            &self,
135        ) -> WKWebpagePreferencesUpgradeToHTTPSPolicy;
136
137        /// Setter for [`preferredHTTPSNavigationPolicy`][Self::preferredHTTPSNavigationPolicy].
138        #[unsafe(method(setPreferredHTTPSNavigationPolicy:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setPreferredHTTPSNavigationPolicy(
141            &self,
142            preferred_https_navigation_policy: WKWebpagePreferencesUpgradeToHTTPSPolicy,
143        );
144    );
145}
146
147/// Methods declared on superclass `NSObject`.
148impl WKWebpagePreferences {
149    extern_methods!(
150        #[unsafe(method(init))]
151        #[unsafe(method_family = init)]
152        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
153
154        #[unsafe(method(new))]
155        #[unsafe(method_family = new)]
156        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
157    );
158}