objc2_web_kit/generated/
WKNavigationAction.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-app-kit")]
6#[cfg(target_os = "macos")]
7use objc2_app_kit::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// The type of action triggering a navigation.
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationtype?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct WKNavigationType(pub NSInteger);
19impl WKNavigationType {
20    #[doc(alias = "WKNavigationTypeLinkActivated")]
21    pub const LinkActivated: Self = Self(0);
22    #[doc(alias = "WKNavigationTypeFormSubmitted")]
23    pub const FormSubmitted: Self = Self(1);
24    #[doc(alias = "WKNavigationTypeBackForward")]
25    pub const BackForward: Self = Self(2);
26    #[doc(alias = "WKNavigationTypeReload")]
27    pub const Reload: Self = Self(3);
28    #[doc(alias = "WKNavigationTypeFormResubmitted")]
29    pub const FormResubmitted: Self = Self(4);
30    #[doc(alias = "WKNavigationTypeOther")]
31    pub const Other: Self = Self(-1);
32}
33
34unsafe impl Encode for WKNavigationType {
35    const ENCODING: Encoding = NSInteger::ENCODING;
36}
37
38unsafe impl RefEncode for WKNavigationType {
39    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
40}
41
42extern_class!(
43    /// A WKNavigationAction object contains information about an action that may cause a navigation, used for making policy decisions.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/webkit/wknavigationaction?language=objc)
46    #[unsafe(super(NSObject))]
47    #[thread_kind = MainThreadOnly]
48    #[derive(Debug, PartialEq, Eq, Hash)]
49    pub struct WKNavigationAction;
50);
51
52extern_conformance!(
53    unsafe impl NSObjectProtocol for WKNavigationAction {}
54);
55
56impl WKNavigationAction {
57    extern_methods!(
58        #[cfg(feature = "WKFrameInfo")]
59        /// The frame requesting the navigation.
60        #[unsafe(method(sourceFrame))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn sourceFrame(&self) -> Option<Retained<WKFrameInfo>>;
63
64        #[cfg(feature = "WKFrameInfo")]
65        /// The target frame, or nil if this is a new window navigation.
66        #[unsafe(method(targetFrame))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn targetFrame(&self) -> Option<Retained<WKFrameInfo>>;
69
70        /// The type of action that triggered the navigation.
71        ///
72        /// The value is one of the constants of the enumerated type WKNavigationType.
73        #[unsafe(method(navigationType))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn navigationType(&self) -> WKNavigationType;
76
77        /// The navigation's request.
78        #[unsafe(method(request))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn request(&self) -> Retained<NSURLRequest>;
81
82        /// A value indicating whether the web content used a download attribute to indicate that this should be downloaded.
83        #[unsafe(method(shouldPerformDownload))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn shouldPerformDownload(&self) -> bool;
86
87        /// Whether or not the navigation is a redirect from a content rule list.
88        #[unsafe(method(isContentRuleListRedirect))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn isContentRuleListRedirect(&self) -> bool;
91
92        #[cfg(feature = "objc2-app-kit")]
93        #[cfg(target_os = "macos")]
94        /// The modifier keys that were in effect when the navigation was requested.
95        #[unsafe(method(modifierFlags))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn modifierFlags(&self) -> NSEventModifierFlags;
98
99        /// The number of the mouse button causing the navigation to be requested.
100        #[unsafe(method(buttonNumber))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn buttonNumber(&self) -> NSInteger;
103    );
104}
105
106/// Methods declared on superclass `NSObject`.
107impl WKNavigationAction {
108    extern_methods!(
109        #[unsafe(method(init))]
110        #[unsafe(method_family = init)]
111        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
116    );
117}