objc2_safari_services/generated/
SFSafariApplication.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
13extern "C" {
14    /// [Apple's documentation](https://developer.apple.com/documentation/safariservices/sfextensionmessagekey?language=objc)
15    pub static SFExtensionMessageKey: &'static NSString;
16}
17
18extern "C" {
19    /// [Apple's documentation](https://developer.apple.com/documentation/safariservices/sfextensionprofilekey?language=objc)
20    pub static SFExtensionProfileKey: &'static NSString;
21}
22
23extern_class!(
24    /// [Apple's documentation](https://developer.apple.com/documentation/safariservices/sfsafariapplication?language=objc)
25    #[unsafe(super(NSObject))]
26    #[derive(Debug, PartialEq, Eq, Hash)]
27    pub struct SFSafariApplication;
28);
29
30extern_conformance!(
31    unsafe impl NSObjectProtocol for SFSafariApplication {}
32);
33
34impl SFSafariApplication {
35    extern_methods!(
36        #[unsafe(method(new))]
37        #[unsafe(method_family = new)]
38        pub unsafe fn new() -> Retained<Self>;
39
40        #[unsafe(method(init))]
41        #[unsafe(method_family = init)]
42        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
43
44        #[cfg(all(feature = "SFSafariWindow", feature = "block2"))]
45        /// Calls the completion handler with the active browser window.
46        #[unsafe(method(getActiveWindowWithCompletionHandler:))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn getActiveWindowWithCompletionHandler(
49            completion_handler: &block2::DynBlock<dyn Fn(*mut SFSafariWindow)>,
50        );
51
52        #[cfg(all(feature = "SFSafariWindow", feature = "block2"))]
53        /// Calls the completion handler with all currently open windows ordered front to back.
54        #[unsafe(method(getAllWindowsWithCompletionHandler:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn getAllWindowsWithCompletionHandler(
57            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSArray<SFSafariWindow>>)>,
58        );
59
60        #[cfg(all(feature = "SFSafariWindow", feature = "block2"))]
61        /// Opens a new window with a tab containing the URL to pass in.
62        #[unsafe(method(openWindowWithURL:completionHandler:))]
63        #[unsafe(method_family = none)]
64        pub unsafe fn openWindowWithURL_completionHandler(
65            url: &NSURL,
66            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut SFSafariWindow)>>,
67        );
68
69        /// This will cause -validateToolbarItemInWindow:completionHandler: to be called on all windows, to let the extension update enabled states or badges of its toolbar items.
70        #[unsafe(method(setToolbarItemsNeedUpdate))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn setToolbarItemsNeedUpdate();
73
74        #[cfg(all(feature = "block2", feature = "objc2-app-kit"))]
75        #[cfg(target_os = "macos")]
76        /// Gets an NSRunningApplication instance with information about the app that this extension is connected to.
77        #[unsafe(method(getHostApplicationWithCompletionHandler:))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn getHostApplicationWithCompletionHandler(
80            completion_handler: &block2::DynBlock<dyn Fn(NonNull<NSRunningApplication>)>,
81        );
82
83        #[cfg(feature = "block2")]
84        /// Opens Safari Extensions preferences and selects extension with the identifier.
85        #[unsafe(method(showPreferencesForExtensionWithIdentifier:completionHandler:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn showPreferencesForExtensionWithIdentifier_completionHandler(
88            identifier: &NSString,
89            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
90        );
91
92        #[cfg(feature = "block2")]
93        /// # Safety
94        ///
95        /// `user_info` generic should be of the correct type.
96        #[unsafe(method(dispatchMessageWithName:toExtensionWithIdentifier:userInfo:completionHandler:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn dispatchMessageWithName_toExtensionWithIdentifier_userInfo_completionHandler(
99            message_name: &NSString,
100            identifier: &NSString,
101            user_info: Option<&NSDictionary<NSString, AnyObject>>,
102            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
103        );
104    );
105}