Skip to main content

browser_protocol/browser/
mod.rs

1//! The Browser domain defines methods and events for browser managing.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8
9pub type BrowserContextID<'a> = Cow<'a, str>;
10
11
12pub type WindowID = i64;
13
14/// The state of the browser window.
15
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
17pub enum WindowState {
18    #[default]
19    #[serde(rename = "normal")]
20    Normal,
21    #[serde(rename = "minimized")]
22    Minimized,
23    #[serde(rename = "maximized")]
24    Maximized,
25    #[serde(rename = "fullscreen")]
26    Fullscreen,
27}
28
29/// Browser window bounds information
30
31#[derive(Debug, Clone, Serialize, Deserialize, Default)]
32#[serde(rename_all = "camelCase")]
33pub struct Bounds {
34    /// The offset from the left edge of the screen to the window in pixels.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    left: Option<i64>,
37    /// The offset from the top edge of the screen to the window in pixels.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    top: Option<i64>,
40    /// The window width in pixels.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    width: Option<u64>,
43    /// The window height in pixels.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    height: Option<i64>,
46    /// The window state. Default to normal.
47    #[serde(skip_serializing_if = "Option::is_none")]
48    windowState: Option<WindowState>,
49}
50
51impl Bounds {
52    pub fn builder() -> BoundsBuilder {
53        BoundsBuilder {
54            left: None,
55            top: None,
56            width: None,
57            height: None,
58            windowState: None,
59        }
60    }
61    pub fn left(&self) -> Option<i64> { self.left }
62    pub fn top(&self) -> Option<i64> { self.top }
63    pub fn width(&self) -> Option<u64> { self.width }
64    pub fn height(&self) -> Option<i64> { self.height }
65    pub fn windowState(&self) -> Option<&WindowState> { self.windowState.as_ref() }
66}
67
68#[derive(Default)]
69pub struct BoundsBuilder {
70    left: Option<i64>,
71    top: Option<i64>,
72    width: Option<u64>,
73    height: Option<i64>,
74    windowState: Option<WindowState>,
75}
76
77impl BoundsBuilder {
78    /// The offset from the left edge of the screen to the window in pixels.
79    pub fn left(mut self, left: i64) -> Self { self.left = Some(left); self }
80    /// The offset from the top edge of the screen to the window in pixels.
81    pub fn top(mut self, top: i64) -> Self { self.top = Some(top); self }
82    /// The window width in pixels.
83    pub fn width(mut self, width: u64) -> Self { self.width = Some(width); self }
84    /// The window height in pixels.
85    pub fn height(mut self, height: i64) -> Self { self.height = Some(height); self }
86    /// The window state. Default to normal.
87    pub fn windowState(mut self, windowState: WindowState) -> Self { self.windowState = Some(windowState); self }
88    pub fn build(self) -> Bounds {
89        Bounds {
90            left: self.left,
91            top: self.top,
92            width: self.width,
93            height: self.height,
94            windowState: self.windowState,
95        }
96    }
97}
98
99
100#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
101pub enum PermissionType {
102    #[default]
103    #[serde(rename = "ar")]
104    Ar,
105    #[serde(rename = "audioCapture")]
106    AudioCapture,
107    #[serde(rename = "automaticFullscreen")]
108    AutomaticFullscreen,
109    #[serde(rename = "backgroundFetch")]
110    BackgroundFetch,
111    #[serde(rename = "backgroundSync")]
112    BackgroundSync,
113    #[serde(rename = "cameraPanTiltZoom")]
114    CameraPanTiltZoom,
115    #[serde(rename = "capturedSurfaceControl")]
116    CapturedSurfaceControl,
117    #[serde(rename = "clipboardReadWrite")]
118    ClipboardReadWrite,
119    #[serde(rename = "clipboardSanitizedWrite")]
120    ClipboardSanitizedWrite,
121    #[serde(rename = "displayCapture")]
122    DisplayCapture,
123    #[serde(rename = "durableStorage")]
124    DurableStorage,
125    #[serde(rename = "geolocation")]
126    Geolocation,
127    #[serde(rename = "handTracking")]
128    HandTracking,
129    #[serde(rename = "idleDetection")]
130    IdleDetection,
131    #[serde(rename = "keyboardLock")]
132    KeyboardLock,
133    #[serde(rename = "localFonts")]
134    LocalFonts,
135    #[serde(rename = "localNetwork")]
136    LocalNetwork,
137    #[serde(rename = "localNetworkAccess")]
138    LocalNetworkAccess,
139    #[serde(rename = "loopbackNetwork")]
140    LoopbackNetwork,
141    #[serde(rename = "midi")]
142    Midi,
143    #[serde(rename = "midiSysex")]
144    MidiSysex,
145    #[serde(rename = "nfc")]
146    Nfc,
147    #[serde(rename = "notifications")]
148    Notifications,
149    #[serde(rename = "paymentHandler")]
150    PaymentHandler,
151    #[serde(rename = "periodicBackgroundSync")]
152    PeriodicBackgroundSync,
153    #[serde(rename = "pointerLock")]
154    PointerLock,
155    #[serde(rename = "protectedMediaIdentifier")]
156    ProtectedMediaIdentifier,
157    #[serde(rename = "sensors")]
158    Sensors,
159    #[serde(rename = "smartCard")]
160    SmartCard,
161    #[serde(rename = "speakerSelection")]
162    SpeakerSelection,
163    #[serde(rename = "storageAccess")]
164    StorageAccess,
165    #[serde(rename = "topLevelStorageAccess")]
166    TopLevelStorageAccess,
167    #[serde(rename = "videoCapture")]
168    VideoCapture,
169    #[serde(rename = "vr")]
170    Vr,
171    #[serde(rename = "wakeLockScreen")]
172    WakeLockScreen,
173    #[serde(rename = "wakeLockSystem")]
174    WakeLockSystem,
175    #[serde(rename = "webAppInstallation")]
176    WebAppInstallation,
177    #[serde(rename = "webPrinting")]
178    WebPrinting,
179    #[serde(rename = "windowManagement")]
180    WindowManagement,
181}
182
183
184#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
185pub enum PermissionSetting {
186    #[default]
187    #[serde(rename = "granted")]
188    Granted,
189    #[serde(rename = "denied")]
190    Denied,
191    #[serde(rename = "prompt")]
192    Prompt,
193}
194
195/// Definition of PermissionDescriptor defined in the Permissions API:
196/// https://w3c.github.io/permissions/#dom-permissiondescriptor.
197
198#[derive(Debug, Clone, Serialize, Deserialize, Default)]
199#[serde(rename_all = "camelCase")]
200pub struct PermissionDescriptor<'a> {
201    /// Name of permission.
202    /// See https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/permissions/permission_descriptor.idl for valid permission names.
203    name: Cow<'a, str>,
204    /// For "midi" permission, may also specify sysex control.
205    #[serde(skip_serializing_if = "Option::is_none")]
206    sysex: Option<bool>,
207    /// For "push" permission, may specify userVisibleOnly.
208    /// Note that userVisibleOnly = true is the only currently supported type.
209    #[serde(skip_serializing_if = "Option::is_none")]
210    userVisibleOnly: Option<bool>,
211    /// For "clipboard" permission, may specify allowWithoutSanitization.
212    #[serde(skip_serializing_if = "Option::is_none")]
213    allowWithoutSanitization: Option<bool>,
214    /// For "fullscreen" permission, must specify allowWithoutGesture:true.
215    #[serde(skip_serializing_if = "Option::is_none")]
216    allowWithoutGesture: Option<bool>,
217    /// For "camera" permission, may specify panTiltZoom.
218    #[serde(skip_serializing_if = "Option::is_none")]
219    panTiltZoom: Option<bool>,
220}
221
222impl<'a> PermissionDescriptor<'a> {
223    pub fn builder(name: impl Into<Cow<'a, str>>) -> PermissionDescriptorBuilder<'a> {
224        PermissionDescriptorBuilder {
225            name: name.into(),
226            sysex: None,
227            userVisibleOnly: None,
228            allowWithoutSanitization: None,
229            allowWithoutGesture: None,
230            panTiltZoom: None,
231        }
232    }
233    pub fn name(&self) -> &str { self.name.as_ref() }
234    pub fn sysex(&self) -> Option<bool> { self.sysex }
235    pub fn userVisibleOnly(&self) -> Option<bool> { self.userVisibleOnly }
236    pub fn allowWithoutSanitization(&self) -> Option<bool> { self.allowWithoutSanitization }
237    pub fn allowWithoutGesture(&self) -> Option<bool> { self.allowWithoutGesture }
238    pub fn panTiltZoom(&self) -> Option<bool> { self.panTiltZoom }
239}
240
241
242pub struct PermissionDescriptorBuilder<'a> {
243    name: Cow<'a, str>,
244    sysex: Option<bool>,
245    userVisibleOnly: Option<bool>,
246    allowWithoutSanitization: Option<bool>,
247    allowWithoutGesture: Option<bool>,
248    panTiltZoom: Option<bool>,
249}
250
251impl<'a> PermissionDescriptorBuilder<'a> {
252    /// For "midi" permission, may also specify sysex control.
253    pub fn sysex(mut self, sysex: bool) -> Self { self.sysex = Some(sysex); self }
254    /// For "push" permission, may specify userVisibleOnly.
255    /// Note that userVisibleOnly = true is the only currently supported type.
256    pub fn userVisibleOnly(mut self, userVisibleOnly: bool) -> Self { self.userVisibleOnly = Some(userVisibleOnly); self }
257    /// For "clipboard" permission, may specify allowWithoutSanitization.
258    pub fn allowWithoutSanitization(mut self, allowWithoutSanitization: bool) -> Self { self.allowWithoutSanitization = Some(allowWithoutSanitization); self }
259    /// For "fullscreen" permission, must specify allowWithoutGesture:true.
260    pub fn allowWithoutGesture(mut self, allowWithoutGesture: bool) -> Self { self.allowWithoutGesture = Some(allowWithoutGesture); self }
261    /// For "camera" permission, may specify panTiltZoom.
262    pub fn panTiltZoom(mut self, panTiltZoom: bool) -> Self { self.panTiltZoom = Some(panTiltZoom); self }
263    pub fn build(self) -> PermissionDescriptor<'a> {
264        PermissionDescriptor {
265            name: self.name,
266            sysex: self.sysex,
267            userVisibleOnly: self.userVisibleOnly,
268            allowWithoutSanitization: self.allowWithoutSanitization,
269            allowWithoutGesture: self.allowWithoutGesture,
270            panTiltZoom: self.panTiltZoom,
271        }
272    }
273}
274
275/// Browser command ids used by executeBrowserCommand.
276
277#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
278pub enum BrowserCommandId {
279    #[default]
280    #[serde(rename = "openTabSearch")]
281    OpenTabSearch,
282    #[serde(rename = "closeTabSearch")]
283    CloseTabSearch,
284    #[serde(rename = "openGlic")]
285    OpenGlic,
286}
287
288/// Chrome histogram bucket.
289
290#[derive(Debug, Clone, Serialize, Deserialize, Default)]
291#[serde(rename_all = "camelCase")]
292pub struct Bucket {
293    /// Minimum value (inclusive).
294    low: i64,
295    /// Maximum value (exclusive).
296    high: i64,
297    /// Number of samples.
298    count: u64,
299}
300
301impl Bucket {
302    pub fn builder(low: i64, high: i64, count: u64) -> BucketBuilder {
303        BucketBuilder {
304            low: low,
305            high: high,
306            count: count,
307        }
308    }
309    pub fn low(&self) -> i64 { self.low }
310    pub fn high(&self) -> i64 { self.high }
311    pub fn count(&self) -> u64 { self.count }
312}
313
314
315pub struct BucketBuilder {
316    low: i64,
317    high: i64,
318    count: u64,
319}
320
321impl BucketBuilder {
322    pub fn build(self) -> Bucket {
323        Bucket {
324            low: self.low,
325            high: self.high,
326            count: self.count,
327        }
328    }
329}
330
331/// Chrome histogram.
332
333#[derive(Debug, Clone, Serialize, Deserialize, Default)]
334#[serde(rename_all = "camelCase")]
335pub struct Histogram<'a> {
336    /// Name.
337    name: Cow<'a, str>,
338    /// Sum of sample values.
339    sum: i64,
340    /// Total number of samples.
341    count: u64,
342    /// Buckets.
343    buckets: Vec<Bucket>,
344}
345
346impl<'a> Histogram<'a> {
347    pub fn builder(name: impl Into<Cow<'a, str>>, sum: i64, count: u64, buckets: Vec<Bucket>) -> HistogramBuilder<'a> {
348        HistogramBuilder {
349            name: name.into(),
350            sum: sum,
351            count: count,
352            buckets: buckets,
353        }
354    }
355    pub fn name(&self) -> &str { self.name.as_ref() }
356    pub fn sum(&self) -> i64 { self.sum }
357    pub fn count(&self) -> u64 { self.count }
358    pub fn buckets(&self) -> &[Bucket] { &self.buckets }
359}
360
361
362pub struct HistogramBuilder<'a> {
363    name: Cow<'a, str>,
364    sum: i64,
365    count: u64,
366    buckets: Vec<Bucket>,
367}
368
369impl<'a> HistogramBuilder<'a> {
370    pub fn build(self) -> Histogram<'a> {
371        Histogram {
372            name: self.name,
373            sum: self.sum,
374            count: self.count,
375            buckets: self.buckets,
376        }
377    }
378}
379
380
381#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
382pub enum PrivacySandboxAPI {
383    #[default]
384    #[serde(rename = "BiddingAndAuctionServices")]
385    BiddingAndAuctionServices,
386    #[serde(rename = "TrustedKeyValue")]
387    TrustedKeyValue,
388}
389
390/// Set permission settings for given embedding and embedded origins.
391
392#[derive(Debug, Clone, Serialize, Deserialize, Default)]
393#[serde(rename_all = "camelCase")]
394pub struct SetPermissionParams<'a> {
395    /// Descriptor of permission to override.
396    permission: PermissionDescriptor<'a>,
397    /// Setting of the permission.
398    setting: PermissionSetting,
399    /// Embedding origin the permission applies to, all origins if not specified.
400    #[serde(skip_serializing_if = "Option::is_none")]
401    origin: Option<Cow<'a, str>>,
402    /// Embedded origin the permission applies to. It is ignored unless the embedding origin is
403    /// present and valid. If the embedding origin is provided but the embedded origin isn't, the
404    /// embedding origin is used as the embedded origin.
405    #[serde(skip_serializing_if = "Option::is_none")]
406    embeddedOrigin: Option<Cow<'a, str>>,
407    /// Context to override. When omitted, default browser context is used.
408    #[serde(skip_serializing_if = "Option::is_none")]
409    browserContextId: Option<BrowserContextID<'a>>,
410}
411
412impl<'a> SetPermissionParams<'a> {
413    pub fn builder(permission: PermissionDescriptor<'a>, setting: PermissionSetting) -> SetPermissionParamsBuilder<'a> {
414        SetPermissionParamsBuilder {
415            permission: permission,
416            setting: setting,
417            origin: None,
418            embeddedOrigin: None,
419            browserContextId: None,
420        }
421    }
422    pub fn permission(&self) -> &PermissionDescriptor<'a> { &self.permission }
423    pub fn setting(&self) -> &PermissionSetting { &self.setting }
424    pub fn origin(&self) -> Option<&str> { self.origin.as_deref() }
425    pub fn embeddedOrigin(&self) -> Option<&str> { self.embeddedOrigin.as_deref() }
426    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
427}
428
429
430pub struct SetPermissionParamsBuilder<'a> {
431    permission: PermissionDescriptor<'a>,
432    setting: PermissionSetting,
433    origin: Option<Cow<'a, str>>,
434    embeddedOrigin: Option<Cow<'a, str>>,
435    browserContextId: Option<BrowserContextID<'a>>,
436}
437
438impl<'a> SetPermissionParamsBuilder<'a> {
439    /// Embedding origin the permission applies to, all origins if not specified.
440    pub fn origin(mut self, origin: impl Into<Cow<'a, str>>) -> Self { self.origin = Some(origin.into()); self }
441    /// Embedded origin the permission applies to. It is ignored unless the embedding origin is
442    /// present and valid. If the embedding origin is provided but the embedded origin isn't, the
443    /// embedding origin is used as the embedded origin.
444    pub fn embeddedOrigin(mut self, embeddedOrigin: impl Into<Cow<'a, str>>) -> Self { self.embeddedOrigin = Some(embeddedOrigin.into()); self }
445    /// Context to override. When omitted, default browser context is used.
446    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
447    pub fn build(self) -> SetPermissionParams<'a> {
448        SetPermissionParams {
449            permission: self.permission,
450            setting: self.setting,
451            origin: self.origin,
452            embeddedOrigin: self.embeddedOrigin,
453            browserContextId: self.browserContextId,
454        }
455    }
456}
457
458impl<'a> SetPermissionParams<'a> { pub const METHOD: &'static str = "Browser.setPermission"; }
459
460impl<'a> crate::CdpCommand<'a> for SetPermissionParams<'a> {
461    const METHOD: &'static str = "Browser.setPermission";
462    type Response = crate::EmptyReturns;
463}
464
465/// Grant specific permissions to the given origin and reject all others. Deprecated. Use
466/// setPermission instead.
467
468#[derive(Debug, Clone, Serialize, Deserialize, Default)]
469#[serde(rename_all = "camelCase")]
470pub struct GrantPermissionsParams<'a> {
471    permissions: Vec<PermissionType>,
472    /// Origin the permission applies to, all origins if not specified.
473    #[serde(skip_serializing_if = "Option::is_none")]
474    origin: Option<Cow<'a, str>>,
475    /// BrowserContext to override permissions. When omitted, default browser context is used.
476    #[serde(skip_serializing_if = "Option::is_none")]
477    browserContextId: Option<BrowserContextID<'a>>,
478}
479
480impl<'a> GrantPermissionsParams<'a> {
481    pub fn builder(permissions: Vec<PermissionType>) -> GrantPermissionsParamsBuilder<'a> {
482        GrantPermissionsParamsBuilder {
483            permissions: permissions,
484            origin: None,
485            browserContextId: None,
486        }
487    }
488    pub fn permissions(&self) -> &[PermissionType] { &self.permissions }
489    pub fn origin(&self) -> Option<&str> { self.origin.as_deref() }
490    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
491}
492
493
494pub struct GrantPermissionsParamsBuilder<'a> {
495    permissions: Vec<PermissionType>,
496    origin: Option<Cow<'a, str>>,
497    browserContextId: Option<BrowserContextID<'a>>,
498}
499
500impl<'a> GrantPermissionsParamsBuilder<'a> {
501    /// Origin the permission applies to, all origins if not specified.
502    pub fn origin(mut self, origin: impl Into<Cow<'a, str>>) -> Self { self.origin = Some(origin.into()); self }
503    /// BrowserContext to override permissions. When omitted, default browser context is used.
504    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
505    pub fn build(self) -> GrantPermissionsParams<'a> {
506        GrantPermissionsParams {
507            permissions: self.permissions,
508            origin: self.origin,
509            browserContextId: self.browserContextId,
510        }
511    }
512}
513
514impl<'a> GrantPermissionsParams<'a> { pub const METHOD: &'static str = "Browser.grantPermissions"; }
515
516impl<'a> crate::CdpCommand<'a> for GrantPermissionsParams<'a> {
517    const METHOD: &'static str = "Browser.grantPermissions";
518    type Response = crate::EmptyReturns;
519}
520
521/// Reset all permission management for all origins.
522
523#[derive(Debug, Clone, Serialize, Deserialize, Default)]
524#[serde(rename_all = "camelCase")]
525pub struct ResetPermissionsParams<'a> {
526    /// BrowserContext to reset permissions. When omitted, default browser context is used.
527    #[serde(skip_serializing_if = "Option::is_none")]
528    browserContextId: Option<BrowserContextID<'a>>,
529}
530
531impl<'a> ResetPermissionsParams<'a> {
532    pub fn builder() -> ResetPermissionsParamsBuilder<'a> {
533        ResetPermissionsParamsBuilder {
534            browserContextId: None,
535        }
536    }
537    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
538}
539
540#[derive(Default)]
541pub struct ResetPermissionsParamsBuilder<'a> {
542    browserContextId: Option<BrowserContextID<'a>>,
543}
544
545impl<'a> ResetPermissionsParamsBuilder<'a> {
546    /// BrowserContext to reset permissions. When omitted, default browser context is used.
547    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
548    pub fn build(self) -> ResetPermissionsParams<'a> {
549        ResetPermissionsParams {
550            browserContextId: self.browserContextId,
551        }
552    }
553}
554
555impl<'a> ResetPermissionsParams<'a> { pub const METHOD: &'static str = "Browser.resetPermissions"; }
556
557impl<'a> crate::CdpCommand<'a> for ResetPermissionsParams<'a> {
558    const METHOD: &'static str = "Browser.resetPermissions";
559    type Response = crate::EmptyReturns;
560}
561
562/// Set the behavior when downloading a file.
563
564#[derive(Debug, Clone, Serialize, Deserialize, Default)]
565#[serde(rename_all = "camelCase")]
566pub struct SetDownloadBehaviorParams<'a> {
567    /// Whether to allow all or deny all download requests, or use default Chrome behavior if
568    /// available (otherwise deny). |allowAndName| allows download and names files according to
569    /// their download guids.
570    behavior: Cow<'a, str>,
571    /// BrowserContext to set download behavior. When omitted, default browser context is used.
572    #[serde(skip_serializing_if = "Option::is_none")]
573    browserContextId: Option<BrowserContextID<'a>>,
574    /// The default path to save downloaded files to. This is required if behavior is set to 'allow'
575    /// or 'allowAndName'.
576    #[serde(skip_serializing_if = "Option::is_none")]
577    downloadPath: Option<Cow<'a, str>>,
578    /// Whether to emit download events (defaults to false).
579    #[serde(skip_serializing_if = "Option::is_none")]
580    eventsEnabled: Option<bool>,
581}
582
583impl<'a> SetDownloadBehaviorParams<'a> {
584    pub fn builder(behavior: impl Into<Cow<'a, str>>) -> SetDownloadBehaviorParamsBuilder<'a> {
585        SetDownloadBehaviorParamsBuilder {
586            behavior: behavior.into(),
587            browserContextId: None,
588            downloadPath: None,
589            eventsEnabled: None,
590        }
591    }
592    pub fn behavior(&self) -> &str { self.behavior.as_ref() }
593    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
594    pub fn downloadPath(&self) -> Option<&str> { self.downloadPath.as_deref() }
595    pub fn eventsEnabled(&self) -> Option<bool> { self.eventsEnabled }
596}
597
598
599pub struct SetDownloadBehaviorParamsBuilder<'a> {
600    behavior: Cow<'a, str>,
601    browserContextId: Option<BrowserContextID<'a>>,
602    downloadPath: Option<Cow<'a, str>>,
603    eventsEnabled: Option<bool>,
604}
605
606impl<'a> SetDownloadBehaviorParamsBuilder<'a> {
607    /// BrowserContext to set download behavior. When omitted, default browser context is used.
608    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
609    /// The default path to save downloaded files to. This is required if behavior is set to 'allow'
610    /// or 'allowAndName'.
611    pub fn downloadPath(mut self, downloadPath: impl Into<Cow<'a, str>>) -> Self { self.downloadPath = Some(downloadPath.into()); self }
612    /// Whether to emit download events (defaults to false).
613    pub fn eventsEnabled(mut self, eventsEnabled: bool) -> Self { self.eventsEnabled = Some(eventsEnabled); self }
614    pub fn build(self) -> SetDownloadBehaviorParams<'a> {
615        SetDownloadBehaviorParams {
616            behavior: self.behavior,
617            browserContextId: self.browserContextId,
618            downloadPath: self.downloadPath,
619            eventsEnabled: self.eventsEnabled,
620        }
621    }
622}
623
624impl<'a> SetDownloadBehaviorParams<'a> { pub const METHOD: &'static str = "Browser.setDownloadBehavior"; }
625
626impl<'a> crate::CdpCommand<'a> for SetDownloadBehaviorParams<'a> {
627    const METHOD: &'static str = "Browser.setDownloadBehavior";
628    type Response = crate::EmptyReturns;
629}
630
631/// Cancel a download if in progress
632
633#[derive(Debug, Clone, Serialize, Deserialize, Default)]
634#[serde(rename_all = "camelCase")]
635pub struct CancelDownloadParams<'a> {
636    /// Global unique identifier of the download.
637    guid: Cow<'a, str>,
638    /// BrowserContext to perform the action in. When omitted, default browser context is used.
639    #[serde(skip_serializing_if = "Option::is_none")]
640    browserContextId: Option<BrowserContextID<'a>>,
641}
642
643impl<'a> CancelDownloadParams<'a> {
644    pub fn builder(guid: impl Into<Cow<'a, str>>) -> CancelDownloadParamsBuilder<'a> {
645        CancelDownloadParamsBuilder {
646            guid: guid.into(),
647            browserContextId: None,
648        }
649    }
650    pub fn guid(&self) -> &str { self.guid.as_ref() }
651    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
652}
653
654
655pub struct CancelDownloadParamsBuilder<'a> {
656    guid: Cow<'a, str>,
657    browserContextId: Option<BrowserContextID<'a>>,
658}
659
660impl<'a> CancelDownloadParamsBuilder<'a> {
661    /// BrowserContext to perform the action in. When omitted, default browser context is used.
662    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
663    pub fn build(self) -> CancelDownloadParams<'a> {
664        CancelDownloadParams {
665            guid: self.guid,
666            browserContextId: self.browserContextId,
667        }
668    }
669}
670
671impl<'a> CancelDownloadParams<'a> { pub const METHOD: &'static str = "Browser.cancelDownload"; }
672
673impl<'a> crate::CdpCommand<'a> for CancelDownloadParams<'a> {
674    const METHOD: &'static str = "Browser.cancelDownload";
675    type Response = crate::EmptyReturns;
676}
677
678#[derive(Debug, Clone, Serialize, Deserialize, Default)]
679pub struct CloseParams {}
680
681impl CloseParams { pub const METHOD: &'static str = "Browser.close"; }
682
683impl<'a> crate::CdpCommand<'a> for CloseParams {
684    const METHOD: &'static str = "Browser.close";
685    type Response = crate::EmptyReturns;
686}
687
688#[derive(Debug, Clone, Serialize, Deserialize, Default)]
689pub struct CrashParams {}
690
691impl CrashParams { pub const METHOD: &'static str = "Browser.crash"; }
692
693impl<'a> crate::CdpCommand<'a> for CrashParams {
694    const METHOD: &'static str = "Browser.crash";
695    type Response = crate::EmptyReturns;
696}
697
698#[derive(Debug, Clone, Serialize, Deserialize, Default)]
699pub struct CrashGpuProcessParams {}
700
701impl CrashGpuProcessParams { pub const METHOD: &'static str = "Browser.crashGpuProcess"; }
702
703impl<'a> crate::CdpCommand<'a> for CrashGpuProcessParams {
704    const METHOD: &'static str = "Browser.crashGpuProcess";
705    type Response = crate::EmptyReturns;
706}
707
708/// Returns version information.
709
710#[derive(Debug, Clone, Serialize, Deserialize, Default)]
711#[serde(rename_all = "camelCase")]
712pub struct GetVersionReturns<'a> {
713    /// Protocol version.
714    protocolVersion: Cow<'a, str>,
715    /// Product name.
716    product: Cow<'a, str>,
717    /// Product revision.
718    revision: Cow<'a, str>,
719    /// User-Agent.
720    userAgent: Cow<'a, str>,
721    /// V8 version.
722    jsVersion: Cow<'a, str>,
723}
724
725impl<'a> GetVersionReturns<'a> {
726    pub fn builder(protocolVersion: impl Into<Cow<'a, str>>, product: impl Into<Cow<'a, str>>, revision: impl Into<Cow<'a, str>>, userAgent: impl Into<Cow<'a, str>>, jsVersion: impl Into<Cow<'a, str>>) -> GetVersionReturnsBuilder<'a> {
727        GetVersionReturnsBuilder {
728            protocolVersion: protocolVersion.into(),
729            product: product.into(),
730            revision: revision.into(),
731            userAgent: userAgent.into(),
732            jsVersion: jsVersion.into(),
733        }
734    }
735    pub fn protocolVersion(&self) -> &str { self.protocolVersion.as_ref() }
736    pub fn product(&self) -> &str { self.product.as_ref() }
737    pub fn revision(&self) -> &str { self.revision.as_ref() }
738    pub fn userAgent(&self) -> &str { self.userAgent.as_ref() }
739    pub fn jsVersion(&self) -> &str { self.jsVersion.as_ref() }
740}
741
742
743pub struct GetVersionReturnsBuilder<'a> {
744    protocolVersion: Cow<'a, str>,
745    product: Cow<'a, str>,
746    revision: Cow<'a, str>,
747    userAgent: Cow<'a, str>,
748    jsVersion: Cow<'a, str>,
749}
750
751impl<'a> GetVersionReturnsBuilder<'a> {
752    pub fn build(self) -> GetVersionReturns<'a> {
753        GetVersionReturns {
754            protocolVersion: self.protocolVersion,
755            product: self.product,
756            revision: self.revision,
757            userAgent: self.userAgent,
758            jsVersion: self.jsVersion,
759        }
760    }
761}
762
763#[derive(Debug, Clone, Serialize, Deserialize, Default)]
764pub struct GetVersionParams {}
765
766impl GetVersionParams { pub const METHOD: &'static str = "Browser.getVersion"; }
767
768impl<'a> crate::CdpCommand<'a> for GetVersionParams {
769    const METHOD: &'static str = "Browser.getVersion";
770    type Response = GetVersionReturns<'a>;
771}
772
773/// Returns the command line switches for the browser process if, and only if
774/// --enable-automation is on the commandline.
775
776#[derive(Debug, Clone, Serialize, Deserialize, Default)]
777#[serde(rename_all = "camelCase")]
778pub struct GetBrowserCommandLineReturns<'a> {
779    /// Commandline parameters
780    arguments: Vec<Cow<'a, str>>,
781}
782
783impl<'a> GetBrowserCommandLineReturns<'a> {
784    pub fn builder(arguments: Vec<Cow<'a, str>>) -> GetBrowserCommandLineReturnsBuilder<'a> {
785        GetBrowserCommandLineReturnsBuilder {
786            arguments: arguments,
787        }
788    }
789    pub fn arguments(&self) -> &[Cow<'a, str>] { &self.arguments }
790}
791
792
793pub struct GetBrowserCommandLineReturnsBuilder<'a> {
794    arguments: Vec<Cow<'a, str>>,
795}
796
797impl<'a> GetBrowserCommandLineReturnsBuilder<'a> {
798    pub fn build(self) -> GetBrowserCommandLineReturns<'a> {
799        GetBrowserCommandLineReturns {
800            arguments: self.arguments,
801        }
802    }
803}
804
805#[derive(Debug, Clone, Serialize, Deserialize, Default)]
806pub struct GetBrowserCommandLineParams {}
807
808impl GetBrowserCommandLineParams { pub const METHOD: &'static str = "Browser.getBrowserCommandLine"; }
809
810impl<'a> crate::CdpCommand<'a> for GetBrowserCommandLineParams {
811    const METHOD: &'static str = "Browser.getBrowserCommandLine";
812    type Response = GetBrowserCommandLineReturns<'a>;
813}
814
815/// Get Chrome histograms.
816
817#[derive(Debug, Clone, Serialize, Deserialize, Default)]
818#[serde(rename_all = "camelCase")]
819pub struct GetHistogramsParams<'a> {
820    /// Requested substring in name. Only histograms which have query as a
821    /// substring in their name are extracted. An empty or absent query returns
822    /// all histograms.
823    #[serde(skip_serializing_if = "Option::is_none")]
824    query: Option<Cow<'a, str>>,
825    /// If true, retrieve delta since last delta call.
826    #[serde(skip_serializing_if = "Option::is_none")]
827    delta: Option<bool>,
828}
829
830impl<'a> GetHistogramsParams<'a> {
831    pub fn builder() -> GetHistogramsParamsBuilder<'a> {
832        GetHistogramsParamsBuilder {
833            query: None,
834            delta: None,
835        }
836    }
837    pub fn query(&self) -> Option<&str> { self.query.as_deref() }
838    pub fn delta(&self) -> Option<bool> { self.delta }
839}
840
841#[derive(Default)]
842pub struct GetHistogramsParamsBuilder<'a> {
843    query: Option<Cow<'a, str>>,
844    delta: Option<bool>,
845}
846
847impl<'a> GetHistogramsParamsBuilder<'a> {
848    /// Requested substring in name. Only histograms which have query as a
849    /// substring in their name are extracted. An empty or absent query returns
850    /// all histograms.
851    pub fn query(mut self, query: impl Into<Cow<'a, str>>) -> Self { self.query = Some(query.into()); self }
852    /// If true, retrieve delta since last delta call.
853    pub fn delta(mut self, delta: bool) -> Self { self.delta = Some(delta); self }
854    pub fn build(self) -> GetHistogramsParams<'a> {
855        GetHistogramsParams {
856            query: self.query,
857            delta: self.delta,
858        }
859    }
860}
861
862/// Get Chrome histograms.
863
864#[derive(Debug, Clone, Serialize, Deserialize, Default)]
865#[serde(rename_all = "camelCase")]
866pub struct GetHistogramsReturns<'a> {
867    /// Histograms.
868    histograms: Vec<Histogram<'a>>,
869}
870
871impl<'a> GetHistogramsReturns<'a> {
872    pub fn builder(histograms: Vec<Histogram<'a>>) -> GetHistogramsReturnsBuilder<'a> {
873        GetHistogramsReturnsBuilder {
874            histograms: histograms,
875        }
876    }
877    pub fn histograms(&self) -> &[Histogram<'a>] { &self.histograms }
878}
879
880
881pub struct GetHistogramsReturnsBuilder<'a> {
882    histograms: Vec<Histogram<'a>>,
883}
884
885impl<'a> GetHistogramsReturnsBuilder<'a> {
886    pub fn build(self) -> GetHistogramsReturns<'a> {
887        GetHistogramsReturns {
888            histograms: self.histograms,
889        }
890    }
891}
892
893impl<'a> GetHistogramsParams<'a> { pub const METHOD: &'static str = "Browser.getHistograms"; }
894
895impl<'a> crate::CdpCommand<'a> for GetHistogramsParams<'a> {
896    const METHOD: &'static str = "Browser.getHistograms";
897    type Response = GetHistogramsReturns<'a>;
898}
899
900/// Get a Chrome histogram by name.
901
902#[derive(Debug, Clone, Serialize, Deserialize, Default)]
903#[serde(rename_all = "camelCase")]
904pub struct GetHistogramParams<'a> {
905    /// Requested histogram name.
906    name: Cow<'a, str>,
907    /// If true, retrieve delta since last delta call.
908    #[serde(skip_serializing_if = "Option::is_none")]
909    delta: Option<bool>,
910}
911
912impl<'a> GetHistogramParams<'a> {
913    pub fn builder(name: impl Into<Cow<'a, str>>) -> GetHistogramParamsBuilder<'a> {
914        GetHistogramParamsBuilder {
915            name: name.into(),
916            delta: None,
917        }
918    }
919    pub fn name(&self) -> &str { self.name.as_ref() }
920    pub fn delta(&self) -> Option<bool> { self.delta }
921}
922
923
924pub struct GetHistogramParamsBuilder<'a> {
925    name: Cow<'a, str>,
926    delta: Option<bool>,
927}
928
929impl<'a> GetHistogramParamsBuilder<'a> {
930    /// If true, retrieve delta since last delta call.
931    pub fn delta(mut self, delta: bool) -> Self { self.delta = Some(delta); self }
932    pub fn build(self) -> GetHistogramParams<'a> {
933        GetHistogramParams {
934            name: self.name,
935            delta: self.delta,
936        }
937    }
938}
939
940/// Get a Chrome histogram by name.
941
942#[derive(Debug, Clone, Serialize, Deserialize, Default)]
943#[serde(rename_all = "camelCase")]
944pub struct GetHistogramReturns<'a> {
945    /// Histogram.
946    histogram: Histogram<'a>,
947}
948
949impl<'a> GetHistogramReturns<'a> {
950    pub fn builder(histogram: Histogram<'a>) -> GetHistogramReturnsBuilder<'a> {
951        GetHistogramReturnsBuilder {
952            histogram: histogram,
953        }
954    }
955    pub fn histogram(&self) -> &Histogram<'a> { &self.histogram }
956}
957
958
959pub struct GetHistogramReturnsBuilder<'a> {
960    histogram: Histogram<'a>,
961}
962
963impl<'a> GetHistogramReturnsBuilder<'a> {
964    pub fn build(self) -> GetHistogramReturns<'a> {
965        GetHistogramReturns {
966            histogram: self.histogram,
967        }
968    }
969}
970
971impl<'a> GetHistogramParams<'a> { pub const METHOD: &'static str = "Browser.getHistogram"; }
972
973impl<'a> crate::CdpCommand<'a> for GetHistogramParams<'a> {
974    const METHOD: &'static str = "Browser.getHistogram";
975    type Response = GetHistogramReturns<'a>;
976}
977
978/// Get position and size of the browser window.
979
980#[derive(Debug, Clone, Serialize, Deserialize, Default)]
981#[serde(rename_all = "camelCase")]
982pub struct GetWindowBoundsParams {
983    /// Browser window id.
984    windowId: WindowID,
985}
986
987impl GetWindowBoundsParams {
988    pub fn builder(windowId: WindowID) -> GetWindowBoundsParamsBuilder {
989        GetWindowBoundsParamsBuilder {
990            windowId: windowId,
991        }
992    }
993    pub fn windowId(&self) -> &WindowID { &self.windowId }
994}
995
996
997pub struct GetWindowBoundsParamsBuilder {
998    windowId: WindowID,
999}
1000
1001impl GetWindowBoundsParamsBuilder {
1002    pub fn build(self) -> GetWindowBoundsParams {
1003        GetWindowBoundsParams {
1004            windowId: self.windowId,
1005        }
1006    }
1007}
1008
1009/// Get position and size of the browser window.
1010
1011#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1012#[serde(rename_all = "camelCase")]
1013pub struct GetWindowBoundsReturns {
1014    /// Bounds information of the window. When window state is 'minimized', the restored window
1015    /// position and size are returned.
1016    bounds: Bounds,
1017}
1018
1019impl GetWindowBoundsReturns {
1020    pub fn builder(bounds: Bounds) -> GetWindowBoundsReturnsBuilder {
1021        GetWindowBoundsReturnsBuilder {
1022            bounds: bounds,
1023        }
1024    }
1025    pub fn bounds(&self) -> &Bounds { &self.bounds }
1026}
1027
1028
1029pub struct GetWindowBoundsReturnsBuilder {
1030    bounds: Bounds,
1031}
1032
1033impl GetWindowBoundsReturnsBuilder {
1034    pub fn build(self) -> GetWindowBoundsReturns {
1035        GetWindowBoundsReturns {
1036            bounds: self.bounds,
1037        }
1038    }
1039}
1040
1041impl GetWindowBoundsParams { pub const METHOD: &'static str = "Browser.getWindowBounds"; }
1042
1043impl<'a> crate::CdpCommand<'a> for GetWindowBoundsParams {
1044    const METHOD: &'static str = "Browser.getWindowBounds";
1045    type Response = GetWindowBoundsReturns;
1046}
1047
1048/// Get the browser window that contains the devtools target.
1049
1050#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1051#[serde(rename_all = "camelCase")]
1052pub struct GetWindowForTargetParams<'a> {
1053    /// Devtools agent host id. If called as a part of the session, associated targetId is used.
1054    #[serde(skip_serializing_if = "Option::is_none")]
1055    targetId: Option<crate::target::TargetID<'a>>,
1056}
1057
1058impl<'a> GetWindowForTargetParams<'a> {
1059    pub fn builder() -> GetWindowForTargetParamsBuilder<'a> {
1060        GetWindowForTargetParamsBuilder {
1061            targetId: None,
1062        }
1063    }
1064    pub fn targetId(&self) -> Option<&crate::target::TargetID<'a>> { self.targetId.as_ref() }
1065}
1066
1067#[derive(Default)]
1068pub struct GetWindowForTargetParamsBuilder<'a> {
1069    targetId: Option<crate::target::TargetID<'a>>,
1070}
1071
1072impl<'a> GetWindowForTargetParamsBuilder<'a> {
1073    /// Devtools agent host id. If called as a part of the session, associated targetId is used.
1074    pub fn targetId(mut self, targetId: crate::target::TargetID<'a>) -> Self { self.targetId = Some(targetId); self }
1075    pub fn build(self) -> GetWindowForTargetParams<'a> {
1076        GetWindowForTargetParams {
1077            targetId: self.targetId,
1078        }
1079    }
1080}
1081
1082/// Get the browser window that contains the devtools target.
1083
1084#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1085#[serde(rename_all = "camelCase")]
1086pub struct GetWindowForTargetReturns {
1087    /// Browser window id.
1088    windowId: WindowID,
1089    /// Bounds information of the window. When window state is 'minimized', the restored window
1090    /// position and size are returned.
1091    bounds: Bounds,
1092}
1093
1094impl GetWindowForTargetReturns {
1095    pub fn builder(windowId: WindowID, bounds: Bounds) -> GetWindowForTargetReturnsBuilder {
1096        GetWindowForTargetReturnsBuilder {
1097            windowId: windowId,
1098            bounds: bounds,
1099        }
1100    }
1101    pub fn windowId(&self) -> &WindowID { &self.windowId }
1102    pub fn bounds(&self) -> &Bounds { &self.bounds }
1103}
1104
1105
1106pub struct GetWindowForTargetReturnsBuilder {
1107    windowId: WindowID,
1108    bounds: Bounds,
1109}
1110
1111impl GetWindowForTargetReturnsBuilder {
1112    pub fn build(self) -> GetWindowForTargetReturns {
1113        GetWindowForTargetReturns {
1114            windowId: self.windowId,
1115            bounds: self.bounds,
1116        }
1117    }
1118}
1119
1120impl<'a> GetWindowForTargetParams<'a> { pub const METHOD: &'static str = "Browser.getWindowForTarget"; }
1121
1122impl<'a> crate::CdpCommand<'a> for GetWindowForTargetParams<'a> {
1123    const METHOD: &'static str = "Browser.getWindowForTarget";
1124    type Response = GetWindowForTargetReturns;
1125}
1126
1127/// Set position and/or size of the browser window.
1128
1129#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1130#[serde(rename_all = "camelCase")]
1131pub struct SetWindowBoundsParams {
1132    /// Browser window id.
1133    windowId: WindowID,
1134    /// New window bounds. The 'minimized', 'maximized' and 'fullscreen' states cannot be combined
1135    /// with 'left', 'top', 'width' or 'height'. Leaves unspecified fields unchanged.
1136    bounds: Bounds,
1137}
1138
1139impl SetWindowBoundsParams {
1140    pub fn builder(windowId: WindowID, bounds: Bounds) -> SetWindowBoundsParamsBuilder {
1141        SetWindowBoundsParamsBuilder {
1142            windowId: windowId,
1143            bounds: bounds,
1144        }
1145    }
1146    pub fn windowId(&self) -> &WindowID { &self.windowId }
1147    pub fn bounds(&self) -> &Bounds { &self.bounds }
1148}
1149
1150
1151pub struct SetWindowBoundsParamsBuilder {
1152    windowId: WindowID,
1153    bounds: Bounds,
1154}
1155
1156impl SetWindowBoundsParamsBuilder {
1157    pub fn build(self) -> SetWindowBoundsParams {
1158        SetWindowBoundsParams {
1159            windowId: self.windowId,
1160            bounds: self.bounds,
1161        }
1162    }
1163}
1164
1165impl SetWindowBoundsParams { pub const METHOD: &'static str = "Browser.setWindowBounds"; }
1166
1167impl<'a> crate::CdpCommand<'a> for SetWindowBoundsParams {
1168    const METHOD: &'static str = "Browser.setWindowBounds";
1169    type Response = crate::EmptyReturns;
1170}
1171
1172/// Set size of the browser contents resizing browser window as necessary.
1173
1174#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1175#[serde(rename_all = "camelCase")]
1176pub struct SetContentsSizeParams {
1177    /// Browser window id.
1178    windowId: WindowID,
1179    /// The window contents width in DIP. Assumes current width if omitted.
1180    /// Must be specified if 'height' is omitted.
1181    #[serde(skip_serializing_if = "Option::is_none")]
1182    width: Option<u64>,
1183    /// The window contents height in DIP. Assumes current height if omitted.
1184    /// Must be specified if 'width' is omitted.
1185    #[serde(skip_serializing_if = "Option::is_none")]
1186    height: Option<i64>,
1187}
1188
1189impl SetContentsSizeParams {
1190    pub fn builder(windowId: WindowID) -> SetContentsSizeParamsBuilder {
1191        SetContentsSizeParamsBuilder {
1192            windowId: windowId,
1193            width: None,
1194            height: None,
1195        }
1196    }
1197    pub fn windowId(&self) -> &WindowID { &self.windowId }
1198    pub fn width(&self) -> Option<u64> { self.width }
1199    pub fn height(&self) -> Option<i64> { self.height }
1200}
1201
1202
1203pub struct SetContentsSizeParamsBuilder {
1204    windowId: WindowID,
1205    width: Option<u64>,
1206    height: Option<i64>,
1207}
1208
1209impl SetContentsSizeParamsBuilder {
1210    /// The window contents width in DIP. Assumes current width if omitted.
1211    /// Must be specified if 'height' is omitted.
1212    pub fn width(mut self, width: u64) -> Self { self.width = Some(width); self }
1213    /// The window contents height in DIP. Assumes current height if omitted.
1214    /// Must be specified if 'width' is omitted.
1215    pub fn height(mut self, height: i64) -> Self { self.height = Some(height); self }
1216    pub fn build(self) -> SetContentsSizeParams {
1217        SetContentsSizeParams {
1218            windowId: self.windowId,
1219            width: self.width,
1220            height: self.height,
1221        }
1222    }
1223}
1224
1225impl SetContentsSizeParams { pub const METHOD: &'static str = "Browser.setContentsSize"; }
1226
1227impl<'a> crate::CdpCommand<'a> for SetContentsSizeParams {
1228    const METHOD: &'static str = "Browser.setContentsSize";
1229    type Response = crate::EmptyReturns;
1230}
1231
1232/// Set dock tile details, platform-specific.
1233
1234#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1235#[serde(rename_all = "camelCase")]
1236pub struct SetDockTileParams<'a> {
1237    #[serde(skip_serializing_if = "Option::is_none")]
1238    badgeLabel: Option<Cow<'a, str>>,
1239    /// Png encoded image. (Encoded as a base64 string when passed over JSON)
1240    #[serde(skip_serializing_if = "Option::is_none")]
1241    image: Option<Cow<'a, str>>,
1242}
1243
1244impl<'a> SetDockTileParams<'a> {
1245    pub fn builder() -> SetDockTileParamsBuilder<'a> {
1246        SetDockTileParamsBuilder {
1247            badgeLabel: None,
1248            image: None,
1249        }
1250    }
1251    pub fn badgeLabel(&self) -> Option<&str> { self.badgeLabel.as_deref() }
1252    pub fn image(&self) -> Option<&str> { self.image.as_deref() }
1253}
1254
1255#[derive(Default)]
1256pub struct SetDockTileParamsBuilder<'a> {
1257    badgeLabel: Option<Cow<'a, str>>,
1258    image: Option<Cow<'a, str>>,
1259}
1260
1261impl<'a> SetDockTileParamsBuilder<'a> {
1262    pub fn badgeLabel(mut self, badgeLabel: impl Into<Cow<'a, str>>) -> Self { self.badgeLabel = Some(badgeLabel.into()); self }
1263    /// Png encoded image. (Encoded as a base64 string when passed over JSON)
1264    pub fn image(mut self, image: impl Into<Cow<'a, str>>) -> Self { self.image = Some(image.into()); self }
1265    pub fn build(self) -> SetDockTileParams<'a> {
1266        SetDockTileParams {
1267            badgeLabel: self.badgeLabel,
1268            image: self.image,
1269        }
1270    }
1271}
1272
1273impl<'a> SetDockTileParams<'a> { pub const METHOD: &'static str = "Browser.setDockTile"; }
1274
1275impl<'a> crate::CdpCommand<'a> for SetDockTileParams<'a> {
1276    const METHOD: &'static str = "Browser.setDockTile";
1277    type Response = crate::EmptyReturns;
1278}
1279
1280/// Invoke custom browser commands used by telemetry.
1281
1282#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1283#[serde(rename_all = "camelCase")]
1284pub struct ExecuteBrowserCommandParams {
1285    commandId: BrowserCommandId,
1286}
1287
1288impl ExecuteBrowserCommandParams {
1289    pub fn builder(commandId: BrowserCommandId) -> ExecuteBrowserCommandParamsBuilder {
1290        ExecuteBrowserCommandParamsBuilder {
1291            commandId: commandId,
1292        }
1293    }
1294    pub fn commandId(&self) -> &BrowserCommandId { &self.commandId }
1295}
1296
1297
1298pub struct ExecuteBrowserCommandParamsBuilder {
1299    commandId: BrowserCommandId,
1300}
1301
1302impl ExecuteBrowserCommandParamsBuilder {
1303    pub fn build(self) -> ExecuteBrowserCommandParams {
1304        ExecuteBrowserCommandParams {
1305            commandId: self.commandId,
1306        }
1307    }
1308}
1309
1310impl ExecuteBrowserCommandParams { pub const METHOD: &'static str = "Browser.executeBrowserCommand"; }
1311
1312impl<'a> crate::CdpCommand<'a> for ExecuteBrowserCommandParams {
1313    const METHOD: &'static str = "Browser.executeBrowserCommand";
1314    type Response = crate::EmptyReturns;
1315}
1316
1317/// Allows a site to use privacy sandbox features that require enrollment
1318/// without the site actually being enrolled. Only supported on page targets.
1319
1320#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1321#[serde(rename_all = "camelCase")]
1322pub struct AddPrivacySandboxEnrollmentOverrideParams<'a> {
1323    url: Cow<'a, str>,
1324}
1325
1326impl<'a> AddPrivacySandboxEnrollmentOverrideParams<'a> {
1327    pub fn builder(url: impl Into<Cow<'a, str>>) -> AddPrivacySandboxEnrollmentOverrideParamsBuilder<'a> {
1328        AddPrivacySandboxEnrollmentOverrideParamsBuilder {
1329            url: url.into(),
1330        }
1331    }
1332    pub fn url(&self) -> &str { self.url.as_ref() }
1333}
1334
1335
1336pub struct AddPrivacySandboxEnrollmentOverrideParamsBuilder<'a> {
1337    url: Cow<'a, str>,
1338}
1339
1340impl<'a> AddPrivacySandboxEnrollmentOverrideParamsBuilder<'a> {
1341    pub fn build(self) -> AddPrivacySandboxEnrollmentOverrideParams<'a> {
1342        AddPrivacySandboxEnrollmentOverrideParams {
1343            url: self.url,
1344        }
1345    }
1346}
1347
1348impl<'a> AddPrivacySandboxEnrollmentOverrideParams<'a> { pub const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride"; }
1349
1350impl<'a> crate::CdpCommand<'a> for AddPrivacySandboxEnrollmentOverrideParams<'a> {
1351    const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride";
1352    type Response = crate::EmptyReturns;
1353}
1354
1355/// Configures encryption keys used with a given privacy sandbox API to talk
1356/// to a trusted coordinator.  Since this is intended for test automation only,
1357/// coordinatorOrigin must be a .test domain. No existing coordinator
1358/// configuration for the origin may exist.
1359
1360#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1361#[serde(rename_all = "camelCase")]
1362pub struct AddPrivacySandboxCoordinatorKeyConfigParams<'a> {
1363    api: PrivacySandboxAPI,
1364    coordinatorOrigin: Cow<'a, str>,
1365    keyConfig: Cow<'a, str>,
1366    /// BrowserContext to perform the action in. When omitted, default browser
1367    /// context is used.
1368    #[serde(skip_serializing_if = "Option::is_none")]
1369    browserContextId: Option<BrowserContextID<'a>>,
1370}
1371
1372impl<'a> AddPrivacySandboxCoordinatorKeyConfigParams<'a> {
1373    pub fn builder(api: PrivacySandboxAPI, coordinatorOrigin: impl Into<Cow<'a, str>>, keyConfig: impl Into<Cow<'a, str>>) -> AddPrivacySandboxCoordinatorKeyConfigParamsBuilder<'a> {
1374        AddPrivacySandboxCoordinatorKeyConfigParamsBuilder {
1375            api: api,
1376            coordinatorOrigin: coordinatorOrigin.into(),
1377            keyConfig: keyConfig.into(),
1378            browserContextId: None,
1379        }
1380    }
1381    pub fn api(&self) -> &PrivacySandboxAPI { &self.api }
1382    pub fn coordinatorOrigin(&self) -> &str { self.coordinatorOrigin.as_ref() }
1383    pub fn keyConfig(&self) -> &str { self.keyConfig.as_ref() }
1384    pub fn browserContextId(&self) -> Option<&BrowserContextID<'a>> { self.browserContextId.as_ref() }
1385}
1386
1387
1388pub struct AddPrivacySandboxCoordinatorKeyConfigParamsBuilder<'a> {
1389    api: PrivacySandboxAPI,
1390    coordinatorOrigin: Cow<'a, str>,
1391    keyConfig: Cow<'a, str>,
1392    browserContextId: Option<BrowserContextID<'a>>,
1393}
1394
1395impl<'a> AddPrivacySandboxCoordinatorKeyConfigParamsBuilder<'a> {
1396    /// BrowserContext to perform the action in. When omitted, default browser
1397    /// context is used.
1398    pub fn browserContextId(mut self, browserContextId: BrowserContextID<'a>) -> Self { self.browserContextId = Some(browserContextId); self }
1399    pub fn build(self) -> AddPrivacySandboxCoordinatorKeyConfigParams<'a> {
1400        AddPrivacySandboxCoordinatorKeyConfigParams {
1401            api: self.api,
1402            coordinatorOrigin: self.coordinatorOrigin,
1403            keyConfig: self.keyConfig,
1404            browserContextId: self.browserContextId,
1405        }
1406    }
1407}
1408
1409impl<'a> AddPrivacySandboxCoordinatorKeyConfigParams<'a> { pub const METHOD: &'static str = "Browser.addPrivacySandboxCoordinatorKeyConfig"; }
1410
1411impl<'a> crate::CdpCommand<'a> for AddPrivacySandboxCoordinatorKeyConfigParams<'a> {
1412    const METHOD: &'static str = "Browser.addPrivacySandboxCoordinatorKeyConfig";
1413    type Response = crate::EmptyReturns;
1414}