Skip to main content

cdp_driver/protocol/
browser.rs

1// @generated by `just generate-methods` from protocol/*.json.
2// Do not edit by hand; edit xtask/ and regenerate.
3
4//! The Browser domain defines methods and events for browser managing.
5//!
6//! Types, command parameters and event payloads for the `Browser`
7//! domain. The method-name constants for the same domain are in
8//! [`crate::methods`].
9
10use serde::{Deserialize, Serialize};
11
12/// Experimental: may change without notice.
13pub type BrowserContextId = String;
14
15/// Experimental: may change without notice.
16pub type WindowId = i64;
17
18/// The state of the browser window.
19///
20/// Experimental: may change without notice.
21#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
22pub enum WindowState {
23    /// `normal`
24    #[serde(rename = "normal")]
25    Normal,
26    /// `minimized`
27    #[serde(rename = "minimized")]
28    Minimized,
29    /// `maximized`
30    #[serde(rename = "maximized")]
31    Maximized,
32    /// `fullscreen`
33    #[serde(rename = "fullscreen")]
34    Fullscreen,
35    /// A value this vendored schema does not list. Chrome adds values ahead of
36    /// the published protocol, so an unrecognised one is kept as it arrived
37    /// rather than failing the payload it came in.
38    #[serde(untagged)]
39    Unrecognized(String),
40}
41
42/// Browser window bounds information
43///
44/// Experimental: may change without notice.
45#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
46pub struct Bounds {
47    /// The offset from the left edge of the screen to the window in pixels.
48    #[serde(default, skip_serializing_if = "Option::is_none")]
49    pub left: Option<i64>,
50    /// The offset from the top edge of the screen to the window in pixels.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub top: Option<i64>,
53    /// The window width in pixels.
54    #[serde(default, skip_serializing_if = "Option::is_none")]
55    pub width: Option<i64>,
56    /// The window height in pixels.
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub height: Option<i64>,
59    /// The window state. Default to normal.
60    #[serde(
61        rename = "windowState",
62        default,
63        skip_serializing_if = "Option::is_none"
64    )]
65    pub window_state: Option<WindowState>,
66}
67
68/// Experimental: may change without notice.
69#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
70pub enum PermissionType {
71    /// `ar`
72    #[serde(rename = "ar")]
73    Ar,
74    /// `audioCapture`
75    #[serde(rename = "audioCapture")]
76    AudioCapture,
77    /// `automaticFullscreen`
78    #[serde(rename = "automaticFullscreen")]
79    AutomaticFullscreen,
80    /// `backgroundFetch`
81    #[serde(rename = "backgroundFetch")]
82    BackgroundFetch,
83    /// `backgroundSync`
84    #[serde(rename = "backgroundSync")]
85    BackgroundSync,
86    /// `cameraPanTiltZoom`
87    #[serde(rename = "cameraPanTiltZoom")]
88    CameraPanTiltZoom,
89    /// `capturedSurfaceControl`
90    #[serde(rename = "capturedSurfaceControl")]
91    CapturedSurfaceControl,
92    /// `clipboardReadWrite`
93    #[serde(rename = "clipboardReadWrite")]
94    ClipboardReadWrite,
95    /// `clipboardSanitizedWrite`
96    #[serde(rename = "clipboardSanitizedWrite")]
97    ClipboardSanitizedWrite,
98    /// `displayCapture`
99    #[serde(rename = "displayCapture")]
100    DisplayCapture,
101    /// `durableStorage`
102    #[serde(rename = "durableStorage")]
103    DurableStorage,
104    /// `geolocation`
105    #[serde(rename = "geolocation")]
106    Geolocation,
107    /// `handTracking`
108    #[serde(rename = "handTracking")]
109    HandTracking,
110    /// `idleDetection`
111    #[serde(rename = "idleDetection")]
112    IdleDetection,
113    /// `keyboardLock`
114    #[serde(rename = "keyboardLock")]
115    KeyboardLock,
116    /// `localFonts`
117    #[serde(rename = "localFonts")]
118    LocalFonts,
119    /// `localNetwork`
120    #[serde(rename = "localNetwork")]
121    LocalNetwork,
122    /// `localNetworkAccess`
123    #[serde(rename = "localNetworkAccess")]
124    LocalNetworkAccess,
125    /// `loopbackNetwork`
126    #[serde(rename = "loopbackNetwork")]
127    LoopbackNetwork,
128    /// `midi`
129    #[serde(rename = "midi")]
130    Midi,
131    /// `midiSysex`
132    #[serde(rename = "midiSysex")]
133    MidiSysex,
134    /// `nfc`
135    #[serde(rename = "nfc")]
136    Nfc,
137    /// `notifications`
138    #[serde(rename = "notifications")]
139    Notifications,
140    /// `paymentHandler`
141    #[serde(rename = "paymentHandler")]
142    PaymentHandler,
143    /// `periodicBackgroundSync`
144    #[serde(rename = "periodicBackgroundSync")]
145    PeriodicBackgroundSync,
146    /// `pointerLock`
147    #[serde(rename = "pointerLock")]
148    PointerLock,
149    /// `protectedMediaIdentifier`
150    #[serde(rename = "protectedMediaIdentifier")]
151    ProtectedMediaIdentifier,
152    /// `sensors`
153    #[serde(rename = "sensors")]
154    Sensors,
155    /// `smartCard`
156    #[serde(rename = "smartCard")]
157    SmartCard,
158    /// `speakerSelection`
159    #[serde(rename = "speakerSelection")]
160    SpeakerSelection,
161    /// `storageAccess`
162    #[serde(rename = "storageAccess")]
163    StorageAccess,
164    /// `videoCapture`
165    #[serde(rename = "videoCapture")]
166    VideoCapture,
167    /// `vr`
168    #[serde(rename = "vr")]
169    Vr,
170    /// `wakeLockScreen`
171    #[serde(rename = "wakeLockScreen")]
172    WakeLockScreen,
173    /// `wakeLockSystem`
174    #[serde(rename = "wakeLockSystem")]
175    WakeLockSystem,
176    /// `webAppInstallation`
177    #[serde(rename = "webAppInstallation")]
178    WebAppInstallation,
179    /// `webPrinting`
180    #[serde(rename = "webPrinting")]
181    WebPrinting,
182    /// `windowManagement`
183    #[serde(rename = "windowManagement")]
184    WindowManagement,
185    /// A value this vendored schema does not list. Chrome adds values ahead of
186    /// the published protocol, so an unrecognised one is kept as it arrived
187    /// rather than failing the payload it came in.
188    #[serde(untagged)]
189    Unrecognized(String),
190}
191
192/// Experimental: may change without notice.
193#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
194pub enum PermissionSetting {
195    /// `granted`
196    #[serde(rename = "granted")]
197    Granted,
198    /// `denied`
199    #[serde(rename = "denied")]
200    Denied,
201    /// `prompt`
202    #[serde(rename = "prompt")]
203    Prompt,
204    /// A value this vendored schema does not list. Chrome adds values ahead of
205    /// the published protocol, so an unrecognised one is kept as it arrived
206    /// rather than failing the payload it came in.
207    #[serde(untagged)]
208    Unrecognized(String),
209}
210
211/// Definition of PermissionDescriptor defined in the Permissions API:
212/// <https://w3c.github.io/permissions/#dom-permissiondescriptor>.
213///
214/// Experimental: may change without notice.
215#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
216pub struct PermissionDescriptor {
217    /// Name of permission. See
218    /// <https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/permissions/permission_descriptor.idl>
219    /// for valid permission names.
220    pub name: String,
221    /// For "midi" permission, may also specify sysex control.
222    #[serde(default, skip_serializing_if = "Option::is_none")]
223    pub sysex: Option<bool>,
224    /// For "push" permission, may specify userVisibleOnly. Note that
225    /// userVisibleOnly = true is the only currently supported type.
226    #[serde(
227        rename = "userVisibleOnly",
228        default,
229        skip_serializing_if = "Option::is_none"
230    )]
231    pub user_visible_only: Option<bool>,
232    /// For "clipboard" permission, may specify allowWithoutSanitization.
233    #[serde(
234        rename = "allowWithoutSanitization",
235        default,
236        skip_serializing_if = "Option::is_none"
237    )]
238    pub allow_without_sanitization: Option<bool>,
239    /// For "fullscreen" permission, must specify allowWithoutGesture:true.
240    #[serde(
241        rename = "allowWithoutGesture",
242        default,
243        skip_serializing_if = "Option::is_none"
244    )]
245    pub allow_without_gesture: Option<bool>,
246    /// For "camera" permission, may specify panTiltZoom.
247    #[serde(
248        rename = "panTiltZoom",
249        default,
250        skip_serializing_if = "Option::is_none"
251    )]
252    pub pan_tilt_zoom: Option<bool>,
253}
254
255/// Browser command ids used by executeBrowserCommand.
256///
257/// Experimental: may change without notice.
258#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
259pub enum BrowserCommandId {
260    /// `openTabSearch`
261    #[serde(rename = "openTabSearch")]
262    OpenTabSearch,
263    /// `closeTabSearch`
264    #[serde(rename = "closeTabSearch")]
265    CloseTabSearch,
266    /// `openGlic`
267    #[serde(rename = "openGlic")]
268    OpenGlic,
269    /// A value this vendored schema does not list. Chrome adds values ahead of
270    /// the published protocol, so an unrecognised one is kept as it arrived
271    /// rather than failing the payload it came in.
272    #[serde(untagged)]
273    Unrecognized(String),
274}
275
276/// Chrome histogram bucket.
277///
278/// Experimental: may change without notice.
279#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
280pub struct Bucket {
281    /// Minimum value (inclusive).
282    pub low: i64,
283    /// Maximum value (exclusive).
284    pub high: i64,
285    /// Number of samples.
286    pub count: i64,
287}
288
289/// Chrome histogram.
290///
291/// Experimental: may change without notice.
292#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
293pub struct Histogram {
294    /// Name.
295    pub name: String,
296    /// Sum of sample values.
297    pub sum: i64,
298    /// Total number of samples.
299    pub count: i64,
300    /// Buckets.
301    pub buckets: Vec<Bucket>,
302}
303
304/// Set permission settings for given embedding and embedded origins.
305///
306/// Experimental: may change without notice.
307///
308/// Parameters of `Browser.setPermission`.
309#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
310pub struct SetPermissionParams {
311    /// Descriptor of permission to override.
312    pub permission: PermissionDescriptor,
313    /// Setting of the permission.
314    pub setting: PermissionSetting,
315    /// Embedding origin the permission applies to, all origins if not specified.
316    #[serde(default, skip_serializing_if = "Option::is_none")]
317    pub origin: Option<String>,
318    /// Embedded origin the permission applies to. It is ignored unless the
319    /// embedding origin is present and valid. If the embedding origin is provided
320    /// but the embedded origin isn't, the embedding origin is used as the
321    /// embedded origin.
322    #[serde(
323        rename = "embeddedOrigin",
324        default,
325        skip_serializing_if = "Option::is_none"
326    )]
327    pub embedded_origin: Option<String>,
328    /// Context to override. When omitted, default browser context is used.
329    #[serde(
330        rename = "browserContextId",
331        default,
332        skip_serializing_if = "Option::is_none"
333    )]
334    pub browser_context_id: Option<BrowserContextId>,
335}
336
337impl crate::typed::Command for SetPermissionParams {
338    const METHOD: &'static str = "Browser.setPermission";
339    type Returns = crate::typed::NoReturns;
340}
341
342/// Grant specific permissions to the given origin and reject all others.
343/// Deprecated. Use setPermission instead.
344///
345/// Deprecated in the protocol.
346///
347/// Experimental: may change without notice.
348///
349/// Parameters of `Browser.grantPermissions`.
350#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
351pub struct GrantPermissionsParams {
352    pub permissions: Vec<PermissionType>,
353    /// Origin the permission applies to, all origins if not specified.
354    #[serde(default, skip_serializing_if = "Option::is_none")]
355    pub origin: Option<String>,
356    /// BrowserContext to override permissions. When omitted, default browser
357    /// context is used.
358    #[serde(
359        rename = "browserContextId",
360        default,
361        skip_serializing_if = "Option::is_none"
362    )]
363    pub browser_context_id: Option<BrowserContextId>,
364}
365
366impl crate::typed::Command for GrantPermissionsParams {
367    const METHOD: &'static str = "Browser.grantPermissions";
368    type Returns = crate::typed::NoReturns;
369}
370
371/// Reset all permission management for all origins.
372///
373/// Parameters of `Browser.resetPermissions`.
374#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
375pub struct ResetPermissionsParams {
376    /// BrowserContext to reset permissions. When omitted, default browser context
377    /// is used.
378    #[serde(
379        rename = "browserContextId",
380        default,
381        skip_serializing_if = "Option::is_none"
382    )]
383    pub browser_context_id: Option<BrowserContextId>,
384}
385
386impl crate::typed::Command for ResetPermissionsParams {
387    const METHOD: &'static str = "Browser.resetPermissions";
388    type Returns = crate::typed::NoReturns;
389}
390
391/// Set the behavior when downloading a file.
392///
393/// Experimental: may change without notice.
394///
395/// Parameters of `Browser.setDownloadBehavior`.
396#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
397pub struct SetDownloadBehaviorParams {
398    /// Whether to allow all or deny all download requests, or use default Chrome
399    /// behavior if available (otherwise deny). |allowAndName| allows download and
400    /// names files according to their download guids.
401    pub behavior: SetDownloadBehaviorBehavior,
402    /// BrowserContext to set download behavior. When omitted, default browser
403    /// context is used.
404    #[serde(
405        rename = "browserContextId",
406        default,
407        skip_serializing_if = "Option::is_none"
408    )]
409    pub browser_context_id: Option<BrowserContextId>,
410    /// The default path to save downloaded files to. This is required if behavior
411    /// is set to 'allow' or 'allowAndName'.
412    #[serde(
413        rename = "downloadPath",
414        default,
415        skip_serializing_if = "Option::is_none"
416    )]
417    pub download_path: Option<String>,
418    /// Whether to emit download events (defaults to false).
419    #[serde(
420        rename = "eventsEnabled",
421        default,
422        skip_serializing_if = "Option::is_none"
423    )]
424    pub events_enabled: Option<bool>,
425}
426
427/// The values `behavior` accepts on `setDownloadBehavior`.
428#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
429pub enum SetDownloadBehaviorBehavior {
430    /// `deny`
431    #[serde(rename = "deny")]
432    Deny,
433    /// `allow`
434    #[serde(rename = "allow")]
435    Allow,
436    /// `allowAndName`
437    #[serde(rename = "allowAndName")]
438    AllowAndName,
439    /// `default`
440    #[serde(rename = "default")]
441    Default,
442    /// A value this vendored schema does not list. Chrome adds values ahead of
443    /// the published protocol, so an unrecognised one is kept as it arrived
444    /// rather than failing the payload it came in.
445    #[serde(untagged)]
446    Unrecognized(String),
447}
448
449impl crate::typed::Command for SetDownloadBehaviorParams {
450    const METHOD: &'static str = "Browser.setDownloadBehavior";
451    type Returns = crate::typed::NoReturns;
452}
453
454/// Cancel a download if in progress
455///
456/// Experimental: may change without notice.
457///
458/// Parameters of `Browser.cancelDownload`.
459#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
460pub struct CancelDownloadParams {
461    /// Global unique identifier of the download.
462    pub guid: String,
463    /// BrowserContext to perform the action in. When omitted, default browser
464    /// context is used.
465    #[serde(
466        rename = "browserContextId",
467        default,
468        skip_serializing_if = "Option::is_none"
469    )]
470    pub browser_context_id: Option<BrowserContextId>,
471}
472
473impl crate::typed::Command for CancelDownloadParams {
474    const METHOD: &'static str = "Browser.cancelDownload";
475    type Returns = crate::typed::NoReturns;
476}
477
478/// Close browser gracefully.
479///
480/// Parameters of `Browser.close`.
481#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
482pub struct CloseParams {}
483
484impl crate::typed::Command for CloseParams {
485    const METHOD: &'static str = "Browser.close";
486    type Returns = crate::typed::NoReturns;
487}
488
489/// Crashes browser on the main thread.
490///
491/// Experimental: may change without notice.
492///
493/// Parameters of `Browser.crash`.
494#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
495pub struct CrashParams {}
496
497impl crate::typed::Command for CrashParams {
498    const METHOD: &'static str = "Browser.crash";
499    type Returns = crate::typed::NoReturns;
500}
501
502/// Crashes GPU process.
503///
504/// Experimental: may change without notice.
505///
506/// Parameters of `Browser.crashGpuProcess`.
507#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
508pub struct CrashGpuProcessParams {}
509
510impl crate::typed::Command for CrashGpuProcessParams {
511    const METHOD: &'static str = "Browser.crashGpuProcess";
512    type Returns = crate::typed::NoReturns;
513}
514
515/// Returns version information.
516///
517/// Parameters of `Browser.getVersion`.
518#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
519pub struct GetVersionParams {}
520
521/// What `Browser.getVersion` answers with.
522#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
523pub struct GetVersionReturns {
524    /// Protocol version.
525    #[serde(rename = "protocolVersion")]
526    pub protocol_version: String,
527    /// Product name.
528    pub product: String,
529    /// Product revision.
530    pub revision: String,
531    /// User-Agent.
532    #[serde(rename = "userAgent")]
533    pub user_agent: String,
534    /// V8 version.
535    #[serde(rename = "jsVersion")]
536    pub js_version: String,
537}
538
539impl crate::typed::Command for GetVersionParams {
540    const METHOD: &'static str = "Browser.getVersion";
541    type Returns = GetVersionReturns;
542}
543
544/// Returns the command line switches for the browser process if, and only if
545/// --enable-automation is on the commandline.
546///
547/// Experimental: may change without notice.
548///
549/// Parameters of `Browser.getBrowserCommandLine`.
550#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
551pub struct GetBrowserCommandLineParams {}
552
553/// What `Browser.getBrowserCommandLine` answers with.
554#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
555pub struct GetBrowserCommandLineReturns {
556    /// Commandline parameters
557    pub arguments: Vec<String>,
558}
559
560impl crate::typed::Command for GetBrowserCommandLineParams {
561    const METHOD: &'static str = "Browser.getBrowserCommandLine";
562    type Returns = GetBrowserCommandLineReturns;
563}
564
565/// Adds or updates a mock camera in the shared video capture device list for
566/// test automation. The mock camera is not scoped to a particular page or
567/// frame and is removed when the DevTools session that created it
568/// disconnects.
569///
570/// Experimental: may change without notice.
571///
572/// Parameters of `Browser.addMockCamera`.
573#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
574pub struct AddMockCameraParams {
575    /// Required non-empty identifier for the mock camera within the current
576    /// DevTools session. Different sessions can use the same identifier without
577    /// replacing each other's cameras. This is not the MediaDeviceInfo.deviceId
578    /// exposed to the page.
579    #[serde(rename = "deviceId")]
580    pub device_id: String,
581}
582
583impl crate::typed::Command for AddMockCameraParams {
584    const METHOD: &'static str = "Browser.addMockCamera";
585    type Returns = crate::typed::NoReturns;
586}
587
588/// Get Chrome histograms.
589///
590/// Experimental: may change without notice.
591///
592/// Parameters of `Browser.getHistograms`.
593#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
594pub struct GetHistogramsParams {
595    /// Requested substring in name. Only histograms which have query as a
596    /// substring in their name are extracted. An empty or absent query returns
597    /// all histograms.
598    #[serde(default, skip_serializing_if = "Option::is_none")]
599    pub query: Option<String>,
600    /// If true, retrieve delta since last delta call.
601    #[serde(default, skip_serializing_if = "Option::is_none")]
602    pub delta: Option<bool>,
603}
604
605/// What `Browser.getHistograms` answers with.
606#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
607pub struct GetHistogramsReturns {
608    /// Histograms.
609    pub histograms: Vec<Histogram>,
610}
611
612impl crate::typed::Command for GetHistogramsParams {
613    const METHOD: &'static str = "Browser.getHistograms";
614    type Returns = GetHistogramsReturns;
615}
616
617/// Get a Chrome histogram by name.
618///
619/// Experimental: may change without notice.
620///
621/// Parameters of `Browser.getHistogram`.
622#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
623pub struct GetHistogramParams {
624    /// Requested histogram name.
625    pub name: String,
626    /// If true, retrieve delta since last delta call.
627    #[serde(default, skip_serializing_if = "Option::is_none")]
628    pub delta: Option<bool>,
629}
630
631/// What `Browser.getHistogram` answers with.
632#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
633pub struct GetHistogramReturns {
634    /// Histogram.
635    pub histogram: Histogram,
636}
637
638impl crate::typed::Command for GetHistogramParams {
639    const METHOD: &'static str = "Browser.getHistogram";
640    type Returns = GetHistogramReturns;
641}
642
643/// Get position and size of the browser window.
644///
645/// Experimental: may change without notice.
646///
647/// Parameters of `Browser.getWindowBounds`.
648#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
649pub struct GetWindowBoundsParams {
650    /// Browser window id.
651    #[serde(rename = "windowId")]
652    pub window_id: WindowId,
653}
654
655/// What `Browser.getWindowBounds` answers with.
656#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
657pub struct GetWindowBoundsReturns {
658    /// Bounds information of the window. When window state is 'minimized', the
659    /// restored window position and size are returned.
660    pub bounds: Bounds,
661}
662
663impl crate::typed::Command for GetWindowBoundsParams {
664    const METHOD: &'static str = "Browser.getWindowBounds";
665    type Returns = GetWindowBoundsReturns;
666}
667
668/// Get the browser window that contains the devtools target.
669///
670/// Experimental: may change without notice.
671///
672/// Parameters of `Browser.getWindowForTarget`.
673#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
674pub struct GetWindowForTargetParams {
675    /// Devtools agent host id. If called as a part of the session, associated
676    /// targetId is used.
677    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
678    pub target_id: Option<crate::protocol::target::TargetId>,
679}
680
681/// What `Browser.getWindowForTarget` answers with.
682#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
683pub struct GetWindowForTargetReturns {
684    /// Browser window id.
685    #[serde(rename = "windowId")]
686    pub window_id: WindowId,
687    /// Bounds information of the window. When window state is 'minimized', the
688    /// restored window position and size are returned.
689    pub bounds: Bounds,
690}
691
692impl crate::typed::Command for GetWindowForTargetParams {
693    const METHOD: &'static str = "Browser.getWindowForTarget";
694    type Returns = GetWindowForTargetReturns;
695}
696
697/// Set position and/or size of the browser window.
698///
699/// Experimental: may change without notice.
700///
701/// Parameters of `Browser.setWindowBounds`.
702#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
703pub struct SetWindowBoundsParams {
704    /// Browser window id.
705    #[serde(rename = "windowId")]
706    pub window_id: WindowId,
707    /// New window bounds. The 'minimized', 'maximized' and 'fullscreen' states
708    /// cannot be combined with 'left', 'top', 'width' or 'height'. Leaves
709    /// unspecified fields unchanged.
710    pub bounds: Bounds,
711}
712
713impl crate::typed::Command for SetWindowBoundsParams {
714    const METHOD: &'static str = "Browser.setWindowBounds";
715    type Returns = crate::typed::NoReturns;
716}
717
718/// Set size of the browser contents resizing browser window as necessary.
719///
720/// Experimental: may change without notice.
721///
722/// Parameters of `Browser.setContentsSize`.
723#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
724pub struct SetContentsSizeParams {
725    /// Browser window id.
726    #[serde(rename = "windowId")]
727    pub window_id: WindowId,
728    /// The window contents width in DIP. Assumes current width if omitted. Must
729    /// be specified if 'height' is omitted.
730    #[serde(default, skip_serializing_if = "Option::is_none")]
731    pub width: Option<i64>,
732    /// The window contents height in DIP. Assumes current height if omitted. Must
733    /// be specified if 'width' is omitted.
734    #[serde(default, skip_serializing_if = "Option::is_none")]
735    pub height: Option<i64>,
736}
737
738impl crate::typed::Command for SetContentsSizeParams {
739    const METHOD: &'static str = "Browser.setContentsSize";
740    type Returns = crate::typed::NoReturns;
741}
742
743/// Set dock tile details, platform-specific.
744///
745/// Experimental: may change without notice.
746///
747/// Parameters of `Browser.setDockTile`.
748#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
749pub struct SetDockTileParams {
750    #[serde(
751        rename = "badgeLabel",
752        default,
753        skip_serializing_if = "Option::is_none"
754    )]
755    pub badge_label: Option<String>,
756    /// Png encoded image. (Encoded as a base64 string when passed over JSON)
757    #[serde(default, skip_serializing_if = "Option::is_none")]
758    pub image: Option<String>,
759}
760
761impl crate::typed::Command for SetDockTileParams {
762    const METHOD: &'static str = "Browser.setDockTile";
763    type Returns = crate::typed::NoReturns;
764}
765
766/// Invoke custom browser commands used by telemetry.
767///
768/// Experimental: may change without notice.
769///
770/// Parameters of `Browser.executeBrowserCommand`.
771#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
772pub struct ExecuteBrowserCommandParams {
773    #[serde(rename = "commandId")]
774    pub command_id: BrowserCommandId,
775}
776
777impl crate::typed::Command for ExecuteBrowserCommandParams {
778    const METHOD: &'static str = "Browser.executeBrowserCommand";
779    type Returns = crate::typed::NoReturns;
780}
781
782/// Allows a site to use privacy sandbox features that require enrollment
783/// without the site actually being enrolled. Only supported on page targets.
784///
785/// Parameters of `Browser.addPrivacySandboxEnrollmentOverride`.
786#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
787pub struct AddPrivacySandboxEnrollmentOverrideParams {
788    pub url: String,
789}
790
791impl crate::typed::Command for AddPrivacySandboxEnrollmentOverrideParams {
792    const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride";
793    type Returns = crate::typed::NoReturns;
794}
795
796/// Gets the current globally-applied privacy control status See
797/// <https://www.w3.org/TR/gpc/#get-global-privacy-control>
798///
799/// Experimental: may change without notice.
800///
801/// Parameters of `Browser.getGlobalPrivacyControl`.
802#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
803pub struct GetGlobalPrivacyControlParams {}
804
805/// What `Browser.getGlobalPrivacyControl` answers with.
806#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
807pub struct GetGlobalPrivacyControlReturns {
808    pub gpc: bool,
809}
810
811impl crate::typed::Command for GetGlobalPrivacyControlParams {
812    const METHOD: &'static str = "Browser.getGlobalPrivacyControl";
813    type Returns = GetGlobalPrivacyControlReturns;
814}
815
816/// Sets and then gets the current globally-applied privacy control status See
817/// <https://www.w3.org/TR/gpc/#set-global-privacy-control>
818///
819/// Experimental: may change without notice.
820///
821/// Parameters of `Browser.setGlobalPrivacyControl`.
822#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
823pub struct SetGlobalPrivacyControlParams {
824    pub gpc: bool,
825}
826
827/// What `Browser.setGlobalPrivacyControl` answers with.
828#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
829pub struct SetGlobalPrivacyControlReturns {
830    pub gpc: bool,
831}
832
833impl crate::typed::Command for SetGlobalPrivacyControlParams {
834    const METHOD: &'static str = "Browser.setGlobalPrivacyControl";
835    type Returns = SetGlobalPrivacyControlReturns;
836}
837
838/// Fired when page is about to start a download.
839///
840/// Experimental: may change without notice.
841///
842/// Payload of the `Browser.downloadWillBegin` event.
843#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
844pub struct DownloadWillBeginEvent {
845    /// Id of the frame that caused the download to begin.
846    #[serde(rename = "frameId")]
847    pub frame_id: crate::protocol::page::FrameId,
848    /// Global unique identifier of the download.
849    pub guid: String,
850    /// URL of the resource being downloaded.
851    pub url: String,
852    /// Suggested file name of the resource (the actual name of the file saved on
853    /// disk may differ).
854    #[serde(rename = "suggestedFilename")]
855    pub suggested_filename: String,
856}
857
858impl crate::typed::Event for DownloadWillBeginEvent {
859    const METHOD: &'static str = "Browser.downloadWillBegin";
860}
861
862/// Fired when download makes progress. Last call has |done| == true.
863///
864/// Experimental: may change without notice.
865///
866/// Payload of the `Browser.downloadProgress` event.
867#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
868pub struct DownloadProgressEvent {
869    /// Global unique identifier of the download.
870    pub guid: String,
871    /// Total expected bytes to download.
872    #[serde(rename = "totalBytes")]
873    pub total_bytes: f64,
874    /// Total bytes received.
875    #[serde(rename = "receivedBytes")]
876    pub received_bytes: f64,
877    /// Download status.
878    pub state: DownloadProgressState,
879    /// If download is "completed", provides the path of the downloaded file.
880    /// Depending on the platform, it is not guaranteed to be set, nor the file is
881    /// guaranteed to exist.
882    ///
883    /// Experimental: may change without notice.
884    #[serde(rename = "filePath", default, skip_serializing_if = "Option::is_none")]
885    pub file_path: Option<String>,
886}
887
888/// The values `state` accepts on `downloadProgress`.
889#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
890pub enum DownloadProgressState {
891    /// `inProgress`
892    #[serde(rename = "inProgress")]
893    InProgress,
894    /// `completed`
895    #[serde(rename = "completed")]
896    Completed,
897    /// `canceled`
898    #[serde(rename = "canceled")]
899    Canceled,
900    /// A value this vendored schema does not list. Chrome adds values ahead of
901    /// the published protocol, so an unrecognised one is kept as it arrived
902    /// rather than failing the payload it came in.
903    #[serde(untagged)]
904    Unrecognized(String),
905}
906
907impl crate::typed::Event for DownloadProgressEvent {
908    const METHOD: &'static str = "Browser.downloadProgress";
909}