browser-protocol 0.1.2

Generated Rust types and commands for the Chrome DevTools Protocol (browser-protocol)
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
//! The Browser domain defines methods and events for browser managing.
use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;


pub type BrowserContextID = String;


pub type WindowID = i64;

/// The state of the browser window.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum WindowState {
    #[default]
    Normal,
    Minimized,
    Maximized,
    Fullscreen,
}

/// Browser window bounds information

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Bounds {
    /// The offset from the left edge of the screen to the window in pixels.

    #[serde(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(skip_serializing_if = "Option::is_none")]
    pub top: Option<i64>,
    /// The window width in pixels.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u64>,
    /// The window height in pixels.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
    /// The window state. Default to normal.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub windowState: Option<WindowState>,
}


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum PermissionType {
    #[default]
    Ar,
    AudioCapture,
    AutomaticFullscreen,
    BackgroundFetch,
    BackgroundSync,
    CameraPanTiltZoom,
    CapturedSurfaceControl,
    ClipboardReadWrite,
    ClipboardSanitizedWrite,
    DisplayCapture,
    DurableStorage,
    Geolocation,
    HandTracking,
    IdleDetection,
    KeyboardLock,
    LocalFonts,
    LocalNetwork,
    LocalNetworkAccess,
    LoopbackNetwork,
    Midi,
    MidiSysex,
    Nfc,
    Notifications,
    PaymentHandler,
    PeriodicBackgroundSync,
    PointerLock,
    ProtectedMediaIdentifier,
    Sensors,
    SmartCard,
    SpeakerSelection,
    StorageAccess,
    TopLevelStorageAccess,
    VideoCapture,
    Vr,
    WakeLockScreen,
    WakeLockSystem,
    WebAppInstallation,
    WebPrinting,
    WindowManagement,
}


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum PermissionSetting {
    #[default]
    Granted,
    Denied,
    Prompt,
}

/// Definition of PermissionDescriptor defined in the Permissions API:
/// https://w3c.github.io/permissions/#dom-permissiondescriptor.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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(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(skip_serializing_if = "Option::is_none")]
    pub userVisibleOnly: Option<bool>,
    /// For "clipboard" permission, may specify allowWithoutSanitization.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub allowWithoutSanitization: Option<bool>,
    /// For "fullscreen" permission, must specify allowWithoutGesture:true.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub allowWithoutGesture: Option<bool>,
    /// For "camera" permission, may specify panTiltZoom.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub panTiltZoom: Option<bool>,
}

/// Browser command ids used by executeBrowserCommand.

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum BrowserCommandId {
    #[default]
    OpenTabSearch,
    CloseTabSearch,
    OpenGlic,
}

/// Chrome histogram bucket.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Bucket {
    /// Minimum value (inclusive).

    pub low: i64,
    /// Maximum value (exclusive).

    pub high: i64,
    /// Number of samples.

    pub count: u64,
}

/// Chrome histogram.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct Histogram {
    /// Name.

    pub name: String,
    /// Sum of sample values.

    pub sum: i64,
    /// Total number of samples.

    pub count: u64,
    /// Buckets.

    pub buckets: Vec<Bucket>,
}


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum PrivacySandboxAPI {
    #[default]
    BiddingAndAuctionServices,
    TrustedKeyValue,
}

/// Set permission settings for given embedding and embedded origins.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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(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(skip_serializing_if = "Option::is_none")]
    pub embeddedOrigin: Option<String>,
    /// Context to override. When omitted, default browser context is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
}

impl SetPermissionParams { pub const METHOD: &'static str = "Browser.setPermission"; }

impl crate::CdpCommand for SetPermissionParams {
    const METHOD: &'static str = "Browser.setPermission";
    type Response = crate::EmptyReturns;
}

/// Grant specific permissions to the given origin and reject all others. Deprecated. Use
/// setPermission instead.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GrantPermissionsParams {

    pub permissions: Vec<PermissionType>,
    /// Origin the permission applies to, all origins if not specified.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub origin: Option<String>,
    /// BrowserContext to override permissions. When omitted, default browser context is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
}

impl GrantPermissionsParams { pub const METHOD: &'static str = "Browser.grantPermissions"; }

impl crate::CdpCommand for GrantPermissionsParams {
    const METHOD: &'static str = "Browser.grantPermissions";
    type Response = crate::EmptyReturns;
}

/// Reset all permission management for all origins.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ResetPermissionsParams {
    /// BrowserContext to reset permissions. When omitted, default browser context is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
}

impl ResetPermissionsParams { pub const METHOD: &'static str = "Browser.resetPermissions"; }

impl crate::CdpCommand for ResetPermissionsParams {
    const METHOD: &'static str = "Browser.resetPermissions";
    type Response = crate::EmptyReturns;
}

/// Set the behavior when downloading a file.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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: String,
    /// BrowserContext to set download behavior. When omitted, default browser context is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
    /// The default path to save downloaded files to. This is required if behavior is set to 'allow'
    /// or 'allowAndName'.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub downloadPath: Option<String>,
    /// Whether to emit download events (defaults to false).

    #[serde(skip_serializing_if = "Option::is_none")]
    pub eventsEnabled: Option<bool>,
}

impl SetDownloadBehaviorParams { pub const METHOD: &'static str = "Browser.setDownloadBehavior"; }

impl crate::CdpCommand for SetDownloadBehaviorParams {
    const METHOD: &'static str = "Browser.setDownloadBehavior";
    type Response = crate::EmptyReturns;
}

/// Cancel a download if in progress

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
}

impl CancelDownloadParams { pub const METHOD: &'static str = "Browser.cancelDownload"; }

impl crate::CdpCommand for CancelDownloadParams {
    const METHOD: &'static str = "Browser.cancelDownload";
    type Response = crate::EmptyReturns;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CloseParams {}

impl CloseParams { pub const METHOD: &'static str = "Browser.close"; }

impl crate::CdpCommand for CloseParams {
    const METHOD: &'static str = "Browser.close";
    type Response = crate::EmptyReturns;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CrashParams {}

impl CrashParams { pub const METHOD: &'static str = "Browser.crash"; }

impl crate::CdpCommand for CrashParams {
    const METHOD: &'static str = "Browser.crash";
    type Response = crate::EmptyReturns;
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct CrashGpuProcessParams {}

impl CrashGpuProcessParams { pub const METHOD: &'static str = "Browser.crashGpuProcess"; }

impl crate::CdpCommand for CrashGpuProcessParams {
    const METHOD: &'static str = "Browser.crashGpuProcess";
    type Response = crate::EmptyReturns;
}

/// Returns version information.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetVersionReturns {
    /// Protocol version.

    pub protocolVersion: String,
    /// Product name.

    pub product: String,
    /// Product revision.

    pub revision: String,
    /// User-Agent.

    pub userAgent: String,
    /// V8 version.

    pub jsVersion: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetVersionParams {}

impl GetVersionParams { pub const METHOD: &'static str = "Browser.getVersion"; }

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

/// Returns the command line switches for the browser process if, and only if
/// --enable-automation is on the commandline.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetBrowserCommandLineReturns {
    /// Commandline parameters

    pub arguments: Vec<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct GetBrowserCommandLineParams {}

impl GetBrowserCommandLineParams { pub const METHOD: &'static str = "Browser.getBrowserCommandLine"; }

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

/// Get Chrome histograms.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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(skip_serializing_if = "Option::is_none")]
    pub query: Option<String>,
    /// If true, retrieve delta since last delta call.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub delta: Option<bool>,
}

/// Get Chrome histograms.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetHistogramsReturns {
    /// Histograms.

    pub histograms: Vec<Histogram>,
}

impl GetHistogramsParams { pub const METHOD: &'static str = "Browser.getHistograms"; }

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

/// Get a Chrome histogram by name.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetHistogramParams {
    /// Requested histogram name.

    pub name: String,
    /// If true, retrieve delta since last delta call.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub delta: Option<bool>,
}

/// Get a Chrome histogram by name.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetHistogramReturns {
    /// Histogram.

    pub histogram: Histogram,
}

impl GetHistogramParams { pub const METHOD: &'static str = "Browser.getHistogram"; }

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

/// Get position and size of the browser window.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetWindowBoundsParams {
    /// Browser window id.

    pub windowId: WindowID,
}

/// Get position and size of the browser window.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
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 GetWindowBoundsParams { pub const METHOD: &'static str = "Browser.getWindowBounds"; }

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

/// Get the browser window that contains the devtools target.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetWindowForTargetParams {
    /// Devtools agent host id. If called as a part of the session, associated targetId is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub targetId: Option<crate::target::TargetID>,
}

/// Get the browser window that contains the devtools target.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct GetWindowForTargetReturns {
    /// Browser window id.

    pub windowId: WindowID,
    /// Bounds information of the window. When window state is 'minimized', the restored window
    /// position and size are returned.

    pub bounds: Bounds,
}

impl GetWindowForTargetParams { pub const METHOD: &'static str = "Browser.getWindowForTarget"; }

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

/// Set position and/or size of the browser window.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetWindowBoundsParams {
    /// Browser window id.

    pub windowId: 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 SetWindowBoundsParams { pub const METHOD: &'static str = "Browser.setWindowBounds"; }

impl crate::CdpCommand for SetWindowBoundsParams {
    const METHOD: &'static str = "Browser.setWindowBounds";
    type Response = crate::EmptyReturns;
}

/// Set size of the browser contents resizing browser window as necessary.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetContentsSizeParams {
    /// Browser window id.

    pub windowId: WindowID,
    /// The window contents width in DIP. Assumes current width if omitted.
    /// Must be specified if 'height' is omitted.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub width: Option<u64>,
    /// The window contents height in DIP. Assumes current height if omitted.
    /// Must be specified if 'width' is omitted.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub height: Option<i64>,
}

impl SetContentsSizeParams { pub const METHOD: &'static str = "Browser.setContentsSize"; }

impl crate::CdpCommand for SetContentsSizeParams {
    const METHOD: &'static str = "Browser.setContentsSize";
    type Response = crate::EmptyReturns;
}

/// Set dock tile details, platform-specific.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetDockTileParams {

    #[serde(skip_serializing_if = "Option::is_none")]
    pub badgeLabel: Option<String>,
    /// Png encoded image. (Encoded as a base64 string when passed over JSON)

    #[serde(skip_serializing_if = "Option::is_none")]
    pub image: Option<String>,
}

impl SetDockTileParams { pub const METHOD: &'static str = "Browser.setDockTile"; }

impl crate::CdpCommand for SetDockTileParams {
    const METHOD: &'static str = "Browser.setDockTile";
    type Response = crate::EmptyReturns;
}

/// Invoke custom browser commands used by telemetry.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ExecuteBrowserCommandParams {

    pub commandId: BrowserCommandId,
}

impl ExecuteBrowserCommandParams { pub const METHOD: &'static str = "Browser.executeBrowserCommand"; }

impl crate::CdpCommand for ExecuteBrowserCommandParams {
    const METHOD: &'static str = "Browser.executeBrowserCommand";
    type Response = crate::EmptyReturns;
}

/// Allows a site to use privacy sandbox features that require enrollment
/// without the site actually being enrolled. Only supported on page targets.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddPrivacySandboxEnrollmentOverrideParams {

    pub url: String,
}

impl AddPrivacySandboxEnrollmentOverrideParams { pub const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride"; }

impl crate::CdpCommand for AddPrivacySandboxEnrollmentOverrideParams {
    const METHOD: &'static str = "Browser.addPrivacySandboxEnrollmentOverride";
    type Response = crate::EmptyReturns;
}

/// Configures encryption keys used with a given privacy sandbox API to talk
/// to a trusted coordinator.  Since this is intended for test automation only,
/// coordinatorOrigin must be a .test domain. No existing coordinator
/// configuration for the origin may exist.

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddPrivacySandboxCoordinatorKeyConfigParams {

    pub api: PrivacySandboxAPI,

    pub coordinatorOrigin: String,

    pub keyConfig: String,
    /// BrowserContext to perform the action in. When omitted, default browser
    /// context is used.

    #[serde(skip_serializing_if = "Option::is_none")]
    pub browserContextId: Option<BrowserContextID>,
}

impl AddPrivacySandboxCoordinatorKeyConfigParams { pub const METHOD: &'static str = "Browser.addPrivacySandboxCoordinatorKeyConfig"; }

impl crate::CdpCommand for AddPrivacySandboxCoordinatorKeyConfigParams {
    const METHOD: &'static str = "Browser.addPrivacySandboxCoordinatorKeyConfig";
    type Response = crate::EmptyReturns;
}