-
-
Notifications
You must be signed in to change notification settings - Fork 282
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
feat: Implement navigation event and cancellation, closes #456 #519
feat: Implement navigation event and cancellation, closes #456 #519
Conversation
Adjust relevant structs/functions to take generic arguments due to new constraint.
I think this is a really great feature to be added! Could this just be the config of Webview? Webcontext usually describes shared behaviour (like webdriver setup). |
I could move this code into the webview fairly easily I think, including using the same type aliasing trick to reduce breakage. The reason I picked the WebContext is because it was already being used for things like the webview data directory override, which has a similar execution. I do think that the |
No longer make WebContext generic over user event type. Only take single closure, which defines behaviour to execute when navigation occurs, and also whether to cancel navigation. If user wishes to submit an event, they should simply move an event proxy into the event closure and submit an event through it - see updated example. WebViewBuilder will now raise return an error if there is no WebContext to attach callback to.
I've done some thinking about your suggestions and reworked the feature's implementation. |
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.
Looks good so far except the handler shouldn't be tied to WebContext
at all. Instead, it should be on Webview
same as the ipc handler.
I've removed all modifications to WebContext and instead stored the navigation handler in |
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.
Webview2 implementation Looking good so far except two small comments below.
Co-authored-by: Amr Bashir <[email protected]>
Implement in a different PR
0500e74 |
Here's the one for macos but I suppose it won't be easy to implement if you are not familiar with c/objc ffi. |
I don't really have any experience with objc ffi so if you could lend a hand after the Android port effort that would be great. I'll still try and give it a shot in my own time but I don't expect much |
The function is still not called yet. But this is a prove it can work.
Just add the macos and it's working! I just need the agreement and I'll help pushing the commits. I know some might be busy on work days. |
Seems okay but I could see it the other way around too so we gonna have to document this. and If we want more clarity, we can use an enum enum Navigation {
Allow,
Deny
}
|
I'm very happy with the result. Thank you @atlanticaccent for the help! |
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
Checklist
fix: remove a typo, closes #___, #___
)Other information
Notable: the design approach taken is to:
WebContextGeneric<()>
is provided, namedWebContext
which effectively hides any generic functionality from consumers that do not need it.WebContextGeneric::with_navigation_event
which requires as argument a closure that can construct the user event that is emitted whenever a navigation occurs, thus ensuring that any user defined events also include an event for navigation