pub unsafe trait WKUIDelegate: NSObjectProtocol + MainThreadOnly {
// Provided methods
unsafe fn webView_createWebViewWithConfiguration_forNavigationAction_windowFeatures(
&self,
web_view: &WKWebView,
configuration: &WKWebViewConfiguration,
navigation_action: &WKNavigationAction,
window_features: &WKWindowFeatures,
) -> Option<Retained<WKWebView>>
where Self: Sized + Message { ... }
unsafe fn webViewDidClose(&self, web_view: &WKWebView)
where Self: Sized + Message { ... }
unsafe fn webView_runJavaScriptAlertPanelWithMessage_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
message: &NSString,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn()>,
)
where Self: Sized + Message { ... }
unsafe fn webView_runJavaScriptConfirmPanelWithMessage_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
message: &NSString,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(Bool)>,
)
where Self: Sized + Message { ... }
unsafe fn webView_runJavaScriptTextInputPanelWithPrompt_defaultText_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
prompt: &NSString,
default_text: Option<&NSString>,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(*mut NSString)>,
)
where Self: Sized + Message { ... }
unsafe fn webView_requestMediaCapturePermissionForOrigin_initiatedByFrame_type_decisionHandler(
&self,
web_view: &WKWebView,
origin: &WKSecurityOrigin,
frame: &WKFrameInfo,
type: WKMediaCaptureType,
decision_handler: &Block<dyn Fn(WKPermissionDecision)>,
)
where Self: Sized + Message { ... }
unsafe fn webView_requestDeviceOrientationAndMotionPermissionForOrigin_initiatedByFrame_decisionHandler(
&self,
web_view: &WKWebView,
origin: &WKSecurityOrigin,
frame: &WKFrameInfo,
decision_handler: &Block<dyn Fn(WKPermissionDecision)>,
)
where Self: Sized + Message { ... }
unsafe fn webView_runOpenPanelWithParameters_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
parameters: &WKOpenPanelParameters,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(*mut NSArray<NSURL>)>,
)
where Self: Sized + Message { ... }
}
WKUIDelegate
only.Expand description
A class conforming to the WKUIDelegate protocol provides methods for presenting native UI on behalf of a webpage.
See also Apple’s documentation
Provided Methods§
Available on crate feature WKNavigationAction
and crate feature WKWebView
and crate feature WKWebViewConfiguration
and crate feature WKWindowFeatures
and crate feature objc2-app-kit
and macOS only.
WKNavigationAction
and crate feature WKWebView
and crate feature WKWebViewConfiguration
and crate feature WKWindowFeatures
and crate feature objc2-app-kit
and macOS only.Creates a new web view.
Parameter webView
: The web view invoking the delegate method.
Parameter configuration
: The configuration to use when creating the new web
view. This configuration is a copy of webView.configuration.
Parameter navigationAction
: The navigation action causing the new web view to
be created.
Parameter windowFeatures
: Window features requested by the webpage.
Returns: A new web view or nil.
The web view returned must be created with the specified configuration. WebKit will load the request in the returned web view.
If you do not implement this method, the web view will cancel the navigation.
Sourceunsafe fn webViewDidClose(&self, web_view: &WKWebView)
Available on crate feature WKWebView
and crate feature objc2-app-kit
and macOS only.
unsafe fn webViewDidClose(&self, web_view: &WKWebView)
WKWebView
and crate feature objc2-app-kit
and macOS only.Notifies your app that the DOM window object’s close() method completed successfully.
Parameter webView
: The web view invoking the delegate method.
Your app should remove the web view from the view hierarchy and update the UI as needed, such as by closing the containing browser tab or window.
Sourceunsafe fn webView_runJavaScriptAlertPanelWithMessage_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
message: &NSString,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn()>,
)
Available on crate feature WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_runJavaScriptAlertPanelWithMessage_initiatedByFrame_completionHandler( &self, web_view: &WKWebView, message: &NSString, frame: &WKFrameInfo, completion_handler: &Block<dyn Fn()>, )
WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.Displays a JavaScript alert panel.
Parameter webView
: The web view invoking the delegate method.
Parameter message
: The message to display.
Parameter frame
: Information about the frame whose JavaScript initiated this
call.
Parameter completionHandler
: The completion handler to call after the alert
panel has been dismissed.
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have a single OK button.
If you do not implement this method, the web view will behave as if the user selected the OK button.
Sourceunsafe fn webView_runJavaScriptConfirmPanelWithMessage_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
message: &NSString,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(Bool)>,
)
Available on crate feature WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_runJavaScriptConfirmPanelWithMessage_initiatedByFrame_completionHandler( &self, web_view: &WKWebView, message: &NSString, frame: &WKFrameInfo, completion_handler: &Block<dyn Fn(Bool)>, )
WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.Displays a JavaScript confirm panel.
Parameter webView
: The web view invoking the delegate method.
Parameter message
: The message to display.
Parameter frame
: Information about the frame whose JavaScript initiated this call.
Parameter completionHandler
: The completion handler to call after the confirm
panel has been dismissed. Pass YES if the user chose OK, NO if the user
chose Cancel.
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have two buttons, such as OK and Cancel.
If you do not implement this method, the web view will behave as if the user selected the Cancel button.
Sourceunsafe fn webView_runJavaScriptTextInputPanelWithPrompt_defaultText_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
prompt: &NSString,
default_text: Option<&NSString>,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(*mut NSString)>,
)
Available on crate feature WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_runJavaScriptTextInputPanelWithPrompt_defaultText_initiatedByFrame_completionHandler( &self, web_view: &WKWebView, prompt: &NSString, default_text: Option<&NSString>, frame: &WKFrameInfo, completion_handler: &Block<dyn Fn(*mut NSString)>, )
WKFrameInfo
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.Displays a JavaScript text input panel.
Parameter webView
: The web view invoking the delegate method.
Parameter prompt
: The prompt to display.
Parameter defaultText
: The initial text to display in the text entry field.
Parameter frame
: Information about the frame whose JavaScript initiated this call.
Parameter completionHandler
: The completion handler to call after the text
input panel has been dismissed. Pass the entered text if the user chose
OK, otherwise nil.
For user security, your app should call attention to the fact that a specific website controls the content in this panel. A simple forumla for identifying the controlling website is frame.request.URL.host. The panel should have two buttons, such as OK and Cancel, and a field in which to enter text.
If you do not implement this method, the web view will behave as if the user selected the Cancel button.
Sourceunsafe fn webView_requestMediaCapturePermissionForOrigin_initiatedByFrame_type_decisionHandler(
&self,
web_view: &WKWebView,
origin: &WKSecurityOrigin,
frame: &WKFrameInfo,
type: WKMediaCaptureType,
decision_handler: &Block<dyn Fn(WKPermissionDecision)>,
)
Available on crate feature WKFrameInfo
and crate feature WKSecurityOrigin
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_requestMediaCapturePermissionForOrigin_initiatedByFrame_type_decisionHandler( &self, web_view: &WKWebView, origin: &WKSecurityOrigin, frame: &WKFrameInfo, type: WKMediaCaptureType, decision_handler: &Block<dyn Fn(WKPermissionDecision)>, )
WKFrameInfo
and crate feature WKSecurityOrigin
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.A delegate to request permission for microphone audio and camera video access.
Parameter webView
: The web view invoking the delegate method.
Parameter origin
: The origin of the page.
Parameter frame
: Information about the frame whose JavaScript initiated this call.
Parameter type
: The type of capture (camera, microphone).
Parameter decisionHandler
: The completion handler to call once the decision is made
If not implemented, the result is the same as calling the decisionHandler with WKPermissionDecisionPrompt.
Sourceunsafe fn webView_requestDeviceOrientationAndMotionPermissionForOrigin_initiatedByFrame_decisionHandler(
&self,
web_view: &WKWebView,
origin: &WKSecurityOrigin,
frame: &WKFrameInfo,
decision_handler: &Block<dyn Fn(WKPermissionDecision)>,
)
Available on crate feature WKFrameInfo
and crate feature WKSecurityOrigin
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_requestDeviceOrientationAndMotionPermissionForOrigin_initiatedByFrame_decisionHandler( &self, web_view: &WKWebView, origin: &WKSecurityOrigin, frame: &WKFrameInfo, decision_handler: &Block<dyn Fn(WKPermissionDecision)>, )
WKFrameInfo
and crate feature WKSecurityOrigin
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.Allows your app to determine whether or not the given security origin should have access to the device’s orientation and motion.
Parameter securityOrigin
: The security origin which requested access to the device’s orientation and motion.
Parameter frame
: The frame that initiated the request.
Parameter decisionHandler
: The decision handler to call once the app has made its decision.
Sourceunsafe fn webView_runOpenPanelWithParameters_initiatedByFrame_completionHandler(
&self,
web_view: &WKWebView,
parameters: &WKOpenPanelParameters,
frame: &WKFrameInfo,
completion_handler: &Block<dyn Fn(*mut NSArray<NSURL>)>,
)
Available on crate feature WKFrameInfo
and crate feature WKOpenPanelParameters
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.
unsafe fn webView_runOpenPanelWithParameters_initiatedByFrame_completionHandler( &self, web_view: &WKWebView, parameters: &WKOpenPanelParameters, frame: &WKFrameInfo, completion_handler: &Block<dyn Fn(*mut NSArray<NSURL>)>, )
WKFrameInfo
and crate feature WKOpenPanelParameters
and crate feature WKWebView
and crate feature block2
and crate feature objc2-app-kit
and macOS only.Displays a file upload panel.
Parameter webView
: The web view invoking the delegate method.
Parameter parameters
: Parameters describing the file upload control.
Parameter frame
: Information about the frame whose file upload control initiated this call.
Parameter completionHandler
: The completion handler to call after open panel has been dismissed. Pass the selected URLs if the user chose OK, otherwise nil.
If you do not implement this method, the web view will behave as if the user selected the Cancel button.