Skip to main content

browser_protocol/pwa/
mod.rs

1//! This domain allows interacting with the browser to control PWAs.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8/// The following types are the replica of
9/// <https://crsrc.org/c/chrome/browser/web_applications/proto/web_app_os_integration_state.proto;drc=9910d3be894c8f142c977ba1023f30a656bc13fc;l=67>
10
11#[derive(Debug, Clone, Serialize, Deserialize, Default)]
12#[serde(rename_all = "camelCase")]
13pub struct FileHandlerAccept<'a> {
14    /// New name of the mimetype according to
15    /// <https://www.iana.org/assignments/media-types/media-types.xhtml>
16    #[serde(rename = "mediaType")]
17    media_type: Cow<'a, str>,
18    #[serde(rename = "fileExtensions")]
19    file_extensions: Vec<Cow<'a, str>>,
20}
21
22impl<'a> FileHandlerAccept<'a> {
23    /// Creates a builder for this type with the required parameters:
24    /// * `media_type`: New name of the mimetype according to <https://www.iana.org/assignments/media-types/media-types.xhtml>
25    /// * `file_extensions`: 
26    pub fn builder(media_type: impl Into<Cow<'a, str>>, file_extensions: Vec<Cow<'a, str>>) -> FileHandlerAcceptBuilder<'a> {
27        FileHandlerAcceptBuilder {
28            media_type: media_type.into(),
29            file_extensions: file_extensions,
30        }
31    }
32    /// New name of the mimetype according to
33    /// <https://www.iana.org/assignments/media-types/media-types.xhtml>
34    pub fn media_type(&self) -> &str { self.media_type.as_ref() }
35    pub fn file_extensions(&self) -> &[Cow<'a, str>] { &self.file_extensions }
36}
37
38
39pub struct FileHandlerAcceptBuilder<'a> {
40    media_type: Cow<'a, str>,
41    file_extensions: Vec<Cow<'a, str>>,
42}
43
44impl<'a> FileHandlerAcceptBuilder<'a> {
45    pub fn build(self) -> FileHandlerAccept<'a> {
46        FileHandlerAccept {
47            media_type: self.media_type,
48            file_extensions: self.file_extensions,
49        }
50    }
51}
52
53
54#[derive(Debug, Clone, Serialize, Deserialize, Default)]
55#[serde(rename_all = "camelCase")]
56pub struct FileHandler<'a> {
57    action: Cow<'a, str>,
58    accepts: Vec<FileHandlerAccept<'a>>,
59    #[serde(rename = "displayName")]
60    display_name: Cow<'a, str>,
61}
62
63impl<'a> FileHandler<'a> {
64    /// Creates a builder for this type with the required parameters:
65    /// * `action`: 
66    /// * `accepts`: 
67    /// * `display_name`: 
68    pub fn builder(action: impl Into<Cow<'a, str>>, accepts: Vec<FileHandlerAccept<'a>>, display_name: impl Into<Cow<'a, str>>) -> FileHandlerBuilder<'a> {
69        FileHandlerBuilder {
70            action: action.into(),
71            accepts: accepts,
72            display_name: display_name.into(),
73        }
74    }
75    pub fn action(&self) -> &str { self.action.as_ref() }
76    pub fn accepts(&self) -> &[FileHandlerAccept<'a>] { &self.accepts }
77    pub fn display_name(&self) -> &str { self.display_name.as_ref() }
78}
79
80
81pub struct FileHandlerBuilder<'a> {
82    action: Cow<'a, str>,
83    accepts: Vec<FileHandlerAccept<'a>>,
84    display_name: Cow<'a, str>,
85}
86
87impl<'a> FileHandlerBuilder<'a> {
88    pub fn build(self) -> FileHandler<'a> {
89        FileHandler {
90            action: self.action,
91            accepts: self.accepts,
92            display_name: self.display_name,
93        }
94    }
95}
96
97/// If user prefers opening the app in browser or an app window.
98
99#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
100pub enum DisplayMode {
101    #[default]
102    #[serde(rename = "standalone")]
103    Standalone,
104    #[serde(rename = "browser")]
105    Browser,
106}
107
108/// Returns the following OS state for the given manifest id.
109
110#[derive(Debug, Clone, Serialize, Deserialize, Default)]
111#[serde(rename_all = "camelCase")]
112pub struct GetOsAppStateParams<'a> {
113    /// The id from the webapp's manifest file, commonly it's the url of the
114    /// site installing the webapp. See
115    /// <https://web.dev/learn/pwa/web-app-manifest>.
116    #[serde(rename = "manifestId")]
117    manifest_id: Cow<'a, str>,
118}
119
120impl<'a> GetOsAppStateParams<'a> {
121    /// Creates a builder for this type with the required parameters:
122    /// * `manifest_id`: The id from the webapp's manifest file, commonly it's the url of the site installing the webapp. See <https://web.dev/learn/pwa/web-app-manifest>.
123    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> GetOsAppStateParamsBuilder<'a> {
124        GetOsAppStateParamsBuilder {
125            manifest_id: manifest_id.into(),
126        }
127    }
128    /// The id from the webapp's manifest file, commonly it's the url of the
129    /// site installing the webapp. See
130    /// <https://web.dev/learn/pwa/web-app-manifest>.
131    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
132}
133
134
135pub struct GetOsAppStateParamsBuilder<'a> {
136    manifest_id: Cow<'a, str>,
137}
138
139impl<'a> GetOsAppStateParamsBuilder<'a> {
140    pub fn build(self) -> GetOsAppStateParams<'a> {
141        GetOsAppStateParams {
142            manifest_id: self.manifest_id,
143        }
144    }
145}
146
147/// Returns the following OS state for the given manifest id.
148
149#[derive(Debug, Clone, Serialize, Deserialize, Default)]
150#[serde(rename_all = "camelCase")]
151pub struct GetOsAppStateReturns<'a> {
152    #[serde(rename = "badgeCount")]
153    badge_count: u64,
154    #[serde(rename = "fileHandlers")]
155    file_handlers: Vec<FileHandler<'a>>,
156}
157
158impl<'a> GetOsAppStateReturns<'a> {
159    /// Creates a builder for this type with the required parameters:
160    /// * `badge_count`: 
161    /// * `file_handlers`: 
162    pub fn builder(badge_count: u64, file_handlers: Vec<FileHandler<'a>>) -> GetOsAppStateReturnsBuilder<'a> {
163        GetOsAppStateReturnsBuilder {
164            badge_count: badge_count,
165            file_handlers: file_handlers,
166        }
167    }
168    pub fn badge_count(&self) -> u64 { self.badge_count }
169    pub fn file_handlers(&self) -> &[FileHandler<'a>] { &self.file_handlers }
170}
171
172
173pub struct GetOsAppStateReturnsBuilder<'a> {
174    badge_count: u64,
175    file_handlers: Vec<FileHandler<'a>>,
176}
177
178impl<'a> GetOsAppStateReturnsBuilder<'a> {
179    pub fn build(self) -> GetOsAppStateReturns<'a> {
180        GetOsAppStateReturns {
181            badge_count: self.badge_count,
182            file_handlers: self.file_handlers,
183        }
184    }
185}
186
187impl<'a> GetOsAppStateParams<'a> { pub const METHOD: &'static str = "PWA.getOsAppState"; }
188
189impl<'a> crate::CdpCommand<'a> for GetOsAppStateParams<'a> {
190    const METHOD: &'static str = "PWA.getOsAppState";
191    type Response = GetOsAppStateReturns<'a>;
192}
193
194/// Installs the given manifest identity, optionally using the given installUrlOrBundleUrl
195/// 
196/// IWA-specific install description:
197/// manifestId corresponds to isolated-app:// + web_package::SignedWebBundleId
198/// 
199/// File installation mode:
200/// The installUrlOrBundleUrl can be either file:// or http(s):// pointing
201/// to a signed web bundle (.swbn). In this case SignedWebBundleId must correspond to
202/// The .swbn file's signing key.
203/// 
204/// Dev proxy installation mode:
205/// installUrlOrBundleUrl must be http(s):// that serves dev mode IWA.
206/// web_package::SignedWebBundleId must be of type dev proxy.
207/// 
208/// The advantage of dev proxy mode is that all changes to IWA
209/// automatically will be reflected in the running app without
210/// reinstallation.
211/// 
212/// To generate bundle id for proxy mode:
213/// 1. Generate 32 random bytes.
214/// 2. Add a specific suffix at the end following the documentation
215/// <https://github.com/WICG/isolated-web-apps/blob/main/Scheme.md#suffix>
216/// 3. Encode the entire sequence using Base32 without padding.
217/// 
218/// If Chrome is not in IWA dev
219/// mode, the installation will fail, regardless of the state of the allowlist.
220
221#[derive(Debug, Clone, Serialize, Deserialize, Default)]
222#[serde(rename_all = "camelCase")]
223pub struct InstallParams<'a> {
224    #[serde(rename = "manifestId")]
225    manifest_id: Cow<'a, str>,
226    /// The location of the app or bundle overriding the one derived from the
227    /// manifestId.
228    #[serde(skip_serializing_if = "Option::is_none", rename = "installUrlOrBundleUrl")]
229    install_url_or_bundle_url: Option<Cow<'a, str>>,
230}
231
232impl<'a> InstallParams<'a> {
233    /// Creates a builder for this type with the required parameters:
234    /// * `manifest_id`: 
235    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> InstallParamsBuilder<'a> {
236        InstallParamsBuilder {
237            manifest_id: manifest_id.into(),
238            install_url_or_bundle_url: None,
239        }
240    }
241    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
242    /// The location of the app or bundle overriding the one derived from the
243    /// manifestId.
244    pub fn install_url_or_bundle_url(&self) -> Option<&str> { self.install_url_or_bundle_url.as_deref() }
245}
246
247
248pub struct InstallParamsBuilder<'a> {
249    manifest_id: Cow<'a, str>,
250    install_url_or_bundle_url: Option<Cow<'a, str>>,
251}
252
253impl<'a> InstallParamsBuilder<'a> {
254    /// The location of the app or bundle overriding the one derived from the
255    /// manifestId.
256    pub fn install_url_or_bundle_url(mut self, install_url_or_bundle_url: impl Into<Cow<'a, str>>) -> Self { self.install_url_or_bundle_url = Some(install_url_or_bundle_url.into()); self }
257    pub fn build(self) -> InstallParams<'a> {
258        InstallParams {
259            manifest_id: self.manifest_id,
260            install_url_or_bundle_url: self.install_url_or_bundle_url,
261        }
262    }
263}
264
265impl<'a> InstallParams<'a> { pub const METHOD: &'static str = "PWA.install"; }
266
267impl<'a> crate::CdpCommand<'a> for InstallParams<'a> {
268    const METHOD: &'static str = "PWA.install";
269    type Response = crate::EmptyReturns;
270}
271
272/// Uninstalls the given manifest_id and closes any opened app windows.
273
274#[derive(Debug, Clone, Serialize, Deserialize, Default)]
275#[serde(rename_all = "camelCase")]
276pub struct UninstallParams<'a> {
277    #[serde(rename = "manifestId")]
278    manifest_id: Cow<'a, str>,
279}
280
281impl<'a> UninstallParams<'a> {
282    /// Creates a builder for this type with the required parameters:
283    /// * `manifest_id`: 
284    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> UninstallParamsBuilder<'a> {
285        UninstallParamsBuilder {
286            manifest_id: manifest_id.into(),
287        }
288    }
289    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
290}
291
292
293pub struct UninstallParamsBuilder<'a> {
294    manifest_id: Cow<'a, str>,
295}
296
297impl<'a> UninstallParamsBuilder<'a> {
298    pub fn build(self) -> UninstallParams<'a> {
299        UninstallParams {
300            manifest_id: self.manifest_id,
301        }
302    }
303}
304
305impl<'a> UninstallParams<'a> { pub const METHOD: &'static str = "PWA.uninstall"; }
306
307impl<'a> crate::CdpCommand<'a> for UninstallParams<'a> {
308    const METHOD: &'static str = "PWA.uninstall";
309    type Response = crate::EmptyReturns;
310}
311
312/// Launches the installed web app, or an url in the same web app instead of the
313/// default start url if it is provided. Returns a page Target.TargetID which
314/// can be used to attach to via Target.attachToTarget or similar APIs.
315
316#[derive(Debug, Clone, Serialize, Deserialize, Default)]
317#[serde(rename_all = "camelCase")]
318pub struct LaunchParams<'a> {
319    #[serde(rename = "manifestId")]
320    manifest_id: Cow<'a, str>,
321    #[serde(skip_serializing_if = "Option::is_none")]
322    url: Option<Cow<'a, str>>,
323}
324
325impl<'a> LaunchParams<'a> {
326    /// Creates a builder for this type with the required parameters:
327    /// * `manifest_id`: 
328    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> LaunchParamsBuilder<'a> {
329        LaunchParamsBuilder {
330            manifest_id: manifest_id.into(),
331            url: None,
332        }
333    }
334    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
335    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
336}
337
338
339pub struct LaunchParamsBuilder<'a> {
340    manifest_id: Cow<'a, str>,
341    url: Option<Cow<'a, str>>,
342}
343
344impl<'a> LaunchParamsBuilder<'a> {
345    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
346    pub fn build(self) -> LaunchParams<'a> {
347        LaunchParams {
348            manifest_id: self.manifest_id,
349            url: self.url,
350        }
351    }
352}
353
354/// Launches the installed web app, or an url in the same web app instead of the
355/// default start url if it is provided. Returns a page Target.TargetID which
356/// can be used to attach to via Target.attachToTarget or similar APIs.
357
358#[derive(Debug, Clone, Serialize, Deserialize, Default)]
359#[serde(rename_all = "camelCase")]
360pub struct LaunchReturns<'a> {
361    /// ID of the tab target created as a result.
362    #[serde(rename = "targetId")]
363    target_id: crate::target::TargetID<'a>,
364}
365
366impl<'a> LaunchReturns<'a> {
367    /// Creates a builder for this type with the required parameters:
368    /// * `target_id`: ID of the tab target created as a result.
369    pub fn builder(target_id: crate::target::TargetID<'a>) -> LaunchReturnsBuilder<'a> {
370        LaunchReturnsBuilder {
371            target_id: target_id,
372        }
373    }
374    /// ID of the tab target created as a result.
375    pub fn target_id(&self) -> &crate::target::TargetID<'a> { &self.target_id }
376}
377
378
379pub struct LaunchReturnsBuilder<'a> {
380    target_id: crate::target::TargetID<'a>,
381}
382
383impl<'a> LaunchReturnsBuilder<'a> {
384    pub fn build(self) -> LaunchReturns<'a> {
385        LaunchReturns {
386            target_id: self.target_id,
387        }
388    }
389}
390
391impl<'a> LaunchParams<'a> { pub const METHOD: &'static str = "PWA.launch"; }
392
393impl<'a> crate::CdpCommand<'a> for LaunchParams<'a> {
394    const METHOD: &'static str = "PWA.launch";
395    type Response = LaunchReturns<'a>;
396}
397
398/// Opens one or more local files from an installed web app identified by its
399/// manifestId. The web app needs to have file handlers registered to process
400/// the files. The API returns one or more page Target.TargetIDs which can be
401/// used to attach to via Target.attachToTarget or similar APIs.
402/// If some files in the parameters cannot be handled by the web app, they will
403/// be ignored. If none of the files can be handled, this API returns an error.
404/// If no files are provided as the parameter, this API also returns an error.
405/// 
406/// According to the definition of the file handlers in the manifest file, one
407/// Target.TargetID may represent a page handling one or more files. The order
408/// of the returned Target.TargetIDs is not guaranteed.
409/// 
410/// TODO(crbug.com/339454034): Check the existences of the input files.
411
412#[derive(Debug, Clone, Serialize, Deserialize, Default)]
413#[serde(rename_all = "camelCase")]
414pub struct LaunchFilesInAppParams<'a> {
415    #[serde(rename = "manifestId")]
416    manifest_id: Cow<'a, str>,
417    files: Vec<Cow<'a, str>>,
418}
419
420impl<'a> LaunchFilesInAppParams<'a> {
421    /// Creates a builder for this type with the required parameters:
422    /// * `manifest_id`: 
423    /// * `files`: 
424    pub fn builder(manifest_id: impl Into<Cow<'a, str>>, files: Vec<Cow<'a, str>>) -> LaunchFilesInAppParamsBuilder<'a> {
425        LaunchFilesInAppParamsBuilder {
426            manifest_id: manifest_id.into(),
427            files: files,
428        }
429    }
430    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
431    pub fn files(&self) -> &[Cow<'a, str>] { &self.files }
432}
433
434
435pub struct LaunchFilesInAppParamsBuilder<'a> {
436    manifest_id: Cow<'a, str>,
437    files: Vec<Cow<'a, str>>,
438}
439
440impl<'a> LaunchFilesInAppParamsBuilder<'a> {
441    pub fn build(self) -> LaunchFilesInAppParams<'a> {
442        LaunchFilesInAppParams {
443            manifest_id: self.manifest_id,
444            files: self.files,
445        }
446    }
447}
448
449/// Opens one or more local files from an installed web app identified by its
450/// manifestId. The web app needs to have file handlers registered to process
451/// the files. The API returns one or more page Target.TargetIDs which can be
452/// used to attach to via Target.attachToTarget or similar APIs.
453/// If some files in the parameters cannot be handled by the web app, they will
454/// be ignored. If none of the files can be handled, this API returns an error.
455/// If no files are provided as the parameter, this API also returns an error.
456/// 
457/// According to the definition of the file handlers in the manifest file, one
458/// Target.TargetID may represent a page handling one or more files. The order
459/// of the returned Target.TargetIDs is not guaranteed.
460/// 
461/// TODO(crbug.com/339454034): Check the existences of the input files.
462
463#[derive(Debug, Clone, Serialize, Deserialize, Default)]
464#[serde(rename_all = "camelCase")]
465pub struct LaunchFilesInAppReturns<'a> {
466    /// IDs of the tab targets created as the result.
467    #[serde(rename = "targetIds")]
468    target_ids: Vec<crate::target::TargetID<'a>>,
469}
470
471impl<'a> LaunchFilesInAppReturns<'a> {
472    /// Creates a builder for this type with the required parameters:
473    /// * `target_ids`: IDs of the tab targets created as the result.
474    pub fn builder(target_ids: Vec<crate::target::TargetID<'a>>) -> LaunchFilesInAppReturnsBuilder<'a> {
475        LaunchFilesInAppReturnsBuilder {
476            target_ids: target_ids,
477        }
478    }
479    /// IDs of the tab targets created as the result.
480    pub fn target_ids(&self) -> &[crate::target::TargetID<'a>] { &self.target_ids }
481}
482
483
484pub struct LaunchFilesInAppReturnsBuilder<'a> {
485    target_ids: Vec<crate::target::TargetID<'a>>,
486}
487
488impl<'a> LaunchFilesInAppReturnsBuilder<'a> {
489    pub fn build(self) -> LaunchFilesInAppReturns<'a> {
490        LaunchFilesInAppReturns {
491            target_ids: self.target_ids,
492        }
493    }
494}
495
496impl<'a> LaunchFilesInAppParams<'a> { pub const METHOD: &'static str = "PWA.launchFilesInApp"; }
497
498impl<'a> crate::CdpCommand<'a> for LaunchFilesInAppParams<'a> {
499    const METHOD: &'static str = "PWA.launchFilesInApp";
500    type Response = LaunchFilesInAppReturns<'a>;
501}
502
503/// Opens the current page in its web app identified by the manifest id, needs
504/// to be called on a page target. This function returns immediately without
505/// waiting for the app to finish loading.
506
507#[derive(Debug, Clone, Serialize, Deserialize, Default)]
508#[serde(rename_all = "camelCase")]
509pub struct OpenCurrentPageInAppParams<'a> {
510    #[serde(rename = "manifestId")]
511    manifest_id: Cow<'a, str>,
512}
513
514impl<'a> OpenCurrentPageInAppParams<'a> {
515    /// Creates a builder for this type with the required parameters:
516    /// * `manifest_id`: 
517    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> OpenCurrentPageInAppParamsBuilder<'a> {
518        OpenCurrentPageInAppParamsBuilder {
519            manifest_id: manifest_id.into(),
520        }
521    }
522    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
523}
524
525
526pub struct OpenCurrentPageInAppParamsBuilder<'a> {
527    manifest_id: Cow<'a, str>,
528}
529
530impl<'a> OpenCurrentPageInAppParamsBuilder<'a> {
531    pub fn build(self) -> OpenCurrentPageInAppParams<'a> {
532        OpenCurrentPageInAppParams {
533            manifest_id: self.manifest_id,
534        }
535    }
536}
537
538impl<'a> OpenCurrentPageInAppParams<'a> { pub const METHOD: &'static str = "PWA.openCurrentPageInApp"; }
539
540impl<'a> crate::CdpCommand<'a> for OpenCurrentPageInAppParams<'a> {
541    const METHOD: &'static str = "PWA.openCurrentPageInApp";
542    type Response = crate::EmptyReturns;
543}
544
545/// Changes user settings of the web app identified by its manifestId. If the
546/// app was not installed, this command returns an error. Unset parameters will
547/// be ignored; unrecognized values will cause an error.
548/// 
549/// Unlike the ones defined in the manifest files of the web apps, these
550/// settings are provided by the browser and controlled by the users, they
551/// impact the way the browser handling the web apps.
552/// 
553/// See the comment of each parameter.
554
555#[derive(Debug, Clone, Serialize, Deserialize, Default)]
556#[serde(rename_all = "camelCase")]
557pub struct ChangeAppUserSettingsParams<'a> {
558    #[serde(rename = "manifestId")]
559    manifest_id: Cow<'a, str>,
560    /// If user allows the links clicked on by the user in the app's scope, or
561    /// extended scope if the manifest has scope extensions and the flags
562    /// 'DesktopPWAsLinkCapturingWithScopeExtensions' and
563    /// 'WebAppEnableScopeExtensions' are enabled.
564    /// 
565    /// Note, the API does not support resetting the linkCapturing to the
566    /// initial value, uninstalling and installing the web app again will reset
567    /// it.
568    /// 
569    /// TODO(crbug.com/339453269): Setting this value on ChromeOS is not
570    /// supported yet.
571    #[serde(skip_serializing_if = "Option::is_none", rename = "linkCapturing")]
572    link_capturing: Option<bool>,
573    #[serde(skip_serializing_if = "Option::is_none", rename = "displayMode")]
574    display_mode: Option<DisplayMode>,
575}
576
577impl<'a> ChangeAppUserSettingsParams<'a> {
578    /// Creates a builder for this type with the required parameters:
579    /// * `manifest_id`: 
580    pub fn builder(manifest_id: impl Into<Cow<'a, str>>) -> ChangeAppUserSettingsParamsBuilder<'a> {
581        ChangeAppUserSettingsParamsBuilder {
582            manifest_id: manifest_id.into(),
583            link_capturing: None,
584            display_mode: None,
585        }
586    }
587    pub fn manifest_id(&self) -> &str { self.manifest_id.as_ref() }
588    /// If user allows the links clicked on by the user in the app's scope, or
589    /// extended scope if the manifest has scope extensions and the flags
590    /// 'DesktopPWAsLinkCapturingWithScopeExtensions' and
591    /// 'WebAppEnableScopeExtensions' are enabled.
592    /// 
593    /// Note, the API does not support resetting the linkCapturing to the
594    /// initial value, uninstalling and installing the web app again will reset
595    /// it.
596    /// 
597    /// TODO(crbug.com/339453269): Setting this value on ChromeOS is not
598    /// supported yet.
599    pub fn link_capturing(&self) -> Option<bool> { self.link_capturing }
600    pub fn display_mode(&self) -> Option<&DisplayMode> { self.display_mode.as_ref() }
601}
602
603
604pub struct ChangeAppUserSettingsParamsBuilder<'a> {
605    manifest_id: Cow<'a, str>,
606    link_capturing: Option<bool>,
607    display_mode: Option<DisplayMode>,
608}
609
610impl<'a> ChangeAppUserSettingsParamsBuilder<'a> {
611    /// If user allows the links clicked on by the user in the app's scope, or
612    /// extended scope if the manifest has scope extensions and the flags
613    /// 'DesktopPWAsLinkCapturingWithScopeExtensions' and
614    /// 'WebAppEnableScopeExtensions' are enabled.
615    /// 
616    /// Note, the API does not support resetting the linkCapturing to the
617    /// initial value, uninstalling and installing the web app again will reset
618    /// it.
619    /// 
620    /// TODO(crbug.com/339453269): Setting this value on ChromeOS is not
621    /// supported yet.
622    pub fn link_capturing(mut self, link_capturing: bool) -> Self { self.link_capturing = Some(link_capturing); self }
623    pub fn display_mode(mut self, display_mode: impl Into<DisplayMode>) -> Self { self.display_mode = Some(display_mode.into()); self }
624    pub fn build(self) -> ChangeAppUserSettingsParams<'a> {
625        ChangeAppUserSettingsParams {
626            manifest_id: self.manifest_id,
627            link_capturing: self.link_capturing,
628            display_mode: self.display_mode,
629        }
630    }
631}
632
633impl<'a> ChangeAppUserSettingsParams<'a> { pub const METHOD: &'static str = "PWA.changeAppUserSettings"; }
634
635impl<'a> crate::CdpCommand<'a> for ChangeAppUserSettingsParams<'a> {
636    const METHOD: &'static str = "PWA.changeAppUserSettings";
637    type Response = crate::EmptyReturns;
638}