Common/WebView/DTO/WebViewContentOptionsDTO.rs
1//! # WebViewContentOptionsDTO
2//!
3//! Defines the Data Transfer Object for a WebView's content and security
4//! settings.
5
6use serde::{Deserialize, Serialize};
7use serde_json::Value;
8
9/// A serializable struct that represents the options controlling the content
10/// within a WebView, including script enablement and local resource access.
11///
12/// This DTO is sent from `Cocoon` to `Mountain` when a WebView is created to
13/// configure its security sandbox and capabilities.
14#[derive(Serialize, Deserialize, Debug, Clone)]
15#[serde(rename_all = "PascalCase")]
16pub struct WebViewContentOptionsDTO {
17 /// Enables the use of `vscode:command:` URIs within the WebView.
18 pub EnableCommandURIs:Option<bool>,
19
20 /// Enables the execution of scripts within the WebView.
21 pub EnableScripts:Option<bool>,
22
23 /// Enables the use of HTML forms within the WebView.
24 pub EnableForms:Option<bool>,
25
26 /// An optional array of port mappings for forwarding traffic from the
27 /// WebView to the extension host. Serialized
28 /// `Vec<{ webviewPort: number, extensionHostPort: number }>`.
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub PortMapping:Option<Value>,
31
32 /// An optional array of URIs that define the root paths from which the
33 /// WebView is allowed to load local resources. Serialized
34 /// `Vec<UriComponents>`.
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub LocalResourceRoots:Option<Value>,
37}