-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(ipc): use http::Request on with_ipc_handler #1183
Conversation
src/lib.rs
Outdated
@@ -1025,6 +1025,26 @@ impl<'a> WebViewBuilder<'a> { | |||
} | |||
} | |||
|
|||
/// Request from a IPC message. See [`WebViewBuilder::with_ipc_handler`] for more information. | |||
pub struct IpcRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of a new type, can't we just pass the url as a second argument with Option<String>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should use http::Request instead? we might add new parameters to this closure in the future (like a closure to provide a response to the webview) and it's more type safe to have a dedicated type for multiple parameters
@amrbashir sorry had to push a docs update :D |
This pull request changes the ipc_handler closure to get a new IpcRequest type instead of only receive the message string.
On macOS, iOS and Windows, we can read the request URL which enhances the security checks to verify the request source (currently only the url() function can be used, which does not work on contexts where an iframe is used).
For custom protocols, I believe the Origin header can be used instead of this.