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