Remove the special cases for the old Browser package
A browser request now needs the session token of its window. Disabling an old runestone.browser package no longer stops the engine. One list of built-in modules starts the browser and the theme editor, and the plugin menus skip their tools. The access rules no longer treat the browser ID in a special way.
This commit is contained in:
@@ -13,7 +13,6 @@ use tauri::{AppHandle, Emitter, Manager, State};
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
const PLUGIN: &str = "runestone.browser";
|
||||
const COMMANDS: &[&str] = &[
|
||||
"state",
|
||||
"newTab",
|
||||
@@ -571,16 +570,12 @@ pub async fn browser_request(
|
||||
session: Option<String>,
|
||||
) -> Result<Value> {
|
||||
let owner = window.label().to_string();
|
||||
// The plugin lease check can wait for the plugin lock, so it also runs on the blocking worker.
|
||||
// A request can wait for the engine to start or to answer, so it runs on the blocking worker.
|
||||
tauri::async_runtime::spawn_blocking(move || {
|
||||
if let Some(token) = session {
|
||||
app.state::<BrowserState>().require_session(&owner, &token)?;
|
||||
} else {
|
||||
app.state::<crate::plugins::PluginState>()
|
||||
.require_lease(&app, &owner, PLUGIN)?;
|
||||
}
|
||||
app.state::<BrowserState>()
|
||||
.request(&app, &owner, &command, args)
|
||||
let state = app.state::<BrowserState>();
|
||||
// Only the built-in browser gets a session from `browser_connect`. A request without one fails.
|
||||
state.require_session(&owner, session.as_deref().unwrap_or_default())?;
|
||||
state.request(&app, &owner, &command, args)
|
||||
})
|
||||
.await?
|
||||
}
|
||||
|
||||
@@ -1365,13 +1365,7 @@ pub async fn plugins_set_enabled(
|
||||
enabled: bool,
|
||||
hash: Option<String>,
|
||||
) -> Result<()> {
|
||||
let stop_browser = id == "runestone.browser" && !enabled;
|
||||
PluginState::run(&app, move |service| service.set_enabled(&id, enabled, hash.as_deref())).await?;
|
||||
if stop_browser {
|
||||
// Stopping the browser engine waits for its reply.
|
||||
let browser_app = app.clone();
|
||||
tauri::async_runtime::spawn_blocking(move || browser_app.state::<crate::browser::BrowserState>().close_all()).await?;
|
||||
}
|
||||
changed(&app);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user