Pass site permission grants to sidecar snapshots

This commit is contained in:
2026-05-09 00:01:14 -04:00
parent 4ed1666ece
commit 79d9646ab8
10 changed files with 303 additions and 12 deletions
+4 -1
View File
@@ -10,7 +10,7 @@ use ely_domain::ProfileId;
use serde::Deserialize;
use thiserror::Error;
pub use super::servo_sidecar_request::SidecarSnapshotRequest;
pub use super::servo_sidecar_request::{SidecarSitePermission, SidecarSnapshotRequest};
use super::{
servo_profile_data::{
@@ -112,6 +112,9 @@ impl ServoSidecarClient {
if let Some(typed_text) = request.typed_text.as_deref() {
command.arg("--type-text").arg(typed_text);
}
for permission in &request.site_permissions {
command.arg("--site-permission").arg(permission.to_arg());
}
let mut child = command
.stdout(Stdio::piped())
@@ -1,4 +1,4 @@
use ely_domain::{ProfileId, UrlText};
use ely_domain::{ProfileId, SiteOrigin, SitePermissionDecision, SitePermissionFeature, UrlText};
use super::ProfileDataMode;
@@ -13,6 +13,7 @@ pub struct SidecarSnapshotRequest {
pub(in crate::services) scroll_y: i32,
pub(in crate::services) click_point: Option<SidecarClickPoint>,
pub(in crate::services) typed_text: Option<String>,
pub(in crate::services) site_permissions: Vec<SidecarSitePermission>,
}
impl SidecarSnapshotRequest {
@@ -28,6 +29,7 @@ impl SidecarSnapshotRequest {
scroll_y: 0,
click_point: None,
typed_text: None,
site_permissions: Vec::new(),
}
}
@@ -56,6 +58,12 @@ impl SidecarSnapshotRequest {
self
}
#[must_use]
pub fn with_site_permissions(mut self, site_permissions: Vec<SidecarSitePermission>) -> Self {
self.site_permissions = site_permissions;
self
}
#[cfg(test)]
pub(crate) fn typed_text_for_test(&self) -> Option<&str> {
self.typed_text.as_deref()
@@ -77,3 +85,45 @@ pub(in crate::services) struct SidecarClickPoint {
pub(in crate::services) x: u32,
pub(in crate::services) y: u32,
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct SidecarSitePermission {
origin: SiteOrigin,
feature: SitePermissionFeature,
decision: SitePermissionDecision,
}
impl SidecarSitePermission {
#[must_use]
pub fn new(
origin: SiteOrigin,
feature: SitePermissionFeature,
decision: SitePermissionDecision,
) -> Self {
Self { origin, feature, decision }
}
pub(in crate::services) fn to_arg(&self) -> String {
serde_json::json!({
"origin": self.origin.as_str(),
"feature": self.feature.as_str(),
"decision": self.decision.as_str(),
})
.to_string()
}
#[cfg(test)]
pub(crate) fn origin(&self) -> &SiteOrigin {
&self.origin
}
#[cfg(test)]
pub(crate) fn feature(&self) -> SitePermissionFeature {
self.feature
}
#[cfg(test)]
pub(crate) fn decision(&self) -> SitePermissionDecision {
self.decision
}
}