1use serde::{Deserialize, Serialize};
2#[doc = "Returns the following OS state for the given manifest id.\n[getOsAppState](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-getOsAppState)"]
3#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
4pub struct GetOsAppStateParams {
5 #[doc = "The id from the webapp's manifest file, commonly it's the url of the\nsite installing the webapp. See\nhttps://web.dev/learn/pwa/web-app-manifest."]
6 #[serde(rename = "manifestId")]
7 pub manifest_id: String,
8}
9impl GetOsAppStateParams {
10 pub fn new(manifest_id: impl Into<String>) -> Self {
11 Self {
12 manifest_id: manifest_id.into(),
13 }
14 }
15}
16impl<T: Into<String>> From<T> for GetOsAppStateParams {
17 fn from(url: T) -> Self {
18 GetOsAppStateParams::new(url)
19 }
20}
21#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
22pub enum GetOsAppStateMethod {
23 #[serde(rename = "PWA.getOsAppState")]
24 GetOsAppState,
25}
26#[doc = "Returns the following OS state for the given manifest id.\n[getOsAppState](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-getOsAppState)"]
27#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
28pub struct GetOsAppState {
29 pub method: GetOsAppStateMethod,
30 pub params: GetOsAppStateParams,
31}
32impl GetOsAppState {
33 pub const IDENTIFIER: &'static str = "PWA.getOsAppState";
34 pub fn identifier(&self) -> &'static str {
35 Self::IDENTIFIER
36 }
37}
38impl crate::CommandResult for GetOsAppState {
39 type Result = super::results::GetOsAppStateResult;
40}
41#[doc = "Installs the given manifest identity, optionally using the given installUrlOrBundleUrl\n\nIWA-specific install description:\nmanifestId corresponds to isolated-app:// + web_package::SignedWebBundleId\n\nFile installation mode:\nThe installUrlOrBundleUrl can be either file:// or http(s):// pointing\nto a signed web bundle (.swbn). In this case SignedWebBundleId must correspond to\nThe .swbn file's signing key.\n\nDev proxy installation mode:\ninstallUrlOrBundleUrl must be http(s):// that serves dev mode IWA.\nweb_package::SignedWebBundleId must be of type dev proxy.\n\nThe advantage of dev proxy mode is that all changes to IWA\nautomatically will be reflected in the running app without\nreinstallation.\n\nTo generate bundle id for proxy mode:\n1. Generate 32 random bytes.\n2. Add a specific suffix at the end following the documentation\nhttps://github.com/WICG/isolated-web-apps/blob/main/Scheme.md#suffix\n3. Encode the entire sequence using Base32 without padding.\n\nIf Chrome is not in IWA dev\nmode, the installation will fail, regardless of the state of the allowlist.\n[install](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-install)"]
42#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
43pub struct InstallParams {
44 #[serde(rename = "manifestId")]
45 pub manifest_id: String,
46 #[doc = "The location of the app or bundle overriding the one derived from the\nmanifestId."]
47 #[serde(rename = "installUrlOrBundleUrl")]
48 #[serde(skip_serializing_if = "Option::is_none")]
49 #[serde(default)]
50 pub install_url_or_bundle_url: Option<String>,
51}
52impl InstallParams {
53 pub fn new(manifest_id: impl Into<String>) -> Self {
54 Self {
55 manifest_id: manifest_id.into(),
56 install_url_or_bundle_url: None,
57 }
58 }
59}
60impl<T: Into<String>> From<T> for InstallParams {
61 fn from(url: T) -> Self {
62 InstallParams::new(url)
63 }
64}
65#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
66pub enum InstallMethod {
67 #[serde(rename = "PWA.install")]
68 Install,
69}
70#[doc = "Installs the given manifest identity, optionally using the given installUrlOrBundleUrl\n\nIWA-specific install description:\nmanifestId corresponds to isolated-app:// + web_package::SignedWebBundleId\n\nFile installation mode:\nThe installUrlOrBundleUrl can be either file:// or http(s):// pointing\nto a signed web bundle (.swbn). In this case SignedWebBundleId must correspond to\nThe .swbn file's signing key.\n\nDev proxy installation mode:\ninstallUrlOrBundleUrl must be http(s):// that serves dev mode IWA.\nweb_package::SignedWebBundleId must be of type dev proxy.\n\nThe advantage of dev proxy mode is that all changes to IWA\nautomatically will be reflected in the running app without\nreinstallation.\n\nTo generate bundle id for proxy mode:\n1. Generate 32 random bytes.\n2. Add a specific suffix at the end following the documentation\nhttps://github.com/WICG/isolated-web-apps/blob/main/Scheme.md#suffix\n3. Encode the entire sequence using Base32 without padding.\n\nIf Chrome is not in IWA dev\nmode, the installation will fail, regardless of the state of the allowlist.\n[install](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-install)"]
71#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
72pub struct Install {
73 pub method: InstallMethod,
74 pub params: InstallParams,
75}
76impl Install {
77 pub const IDENTIFIER: &'static str = "PWA.install";
78 pub fn identifier(&self) -> &'static str {
79 Self::IDENTIFIER
80 }
81}
82impl crate::CommandResult for Install {
83 type Result = super::results::InstallResult;
84}
85#[doc = "Uninstalls the given manifest_id and closes any opened app windows.\n[uninstall](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-uninstall)"]
86#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
87pub struct UninstallParams {
88 #[serde(rename = "manifestId")]
89 pub manifest_id: String,
90}
91impl UninstallParams {
92 pub fn new(manifest_id: impl Into<String>) -> Self {
93 Self {
94 manifest_id: manifest_id.into(),
95 }
96 }
97}
98impl<T: Into<String>> From<T> for UninstallParams {
99 fn from(url: T) -> Self {
100 UninstallParams::new(url)
101 }
102}
103#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
104pub enum UninstallMethod {
105 #[serde(rename = "PWA.uninstall")]
106 Uninstall,
107}
108#[doc = "Uninstalls the given manifest_id and closes any opened app windows.\n[uninstall](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-uninstall)"]
109#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
110pub struct Uninstall {
111 pub method: UninstallMethod,
112 pub params: UninstallParams,
113}
114impl Uninstall {
115 pub const IDENTIFIER: &'static str = "PWA.uninstall";
116 pub fn identifier(&self) -> &'static str {
117 Self::IDENTIFIER
118 }
119}
120impl crate::CommandResult for Uninstall {
121 type Result = super::results::UninstallResult;
122}
123#[doc = "Launches the installed web app, or an url in the same web app instead of the\ndefault start url if it is provided. Returns a page Target.TargetID which\ncan be used to attach to via Target.attachToTarget or similar APIs.\n[launch](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-launch)"]
124#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
125pub struct LaunchParams {
126 #[serde(rename = "manifestId")]
127 pub manifest_id: String,
128 #[serde(rename = "url")]
129 #[serde(skip_serializing_if = "Option::is_none")]
130 #[serde(default)]
131 pub url: Option<String>,
132}
133impl LaunchParams {
134 pub fn new(manifest_id: impl Into<String>) -> Self {
135 Self {
136 manifest_id: manifest_id.into(),
137 url: None,
138 }
139 }
140}
141impl<T: Into<String>> From<T> for LaunchParams {
142 fn from(url: T) -> Self {
143 LaunchParams::new(url)
144 }
145}
146#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
147pub enum LaunchMethod {
148 #[serde(rename = "PWA.launch")]
149 Launch,
150}
151#[doc = "Launches the installed web app, or an url in the same web app instead of the\ndefault start url if it is provided. Returns a page Target.TargetID which\ncan be used to attach to via Target.attachToTarget or similar APIs.\n[launch](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-launch)"]
152#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
153pub struct Launch {
154 pub method: LaunchMethod,
155 pub params: LaunchParams,
156}
157impl Launch {
158 pub const IDENTIFIER: &'static str = "PWA.launch";
159 pub fn identifier(&self) -> &'static str {
160 Self::IDENTIFIER
161 }
162}
163impl crate::CommandResult for Launch {
164 type Result = super::results::LaunchResult;
165}
166#[doc = "Opens one or more local files from an installed web app identified by its\nmanifestId. The web app needs to have file handlers registered to process\nthe files. The API returns one or more page Target.TargetIDs which can be\nused to attach to via Target.attachToTarget or similar APIs.\nIf some files in the parameters cannot be handled by the web app, they will\nbe ignored. If none of the files can be handled, this API returns an error.\nIf no files are provided as the parameter, this API also returns an error.\n\nAccording to the definition of the file handlers in the manifest file, one\nTarget.TargetID may represent a page handling one or more files. The order\nof the returned Target.TargetIDs is not guaranteed.\n\nTODO(crbug.com/339454034): Check the existences of the input files.\n[launchFilesInApp](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-launchFilesInApp)"]
167#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
168pub struct LaunchFilesInAppParams {
169 #[serde(rename = "manifestId")]
170 pub manifest_id: String,
171 #[serde(rename = "files")]
172 #[serde(skip_serializing_if = "Vec::is_empty")]
173 pub files: Vec<String>,
174}
175impl LaunchFilesInAppParams {
176 pub fn new(manifest_id: impl Into<String>, files: Vec<String>) -> Self {
177 Self {
178 manifest_id: manifest_id.into(),
179 files,
180 }
181 }
182}
183#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
184pub enum LaunchFilesInAppMethod {
185 #[serde(rename = "PWA.launchFilesInApp")]
186 LaunchFilesInApp,
187}
188#[doc = "Opens one or more local files from an installed web app identified by its\nmanifestId. The web app needs to have file handlers registered to process\nthe files. The API returns one or more page Target.TargetIDs which can be\nused to attach to via Target.attachToTarget or similar APIs.\nIf some files in the parameters cannot be handled by the web app, they will\nbe ignored. If none of the files can be handled, this API returns an error.\nIf no files are provided as the parameter, this API also returns an error.\n\nAccording to the definition of the file handlers in the manifest file, one\nTarget.TargetID may represent a page handling one or more files. The order\nof the returned Target.TargetIDs is not guaranteed.\n\nTODO(crbug.com/339454034): Check the existences of the input files.\n[launchFilesInApp](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-launchFilesInApp)"]
189#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
190pub struct LaunchFilesInApp {
191 pub method: LaunchFilesInAppMethod,
192 pub params: LaunchFilesInAppParams,
193}
194impl LaunchFilesInApp {
195 pub const IDENTIFIER: &'static str = "PWA.launchFilesInApp";
196 pub fn identifier(&self) -> &'static str {
197 Self::IDENTIFIER
198 }
199}
200impl crate::CommandResult for LaunchFilesInApp {
201 type Result = super::results::LaunchFilesInAppResult;
202}
203#[doc = "Opens the current page in its web app identified by the manifest id, needs\nto be called on a page target. This function returns immediately without\nwaiting for the app to finish loading.\n[openCurrentPageInApp](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-openCurrentPageInApp)"]
204#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
205pub struct OpenCurrentPageInAppParams {
206 #[serde(rename = "manifestId")]
207 pub manifest_id: String,
208}
209impl OpenCurrentPageInAppParams {
210 pub fn new(manifest_id: impl Into<String>) -> Self {
211 Self {
212 manifest_id: manifest_id.into(),
213 }
214 }
215}
216impl<T: Into<String>> From<T> for OpenCurrentPageInAppParams {
217 fn from(url: T) -> Self {
218 OpenCurrentPageInAppParams::new(url)
219 }
220}
221#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
222pub enum OpenCurrentPageInAppMethod {
223 #[serde(rename = "PWA.openCurrentPageInApp")]
224 OpenCurrentPageInApp,
225}
226#[doc = "Opens the current page in its web app identified by the manifest id, needs\nto be called on a page target. This function returns immediately without\nwaiting for the app to finish loading.\n[openCurrentPageInApp](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-openCurrentPageInApp)"]
227#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
228pub struct OpenCurrentPageInApp {
229 pub method: OpenCurrentPageInAppMethod,
230 pub params: OpenCurrentPageInAppParams,
231}
232impl OpenCurrentPageInApp {
233 pub const IDENTIFIER: &'static str = "PWA.openCurrentPageInApp";
234 pub fn identifier(&self) -> &'static str {
235 Self::IDENTIFIER
236 }
237}
238impl crate::CommandResult for OpenCurrentPageInApp {
239 type Result = super::results::OpenCurrentPageInAppResult;
240}
241#[doc = "Changes user settings of the web app identified by its manifestId. If the\napp was not installed, this command returns an error. Unset parameters will\nbe ignored; unrecognized values will cause an error.\n\nUnlike the ones defined in the manifest files of the web apps, these\nsettings are provided by the browser and controlled by the users, they\nimpact the way the browser handling the web apps.\n\nSee the comment of each parameter.\n[changeAppUserSettings](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-changeAppUserSettings)"]
242#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
243pub struct ChangeAppUserSettingsParams {
244 #[serde(rename = "manifestId")]
245 pub manifest_id: String,
246 #[doc = "If user allows the links clicked on by the user in the app's scope, or\nextended scope if the manifest has scope extensions and the flags\n`DesktopPWAsLinkCapturingWithScopeExtensions` and\n`WebAppEnableScopeExtensions` are enabled.\n\nNote, the API does not support resetting the linkCapturing to the\ninitial value, uninstalling and installing the web app again will reset\nit.\n\nTODO(crbug.com/339453269): Setting this value on ChromeOS is not\nsupported yet."]
247 #[serde(rename = "linkCapturing")]
248 #[serde(skip_serializing_if = "Option::is_none")]
249 #[serde(default)]
250 pub link_capturing: Option<bool>,
251 #[serde(rename = "displayMode")]
252 #[serde(skip_serializing_if = "Option::is_none")]
253 #[serde(default)]
254 pub display_mode: Option<super::types::DisplayMode>,
255}
256impl ChangeAppUserSettingsParams {
257 pub fn new(manifest_id: impl Into<String>) -> Self {
258 Self {
259 manifest_id: manifest_id.into(),
260 link_capturing: None,
261 display_mode: None,
262 }
263 }
264}
265impl<T: Into<String>> From<T> for ChangeAppUserSettingsParams {
266 fn from(url: T) -> Self {
267 ChangeAppUserSettingsParams::new(url)
268 }
269}
270#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
271pub enum ChangeAppUserSettingsMethod {
272 #[serde(rename = "PWA.changeAppUserSettings")]
273 ChangeAppUserSettings,
274}
275#[doc = "Changes user settings of the web app identified by its manifestId. If the\napp was not installed, this command returns an error. Unset parameters will\nbe ignored; unrecognized values will cause an error.\n\nUnlike the ones defined in the manifest files of the web apps, these\nsettings are provided by the browser and controlled by the users, they\nimpact the way the browser handling the web apps.\n\nSee the comment of each parameter.\n[changeAppUserSettings](https://chromedevtools.github.io/devtools-protocol/tot/PWA/#method-changeAppUserSettings)"]
276#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
277pub struct ChangeAppUserSettings {
278 pub method: ChangeAppUserSettingsMethod,
279 pub params: ChangeAppUserSettingsParams,
280}
281impl ChangeAppUserSettings {
282 pub const IDENTIFIER: &'static str = "PWA.changeAppUserSettings";
283 pub fn identifier(&self) -> &'static str {
284 Self::IDENTIFIER
285 }
286}
287impl crate::CommandResult for ChangeAppUserSettings {
288 type Result = super::results::ChangeAppUserSettingsResult;
289}
290group_enum ! (PwaCommands { GetOsAppState (GetOsAppState) , Install (Install) , Uninstall (Uninstall) , Launch (Launch) , LaunchFilesInApp (LaunchFilesInApp) , OpenCurrentPageInApp (OpenCurrentPageInApp) , ChangeAppUserSettings (ChangeAppUserSettings) } + identifiable);