cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! The Browser domain defines methods and events for browser managing.
//!
//! Types, command parameters and event payloads for the `Browser`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].

use serde::{Deserialize, Serialize};

/// Experimental: may change without notice.
pub type BrowserContextId = String;

/// Experimental: may change without notice.
pub type WindowId = i64;

/// The state of the browser window.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum WindowState {
    /// `normal`
    #[serde(rename = "normal")]
    Normal,
    /// `minimized`
    #[serde(rename = "minimized")]
    Minimized,
    /// `maximized`
    #[serde(rename = "maximized")]
    Maximized,
    /// `fullscreen`
    #[serde(rename = "fullscreen")]
    Fullscreen,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Browser window bounds information
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Bounds {
    /// The offset from the left edge of the screen to the window in pixels.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub left: Option<i64>,
    /// The offset from the top edge of the screen to the window in pixels.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub top: Option<i64>,
    /// The window width in pixels.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
    /// The window height in pixels.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
    /// The window state. Default to normal.
    #[serde(
        rename = "windowState",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub window_state: Option<WindowState>,
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PermissionType {
    /// `ar`
    #[serde(rename = "ar")]
    Ar,
    /// `audioCapture`
    #[serde(rename = "audioCapture")]
    AudioCapture,
    /// `automaticFullscreen`
    #[serde(rename = "automaticFullscreen")]
    AutomaticFullscreen,
    /// `backgroundFetch`
    #[serde(rename = "backgroundFetch")]
    BackgroundFetch,
    /// `backgroundSync`
    #[serde(rename = "backgroundSync")]
    BackgroundSync,
    /// `cameraPanTiltZoom`
    #[serde(rename = "cameraPanTiltZoom")]
    CameraPanTiltZoom,
    /// `capturedSurfaceControl`
    #[serde(rename = "capturedSurfaceControl")]
    CapturedSurfaceControl,
    /// `clipboardReadWrite`
    #[serde(rename = "clipboardReadWrite")]
    ClipboardReadWrite,
    /// `clipboardSanitizedWrite`
    #[serde(rename = "clipboardSanitizedWrite")]
    ClipboardSanitizedWrite,
    /// `displayCapture`
    #[serde(rename = "displayCapture")]
    DisplayCapture,
    /// `durableStorage`
    #[serde(rename = "durableStorage")]
    DurableStorage,
    /// `geolocation`
    #[serde(rename = "geolocation")]
    Geolocation,
    /// `handTracking`
    #[serde(rename = "handTracking")]
    HandTracking,
    /// `idleDetection`
    #[serde(rename = "idleDetection")]
    IdleDetection,
    /// `keyboardLock`
    #[serde(rename = "keyboardLock")]
    KeyboardLock,
    /// `localFonts`
    #[serde(rename = "localFonts")]
    LocalFonts,
    /// `localNetwork`
    #[serde(rename = "localNetwork")]
    LocalNetwork,
    /// `localNetworkAccess`
    #[serde(rename = "localNetworkAccess")]
    LocalNetworkAccess,
    /// `loopbackNetwork`
    #[serde(rename = "loopbackNetwork")]
    LoopbackNetwork,
    /// `midi`
    #[serde(rename = "midi")]
    Midi,
    /// `midiSysex`
    #[serde(rename = "midiSysex")]
    MidiSysex,
    /// `nfc`
    #[serde(rename = "nfc")]
    Nfc,
    /// `notifications`
    #[serde(rename = "notifications")]
    Notifications,
    /// `paymentHandler`
    #[serde(rename = "paymentHandler")]
    PaymentHandler,
    /// `periodicBackgroundSync`
    #[serde(rename = "periodicBackgroundSync")]
    PeriodicBackgroundSync,
    /// `pointerLock`
    #[serde(rename = "pointerLock")]
    PointerLock,
    /// `protectedMediaIdentifier`
    #[serde(rename = "protectedMediaIdentifier")]
    ProtectedMediaIdentifier,
    /// `sensors`
    #[serde(rename = "sensors")]
    Sensors,
    /// `smartCard`
    #[serde(rename = "smartCard")]
    SmartCard,
    /// `speakerSelection`
    #[serde(rename = "speakerSelection")]
    SpeakerSelection,
    /// `storageAccess`
    #[serde(rename = "storageAccess")]
    StorageAccess,
    /// `videoCapture`
    #[serde(rename = "videoCapture")]
    VideoCapture,
    /// `vr`
    #[serde(rename = "vr")]
    Vr,
    /// `wakeLockScreen`
    #[serde(rename = "wakeLockScreen")]
    WakeLockScreen,
    /// `wakeLockSystem`
    #[serde(rename = "wakeLockSystem")]
    WakeLockSystem,
    /// `webAppInstallation`
    #[serde(rename = "webAppInstallation")]
    WebAppInstallation,
    /// `webPrinting`
    #[serde(rename = "webPrinting")]
    WebPrinting,
    /// `windowManagement`
    #[serde(rename = "windowManagement")]
    WindowManagement,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum PermissionSetting {
    /// `granted`
    #[serde(rename = "granted")]
    Granted,
    /// `denied`
    #[serde(rename = "denied")]
    Denied,
    /// `prompt`
    #[serde(rename = "prompt")]
    Prompt,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Definition of PermissionDescriptor defined in the Permissions API:
/// <https://w3c.github.io/permissions/#dom-permissiondescriptor>.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct PermissionDescriptor {
    /// Name of permission. See
    /// <https://cs.chromium.org/chromium/src/third_party/blink/renderer/modules/permissions/permission_descriptor.idl>
    /// for valid permission names.
    pub name: String,
    /// For "midi" permission, may also specify sysex control.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub sysex: Option<bool>,
    /// For "push" permission, may specify userVisibleOnly. Note that
    /// userVisibleOnly = true is the only currently supported type.
    #[serde(
        rename = "userVisibleOnly",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub user_visible_only: Option<bool>,
    /// For "clipboard" permission, may specify allowWithoutSanitization.
    #[serde(
        rename = "allowWithoutSanitization",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub allow_without_sanitization: Option<bool>,
    /// For "fullscreen" permission, must specify allowWithoutGesture:true.
    #[serde(
        rename = "allowWithoutGesture",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub allow_without_gesture: Option<bool>,
    /// For "camera" permission, may specify panTiltZoom.
    #[serde(
        rename = "panTiltZoom",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub pan_tilt_zoom: Option<bool>,
}

/// Browser command ids used by executeBrowserCommand.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum BrowserCommandId {
    /// `openTabSearch`
    #[serde(rename = "openTabSearch")]
    OpenTabSearch,
    /// `closeTabSearch`
    #[serde(rename = "closeTabSearch")]
    CloseTabSearch,
    /// `openGlic`
    #[serde(rename = "openGlic")]
    OpenGlic,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Chrome histogram bucket.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Bucket {
    /// Minimum value (inclusive).
    pub low: i64,
    /// Maximum value (exclusive).
    pub high: i64,
    /// Number of samples.
    pub count: i64,
}

/// Chrome histogram.
///
/// Experimental: may change without notice.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct Histogram {
    /// Name.
    pub name: String,
    /// Sum of sample values.
    pub sum: i64,
    /// Total number of samples.
    pub count: i64,
    /// Buckets.
    pub buckets: Vec<Bucket>,
}

/// Set permission settings for given embedding and embedded origins.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setPermission`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SetPermissionParams {
    /// Descriptor of permission to override.
    pub permission: PermissionDescriptor,
    /// Setting of the permission.
    pub setting: PermissionSetting,
    /// Embedding origin the permission applies to, all origins if not specified.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub origin: Option<String>,
    /// Embedded origin the permission applies to. It is ignored unless the
    /// embedding origin is present and valid. If the embedding origin is provided
    /// but the embedded origin isn't, the embedding origin is used as the
    /// embedded origin.
    #[serde(
        rename = "embeddedOrigin",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub embedded_origin: Option<String>,
    /// Context to override. When omitted, default browser context is used.
    #[serde(
        rename = "browserContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub browser_context_id: Option<BrowserContextId>,
}

impl crate::typed::Command for SetPermissionParams {
    const METHOD: &'static str = "Browser.setPermission";
    type Returns = crate::typed::NoReturns;
}

/// Grant specific permissions to the given origin and reject all others.
/// Deprecated. Use setPermission instead.
///
/// Deprecated in the protocol.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.grantPermissions`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GrantPermissionsParams {
    pub permissions: Vec<PermissionType>,
    /// Origin the permission applies to, all origins if not specified.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub origin: Option<String>,
    /// BrowserContext to override permissions. When omitted, default browser
    /// context is used.
    #[serde(
        rename = "browserContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub browser_context_id: Option<BrowserContextId>,
}

impl crate::typed::Command for GrantPermissionsParams {
    const METHOD: &'static str = "Browser.grantPermissions";
    type Returns = crate::typed::NoReturns;
}

/// Reset all permission management for all origins.
///
/// Parameters of `Browser.resetPermissions`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ResetPermissionsParams {
    /// BrowserContext to reset permissions. When omitted, default browser context
    /// is used.
    #[serde(
        rename = "browserContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub browser_context_id: Option<BrowserContextId>,
}

impl crate::typed::Command for ResetPermissionsParams {
    const METHOD: &'static str = "Browser.resetPermissions";
    type Returns = crate::typed::NoReturns;
}

/// Set the behavior when downloading a file.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setDownloadBehavior`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SetDownloadBehaviorParams {
    /// 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.
    pub behavior: SetDownloadBehaviorBehavior,
    /// BrowserContext to set download behavior. When omitted, default browser
    /// context is used.
    #[serde(
        rename = "browserContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub browser_context_id: Option<BrowserContextId>,
    /// The default path to save downloaded files to. This is required if behavior
    /// is set to 'allow' or 'allowAndName'.
    #[serde(
        rename = "downloadPath",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub download_path: Option<String>,
    /// Whether to emit download events (defaults to false).
    #[serde(
        rename = "eventsEnabled",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub events_enabled: Option<bool>,
}

/// The values `behavior` accepts on `setDownloadBehavior`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum SetDownloadBehaviorBehavior {
    /// `deny`
    #[serde(rename = "deny")]
    Deny,
    /// `allow`
    #[serde(rename = "allow")]
    Allow,
    /// `allowAndName`
    #[serde(rename = "allowAndName")]
    AllowAndName,
    /// `default`
    #[serde(rename = "default")]
    Default,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

impl crate::typed::Command for SetDownloadBehaviorParams {
    const METHOD: &'static str = "Browser.setDownloadBehavior";
    type Returns = crate::typed::NoReturns;
}

/// Cancel a download if in progress
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.cancelDownload`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CancelDownloadParams {
    /// Global unique identifier of the download.
    pub guid: String,
    /// BrowserContext to perform the action in. When omitted, default browser
    /// context is used.
    #[serde(
        rename = "browserContextId",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub browser_context_id: Option<BrowserContextId>,
}

impl crate::typed::Command for CancelDownloadParams {
    const METHOD: &'static str = "Browser.cancelDownload";
    type Returns = crate::typed::NoReturns;
}

/// Close browser gracefully.
///
/// Parameters of `Browser.close`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CloseParams {}

impl crate::typed::Command for CloseParams {
    const METHOD: &'static str = "Browser.close";
    type Returns = crate::typed::NoReturns;
}

/// Crashes browser on the main thread.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.crash`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CrashParams {}

impl crate::typed::Command for CrashParams {
    const METHOD: &'static str = "Browser.crash";
    type Returns = crate::typed::NoReturns;
}

/// Crashes GPU process.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.crashGpuProcess`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct CrashGpuProcessParams {}

impl crate::typed::Command for CrashGpuProcessParams {
    const METHOD: &'static str = "Browser.crashGpuProcess";
    type Returns = crate::typed::NoReturns;
}

/// Returns version information.
///
/// Parameters of `Browser.getVersion`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetVersionParams {}

/// What `Browser.getVersion` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetVersionReturns {
    /// Protocol version.
    #[serde(rename = "protocolVersion")]
    pub protocol_version: String,
    /// Product name.
    pub product: String,
    /// Product revision.
    pub revision: String,
    /// User-Agent.
    #[serde(rename = "userAgent")]
    pub user_agent: String,
    /// V8 version.
    #[serde(rename = "jsVersion")]
    pub js_version: String,
}

impl crate::typed::Command for GetVersionParams {
    const METHOD: &'static str = "Browser.getVersion";
    type Returns = GetVersionReturns;
}

/// Returns the command line switches for the browser process if, and only if
/// --enable-automation is on the commandline.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getBrowserCommandLine`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetBrowserCommandLineParams {}

/// What `Browser.getBrowserCommandLine` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetBrowserCommandLineReturns {
    /// Commandline parameters
    pub arguments: Vec<String>,
}

impl crate::typed::Command for GetBrowserCommandLineParams {
    const METHOD: &'static str = "Browser.getBrowserCommandLine";
    type Returns = GetBrowserCommandLineReturns;
}

/// Adds or updates a mock camera in the shared video capture device list for
/// test automation. The mock camera is not scoped to a particular page or
/// frame and is removed when the DevTools session that created it
/// disconnects.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.addMockCamera`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddMockCameraParams {
    /// Required non-empty identifier for the mock camera within the current
    /// DevTools session. Different sessions can use the same identifier without
    /// replacing each other's cameras. This is not the MediaDeviceInfo.deviceId
    /// exposed to the page.
    #[serde(rename = "deviceId")]
    pub device_id: String,
}

impl crate::typed::Command for AddMockCameraParams {
    const METHOD: &'static str = "Browser.addMockCamera";
    type Returns = crate::typed::NoReturns;
}

/// Get Chrome histograms.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getHistograms`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHistogramsParams {
    /// Requested substring in name. Only histograms which have query as a
    /// substring in their name are extracted. An empty or absent query returns
    /// all histograms.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub query: Option<String>,
    /// If true, retrieve delta since last delta call.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delta: Option<bool>,
}

/// What `Browser.getHistograms` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHistogramsReturns {
    /// Histograms.
    pub histograms: Vec<Histogram>,
}

impl crate::typed::Command for GetHistogramsParams {
    const METHOD: &'static str = "Browser.getHistograms";
    type Returns = GetHistogramsReturns;
}

/// Get a Chrome histogram by name.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getHistogram`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHistogramParams {
    /// Requested histogram name.
    pub name: String,
    /// If true, retrieve delta since last delta call.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub delta: Option<bool>,
}

/// What `Browser.getHistogram` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetHistogramReturns {
    /// Histogram.
    pub histogram: Histogram,
}

impl crate::typed::Command for GetHistogramParams {
    const METHOD: &'static str = "Browser.getHistogram";
    type Returns = GetHistogramReturns;
}

/// Get position and size of the browser window.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getWindowBounds`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetWindowBoundsParams {
    /// Browser window id.
    #[serde(rename = "windowId")]
    pub window_id: WindowId,
}

/// What `Browser.getWindowBounds` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetWindowBoundsReturns {
    /// Bounds information of the window. When window state is 'minimized', the
    /// restored window position and size are returned.
    pub bounds: Bounds,
}

impl crate::typed::Command for GetWindowBoundsParams {
    const METHOD: &'static str = "Browser.getWindowBounds";
    type Returns = GetWindowBoundsReturns;
}

/// Get the browser window that contains the devtools target.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getWindowForTarget`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetWindowForTargetParams {
    /// Devtools agent host id. If called as a part of the session, associated
    /// targetId is used.
    #[serde(rename = "targetId", default, skip_serializing_if = "Option::is_none")]
    pub target_id: Option<crate::protocol::target::TargetId>,
}

/// What `Browser.getWindowForTarget` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetWindowForTargetReturns {
    /// Browser window id.
    #[serde(rename = "windowId")]
    pub window_id: WindowId,
    /// Bounds information of the window. When window state is 'minimized', the
    /// restored window position and size are returned.
    pub bounds: Bounds,
}

impl crate::typed::Command for GetWindowForTargetParams {
    const METHOD: &'static str = "Browser.getWindowForTarget";
    type Returns = GetWindowForTargetReturns;
}

/// Set position and/or size of the browser window.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setWindowBounds`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetWindowBoundsParams {
    /// Browser window id.
    #[serde(rename = "windowId")]
    pub window_id: WindowId,
    /// New window bounds. The 'minimized', 'maximized' and 'fullscreen' states
    /// cannot be combined with 'left', 'top', 'width' or 'height'. Leaves
    /// unspecified fields unchanged.
    pub bounds: Bounds,
}

impl crate::typed::Command for SetWindowBoundsParams {
    const METHOD: &'static str = "Browser.setWindowBounds";
    type Returns = crate::typed::NoReturns;
}

/// Set size of the browser contents resizing browser window as necessary.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setContentsSize`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetContentsSizeParams {
    /// Browser window id.
    #[serde(rename = "windowId")]
    pub window_id: WindowId,
    /// The window contents width in DIP. Assumes current width if omitted. Must
    /// be specified if 'height' is omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub width: Option<i64>,
    /// The window contents height in DIP. Assumes current height if omitted. Must
    /// be specified if 'width' is omitted.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
}

impl crate::typed::Command for SetContentsSizeParams {
    const METHOD: &'static str = "Browser.setContentsSize";
    type Returns = crate::typed::NoReturns;
}

/// Set dock tile details, platform-specific.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setDockTile`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetDockTileParams {
    #[serde(
        rename = "badgeLabel",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub badge_label: Option<String>,
    /// Png encoded image. (Encoded as a base64 string when passed over JSON)
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub image: Option<String>,
}

impl crate::typed::Command for SetDockTileParams {
    const METHOD: &'static str = "Browser.setDockTile";
    type Returns = crate::typed::NoReturns;
}

/// Invoke custom browser commands used by telemetry.
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.executeBrowserCommand`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ExecuteBrowserCommandParams {
    #[serde(rename = "commandId")]
    pub command_id: BrowserCommandId,
}

impl crate::typed::Command for ExecuteBrowserCommandParams {
    const METHOD: &'static str = "Browser.executeBrowserCommand";
    type Returns = crate::typed::NoReturns;
}

/// Allows a site to use privacy sandbox features that require enrollment
/// without the site actually being enrolled. Only supported on page targets.
///
/// Parameters of `Browser.addPrivacySandboxEnrollmentOverride`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct AddPrivacySandboxEnrollmentOverrideParams {
    pub url: String,
}

impl crate::typed::Command for AddPrivacySandboxEnrollmentOverrideParams {
    const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride";
    type Returns = crate::typed::NoReturns;
}

/// Gets the current globally-applied privacy control status See
/// <https://www.w3.org/TR/gpc/#get-global-privacy-control>
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.getGlobalPrivacyControl`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetGlobalPrivacyControlParams {}

/// What `Browser.getGlobalPrivacyControl` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetGlobalPrivacyControlReturns {
    pub gpc: bool,
}

impl crate::typed::Command for GetGlobalPrivacyControlParams {
    const METHOD: &'static str = "Browser.getGlobalPrivacyControl";
    type Returns = GetGlobalPrivacyControlReturns;
}

/// Sets and then gets the current globally-applied privacy control status See
/// <https://www.w3.org/TR/gpc/#set-global-privacy-control>
///
/// Experimental: may change without notice.
///
/// Parameters of `Browser.setGlobalPrivacyControl`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetGlobalPrivacyControlParams {
    pub gpc: bool,
}

/// What `Browser.setGlobalPrivacyControl` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct SetGlobalPrivacyControlReturns {
    pub gpc: bool,
}

impl crate::typed::Command for SetGlobalPrivacyControlParams {
    const METHOD: &'static str = "Browser.setGlobalPrivacyControl";
    type Returns = SetGlobalPrivacyControlReturns;
}

/// Fired when page is about to start a download.
///
/// Experimental: may change without notice.
///
/// Payload of the `Browser.downloadWillBegin` event.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DownloadWillBeginEvent {
    /// Id of the frame that caused the download to begin.
    #[serde(rename = "frameId")]
    pub frame_id: crate::protocol::page::FrameId,
    /// Global unique identifier of the download.
    pub guid: String,
    /// URL of the resource being downloaded.
    pub url: String,
    /// Suggested file name of the resource (the actual name of the file saved on
    /// disk may differ).
    #[serde(rename = "suggestedFilename")]
    pub suggested_filename: String,
}

impl crate::typed::Event for DownloadWillBeginEvent {
    const METHOD: &'static str = "Browser.downloadWillBegin";
}

/// Fired when download makes progress. Last call has |done| == true.
///
/// Experimental: may change without notice.
///
/// Payload of the `Browser.downloadProgress` event.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DownloadProgressEvent {
    /// Global unique identifier of the download.
    pub guid: String,
    /// Total expected bytes to download.
    #[serde(rename = "totalBytes")]
    pub total_bytes: f64,
    /// Total bytes received.
    #[serde(rename = "receivedBytes")]
    pub received_bytes: f64,
    /// Download status.
    pub state: DownloadProgressState,
    /// If download is "completed", provides the path of the downloaded file.
    /// Depending on the platform, it is not guaranteed to be set, nor the file is
    /// guaranteed to exist.
    ///
    /// Experimental: may change without notice.
    #[serde(rename = "filePath", default, skip_serializing_if = "Option::is_none")]
    pub file_path: Option<String>,
}

/// The values `state` accepts on `downloadProgress`.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum DownloadProgressState {
    /// `inProgress`
    #[serde(rename = "inProgress")]
    InProgress,
    /// `completed`
    #[serde(rename = "completed")]
    Completed,
    /// `canceled`
    #[serde(rename = "canceled")]
    Canceled,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

impl crate::typed::Event for DownloadProgressEvent {
    const METHOD: &'static str = "Browser.downloadProgress";
}