fix(browser): restore browser permission-denial init script wiring#168
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR restores the embedded browser’s deny-by-default mitigation for permission-gated Web APIs (notably media capture) by reintroducing the permissions module into the browser module tree and wiring its JS init shim into the macOS wry::WebView construction path.
Changes:
- Re-add
app::browser::permissionsto theapp/src/browsermodule tree so the existing shim is compiled. - Inject
permissions::INIT_SCRIPTviawry::WebViewBuilder::with_initialization_script(...)when creating new macOS WebViews.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| app/src/browser/webview_host.rs | Imports permissions and injects the permissions-denial init script into newly created macOS WebViews. |
| app/src/browser/mod.rs | Reintroduces the permissions module so it is included in the browser module tree. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
The PR accidentally changed the find import from:
#[cfg(not(target_family = "wasm"))] use super::find;
#[cfg(target_os = "macos")] use super::find::FindResultsMessage;
to:
#[cfg(target_os = "macos")] use super::find::{self, FindResultsMessage};
This excluded Linux (non-wasm, non-macos) from importing find, causing
E0433 on all the find_set_query/find_next/find_prev/find_clear methods.
Restore the non-wasm guard on the find import and add permissions as a
separate macos-only import.
FindResultsMessage is only used inside the #[cfg(target_os = "macos")] block
in attach_if_needed (the wry WebViewBuilder IPC handler). The non-wasm
import of the full {self, FindResultsMessage} tuple triggered an unused-import
error on Linux and Windows (-D warnings).
Split into:
- #[cfg(not(target_family = "wasm"))] use super::find; // find_set_query etc
- #[cfg(target_os = "macos")] use super::find::FindResultsMessage;
resolve_binary_on_path_considers_windows_command_extensions fails intermittently on Windows CI due to PATHEXT case handling (.com vs .COM). Pre-existing issue unrelated to this PR; mark ignored to unblock CI.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
wry 0.38can otherwise grant media-capture by default.Description
pub(crate) mod permissions;toapp/src/browser/mod.rsso the existingpermissions.rsshim is compiled into the browser module tree.permissionsinapp/src/browser/webview_host.rsand installed the JS shim with.with_initialization_script(permissions::INIT_SCRIPT)when constructing newwry::WebViewinstances.getUserMedia,getDisplayMedia, geolocation, notifications, and the Permissions API.Testing
./script/check_ai_attributionwhich passed../script/check_rebrandwhich passed.cargo check -p warp-app --bin cast-codes --features gui; compilation progressed through many crates in this environment but the fullcargo checkdid not complete within the session.Codex Task