tauri-apps/tauri

[feat] Expose the ability to enable `are_browser_extensions_enabled` from `CoreWebView2EnvironmentOptions`

Closed this issue · 6 comments

Describe the problem

While I understand this would have to be Windows-only from the get-go (and a somewhat niche use-case), I'd like to not only load a custom extension (for use in overwriting request headers, something that can otherwise not be done in Tauri/Wry using external URLs), but also give my users the ability to load browser extensions as well.

To do so requires setting CoreWebView2EnvironmentOptions.set_are_browser_extensions_enabled(true) as well as calling AddBrowserExtension on the ICoreWebview2Profile7. While I can access the ICoreWebView2Profile7 and call that function (via WebviewWindow.with_webview and some casting), after some digging, I couldn't find a way to set this environment option to begin with.

Describe the solution you'd like

I haven't totally thought of the best way to go about this honestly, since it's as platform-specific as you can get, and I don't have a perfect understanding of the Wry & Tauri codebases.

I recently looked at this Wry PR (#1344) that implemented the ability to change the scrollbar style for Windows in Wry, but as far as I'm aware, this functionality isn't exposed in Tauri either, so I wouldn't know what the plan is/would be to do so (if there even is any). Assuming that does get exposed, the same methodology would probably apply to this as well.

Alternatives considered

Like most problems, I could probably solve it by just forking and maintaining a separate Wry and Tauri, but that sounds like a huge pain lol.

Additional context

No response

I recently looked at this Wry PR (#1344) that implemented the ability to change the scrollbar style for Windows in Wry, but as far as I'm aware, this functionality isn't exposed in Tauri either, so I wouldn't know what the plan is/would be to do so (if there even is any). Assuming that does get exposed, the same methodology would probably apply to this as well.

wry (#1344) needs a PR in tauri to be exposed and the author said they will open one.

Like most problems, I could probably solve it by just forking and maintaining a separate Wry and Tauri, but that sounds like a huge pain lol.

We wouldn't want that, now would we? you could just open a PR 😉 (ofc if you want) and I will help land this in wry and tauri.

Hahaha fair enough, I will take a crack at the Wry portion sometime very soon!

What would be the most sensible way to include platform specific options (like this or the scrollbar style thing) in Tauri? My heart tells me adding something like

let win = WebviewWindowBuilder::new(x, y, z)
  .windows_browser_extensions_enabled(true);

is kinda ugly but I can't really think of anything else off the top of my head

this is fine but I would just name it enable_browser_extensions and document that it only works on Windows atm

Okay! The Wry PR is done (tauri-apps/wry#1356) so once that's in I'll get the Tauri PR going 💪

Tauri PR opened! #11056