pub unsafe trait WKWebExtensionWindow: NSObjectProtocol + MainThreadOnly {
// Provided methods
unsafe fn tabsForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> Retained<NSArray<ProtocolObject<dyn WKWebExtensionTab>>>
where Self: Sized + Message { ... }
unsafe fn activeTabForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> Option<Retained<ProtocolObject<dyn WKWebExtensionTab>>>
where Self: Sized + Message { ... }
unsafe fn windowTypeForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> WKWebExtensionWindowType
where Self: Sized + Message { ... }
unsafe fn windowStateForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> WKWebExtensionWindowState
where Self: Sized + Message { ... }
unsafe fn setWindowState_forWebExtensionContext_completionHandler(
&self,
state: WKWebExtensionWindowState,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn isPrivateForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> bool
where Self: Sized + Message { ... }
unsafe fn screenFrameForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> CGRect
where Self: Sized + Message { ... }
unsafe fn frameForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> CGRect
where Self: Sized + Message { ... }
unsafe fn setFrame_forWebExtensionContext_completionHandler(
&self,
frame: CGRect,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn focusForWebExtensionContext_completionHandler(
&self,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
unsafe fn closeForWebExtensionContext_completionHandler(
&self,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
where Self: Sized + Message { ... }
}
WKWebExtensionWindow
only.Expand description
A class conforming to the WKWebExtensionWindow
protocol represents a window to web extensions.
See also Apple’s documentation
Provided Methods§
Sourceunsafe fn tabsForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> Retained<NSArray<ProtocolObject<dyn WKWebExtensionTab>>>
Available on crate features WKWebExtensionContext
and WKWebExtensionTab
only.
unsafe fn tabsForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> Retained<NSArray<ProtocolObject<dyn WKWebExtensionTab>>>
WKWebExtensionContext
and WKWebExtensionTab
only.Called when the tabs are needed for the window.
Parameter context
: The context in which the web extension is running.
Returns: An array of tabs in the window.
Defaults to an empty array if not implemented.
Sourceunsafe fn activeTabForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> Option<Retained<ProtocolObject<dyn WKWebExtensionTab>>>
Available on crate features WKWebExtensionContext
and WKWebExtensionTab
only.
unsafe fn activeTabForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> Option<Retained<ProtocolObject<dyn WKWebExtensionTab>>>
WKWebExtensionContext
and WKWebExtensionTab
only.Called when the active tab is needed for the window.
Parameter context
: The context in which the web extension is running.
Returns: The active tab in the window, which represents the frontmost tab currently in view.
Defaults to nil
if not implemented.
Sourceunsafe fn windowTypeForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> WKWebExtensionWindowType
Available on crate feature WKWebExtensionContext
only.
unsafe fn windowTypeForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> WKWebExtensionWindowType
WKWebExtensionContext
only.Called when the type of the window is needed.
Parameter context
: The context in which the web extension is running.
Returns: The type of the window.
Defaults toWKWebExtensionWindowTypeNormal
if not implemented.
Sourceunsafe fn windowStateForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> WKWebExtensionWindowState
Available on crate feature WKWebExtensionContext
only.
unsafe fn windowStateForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> WKWebExtensionWindowState
WKWebExtensionContext
only.Called when the state of the window is needed.
Parameter context
: The context in which the web extension is running.
Returns: The state of the window.
Defaults toWKWebExtensionWindowStateNormal
if not implemented.
Sourceunsafe fn setWindowState_forWebExtensionContext_completionHandler(
&self,
state: WKWebExtensionWindowState,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features WKWebExtensionContext
and block2
only.
unsafe fn setWindowState_forWebExtensionContext_completionHandler( &self, state: WKWebExtensionWindowState, context: &WKWebExtensionContext, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
WKWebExtensionContext
and block2
only.Called to set the state of the window.
Parameter context
: The context in which the web extension is running.
Parameter state
: The new state of the window.
Parameter completionHandler
: A block that must be called upon completion. It takes a single error argument,
which should be provided if any errors occurred.
The implementation of windowStateForWebExtensionContext:
is a prerequisite.
Without it, this method will not be called.
See also: windowStateForWebExtensionContext:
Sourceunsafe fn isPrivateForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> bool
Available on crate feature WKWebExtensionContext
only.
unsafe fn isPrivateForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> bool
WKWebExtensionContext
only.Called when the private state of the window is needed.
Parameter context
: The context in which the web extension is running.
Returns: YES
if the window is private, NO
otherwise.
Defaults to NO
if not implemented. This value is cached and will not change for the duration of the window or its contained tabs.
Note: To ensure proper isolation between private and non-private data, web views associated with private data must use a
different WKUserContentController
. Likewise, to be identified as a private web view and to ensure that cookies and other
website data is not shared, private web views must be configured to use a non-persistent WKWebsiteDataStore
.
Sourceunsafe fn screenFrameForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> CGRect
Available on crate features WKWebExtensionContext
and objc2-core-foundation
only.
unsafe fn screenFrameForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> CGRect
WKWebExtensionContext
and objc2-core-foundation
only.Called when the screen frame containing the window is needed.
Parameter context
: The context associated with the running web extension.
Returns: The frame for the screen containing the window.
Defaults to CGRectNull
if not implemented.
Sourceunsafe fn frameForWebExtensionContext(
&self,
context: &WKWebExtensionContext,
) -> CGRect
Available on crate features WKWebExtensionContext
and objc2-core-foundation
only.
unsafe fn frameForWebExtensionContext( &self, context: &WKWebExtensionContext, ) -> CGRect
WKWebExtensionContext
and objc2-core-foundation
only.Called when the frame of the window is needed.
Parameter context
: The context in which the web extension is running.
Returns: The frame of the window, in screen coordinates
Defaults to CGRectNull
if not implemented.
Sourceunsafe fn setFrame_forWebExtensionContext_completionHandler(
&self,
frame: CGRect,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features WKWebExtensionContext
and block2
and objc2-core-foundation
only.
unsafe fn setFrame_forWebExtensionContext_completionHandler( &self, frame: CGRect, context: &WKWebExtensionContext, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
WKWebExtensionContext
and block2
and objc2-core-foundation
only.Called to set the frame of the window.
Parameter context
: The context in which the web extension is running.
Parameter frame
: The new frame of the window, in screen coordinates.
Parameter completionHandler
: A block that must be called upon completion. It takes a single error argument,
which should be provided if any errors occurred.
On macOS, the implementation of both frameForWebExtensionContext:
and screenFrameForWebExtensionContext:
are prerequisites. On iOS, iPadOS, and visionOS, only frameForWebExtensionContext:
is a prerequisite. Without the respective method(s),
this method will not be called.
See also: frameForWebExtensionContext:
See also: screenFrameForWebExtensionContext:
Sourceunsafe fn focusForWebExtensionContext_completionHandler(
&self,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features WKWebExtensionContext
and block2
only.
unsafe fn focusForWebExtensionContext_completionHandler( &self, context: &WKWebExtensionContext, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
WKWebExtensionContext
and block2
only.Called to focus the window.
Parameter context
: The context in which the web extension is running.
Parameter completionHandler
: A block that must be called upon completion. It takes a single error argument,
which should be provided if any errors occurred.
No action is performed if not implemented.
Sourceunsafe fn closeForWebExtensionContext_completionHandler(
&self,
context: &WKWebExtensionContext,
completion_handler: &DynBlock<dyn Fn(*mut NSError)>,
)
Available on crate features WKWebExtensionContext
and block2
only.
unsafe fn closeForWebExtensionContext_completionHandler( &self, context: &WKWebExtensionContext, completion_handler: &DynBlock<dyn Fn(*mut NSError)>, )
WKWebExtensionContext
and block2
only.Called to close the window.
Parameter context
: The context in which the web extension is running.
Parameter completionHandler
: A block that must be called upon completion. It takes a single error argument,
which should be provided if any errors occurred.
No action is performed if not implemented.