Skip to main content

browser_protocol/page/
mod.rs

1//! Actions and events related to the inspected page belong to the page domain.
2
3
4use serde::{Serialize, Deserialize};
5use serde_json::Value as JsonValue;
6use std::borrow::Cow;
7
8/// Unique frame identifier.
9
10pub type FrameId<'a> = Cow<'a, str>;
11
12/// Indicates whether a frame has been identified as an ad.
13
14#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
15pub enum AdFrameType {
16    #[default]
17    #[serde(rename = "none")]
18    None,
19    #[serde(rename = "child")]
20    Child,
21    #[serde(rename = "root")]
22    Root,
23}
24
25
26#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
27pub enum AdFrameExplanation {
28    #[default]
29    #[serde(rename = "ParentIsAd")]
30    ParentIsAd,
31    #[serde(rename = "CreatedByAdScript")]
32    CreatedByAdScript,
33    #[serde(rename = "MatchedBlockingRule")]
34    MatchedBlockingRule,
35}
36
37/// Indicates whether a frame has been identified as an ad and why.
38
39#[derive(Debug, Clone, Serialize, Deserialize, Default)]
40#[serde(rename_all = "camelCase")]
41pub struct AdFrameStatus {
42    adFrameType: AdFrameType,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    explanations: Option<Vec<AdFrameExplanation>>,
45}
46
47impl AdFrameStatus {
48    pub fn builder(adFrameType: AdFrameType) -> AdFrameStatusBuilder {
49        AdFrameStatusBuilder {
50            adFrameType: adFrameType,
51            explanations: None,
52        }
53    }
54    pub fn adFrameType(&self) -> &AdFrameType { &self.adFrameType }
55    pub fn explanations(&self) -> Option<&[AdFrameExplanation]> { self.explanations.as_deref() }
56}
57
58
59pub struct AdFrameStatusBuilder {
60    adFrameType: AdFrameType,
61    explanations: Option<Vec<AdFrameExplanation>>,
62}
63
64impl AdFrameStatusBuilder {
65    pub fn explanations(mut self, explanations: Vec<AdFrameExplanation>) -> Self { self.explanations = Some(explanations); self }
66    pub fn build(self) -> AdFrameStatus {
67        AdFrameStatus {
68            adFrameType: self.adFrameType,
69            explanations: self.explanations,
70        }
71    }
72}
73
74/// Indicates whether the frame is a secure context and why it is the case.
75
76#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
77pub enum SecureContextType {
78    #[default]
79    #[serde(rename = "Secure")]
80    Secure,
81    #[serde(rename = "SecureLocalhost")]
82    SecureLocalhost,
83    #[serde(rename = "InsecureScheme")]
84    InsecureScheme,
85    #[serde(rename = "InsecureAncestor")]
86    InsecureAncestor,
87}
88
89/// Indicates whether the frame is cross-origin isolated and why it is the case.
90
91#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
92pub enum CrossOriginIsolatedContextType {
93    #[default]
94    #[serde(rename = "Isolated")]
95    Isolated,
96    #[serde(rename = "NotIsolated")]
97    NotIsolated,
98    #[serde(rename = "NotIsolatedFeatureDisabled")]
99    NotIsolatedFeatureDisabled,
100}
101
102
103#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
104pub enum GatedAPIFeatures {
105    #[default]
106    #[serde(rename = "SharedArrayBuffers")]
107    SharedArrayBuffers,
108    #[serde(rename = "SharedArrayBuffersTransferAllowed")]
109    SharedArrayBuffersTransferAllowed,
110    #[serde(rename = "PerformanceMeasureMemory")]
111    PerformanceMeasureMemory,
112    #[serde(rename = "PerformanceProfile")]
113    PerformanceProfile,
114}
115
116/// All Permissions Policy features. This enum should match the one defined
117/// in services/network/public/cpp/permissions_policy/permissions_policy_features.json5.
118/// LINT.IfChange(PermissionsPolicyFeature)
119
120#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
121pub enum PermissionsPolicyFeature {
122    #[default]
123    #[serde(rename = "accelerometer")]
124    Accelerometer,
125    #[serde(rename = "all-screens-capture")]
126    AllScreensCapture,
127    #[serde(rename = "ambient-light-sensor")]
128    AmbientLightSensor,
129    #[serde(rename = "aria-notify")]
130    AriaNotify,
131    #[serde(rename = "attribution-reporting")]
132    AttributionReporting,
133    #[serde(rename = "autofill")]
134    Autofill,
135    #[serde(rename = "autoplay")]
136    Autoplay,
137    #[serde(rename = "bluetooth")]
138    Bluetooth,
139    #[serde(rename = "browsing-topics")]
140    BrowsingTopics,
141    #[serde(rename = "camera")]
142    Camera,
143    #[serde(rename = "captured-surface-control")]
144    CapturedSurfaceControl,
145    #[serde(rename = "ch-dpr")]
146    ChDpr,
147    #[serde(rename = "ch-device-memory")]
148    ChDeviceMemory,
149    #[serde(rename = "ch-downlink")]
150    ChDownlink,
151    #[serde(rename = "ch-ect")]
152    ChEct,
153    #[serde(rename = "ch-prefers-color-scheme")]
154    ChPrefersColorScheme,
155    #[serde(rename = "ch-prefers-reduced-motion")]
156    ChPrefersReducedMotion,
157    #[serde(rename = "ch-prefers-reduced-transparency")]
158    ChPrefersReducedTransparency,
159    #[serde(rename = "ch-rtt")]
160    ChRtt,
161    #[serde(rename = "ch-save-data")]
162    ChSaveData,
163    #[serde(rename = "ch-ua")]
164    ChUa,
165    #[serde(rename = "ch-ua-arch")]
166    ChUaArch,
167    #[serde(rename = "ch-ua-bitness")]
168    ChUaBitness,
169    #[serde(rename = "ch-ua-high-entropy-values")]
170    ChUaHighEntropyValues,
171    #[serde(rename = "ch-ua-platform")]
172    ChUaPlatform,
173    #[serde(rename = "ch-ua-model")]
174    ChUaModel,
175    #[serde(rename = "ch-ua-mobile")]
176    ChUaMobile,
177    #[serde(rename = "ch-ua-form-factors")]
178    ChUaFormFactors,
179    #[serde(rename = "ch-ua-full-version")]
180    ChUaFullVersion,
181    #[serde(rename = "ch-ua-full-version-list")]
182    ChUaFullVersionList,
183    #[serde(rename = "ch-ua-platform-version")]
184    ChUaPlatformVersion,
185    #[serde(rename = "ch-ua-wow64")]
186    ChUaWow64,
187    #[serde(rename = "ch-viewport-height")]
188    ChViewportHeight,
189    #[serde(rename = "ch-viewport-width")]
190    ChViewportWidth,
191    #[serde(rename = "ch-width")]
192    ChWidth,
193    #[serde(rename = "clipboard-read")]
194    ClipboardRead,
195    #[serde(rename = "clipboard-write")]
196    ClipboardWrite,
197    #[serde(rename = "compute-pressure")]
198    ComputePressure,
199    #[serde(rename = "controlled-frame")]
200    ControlledFrame,
201    #[serde(rename = "cross-origin-isolated")]
202    CrossOriginIsolated,
203    #[serde(rename = "deferred-fetch")]
204    DeferredFetch,
205    #[serde(rename = "deferred-fetch-minimal")]
206    DeferredFetchMinimal,
207    #[serde(rename = "device-attributes")]
208    DeviceAttributes,
209    #[serde(rename = "digital-credentials-create")]
210    DigitalCredentialsCreate,
211    #[serde(rename = "digital-credentials-get")]
212    DigitalCredentialsGet,
213    #[serde(rename = "direct-sockets")]
214    DirectSockets,
215    #[serde(rename = "direct-sockets-multicast")]
216    DirectSocketsMulticast,
217    #[serde(rename = "direct-sockets-private")]
218    DirectSocketsPrivate,
219    #[serde(rename = "display-capture")]
220    DisplayCapture,
221    #[serde(rename = "document-domain")]
222    DocumentDomain,
223    #[serde(rename = "encrypted-media")]
224    EncryptedMedia,
225    #[serde(rename = "execution-while-out-of-viewport")]
226    ExecutionWhileOutOfViewport,
227    #[serde(rename = "execution-while-not-rendered")]
228    ExecutionWhileNotRendered,
229    #[serde(rename = "focus-without-user-activation")]
230    FocusWithoutUserActivation,
231    #[serde(rename = "fullscreen")]
232    Fullscreen,
233    #[serde(rename = "frobulate")]
234    Frobulate,
235    #[serde(rename = "gamepad")]
236    Gamepad,
237    #[serde(rename = "geolocation")]
238    Geolocation,
239    #[serde(rename = "gyroscope")]
240    Gyroscope,
241    #[serde(rename = "hid")]
242    Hid,
243    #[serde(rename = "identity-credentials-get")]
244    IdentityCredentialsGet,
245    #[serde(rename = "idle-detection")]
246    IdleDetection,
247    #[serde(rename = "interest-cohort")]
248    InterestCohort,
249    #[serde(rename = "join-ad-interest-group")]
250    JoinAdInterestGroup,
251    #[serde(rename = "keyboard-map")]
252    KeyboardMap,
253    #[serde(rename = "language-detector")]
254    LanguageDetector,
255    #[serde(rename = "language-model")]
256    LanguageModel,
257    #[serde(rename = "local-fonts")]
258    LocalFonts,
259    #[serde(rename = "local-network")]
260    LocalNetwork,
261    #[serde(rename = "local-network-access")]
262    LocalNetworkAccess,
263    #[serde(rename = "loopback-network")]
264    LoopbackNetwork,
265    #[serde(rename = "magnetometer")]
266    Magnetometer,
267    #[serde(rename = "manual-text")]
268    ManualText,
269    #[serde(rename = "media-playback-while-not-visible")]
270    MediaPlaybackWhileNotVisible,
271    #[serde(rename = "microphone")]
272    Microphone,
273    #[serde(rename = "midi")]
274    Midi,
275    #[serde(rename = "on-device-speech-recognition")]
276    OnDeviceSpeechRecognition,
277    #[serde(rename = "otp-credentials")]
278    OtpCredentials,
279    #[serde(rename = "payment")]
280    Payment,
281    #[serde(rename = "picture-in-picture")]
282    PictureInPicture,
283    #[serde(rename = "private-aggregation")]
284    PrivateAggregation,
285    #[serde(rename = "private-state-token-issuance")]
286    PrivateStateTokenIssuance,
287    #[serde(rename = "private-state-token-redemption")]
288    PrivateStateTokenRedemption,
289    #[serde(rename = "publickey-credentials-create")]
290    PublickeyCredentialsCreate,
291    #[serde(rename = "publickey-credentials-get")]
292    PublickeyCredentialsGet,
293    #[serde(rename = "record-ad-auction-events")]
294    RecordAdAuctionEvents,
295    #[serde(rename = "rewriter")]
296    Rewriter,
297    #[serde(rename = "run-ad-auction")]
298    RunAdAuction,
299    #[serde(rename = "screen-wake-lock")]
300    ScreenWakeLock,
301    #[serde(rename = "serial")]
302    Serial,
303    #[serde(rename = "shared-storage")]
304    SharedStorage,
305    #[serde(rename = "shared-storage-select-url")]
306    SharedStorageSelectUrl,
307    #[serde(rename = "smart-card")]
308    SmartCard,
309    #[serde(rename = "speaker-selection")]
310    SpeakerSelection,
311    #[serde(rename = "storage-access")]
312    StorageAccess,
313    #[serde(rename = "sub-apps")]
314    SubApps,
315    #[serde(rename = "summarizer")]
316    Summarizer,
317    #[serde(rename = "sync-xhr")]
318    SyncXhr,
319    #[serde(rename = "translator")]
320    Translator,
321    #[serde(rename = "unload")]
322    Unload,
323    #[serde(rename = "usb")]
324    Usb,
325    #[serde(rename = "usb-unrestricted")]
326    UsbUnrestricted,
327    #[serde(rename = "vertical-scroll")]
328    VerticalScroll,
329    #[serde(rename = "web-app-installation")]
330    WebAppInstallation,
331    #[serde(rename = "web-printing")]
332    WebPrinting,
333    #[serde(rename = "web-share")]
334    WebShare,
335    #[serde(rename = "window-management")]
336    WindowManagement,
337    #[serde(rename = "writer")]
338    Writer,
339    #[serde(rename = "xr-spatial-tracking")]
340    XrSpatialTracking,
341}
342
343/// Reason for a permissions policy feature to be disabled.
344
345#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
346pub enum PermissionsPolicyBlockReason {
347    #[default]
348    #[serde(rename = "Header")]
349    Header,
350    #[serde(rename = "IframeAttribute")]
351    IframeAttribute,
352    #[serde(rename = "InFencedFrameTree")]
353    InFencedFrameTree,
354    #[serde(rename = "InIsolatedApp")]
355    InIsolatedApp,
356}
357
358
359#[derive(Debug, Clone, Serialize, Deserialize, Default)]
360#[serde(rename_all = "camelCase")]
361pub struct PermissionsPolicyBlockLocator<'a> {
362    frameId: FrameId<'a>,
363    blockReason: PermissionsPolicyBlockReason,
364}
365
366impl<'a> PermissionsPolicyBlockLocator<'a> {
367    pub fn builder(frameId: FrameId<'a>, blockReason: PermissionsPolicyBlockReason) -> PermissionsPolicyBlockLocatorBuilder<'a> {
368        PermissionsPolicyBlockLocatorBuilder {
369            frameId: frameId,
370            blockReason: blockReason,
371        }
372    }
373    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
374    pub fn blockReason(&self) -> &PermissionsPolicyBlockReason { &self.blockReason }
375}
376
377
378pub struct PermissionsPolicyBlockLocatorBuilder<'a> {
379    frameId: FrameId<'a>,
380    blockReason: PermissionsPolicyBlockReason,
381}
382
383impl<'a> PermissionsPolicyBlockLocatorBuilder<'a> {
384    pub fn build(self) -> PermissionsPolicyBlockLocator<'a> {
385        PermissionsPolicyBlockLocator {
386            frameId: self.frameId,
387            blockReason: self.blockReason,
388        }
389    }
390}
391
392
393#[derive(Debug, Clone, Serialize, Deserialize, Default)]
394#[serde(rename_all = "camelCase")]
395pub struct PermissionsPolicyFeatureState<'a> {
396    feature: PermissionsPolicyFeature,
397    allowed: bool,
398    #[serde(skip_serializing_if = "Option::is_none")]
399    locator: Option<PermissionsPolicyBlockLocator<'a>>,
400}
401
402impl<'a> PermissionsPolicyFeatureState<'a> {
403    pub fn builder(feature: PermissionsPolicyFeature, allowed: bool) -> PermissionsPolicyFeatureStateBuilder<'a> {
404        PermissionsPolicyFeatureStateBuilder {
405            feature: feature,
406            allowed: allowed,
407            locator: None,
408        }
409    }
410    pub fn feature(&self) -> &PermissionsPolicyFeature { &self.feature }
411    pub fn allowed(&self) -> bool { self.allowed }
412    pub fn locator(&self) -> Option<&PermissionsPolicyBlockLocator<'a>> { self.locator.as_ref() }
413}
414
415
416pub struct PermissionsPolicyFeatureStateBuilder<'a> {
417    feature: PermissionsPolicyFeature,
418    allowed: bool,
419    locator: Option<PermissionsPolicyBlockLocator<'a>>,
420}
421
422impl<'a> PermissionsPolicyFeatureStateBuilder<'a> {
423    pub fn locator(mut self, locator: PermissionsPolicyBlockLocator<'a>) -> Self { self.locator = Some(locator); self }
424    pub fn build(self) -> PermissionsPolicyFeatureState<'a> {
425        PermissionsPolicyFeatureState {
426            feature: self.feature,
427            allowed: self.allowed,
428            locator: self.locator,
429        }
430    }
431}
432
433/// Origin Trial(https://www.chromium.org/blink/origin-trials) support.
434/// Status for an Origin Trial token.
435
436#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
437pub enum OriginTrialTokenStatus {
438    #[default]
439    #[serde(rename = "Success")]
440    Success,
441    #[serde(rename = "NotSupported")]
442    NotSupported,
443    #[serde(rename = "Insecure")]
444    Insecure,
445    #[serde(rename = "Expired")]
446    Expired,
447    #[serde(rename = "WrongOrigin")]
448    WrongOrigin,
449    #[serde(rename = "InvalidSignature")]
450    InvalidSignature,
451    #[serde(rename = "Malformed")]
452    Malformed,
453    #[serde(rename = "WrongVersion")]
454    WrongVersion,
455    #[serde(rename = "FeatureDisabled")]
456    FeatureDisabled,
457    #[serde(rename = "TokenDisabled")]
458    TokenDisabled,
459    #[serde(rename = "FeatureDisabledForUser")]
460    FeatureDisabledForUser,
461    #[serde(rename = "UnknownTrial")]
462    UnknownTrial,
463}
464
465/// Status for an Origin Trial.
466
467#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
468pub enum OriginTrialStatus {
469    #[default]
470    #[serde(rename = "Enabled")]
471    Enabled,
472    #[serde(rename = "ValidTokenNotProvided")]
473    ValidTokenNotProvided,
474    #[serde(rename = "OSNotSupported")]
475    OSNotSupported,
476    #[serde(rename = "TrialNotAllowed")]
477    TrialNotAllowed,
478}
479
480
481#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
482pub enum OriginTrialUsageRestriction {
483    #[default]
484    #[serde(rename = "None")]
485    None,
486    #[serde(rename = "Subset")]
487    Subset,
488}
489
490
491#[derive(Debug, Clone, Serialize, Deserialize, Default)]
492#[serde(rename_all = "camelCase")]
493pub struct OriginTrialToken<'a> {
494    origin: Cow<'a, str>,
495    matchSubDomains: bool,
496    trialName: Cow<'a, str>,
497    expiryTime: crate::network::TimeSinceEpoch,
498    isThirdParty: bool,
499    usageRestriction: OriginTrialUsageRestriction,
500}
501
502impl<'a> OriginTrialToken<'a> {
503    pub fn builder(origin: impl Into<Cow<'a, str>>, matchSubDomains: bool, trialName: impl Into<Cow<'a, str>>, expiryTime: crate::network::TimeSinceEpoch, isThirdParty: bool, usageRestriction: OriginTrialUsageRestriction) -> OriginTrialTokenBuilder<'a> {
504        OriginTrialTokenBuilder {
505            origin: origin.into(),
506            matchSubDomains: matchSubDomains,
507            trialName: trialName.into(),
508            expiryTime: expiryTime,
509            isThirdParty: isThirdParty,
510            usageRestriction: usageRestriction,
511        }
512    }
513    pub fn origin(&self) -> &str { self.origin.as_ref() }
514    pub fn matchSubDomains(&self) -> bool { self.matchSubDomains }
515    pub fn trialName(&self) -> &str { self.trialName.as_ref() }
516    pub fn expiryTime(&self) -> &crate::network::TimeSinceEpoch { &self.expiryTime }
517    pub fn isThirdParty(&self) -> bool { self.isThirdParty }
518    pub fn usageRestriction(&self) -> &OriginTrialUsageRestriction { &self.usageRestriction }
519}
520
521
522pub struct OriginTrialTokenBuilder<'a> {
523    origin: Cow<'a, str>,
524    matchSubDomains: bool,
525    trialName: Cow<'a, str>,
526    expiryTime: crate::network::TimeSinceEpoch,
527    isThirdParty: bool,
528    usageRestriction: OriginTrialUsageRestriction,
529}
530
531impl<'a> OriginTrialTokenBuilder<'a> {
532    pub fn build(self) -> OriginTrialToken<'a> {
533        OriginTrialToken {
534            origin: self.origin,
535            matchSubDomains: self.matchSubDomains,
536            trialName: self.trialName,
537            expiryTime: self.expiryTime,
538            isThirdParty: self.isThirdParty,
539            usageRestriction: self.usageRestriction,
540        }
541    }
542}
543
544
545#[derive(Debug, Clone, Serialize, Deserialize, Default)]
546#[serde(rename_all = "camelCase")]
547pub struct OriginTrialTokenWithStatus<'a> {
548    rawTokenText: Cow<'a, str>,
549    /// 'parsedToken' is present only when the token is extractable and
550    /// parsable.
551    #[serde(skip_serializing_if = "Option::is_none")]
552    parsedToken: Option<OriginTrialToken<'a>>,
553    status: OriginTrialTokenStatus,
554}
555
556impl<'a> OriginTrialTokenWithStatus<'a> {
557    pub fn builder(rawTokenText: impl Into<Cow<'a, str>>, status: OriginTrialTokenStatus) -> OriginTrialTokenWithStatusBuilder<'a> {
558        OriginTrialTokenWithStatusBuilder {
559            rawTokenText: rawTokenText.into(),
560            parsedToken: None,
561            status: status,
562        }
563    }
564    pub fn rawTokenText(&self) -> &str { self.rawTokenText.as_ref() }
565    pub fn parsedToken(&self) -> Option<&OriginTrialToken<'a>> { self.parsedToken.as_ref() }
566    pub fn status(&self) -> &OriginTrialTokenStatus { &self.status }
567}
568
569
570pub struct OriginTrialTokenWithStatusBuilder<'a> {
571    rawTokenText: Cow<'a, str>,
572    parsedToken: Option<OriginTrialToken<'a>>,
573    status: OriginTrialTokenStatus,
574}
575
576impl<'a> OriginTrialTokenWithStatusBuilder<'a> {
577    /// 'parsedToken' is present only when the token is extractable and
578    /// parsable.
579    pub fn parsedToken(mut self, parsedToken: OriginTrialToken<'a>) -> Self { self.parsedToken = Some(parsedToken); self }
580    pub fn build(self) -> OriginTrialTokenWithStatus<'a> {
581        OriginTrialTokenWithStatus {
582            rawTokenText: self.rawTokenText,
583            parsedToken: self.parsedToken,
584            status: self.status,
585        }
586    }
587}
588
589
590#[derive(Debug, Clone, Serialize, Deserialize, Default)]
591#[serde(rename_all = "camelCase")]
592pub struct OriginTrial<'a> {
593    trialName: Cow<'a, str>,
594    status: OriginTrialStatus,
595    tokensWithStatus: Vec<OriginTrialTokenWithStatus<'a>>,
596}
597
598impl<'a> OriginTrial<'a> {
599    pub fn builder(trialName: impl Into<Cow<'a, str>>, status: OriginTrialStatus, tokensWithStatus: Vec<OriginTrialTokenWithStatus<'a>>) -> OriginTrialBuilder<'a> {
600        OriginTrialBuilder {
601            trialName: trialName.into(),
602            status: status,
603            tokensWithStatus: tokensWithStatus,
604        }
605    }
606    pub fn trialName(&self) -> &str { self.trialName.as_ref() }
607    pub fn status(&self) -> &OriginTrialStatus { &self.status }
608    pub fn tokensWithStatus(&self) -> &[OriginTrialTokenWithStatus<'a>] { &self.tokensWithStatus }
609}
610
611
612pub struct OriginTrialBuilder<'a> {
613    trialName: Cow<'a, str>,
614    status: OriginTrialStatus,
615    tokensWithStatus: Vec<OriginTrialTokenWithStatus<'a>>,
616}
617
618impl<'a> OriginTrialBuilder<'a> {
619    pub fn build(self) -> OriginTrial<'a> {
620        OriginTrial {
621            trialName: self.trialName,
622            status: self.status,
623            tokensWithStatus: self.tokensWithStatus,
624        }
625    }
626}
627
628/// Additional information about the frame document's security origin.
629
630#[derive(Debug, Clone, Serialize, Deserialize, Default)]
631#[serde(rename_all = "camelCase")]
632pub struct SecurityOriginDetails {
633    /// Indicates whether the frame document's security origin is one
634    /// of the local hostnames (e.g. "localhost") or IP addresses (IPv4
635    /// 127.0.0.0/8 or IPv6 ::1).
636    isLocalhost: bool,
637}
638
639impl SecurityOriginDetails {
640    pub fn builder(isLocalhost: bool) -> SecurityOriginDetailsBuilder {
641        SecurityOriginDetailsBuilder {
642            isLocalhost: isLocalhost,
643        }
644    }
645    pub fn isLocalhost(&self) -> bool { self.isLocalhost }
646}
647
648
649pub struct SecurityOriginDetailsBuilder {
650    isLocalhost: bool,
651}
652
653impl SecurityOriginDetailsBuilder {
654    pub fn build(self) -> SecurityOriginDetails {
655        SecurityOriginDetails {
656            isLocalhost: self.isLocalhost,
657        }
658    }
659}
660
661/// Information about the Frame on the page.
662
663#[derive(Debug, Clone, Serialize, Deserialize, Default)]
664#[serde(rename_all = "camelCase")]
665pub struct Frame<'a> {
666    /// Frame unique identifier.
667    id: FrameId<'a>,
668    /// Parent frame identifier.
669    #[serde(skip_serializing_if = "Option::is_none")]
670    parentId: Option<FrameId<'a>>,
671    /// Identifier of the loader associated with this frame.
672    loaderId: crate::network::LoaderId<'a>,
673    /// Frame's name as specified in the tag.
674    #[serde(skip_serializing_if = "Option::is_none")]
675    name: Option<Cow<'a, str>>,
676    /// Frame document's URL without fragment.
677    url: Cow<'a, str>,
678    /// Frame document's URL fragment including the '#'.
679    #[serde(skip_serializing_if = "Option::is_none")]
680    urlFragment: Option<Cow<'a, str>>,
681    /// Frame document's registered domain, taking the public suffixes list into account.
682    /// Extracted from the Frame's url.
683    /// Example URLs: http://www.google.com/file.html -> "google.com"
684    /// http://a.b.co.uk/file.html      -> "b.co.uk"
685    domainAndRegistry: Cow<'a, str>,
686    /// Frame document's security origin.
687    securityOrigin: Cow<'a, str>,
688    /// Additional details about the frame document's security origin.
689    #[serde(skip_serializing_if = "Option::is_none")]
690    securityOriginDetails: Option<SecurityOriginDetails>,
691    /// Frame document's mimeType as determined by the browser.
692    mimeType: Cow<'a, str>,
693    /// If the frame failed to load, this contains the URL that could not be loaded. Note that unlike url above, this URL may contain a fragment.
694    #[serde(skip_serializing_if = "Option::is_none")]
695    unreachableUrl: Option<Cow<'a, str>>,
696    /// Indicates whether this frame was tagged as an ad and why.
697    #[serde(skip_serializing_if = "Option::is_none")]
698    adFrameStatus: Option<AdFrameStatus>,
699    /// Indicates whether the main document is a secure context and explains why that is the case.
700    secureContextType: SecureContextType,
701    /// Indicates whether this is a cross origin isolated context.
702    crossOriginIsolatedContextType: CrossOriginIsolatedContextType,
703    /// Indicated which gated APIs / features are available.
704    gatedAPIFeatures: Vec<GatedAPIFeatures>,
705}
706
707impl<'a> Frame<'a> {
708    pub fn builder(id: FrameId<'a>, loaderId: crate::network::LoaderId<'a>, url: impl Into<Cow<'a, str>>, domainAndRegistry: impl Into<Cow<'a, str>>, securityOrigin: impl Into<Cow<'a, str>>, mimeType: impl Into<Cow<'a, str>>, secureContextType: SecureContextType, crossOriginIsolatedContextType: CrossOriginIsolatedContextType, gatedAPIFeatures: Vec<GatedAPIFeatures>) -> FrameBuilder<'a> {
709        FrameBuilder {
710            id: id,
711            parentId: None,
712            loaderId: loaderId,
713            name: None,
714            url: url.into(),
715            urlFragment: None,
716            domainAndRegistry: domainAndRegistry.into(),
717            securityOrigin: securityOrigin.into(),
718            securityOriginDetails: None,
719            mimeType: mimeType.into(),
720            unreachableUrl: None,
721            adFrameStatus: None,
722            secureContextType: secureContextType,
723            crossOriginIsolatedContextType: crossOriginIsolatedContextType,
724            gatedAPIFeatures: gatedAPIFeatures,
725        }
726    }
727    pub fn id(&self) -> &FrameId<'a> { &self.id }
728    pub fn parentId(&self) -> Option<&FrameId<'a>> { self.parentId.as_ref() }
729    pub fn loaderId(&self) -> &crate::network::LoaderId<'a> { &self.loaderId }
730    pub fn name(&self) -> Option<&str> { self.name.as_deref() }
731    pub fn url(&self) -> &str { self.url.as_ref() }
732    pub fn urlFragment(&self) -> Option<&str> { self.urlFragment.as_deref() }
733    pub fn domainAndRegistry(&self) -> &str { self.domainAndRegistry.as_ref() }
734    pub fn securityOrigin(&self) -> &str { self.securityOrigin.as_ref() }
735    pub fn securityOriginDetails(&self) -> Option<&SecurityOriginDetails> { self.securityOriginDetails.as_ref() }
736    pub fn mimeType(&self) -> &str { self.mimeType.as_ref() }
737    pub fn unreachableUrl(&self) -> Option<&str> { self.unreachableUrl.as_deref() }
738    pub fn adFrameStatus(&self) -> Option<&AdFrameStatus> { self.adFrameStatus.as_ref() }
739    pub fn secureContextType(&self) -> &SecureContextType { &self.secureContextType }
740    pub fn crossOriginIsolatedContextType(&self) -> &CrossOriginIsolatedContextType { &self.crossOriginIsolatedContextType }
741    pub fn gatedAPIFeatures(&self) -> &[GatedAPIFeatures] { &self.gatedAPIFeatures }
742}
743
744
745pub struct FrameBuilder<'a> {
746    id: FrameId<'a>,
747    parentId: Option<FrameId<'a>>,
748    loaderId: crate::network::LoaderId<'a>,
749    name: Option<Cow<'a, str>>,
750    url: Cow<'a, str>,
751    urlFragment: Option<Cow<'a, str>>,
752    domainAndRegistry: Cow<'a, str>,
753    securityOrigin: Cow<'a, str>,
754    securityOriginDetails: Option<SecurityOriginDetails>,
755    mimeType: Cow<'a, str>,
756    unreachableUrl: Option<Cow<'a, str>>,
757    adFrameStatus: Option<AdFrameStatus>,
758    secureContextType: SecureContextType,
759    crossOriginIsolatedContextType: CrossOriginIsolatedContextType,
760    gatedAPIFeatures: Vec<GatedAPIFeatures>,
761}
762
763impl<'a> FrameBuilder<'a> {
764    /// Parent frame identifier.
765    pub fn parentId(mut self, parentId: FrameId<'a>) -> Self { self.parentId = Some(parentId); self }
766    /// Frame's name as specified in the tag.
767    pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self { self.name = Some(name.into()); self }
768    /// Frame document's URL fragment including the '#'.
769    pub fn urlFragment(mut self, urlFragment: impl Into<Cow<'a, str>>) -> Self { self.urlFragment = Some(urlFragment.into()); self }
770    /// Additional details about the frame document's security origin.
771    pub fn securityOriginDetails(mut self, securityOriginDetails: SecurityOriginDetails) -> Self { self.securityOriginDetails = Some(securityOriginDetails); self }
772    /// If the frame failed to load, this contains the URL that could not be loaded. Note that unlike url above, this URL may contain a fragment.
773    pub fn unreachableUrl(mut self, unreachableUrl: impl Into<Cow<'a, str>>) -> Self { self.unreachableUrl = Some(unreachableUrl.into()); self }
774    /// Indicates whether this frame was tagged as an ad and why.
775    pub fn adFrameStatus(mut self, adFrameStatus: AdFrameStatus) -> Self { self.adFrameStatus = Some(adFrameStatus); self }
776    pub fn build(self) -> Frame<'a> {
777        Frame {
778            id: self.id,
779            parentId: self.parentId,
780            loaderId: self.loaderId,
781            name: self.name,
782            url: self.url,
783            urlFragment: self.urlFragment,
784            domainAndRegistry: self.domainAndRegistry,
785            securityOrigin: self.securityOrigin,
786            securityOriginDetails: self.securityOriginDetails,
787            mimeType: self.mimeType,
788            unreachableUrl: self.unreachableUrl,
789            adFrameStatus: self.adFrameStatus,
790            secureContextType: self.secureContextType,
791            crossOriginIsolatedContextType: self.crossOriginIsolatedContextType,
792            gatedAPIFeatures: self.gatedAPIFeatures,
793        }
794    }
795}
796
797/// Information about the Resource on the page.
798
799#[derive(Debug, Clone, Serialize, Deserialize, Default)]
800#[serde(rename_all = "camelCase")]
801pub struct FrameResource<'a> {
802    /// Resource URL.
803    url: Cow<'a, str>,
804    /// Type of this resource.
805    #[serde(rename = "type")]
806    type_: crate::network::ResourceType,
807    /// Resource mimeType as determined by the browser.
808    mimeType: Cow<'a, str>,
809    /// last-modified timestamp as reported by server.
810    #[serde(skip_serializing_if = "Option::is_none")]
811    lastModified: Option<crate::network::TimeSinceEpoch>,
812    /// Resource content size.
813    #[serde(skip_serializing_if = "Option::is_none")]
814    contentSize: Option<f64>,
815    /// True if the resource failed to load.
816    #[serde(skip_serializing_if = "Option::is_none")]
817    failed: Option<bool>,
818    /// True if the resource was canceled during loading.
819    #[serde(skip_serializing_if = "Option::is_none")]
820    canceled: Option<bool>,
821}
822
823impl<'a> FrameResource<'a> {
824    pub fn builder(url: impl Into<Cow<'a, str>>, type_: crate::network::ResourceType, mimeType: impl Into<Cow<'a, str>>) -> FrameResourceBuilder<'a> {
825        FrameResourceBuilder {
826            url: url.into(),
827            type_: type_,
828            mimeType: mimeType.into(),
829            lastModified: None,
830            contentSize: None,
831            failed: None,
832            canceled: None,
833        }
834    }
835    pub fn url(&self) -> &str { self.url.as_ref() }
836    pub fn type_(&self) -> &crate::network::ResourceType { &self.type_ }
837    pub fn mimeType(&self) -> &str { self.mimeType.as_ref() }
838    pub fn lastModified(&self) -> Option<&crate::network::TimeSinceEpoch> { self.lastModified.as_ref() }
839    pub fn contentSize(&self) -> Option<f64> { self.contentSize }
840    pub fn failed(&self) -> Option<bool> { self.failed }
841    pub fn canceled(&self) -> Option<bool> { self.canceled }
842}
843
844
845pub struct FrameResourceBuilder<'a> {
846    url: Cow<'a, str>,
847    type_: crate::network::ResourceType,
848    mimeType: Cow<'a, str>,
849    lastModified: Option<crate::network::TimeSinceEpoch>,
850    contentSize: Option<f64>,
851    failed: Option<bool>,
852    canceled: Option<bool>,
853}
854
855impl<'a> FrameResourceBuilder<'a> {
856    /// last-modified timestamp as reported by server.
857    pub fn lastModified(mut self, lastModified: crate::network::TimeSinceEpoch) -> Self { self.lastModified = Some(lastModified); self }
858    /// Resource content size.
859    pub fn contentSize(mut self, contentSize: f64) -> Self { self.contentSize = Some(contentSize); self }
860    /// True if the resource failed to load.
861    pub fn failed(mut self, failed: bool) -> Self { self.failed = Some(failed); self }
862    /// True if the resource was canceled during loading.
863    pub fn canceled(mut self, canceled: bool) -> Self { self.canceled = Some(canceled); self }
864    pub fn build(self) -> FrameResource<'a> {
865        FrameResource {
866            url: self.url,
867            type_: self.type_,
868            mimeType: self.mimeType,
869            lastModified: self.lastModified,
870            contentSize: self.contentSize,
871            failed: self.failed,
872            canceled: self.canceled,
873        }
874    }
875}
876
877/// Information about the Frame hierarchy along with their cached resources.
878
879#[derive(Debug, Clone, Serialize, Deserialize, Default)]
880#[serde(rename_all = "camelCase")]
881pub struct FrameResourceTree<'a> {
882    /// Frame information for this tree item.
883    frame: Frame<'a>,
884    /// Child frames.
885    #[serde(skip_serializing_if = "Option::is_none")]
886    childFrames: Option<Vec<Box<FrameResourceTree<'a>>>>,
887    /// Information about frame resources.
888    resources: Vec<FrameResource<'a>>,
889}
890
891impl<'a> FrameResourceTree<'a> {
892    pub fn builder(frame: Frame<'a>, resources: Vec<FrameResource<'a>>) -> FrameResourceTreeBuilder<'a> {
893        FrameResourceTreeBuilder {
894            frame: frame,
895            childFrames: None,
896            resources: resources,
897        }
898    }
899    pub fn frame(&self) -> &Frame<'a> { &self.frame }
900    pub fn childFrames(&self) -> Option<&[Box<FrameResourceTree<'a>>]> { self.childFrames.as_deref() }
901    pub fn resources(&self) -> &[FrameResource<'a>] { &self.resources }
902}
903
904
905pub struct FrameResourceTreeBuilder<'a> {
906    frame: Frame<'a>,
907    childFrames: Option<Vec<Box<FrameResourceTree<'a>>>>,
908    resources: Vec<FrameResource<'a>>,
909}
910
911impl<'a> FrameResourceTreeBuilder<'a> {
912    /// Child frames.
913    pub fn childFrames(mut self, childFrames: Vec<Box<FrameResourceTree<'a>>>) -> Self { self.childFrames = Some(childFrames); self }
914    pub fn build(self) -> FrameResourceTree<'a> {
915        FrameResourceTree {
916            frame: self.frame,
917            childFrames: self.childFrames,
918            resources: self.resources,
919        }
920    }
921}
922
923/// Information about the Frame hierarchy.
924
925#[derive(Debug, Clone, Serialize, Deserialize, Default)]
926#[serde(rename_all = "camelCase")]
927pub struct FrameTree<'a> {
928    /// Frame information for this tree item.
929    frame: Frame<'a>,
930    /// Child frames.
931    #[serde(skip_serializing_if = "Option::is_none")]
932    childFrames: Option<Vec<Box<FrameTree<'a>>>>,
933}
934
935impl<'a> FrameTree<'a> {
936    pub fn builder(frame: Frame<'a>) -> FrameTreeBuilder<'a> {
937        FrameTreeBuilder {
938            frame: frame,
939            childFrames: None,
940        }
941    }
942    pub fn frame(&self) -> &Frame<'a> { &self.frame }
943    pub fn childFrames(&self) -> Option<&[Box<FrameTree<'a>>]> { self.childFrames.as_deref() }
944}
945
946
947pub struct FrameTreeBuilder<'a> {
948    frame: Frame<'a>,
949    childFrames: Option<Vec<Box<FrameTree<'a>>>>,
950}
951
952impl<'a> FrameTreeBuilder<'a> {
953    /// Child frames.
954    pub fn childFrames(mut self, childFrames: Vec<Box<FrameTree<'a>>>) -> Self { self.childFrames = Some(childFrames); self }
955    pub fn build(self) -> FrameTree<'a> {
956        FrameTree {
957            frame: self.frame,
958            childFrames: self.childFrames,
959        }
960    }
961}
962
963/// Unique script identifier.
964
965pub type ScriptIdentifier<'a> = Cow<'a, str>;
966
967/// Transition type.
968
969#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
970pub enum TransitionType {
971    #[default]
972    #[serde(rename = "link")]
973    Link,
974    #[serde(rename = "typed")]
975    Typed,
976    #[serde(rename = "address_bar")]
977    AddressBar,
978    #[serde(rename = "auto_bookmark")]
979    AutoBookmark,
980    #[serde(rename = "auto_subframe")]
981    AutoSubframe,
982    #[serde(rename = "manual_subframe")]
983    ManualSubframe,
984    #[serde(rename = "generated")]
985    Generated,
986    #[serde(rename = "auto_toplevel")]
987    AutoToplevel,
988    #[serde(rename = "form_submit")]
989    FormSubmit,
990    #[serde(rename = "reload")]
991    Reload,
992    #[serde(rename = "keyword")]
993    Keyword,
994    #[serde(rename = "keyword_generated")]
995    KeywordGenerated,
996    #[serde(rename = "other")]
997    Other,
998}
999
1000/// Navigation history entry.
1001
1002#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1003#[serde(rename_all = "camelCase")]
1004pub struct NavigationEntry<'a> {
1005    /// Unique id of the navigation history entry.
1006    id: u64,
1007    /// URL of the navigation history entry.
1008    url: Cow<'a, str>,
1009    /// URL that the user typed in the url bar.
1010    userTypedURL: Cow<'a, str>,
1011    /// Title of the navigation history entry.
1012    title: Cow<'a, str>,
1013    /// Transition type.
1014    transitionType: TransitionType,
1015}
1016
1017impl<'a> NavigationEntry<'a> {
1018    pub fn builder(id: u64, url: impl Into<Cow<'a, str>>, userTypedURL: impl Into<Cow<'a, str>>, title: impl Into<Cow<'a, str>>, transitionType: TransitionType) -> NavigationEntryBuilder<'a> {
1019        NavigationEntryBuilder {
1020            id: id,
1021            url: url.into(),
1022            userTypedURL: userTypedURL.into(),
1023            title: title.into(),
1024            transitionType: transitionType,
1025        }
1026    }
1027    pub fn id(&self) -> u64 { self.id }
1028    pub fn url(&self) -> &str { self.url.as_ref() }
1029    pub fn userTypedURL(&self) -> &str { self.userTypedURL.as_ref() }
1030    pub fn title(&self) -> &str { self.title.as_ref() }
1031    pub fn transitionType(&self) -> &TransitionType { &self.transitionType }
1032}
1033
1034
1035pub struct NavigationEntryBuilder<'a> {
1036    id: u64,
1037    url: Cow<'a, str>,
1038    userTypedURL: Cow<'a, str>,
1039    title: Cow<'a, str>,
1040    transitionType: TransitionType,
1041}
1042
1043impl<'a> NavigationEntryBuilder<'a> {
1044    pub fn build(self) -> NavigationEntry<'a> {
1045        NavigationEntry {
1046            id: self.id,
1047            url: self.url,
1048            userTypedURL: self.userTypedURL,
1049            title: self.title,
1050            transitionType: self.transitionType,
1051        }
1052    }
1053}
1054
1055/// Screencast frame metadata.
1056
1057#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1058#[serde(rename_all = "camelCase")]
1059pub struct ScreencastFrameMetadata {
1060    /// Top offset in DIP.
1061    offsetTop: f64,
1062    /// Page scale factor.
1063    pageScaleFactor: f64,
1064    /// Device screen width in DIP.
1065    deviceWidth: f64,
1066    /// Device screen height in DIP.
1067    deviceHeight: f64,
1068    /// Position of horizontal scroll in CSS pixels.
1069    scrollOffsetX: f64,
1070    /// Position of vertical scroll in CSS pixels.
1071    scrollOffsetY: f64,
1072    /// Frame swap timestamp.
1073    #[serde(skip_serializing_if = "Option::is_none")]
1074    timestamp: Option<crate::network::TimeSinceEpoch>,
1075}
1076
1077impl ScreencastFrameMetadata {
1078    pub fn builder(offsetTop: f64, pageScaleFactor: f64, deviceWidth: f64, deviceHeight: f64, scrollOffsetX: f64, scrollOffsetY: f64) -> ScreencastFrameMetadataBuilder {
1079        ScreencastFrameMetadataBuilder {
1080            offsetTop: offsetTop,
1081            pageScaleFactor: pageScaleFactor,
1082            deviceWidth: deviceWidth,
1083            deviceHeight: deviceHeight,
1084            scrollOffsetX: scrollOffsetX,
1085            scrollOffsetY: scrollOffsetY,
1086            timestamp: None,
1087        }
1088    }
1089    pub fn offsetTop(&self) -> f64 { self.offsetTop }
1090    pub fn pageScaleFactor(&self) -> f64 { self.pageScaleFactor }
1091    pub fn deviceWidth(&self) -> f64 { self.deviceWidth }
1092    pub fn deviceHeight(&self) -> f64 { self.deviceHeight }
1093    pub fn scrollOffsetX(&self) -> f64 { self.scrollOffsetX }
1094    pub fn scrollOffsetY(&self) -> f64 { self.scrollOffsetY }
1095    pub fn timestamp(&self) -> Option<&crate::network::TimeSinceEpoch> { self.timestamp.as_ref() }
1096}
1097
1098
1099pub struct ScreencastFrameMetadataBuilder {
1100    offsetTop: f64,
1101    pageScaleFactor: f64,
1102    deviceWidth: f64,
1103    deviceHeight: f64,
1104    scrollOffsetX: f64,
1105    scrollOffsetY: f64,
1106    timestamp: Option<crate::network::TimeSinceEpoch>,
1107}
1108
1109impl ScreencastFrameMetadataBuilder {
1110    /// Frame swap timestamp.
1111    pub fn timestamp(mut self, timestamp: crate::network::TimeSinceEpoch) -> Self { self.timestamp = Some(timestamp); self }
1112    pub fn build(self) -> ScreencastFrameMetadata {
1113        ScreencastFrameMetadata {
1114            offsetTop: self.offsetTop,
1115            pageScaleFactor: self.pageScaleFactor,
1116            deviceWidth: self.deviceWidth,
1117            deviceHeight: self.deviceHeight,
1118            scrollOffsetX: self.scrollOffsetX,
1119            scrollOffsetY: self.scrollOffsetY,
1120            timestamp: self.timestamp,
1121        }
1122    }
1123}
1124
1125/// Javascript dialog type.
1126
1127#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1128pub enum DialogType {
1129    #[default]
1130    #[serde(rename = "alert")]
1131    Alert,
1132    #[serde(rename = "confirm")]
1133    Confirm,
1134    #[serde(rename = "prompt")]
1135    Prompt,
1136    #[serde(rename = "beforeunload")]
1137    Beforeunload,
1138}
1139
1140/// Error while paring app manifest.
1141
1142#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1143#[serde(rename_all = "camelCase")]
1144pub struct AppManifestError<'a> {
1145    /// Error message.
1146    message: Cow<'a, str>,
1147    /// If critical, this is a non-recoverable parse error.
1148    critical: i64,
1149    /// Error line.
1150    line: i64,
1151    /// Error column.
1152    column: i64,
1153}
1154
1155impl<'a> AppManifestError<'a> {
1156    pub fn builder(message: impl Into<Cow<'a, str>>, critical: i64, line: i64, column: i64) -> AppManifestErrorBuilder<'a> {
1157        AppManifestErrorBuilder {
1158            message: message.into(),
1159            critical: critical,
1160            line: line,
1161            column: column,
1162        }
1163    }
1164    pub fn message(&self) -> &str { self.message.as_ref() }
1165    pub fn critical(&self) -> i64 { self.critical }
1166    pub fn line(&self) -> i64 { self.line }
1167    pub fn column(&self) -> i64 { self.column }
1168}
1169
1170
1171pub struct AppManifestErrorBuilder<'a> {
1172    message: Cow<'a, str>,
1173    critical: i64,
1174    line: i64,
1175    column: i64,
1176}
1177
1178impl<'a> AppManifestErrorBuilder<'a> {
1179    pub fn build(self) -> AppManifestError<'a> {
1180        AppManifestError {
1181            message: self.message,
1182            critical: self.critical,
1183            line: self.line,
1184            column: self.column,
1185        }
1186    }
1187}
1188
1189/// Parsed app manifest properties.
1190
1191#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1192#[serde(rename_all = "camelCase")]
1193pub struct AppManifestParsedProperties<'a> {
1194    /// Computed scope value
1195    scope: Cow<'a, str>,
1196}
1197
1198impl<'a> AppManifestParsedProperties<'a> {
1199    pub fn builder(scope: impl Into<Cow<'a, str>>) -> AppManifestParsedPropertiesBuilder<'a> {
1200        AppManifestParsedPropertiesBuilder {
1201            scope: scope.into(),
1202        }
1203    }
1204    pub fn scope(&self) -> &str { self.scope.as_ref() }
1205}
1206
1207
1208pub struct AppManifestParsedPropertiesBuilder<'a> {
1209    scope: Cow<'a, str>,
1210}
1211
1212impl<'a> AppManifestParsedPropertiesBuilder<'a> {
1213    pub fn build(self) -> AppManifestParsedProperties<'a> {
1214        AppManifestParsedProperties {
1215            scope: self.scope,
1216        }
1217    }
1218}
1219
1220/// Layout viewport position and dimensions.
1221
1222#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1223#[serde(rename_all = "camelCase")]
1224pub struct LayoutViewport {
1225    /// Horizontal offset relative to the document (CSS pixels).
1226    pageX: i64,
1227    /// Vertical offset relative to the document (CSS pixels).
1228    pageY: i64,
1229    /// Width (CSS pixels), excludes scrollbar if present.
1230    clientWidth: u64,
1231    /// Height (CSS pixels), excludes scrollbar if present.
1232    clientHeight: i64,
1233}
1234
1235impl LayoutViewport {
1236    pub fn builder(pageX: i64, pageY: i64, clientWidth: u64, clientHeight: i64) -> LayoutViewportBuilder {
1237        LayoutViewportBuilder {
1238            pageX: pageX,
1239            pageY: pageY,
1240            clientWidth: clientWidth,
1241            clientHeight: clientHeight,
1242        }
1243    }
1244    pub fn pageX(&self) -> i64 { self.pageX }
1245    pub fn pageY(&self) -> i64 { self.pageY }
1246    pub fn clientWidth(&self) -> u64 { self.clientWidth }
1247    pub fn clientHeight(&self) -> i64 { self.clientHeight }
1248}
1249
1250
1251pub struct LayoutViewportBuilder {
1252    pageX: i64,
1253    pageY: i64,
1254    clientWidth: u64,
1255    clientHeight: i64,
1256}
1257
1258impl LayoutViewportBuilder {
1259    pub fn build(self) -> LayoutViewport {
1260        LayoutViewport {
1261            pageX: self.pageX,
1262            pageY: self.pageY,
1263            clientWidth: self.clientWidth,
1264            clientHeight: self.clientHeight,
1265        }
1266    }
1267}
1268
1269/// Visual viewport position, dimensions, and scale.
1270
1271#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1272#[serde(rename_all = "camelCase")]
1273pub struct VisualViewport {
1274    /// Horizontal offset relative to the layout viewport (CSS pixels).
1275    offsetX: f64,
1276    /// Vertical offset relative to the layout viewport (CSS pixels).
1277    offsetY: f64,
1278    /// Horizontal offset relative to the document (CSS pixels).
1279    pageX: f64,
1280    /// Vertical offset relative to the document (CSS pixels).
1281    pageY: f64,
1282    /// Width (CSS pixels), excludes scrollbar if present.
1283    clientWidth: f64,
1284    /// Height (CSS pixels), excludes scrollbar if present.
1285    clientHeight: f64,
1286    /// Scale relative to the ideal viewport (size at width=device-width).
1287    scale: f64,
1288    /// Page zoom factor (CSS to device independent pixels ratio).
1289    #[serde(skip_serializing_if = "Option::is_none")]
1290    zoom: Option<f64>,
1291}
1292
1293impl VisualViewport {
1294    pub fn builder(offsetX: f64, offsetY: f64, pageX: f64, pageY: f64, clientWidth: f64, clientHeight: f64, scale: f64) -> VisualViewportBuilder {
1295        VisualViewportBuilder {
1296            offsetX: offsetX,
1297            offsetY: offsetY,
1298            pageX: pageX,
1299            pageY: pageY,
1300            clientWidth: clientWidth,
1301            clientHeight: clientHeight,
1302            scale: scale,
1303            zoom: None,
1304        }
1305    }
1306    pub fn offsetX(&self) -> f64 { self.offsetX }
1307    pub fn offsetY(&self) -> f64 { self.offsetY }
1308    pub fn pageX(&self) -> f64 { self.pageX }
1309    pub fn pageY(&self) -> f64 { self.pageY }
1310    pub fn clientWidth(&self) -> f64 { self.clientWidth }
1311    pub fn clientHeight(&self) -> f64 { self.clientHeight }
1312    pub fn scale(&self) -> f64 { self.scale }
1313    pub fn zoom(&self) -> Option<f64> { self.zoom }
1314}
1315
1316
1317pub struct VisualViewportBuilder {
1318    offsetX: f64,
1319    offsetY: f64,
1320    pageX: f64,
1321    pageY: f64,
1322    clientWidth: f64,
1323    clientHeight: f64,
1324    scale: f64,
1325    zoom: Option<f64>,
1326}
1327
1328impl VisualViewportBuilder {
1329    /// Page zoom factor (CSS to device independent pixels ratio).
1330    pub fn zoom(mut self, zoom: f64) -> Self { self.zoom = Some(zoom); self }
1331    pub fn build(self) -> VisualViewport {
1332        VisualViewport {
1333            offsetX: self.offsetX,
1334            offsetY: self.offsetY,
1335            pageX: self.pageX,
1336            pageY: self.pageY,
1337            clientWidth: self.clientWidth,
1338            clientHeight: self.clientHeight,
1339            scale: self.scale,
1340            zoom: self.zoom,
1341        }
1342    }
1343}
1344
1345/// Viewport for capturing screenshot.
1346
1347#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1348#[serde(rename_all = "camelCase")]
1349pub struct Viewport {
1350    /// X offset in device independent pixels (dip).
1351    x: f64,
1352    /// Y offset in device independent pixels (dip).
1353    y: f64,
1354    /// Rectangle width in device independent pixels (dip).
1355    width: f64,
1356    /// Rectangle height in device independent pixels (dip).
1357    height: f64,
1358    /// Page scale factor.
1359    scale: f64,
1360}
1361
1362impl Viewport {
1363    pub fn builder(x: f64, y: f64, width: f64, height: f64, scale: f64) -> ViewportBuilder {
1364        ViewportBuilder {
1365            x: x,
1366            y: y,
1367            width: width,
1368            height: height,
1369            scale: scale,
1370        }
1371    }
1372    pub fn x(&self) -> f64 { self.x }
1373    pub fn y(&self) -> f64 { self.y }
1374    pub fn width(&self) -> f64 { self.width }
1375    pub fn height(&self) -> f64 { self.height }
1376    pub fn scale(&self) -> f64 { self.scale }
1377}
1378
1379
1380pub struct ViewportBuilder {
1381    x: f64,
1382    y: f64,
1383    width: f64,
1384    height: f64,
1385    scale: f64,
1386}
1387
1388impl ViewportBuilder {
1389    pub fn build(self) -> Viewport {
1390        Viewport {
1391            x: self.x,
1392            y: self.y,
1393            width: self.width,
1394            height: self.height,
1395            scale: self.scale,
1396        }
1397    }
1398}
1399
1400/// Generic font families collection.
1401
1402#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1403#[serde(rename_all = "camelCase")]
1404pub struct FontFamilies<'a> {
1405    /// The standard font-family.
1406    #[serde(skip_serializing_if = "Option::is_none")]
1407    standard: Option<Cow<'a, str>>,
1408    /// The fixed font-family.
1409    #[serde(skip_serializing_if = "Option::is_none")]
1410    fixed: Option<Cow<'a, str>>,
1411    /// The serif font-family.
1412    #[serde(skip_serializing_if = "Option::is_none")]
1413    serif: Option<Cow<'a, str>>,
1414    /// The sansSerif font-family.
1415    #[serde(skip_serializing_if = "Option::is_none")]
1416    sansSerif: Option<Cow<'a, str>>,
1417    /// The cursive font-family.
1418    #[serde(skip_serializing_if = "Option::is_none")]
1419    cursive: Option<Cow<'a, str>>,
1420    /// The fantasy font-family.
1421    #[serde(skip_serializing_if = "Option::is_none")]
1422    fantasy: Option<Cow<'a, str>>,
1423    /// The math font-family.
1424    #[serde(skip_serializing_if = "Option::is_none")]
1425    math: Option<Cow<'a, str>>,
1426}
1427
1428impl<'a> FontFamilies<'a> {
1429    pub fn builder() -> FontFamiliesBuilder<'a> {
1430        FontFamiliesBuilder {
1431            standard: None,
1432            fixed: None,
1433            serif: None,
1434            sansSerif: None,
1435            cursive: None,
1436            fantasy: None,
1437            math: None,
1438        }
1439    }
1440    pub fn standard(&self) -> Option<&str> { self.standard.as_deref() }
1441    pub fn fixed(&self) -> Option<&str> { self.fixed.as_deref() }
1442    pub fn serif(&self) -> Option<&str> { self.serif.as_deref() }
1443    pub fn sansSerif(&self) -> Option<&str> { self.sansSerif.as_deref() }
1444    pub fn cursive(&self) -> Option<&str> { self.cursive.as_deref() }
1445    pub fn fantasy(&self) -> Option<&str> { self.fantasy.as_deref() }
1446    pub fn math(&self) -> Option<&str> { self.math.as_deref() }
1447}
1448
1449#[derive(Default)]
1450pub struct FontFamiliesBuilder<'a> {
1451    standard: Option<Cow<'a, str>>,
1452    fixed: Option<Cow<'a, str>>,
1453    serif: Option<Cow<'a, str>>,
1454    sansSerif: Option<Cow<'a, str>>,
1455    cursive: Option<Cow<'a, str>>,
1456    fantasy: Option<Cow<'a, str>>,
1457    math: Option<Cow<'a, str>>,
1458}
1459
1460impl<'a> FontFamiliesBuilder<'a> {
1461    /// The standard font-family.
1462    pub fn standard(mut self, standard: impl Into<Cow<'a, str>>) -> Self { self.standard = Some(standard.into()); self }
1463    /// The fixed font-family.
1464    pub fn fixed(mut self, fixed: impl Into<Cow<'a, str>>) -> Self { self.fixed = Some(fixed.into()); self }
1465    /// The serif font-family.
1466    pub fn serif(mut self, serif: impl Into<Cow<'a, str>>) -> Self { self.serif = Some(serif.into()); self }
1467    /// The sansSerif font-family.
1468    pub fn sansSerif(mut self, sansSerif: impl Into<Cow<'a, str>>) -> Self { self.sansSerif = Some(sansSerif.into()); self }
1469    /// The cursive font-family.
1470    pub fn cursive(mut self, cursive: impl Into<Cow<'a, str>>) -> Self { self.cursive = Some(cursive.into()); self }
1471    /// The fantasy font-family.
1472    pub fn fantasy(mut self, fantasy: impl Into<Cow<'a, str>>) -> Self { self.fantasy = Some(fantasy.into()); self }
1473    /// The math font-family.
1474    pub fn math(mut self, math: impl Into<Cow<'a, str>>) -> Self { self.math = Some(math.into()); self }
1475    pub fn build(self) -> FontFamilies<'a> {
1476        FontFamilies {
1477            standard: self.standard,
1478            fixed: self.fixed,
1479            serif: self.serif,
1480            sansSerif: self.sansSerif,
1481            cursive: self.cursive,
1482            fantasy: self.fantasy,
1483            math: self.math,
1484        }
1485    }
1486}
1487
1488/// Font families collection for a script.
1489
1490#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1491#[serde(rename_all = "camelCase")]
1492pub struct ScriptFontFamilies<'a> {
1493    /// Name of the script which these font families are defined for.
1494    script: Cow<'a, str>,
1495    /// Generic font families collection for the script.
1496    fontFamilies: FontFamilies<'a>,
1497}
1498
1499impl<'a> ScriptFontFamilies<'a> {
1500    pub fn builder(script: impl Into<Cow<'a, str>>, fontFamilies: FontFamilies<'a>) -> ScriptFontFamiliesBuilder<'a> {
1501        ScriptFontFamiliesBuilder {
1502            script: script.into(),
1503            fontFamilies: fontFamilies,
1504        }
1505    }
1506    pub fn script(&self) -> &str { self.script.as_ref() }
1507    pub fn fontFamilies(&self) -> &FontFamilies<'a> { &self.fontFamilies }
1508}
1509
1510
1511pub struct ScriptFontFamiliesBuilder<'a> {
1512    script: Cow<'a, str>,
1513    fontFamilies: FontFamilies<'a>,
1514}
1515
1516impl<'a> ScriptFontFamiliesBuilder<'a> {
1517    pub fn build(self) -> ScriptFontFamilies<'a> {
1518        ScriptFontFamilies {
1519            script: self.script,
1520            fontFamilies: self.fontFamilies,
1521        }
1522    }
1523}
1524
1525/// Default font sizes.
1526
1527#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1528#[serde(rename_all = "camelCase")]
1529pub struct FontSizes {
1530    /// Default standard font size.
1531    #[serde(skip_serializing_if = "Option::is_none")]
1532    standard: Option<i64>,
1533    /// Default fixed font size.
1534    #[serde(skip_serializing_if = "Option::is_none")]
1535    fixed: Option<i64>,
1536}
1537
1538impl FontSizes {
1539    pub fn builder() -> FontSizesBuilder {
1540        FontSizesBuilder {
1541            standard: None,
1542            fixed: None,
1543        }
1544    }
1545    pub fn standard(&self) -> Option<i64> { self.standard }
1546    pub fn fixed(&self) -> Option<i64> { self.fixed }
1547}
1548
1549#[derive(Default)]
1550pub struct FontSizesBuilder {
1551    standard: Option<i64>,
1552    fixed: Option<i64>,
1553}
1554
1555impl FontSizesBuilder {
1556    /// Default standard font size.
1557    pub fn standard(mut self, standard: i64) -> Self { self.standard = Some(standard); self }
1558    /// Default fixed font size.
1559    pub fn fixed(mut self, fixed: i64) -> Self { self.fixed = Some(fixed); self }
1560    pub fn build(self) -> FontSizes {
1561        FontSizes {
1562            standard: self.standard,
1563            fixed: self.fixed,
1564        }
1565    }
1566}
1567
1568
1569#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1570pub enum ClientNavigationReason {
1571    #[default]
1572    #[serde(rename = "anchorClick")]
1573    AnchorClick,
1574    #[serde(rename = "formSubmissionGet")]
1575    FormSubmissionGet,
1576    #[serde(rename = "formSubmissionPost")]
1577    FormSubmissionPost,
1578    #[serde(rename = "httpHeaderRefresh")]
1579    HttpHeaderRefresh,
1580    #[serde(rename = "initialFrameNavigation")]
1581    InitialFrameNavigation,
1582    #[serde(rename = "metaTagRefresh")]
1583    MetaTagRefresh,
1584    #[serde(rename = "other")]
1585    Other,
1586    #[serde(rename = "pageBlockInterstitial")]
1587    PageBlockInterstitial,
1588    #[serde(rename = "reload")]
1589    Reload,
1590    #[serde(rename = "scriptInitiated")]
1591    ScriptInitiated,
1592}
1593
1594
1595#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1596pub enum ClientNavigationDisposition {
1597    #[default]
1598    #[serde(rename = "currentTab")]
1599    CurrentTab,
1600    #[serde(rename = "newTab")]
1601    NewTab,
1602    #[serde(rename = "newWindow")]
1603    NewWindow,
1604    #[serde(rename = "download")]
1605    Download,
1606}
1607
1608
1609#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1610#[serde(rename_all = "camelCase")]
1611pub struct InstallabilityErrorArgument<'a> {
1612    /// Argument name (e.g. name:'minimum-icon-size-in-pixels').
1613    name: Cow<'a, str>,
1614    /// Argument value (e.g. value:'64').
1615    value: Cow<'a, str>,
1616}
1617
1618impl<'a> InstallabilityErrorArgument<'a> {
1619    pub fn builder(name: impl Into<Cow<'a, str>>, value: impl Into<Cow<'a, str>>) -> InstallabilityErrorArgumentBuilder<'a> {
1620        InstallabilityErrorArgumentBuilder {
1621            name: name.into(),
1622            value: value.into(),
1623        }
1624    }
1625    pub fn name(&self) -> &str { self.name.as_ref() }
1626    pub fn value(&self) -> &str { self.value.as_ref() }
1627}
1628
1629
1630pub struct InstallabilityErrorArgumentBuilder<'a> {
1631    name: Cow<'a, str>,
1632    value: Cow<'a, str>,
1633}
1634
1635impl<'a> InstallabilityErrorArgumentBuilder<'a> {
1636    pub fn build(self) -> InstallabilityErrorArgument<'a> {
1637        InstallabilityErrorArgument {
1638            name: self.name,
1639            value: self.value,
1640        }
1641    }
1642}
1643
1644/// The installability error
1645
1646#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1647#[serde(rename_all = "camelCase")]
1648pub struct InstallabilityError<'a> {
1649    /// The error id (e.g. 'manifest-missing-suitable-icon').
1650    errorId: Cow<'a, str>,
1651    /// The list of error arguments (e.g. {name:'minimum-icon-size-in-pixels', value:'64'}).
1652    errorArguments: Vec<InstallabilityErrorArgument<'a>>,
1653}
1654
1655impl<'a> InstallabilityError<'a> {
1656    pub fn builder(errorId: impl Into<Cow<'a, str>>, errorArguments: Vec<InstallabilityErrorArgument<'a>>) -> InstallabilityErrorBuilder<'a> {
1657        InstallabilityErrorBuilder {
1658            errorId: errorId.into(),
1659            errorArguments: errorArguments,
1660        }
1661    }
1662    pub fn errorId(&self) -> &str { self.errorId.as_ref() }
1663    pub fn errorArguments(&self) -> &[InstallabilityErrorArgument<'a>] { &self.errorArguments }
1664}
1665
1666
1667pub struct InstallabilityErrorBuilder<'a> {
1668    errorId: Cow<'a, str>,
1669    errorArguments: Vec<InstallabilityErrorArgument<'a>>,
1670}
1671
1672impl<'a> InstallabilityErrorBuilder<'a> {
1673    pub fn build(self) -> InstallabilityError<'a> {
1674        InstallabilityError {
1675            errorId: self.errorId,
1676            errorArguments: self.errorArguments,
1677        }
1678    }
1679}
1680
1681/// The referring-policy used for the navigation.
1682
1683#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
1684pub enum ReferrerPolicy {
1685    #[default]
1686    #[serde(rename = "noReferrer")]
1687    NoReferrer,
1688    #[serde(rename = "noReferrerWhenDowngrade")]
1689    NoReferrerWhenDowngrade,
1690    #[serde(rename = "origin")]
1691    Origin,
1692    #[serde(rename = "originWhenCrossOrigin")]
1693    OriginWhenCrossOrigin,
1694    #[serde(rename = "sameOrigin")]
1695    SameOrigin,
1696    #[serde(rename = "strictOrigin")]
1697    StrictOrigin,
1698    #[serde(rename = "strictOriginWhenCrossOrigin")]
1699    StrictOriginWhenCrossOrigin,
1700    #[serde(rename = "unsafeUrl")]
1701    UnsafeUrl,
1702}
1703
1704/// Per-script compilation cache parameters for 'Page.produceCompilationCache'
1705
1706#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1707#[serde(rename_all = "camelCase")]
1708pub struct CompilationCacheParams<'a> {
1709    /// The URL of the script to produce a compilation cache entry for.
1710    url: Cow<'a, str>,
1711    /// A hint to the backend whether eager compilation is recommended.
1712    /// (the actual compilation mode used is upon backend discretion).
1713    #[serde(skip_serializing_if = "Option::is_none")]
1714    eager: Option<bool>,
1715}
1716
1717impl<'a> CompilationCacheParams<'a> {
1718    pub fn builder(url: impl Into<Cow<'a, str>>) -> CompilationCacheParamsBuilder<'a> {
1719        CompilationCacheParamsBuilder {
1720            url: url.into(),
1721            eager: None,
1722        }
1723    }
1724    pub fn url(&self) -> &str { self.url.as_ref() }
1725    pub fn eager(&self) -> Option<bool> { self.eager }
1726}
1727
1728
1729pub struct CompilationCacheParamsBuilder<'a> {
1730    url: Cow<'a, str>,
1731    eager: Option<bool>,
1732}
1733
1734impl<'a> CompilationCacheParamsBuilder<'a> {
1735    /// A hint to the backend whether eager compilation is recommended.
1736    /// (the actual compilation mode used is upon backend discretion).
1737    pub fn eager(mut self, eager: bool) -> Self { self.eager = Some(eager); self }
1738    pub fn build(self) -> CompilationCacheParams<'a> {
1739        CompilationCacheParams {
1740            url: self.url,
1741            eager: self.eager,
1742        }
1743    }
1744}
1745
1746
1747#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1748#[serde(rename_all = "camelCase")]
1749pub struct FileFilter<'a> {
1750    #[serde(skip_serializing_if = "Option::is_none")]
1751    name: Option<Cow<'a, str>>,
1752    #[serde(skip_serializing_if = "Option::is_none")]
1753    accepts: Option<Vec<Cow<'a, str>>>,
1754}
1755
1756impl<'a> FileFilter<'a> {
1757    pub fn builder() -> FileFilterBuilder<'a> {
1758        FileFilterBuilder {
1759            name: None,
1760            accepts: None,
1761        }
1762    }
1763    pub fn name(&self) -> Option<&str> { self.name.as_deref() }
1764    pub fn accepts(&self) -> Option<&[Cow<'a, str>]> { self.accepts.as_deref() }
1765}
1766
1767#[derive(Default)]
1768pub struct FileFilterBuilder<'a> {
1769    name: Option<Cow<'a, str>>,
1770    accepts: Option<Vec<Cow<'a, str>>>,
1771}
1772
1773impl<'a> FileFilterBuilder<'a> {
1774    pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self { self.name = Some(name.into()); self }
1775    pub fn accepts(mut self, accepts: Vec<Cow<'a, str>>) -> Self { self.accepts = Some(accepts); self }
1776    pub fn build(self) -> FileFilter<'a> {
1777        FileFilter {
1778            name: self.name,
1779            accepts: self.accepts,
1780        }
1781    }
1782}
1783
1784
1785#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1786#[serde(rename_all = "camelCase")]
1787pub struct FileHandler<'a> {
1788    action: Cow<'a, str>,
1789    name: Cow<'a, str>,
1790    #[serde(skip_serializing_if = "Option::is_none")]
1791    icons: Option<Vec<ImageResource<'a>>>,
1792    /// Mimic a map, name is the key, accepts is the value.
1793    #[serde(skip_serializing_if = "Option::is_none")]
1794    accepts: Option<Vec<FileFilter<'a>>>,
1795    /// Won't repeat the enums, using string for easy comparison. Same as the
1796    /// other enums below.
1797    launchType: Cow<'a, str>,
1798}
1799
1800impl<'a> FileHandler<'a> {
1801    pub fn builder(action: impl Into<Cow<'a, str>>, name: impl Into<Cow<'a, str>>, launchType: impl Into<Cow<'a, str>>) -> FileHandlerBuilder<'a> {
1802        FileHandlerBuilder {
1803            action: action.into(),
1804            name: name.into(),
1805            icons: None,
1806            accepts: None,
1807            launchType: launchType.into(),
1808        }
1809    }
1810    pub fn action(&self) -> &str { self.action.as_ref() }
1811    pub fn name(&self) -> &str { self.name.as_ref() }
1812    pub fn icons(&self) -> Option<&[ImageResource<'a>]> { self.icons.as_deref() }
1813    pub fn accepts(&self) -> Option<&[FileFilter<'a>]> { self.accepts.as_deref() }
1814    pub fn launchType(&self) -> &str { self.launchType.as_ref() }
1815}
1816
1817
1818pub struct FileHandlerBuilder<'a> {
1819    action: Cow<'a, str>,
1820    name: Cow<'a, str>,
1821    icons: Option<Vec<ImageResource<'a>>>,
1822    accepts: Option<Vec<FileFilter<'a>>>,
1823    launchType: Cow<'a, str>,
1824}
1825
1826impl<'a> FileHandlerBuilder<'a> {
1827    pub fn icons(mut self, icons: Vec<ImageResource<'a>>) -> Self { self.icons = Some(icons); self }
1828    /// Mimic a map, name is the key, accepts is the value.
1829    pub fn accepts(mut self, accepts: Vec<FileFilter<'a>>) -> Self { self.accepts = Some(accepts); self }
1830    pub fn build(self) -> FileHandler<'a> {
1831        FileHandler {
1832            action: self.action,
1833            name: self.name,
1834            icons: self.icons,
1835            accepts: self.accepts,
1836            launchType: self.launchType,
1837        }
1838    }
1839}
1840
1841/// The image definition used in both icon and screenshot.
1842
1843#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1844#[serde(rename_all = "camelCase")]
1845pub struct ImageResource<'a> {
1846    /// The src field in the definition, but changing to url in favor of
1847    /// consistency.
1848    url: Cow<'a, str>,
1849    #[serde(skip_serializing_if = "Option::is_none")]
1850    sizes: Option<Cow<'a, str>>,
1851    #[serde(skip_serializing_if = "Option::is_none", rename = "type")]
1852    type_: Option<Cow<'a, str>>,
1853}
1854
1855impl<'a> ImageResource<'a> {
1856    pub fn builder(url: impl Into<Cow<'a, str>>) -> ImageResourceBuilder<'a> {
1857        ImageResourceBuilder {
1858            url: url.into(),
1859            sizes: None,
1860            type_: None,
1861        }
1862    }
1863    pub fn url(&self) -> &str { self.url.as_ref() }
1864    pub fn sizes(&self) -> Option<&str> { self.sizes.as_deref() }
1865    pub fn type_(&self) -> Option<&str> { self.type_.as_deref() }
1866}
1867
1868
1869pub struct ImageResourceBuilder<'a> {
1870    url: Cow<'a, str>,
1871    sizes: Option<Cow<'a, str>>,
1872    type_: Option<Cow<'a, str>>,
1873}
1874
1875impl<'a> ImageResourceBuilder<'a> {
1876    pub fn sizes(mut self, sizes: impl Into<Cow<'a, str>>) -> Self { self.sizes = Some(sizes.into()); self }
1877    pub fn type_(mut self, type_: impl Into<Cow<'a, str>>) -> Self { self.type_ = Some(type_.into()); self }
1878    pub fn build(self) -> ImageResource<'a> {
1879        ImageResource {
1880            url: self.url,
1881            sizes: self.sizes,
1882            type_: self.type_,
1883        }
1884    }
1885}
1886
1887
1888#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1889#[serde(rename_all = "camelCase")]
1890pub struct LaunchHandler<'a> {
1891    clientMode: Cow<'a, str>,
1892}
1893
1894impl<'a> LaunchHandler<'a> {
1895    pub fn builder(clientMode: impl Into<Cow<'a, str>>) -> LaunchHandlerBuilder<'a> {
1896        LaunchHandlerBuilder {
1897            clientMode: clientMode.into(),
1898        }
1899    }
1900    pub fn clientMode(&self) -> &str { self.clientMode.as_ref() }
1901}
1902
1903
1904pub struct LaunchHandlerBuilder<'a> {
1905    clientMode: Cow<'a, str>,
1906}
1907
1908impl<'a> LaunchHandlerBuilder<'a> {
1909    pub fn build(self) -> LaunchHandler<'a> {
1910        LaunchHandler {
1911            clientMode: self.clientMode,
1912        }
1913    }
1914}
1915
1916
1917#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1918#[serde(rename_all = "camelCase")]
1919pub struct ProtocolHandler<'a> {
1920    protocol: Cow<'a, str>,
1921    url: Cow<'a, str>,
1922}
1923
1924impl<'a> ProtocolHandler<'a> {
1925    pub fn builder(protocol: impl Into<Cow<'a, str>>, url: impl Into<Cow<'a, str>>) -> ProtocolHandlerBuilder<'a> {
1926        ProtocolHandlerBuilder {
1927            protocol: protocol.into(),
1928            url: url.into(),
1929        }
1930    }
1931    pub fn protocol(&self) -> &str { self.protocol.as_ref() }
1932    pub fn url(&self) -> &str { self.url.as_ref() }
1933}
1934
1935
1936pub struct ProtocolHandlerBuilder<'a> {
1937    protocol: Cow<'a, str>,
1938    url: Cow<'a, str>,
1939}
1940
1941impl<'a> ProtocolHandlerBuilder<'a> {
1942    pub fn build(self) -> ProtocolHandler<'a> {
1943        ProtocolHandler {
1944            protocol: self.protocol,
1945            url: self.url,
1946        }
1947    }
1948}
1949
1950
1951#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1952#[serde(rename_all = "camelCase")]
1953pub struct RelatedApplication<'a> {
1954    #[serde(skip_serializing_if = "Option::is_none")]
1955    id: Option<Cow<'a, str>>,
1956    url: Cow<'a, str>,
1957}
1958
1959impl<'a> RelatedApplication<'a> {
1960    pub fn builder(url: impl Into<Cow<'a, str>>) -> RelatedApplicationBuilder<'a> {
1961        RelatedApplicationBuilder {
1962            id: None,
1963            url: url.into(),
1964        }
1965    }
1966    pub fn id(&self) -> Option<&str> { self.id.as_deref() }
1967    pub fn url(&self) -> &str { self.url.as_ref() }
1968}
1969
1970
1971pub struct RelatedApplicationBuilder<'a> {
1972    id: Option<Cow<'a, str>>,
1973    url: Cow<'a, str>,
1974}
1975
1976impl<'a> RelatedApplicationBuilder<'a> {
1977    pub fn id(mut self, id: impl Into<Cow<'a, str>>) -> Self { self.id = Some(id.into()); self }
1978    pub fn build(self) -> RelatedApplication<'a> {
1979        RelatedApplication {
1980            id: self.id,
1981            url: self.url,
1982        }
1983    }
1984}
1985
1986
1987#[derive(Debug, Clone, Serialize, Deserialize, Default)]
1988#[serde(rename_all = "camelCase")]
1989pub struct ScopeExtension<'a> {
1990    /// Instead of using tuple, this field always returns the serialized string
1991    /// for easy understanding and comparison.
1992    origin: Cow<'a, str>,
1993    hasOriginWildcard: bool,
1994}
1995
1996impl<'a> ScopeExtension<'a> {
1997    pub fn builder(origin: impl Into<Cow<'a, str>>, hasOriginWildcard: bool) -> ScopeExtensionBuilder<'a> {
1998        ScopeExtensionBuilder {
1999            origin: origin.into(),
2000            hasOriginWildcard: hasOriginWildcard,
2001        }
2002    }
2003    pub fn origin(&self) -> &str { self.origin.as_ref() }
2004    pub fn hasOriginWildcard(&self) -> bool { self.hasOriginWildcard }
2005}
2006
2007
2008pub struct ScopeExtensionBuilder<'a> {
2009    origin: Cow<'a, str>,
2010    hasOriginWildcard: bool,
2011}
2012
2013impl<'a> ScopeExtensionBuilder<'a> {
2014    pub fn build(self) -> ScopeExtension<'a> {
2015        ScopeExtension {
2016            origin: self.origin,
2017            hasOriginWildcard: self.hasOriginWildcard,
2018        }
2019    }
2020}
2021
2022
2023#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2024#[serde(rename_all = "camelCase")]
2025pub struct Screenshot<'a> {
2026    image: ImageResource<'a>,
2027    formFactor: Cow<'a, str>,
2028    #[serde(skip_serializing_if = "Option::is_none")]
2029    label: Option<Cow<'a, str>>,
2030}
2031
2032impl<'a> Screenshot<'a> {
2033    pub fn builder(image: ImageResource<'a>, formFactor: impl Into<Cow<'a, str>>) -> ScreenshotBuilder<'a> {
2034        ScreenshotBuilder {
2035            image: image,
2036            formFactor: formFactor.into(),
2037            label: None,
2038        }
2039    }
2040    pub fn image(&self) -> &ImageResource<'a> { &self.image }
2041    pub fn formFactor(&self) -> &str { self.formFactor.as_ref() }
2042    pub fn label(&self) -> Option<&str> { self.label.as_deref() }
2043}
2044
2045
2046pub struct ScreenshotBuilder<'a> {
2047    image: ImageResource<'a>,
2048    formFactor: Cow<'a, str>,
2049    label: Option<Cow<'a, str>>,
2050}
2051
2052impl<'a> ScreenshotBuilder<'a> {
2053    pub fn label(mut self, label: impl Into<Cow<'a, str>>) -> Self { self.label = Some(label.into()); self }
2054    pub fn build(self) -> Screenshot<'a> {
2055        Screenshot {
2056            image: self.image,
2057            formFactor: self.formFactor,
2058            label: self.label,
2059        }
2060    }
2061}
2062
2063
2064#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2065#[serde(rename_all = "camelCase")]
2066pub struct ShareTarget<'a> {
2067    action: Cow<'a, str>,
2068    method: Cow<'a, str>,
2069    enctype: Cow<'a, str>,
2070    /// Embed the ShareTargetParams
2071    #[serde(skip_serializing_if = "Option::is_none")]
2072    title: Option<Cow<'a, str>>,
2073    #[serde(skip_serializing_if = "Option::is_none")]
2074    text: Option<Cow<'a, str>>,
2075    #[serde(skip_serializing_if = "Option::is_none")]
2076    url: Option<Cow<'a, str>>,
2077    #[serde(skip_serializing_if = "Option::is_none")]
2078    files: Option<Vec<FileFilter<'a>>>,
2079}
2080
2081impl<'a> ShareTarget<'a> {
2082    pub fn builder(action: impl Into<Cow<'a, str>>, method: impl Into<Cow<'a, str>>, enctype: impl Into<Cow<'a, str>>) -> ShareTargetBuilder<'a> {
2083        ShareTargetBuilder {
2084            action: action.into(),
2085            method: method.into(),
2086            enctype: enctype.into(),
2087            title: None,
2088            text: None,
2089            url: None,
2090            files: None,
2091        }
2092    }
2093    pub fn action(&self) -> &str { self.action.as_ref() }
2094    pub fn method(&self) -> &str { self.method.as_ref() }
2095    pub fn enctype(&self) -> &str { self.enctype.as_ref() }
2096    pub fn title(&self) -> Option<&str> { self.title.as_deref() }
2097    pub fn text(&self) -> Option<&str> { self.text.as_deref() }
2098    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
2099    pub fn files(&self) -> Option<&[FileFilter<'a>]> { self.files.as_deref() }
2100}
2101
2102
2103pub struct ShareTargetBuilder<'a> {
2104    action: Cow<'a, str>,
2105    method: Cow<'a, str>,
2106    enctype: Cow<'a, str>,
2107    title: Option<Cow<'a, str>>,
2108    text: Option<Cow<'a, str>>,
2109    url: Option<Cow<'a, str>>,
2110    files: Option<Vec<FileFilter<'a>>>,
2111}
2112
2113impl<'a> ShareTargetBuilder<'a> {
2114    /// Embed the ShareTargetParams
2115    pub fn title(mut self, title: impl Into<Cow<'a, str>>) -> Self { self.title = Some(title.into()); self }
2116    pub fn text(mut self, text: impl Into<Cow<'a, str>>) -> Self { self.text = Some(text.into()); self }
2117    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
2118    pub fn files(mut self, files: Vec<FileFilter<'a>>) -> Self { self.files = Some(files); self }
2119    pub fn build(self) -> ShareTarget<'a> {
2120        ShareTarget {
2121            action: self.action,
2122            method: self.method,
2123            enctype: self.enctype,
2124            title: self.title,
2125            text: self.text,
2126            url: self.url,
2127            files: self.files,
2128        }
2129    }
2130}
2131
2132
2133#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2134#[serde(rename_all = "camelCase")]
2135pub struct Shortcut<'a> {
2136    name: Cow<'a, str>,
2137    url: Cow<'a, str>,
2138}
2139
2140impl<'a> Shortcut<'a> {
2141    pub fn builder(name: impl Into<Cow<'a, str>>, url: impl Into<Cow<'a, str>>) -> ShortcutBuilder<'a> {
2142        ShortcutBuilder {
2143            name: name.into(),
2144            url: url.into(),
2145        }
2146    }
2147    pub fn name(&self) -> &str { self.name.as_ref() }
2148    pub fn url(&self) -> &str { self.url.as_ref() }
2149}
2150
2151
2152pub struct ShortcutBuilder<'a> {
2153    name: Cow<'a, str>,
2154    url: Cow<'a, str>,
2155}
2156
2157impl<'a> ShortcutBuilder<'a> {
2158    pub fn build(self) -> Shortcut<'a> {
2159        Shortcut {
2160            name: self.name,
2161            url: self.url,
2162        }
2163    }
2164}
2165
2166
2167#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2168#[serde(rename_all = "camelCase")]
2169pub struct WebAppManifest<'a> {
2170    #[serde(skip_serializing_if = "Option::is_none")]
2171    backgroundColor: Option<Cow<'a, str>>,
2172    /// The extra description provided by the manifest.
2173    #[serde(skip_serializing_if = "Option::is_none")]
2174    description: Option<Cow<'a, str>>,
2175    #[serde(skip_serializing_if = "Option::is_none")]
2176    dir: Option<Cow<'a, str>>,
2177    #[serde(skip_serializing_if = "Option::is_none")]
2178    display: Option<Cow<'a, str>>,
2179    /// The overrided display mode controlled by the user.
2180    #[serde(skip_serializing_if = "Option::is_none")]
2181    displayOverrides: Option<Vec<Cow<'a, str>>>,
2182    /// The handlers to open files.
2183    #[serde(skip_serializing_if = "Option::is_none")]
2184    fileHandlers: Option<Vec<FileHandler<'a>>>,
2185    #[serde(skip_serializing_if = "Option::is_none")]
2186    icons: Option<Vec<ImageResource<'a>>>,
2187    #[serde(skip_serializing_if = "Option::is_none")]
2188    id: Option<Cow<'a, str>>,
2189    #[serde(skip_serializing_if = "Option::is_none")]
2190    lang: Option<Cow<'a, str>>,
2191    /// TODO(crbug.com/1231886): This field is non-standard and part of a Chrome
2192    /// experiment. See:
2193    /// https://github.com/WICG/web-app-launch/blob/main/launch_handler.md
2194    #[serde(skip_serializing_if = "Option::is_none")]
2195    launchHandler: Option<LaunchHandler<'a>>,
2196    #[serde(skip_serializing_if = "Option::is_none")]
2197    name: Option<Cow<'a, str>>,
2198    #[serde(skip_serializing_if = "Option::is_none")]
2199    orientation: Option<Cow<'a, str>>,
2200    #[serde(skip_serializing_if = "Option::is_none")]
2201    preferRelatedApplications: Option<bool>,
2202    /// The handlers to open protocols.
2203    #[serde(skip_serializing_if = "Option::is_none")]
2204    protocolHandlers: Option<Vec<ProtocolHandler<'a>>>,
2205    #[serde(skip_serializing_if = "Option::is_none")]
2206    relatedApplications: Option<Vec<RelatedApplication<'a>>>,
2207    #[serde(skip_serializing_if = "Option::is_none")]
2208    scope: Option<Cow<'a, str>>,
2209    /// Non-standard, see
2210    /// https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md
2211    #[serde(skip_serializing_if = "Option::is_none")]
2212    scopeExtensions: Option<Vec<ScopeExtension<'a>>>,
2213    /// The screenshots used by chromium.
2214    #[serde(skip_serializing_if = "Option::is_none")]
2215    screenshots: Option<Vec<Screenshot<'a>>>,
2216    #[serde(skip_serializing_if = "Option::is_none")]
2217    shareTarget: Option<ShareTarget<'a>>,
2218    #[serde(skip_serializing_if = "Option::is_none")]
2219    shortName: Option<Cow<'a, str>>,
2220    #[serde(skip_serializing_if = "Option::is_none")]
2221    shortcuts: Option<Vec<Shortcut<'a>>>,
2222    #[serde(skip_serializing_if = "Option::is_none")]
2223    startUrl: Option<Cow<'a, str>>,
2224    #[serde(skip_serializing_if = "Option::is_none")]
2225    themeColor: Option<Cow<'a, str>>,
2226}
2227
2228impl<'a> WebAppManifest<'a> {
2229    pub fn builder() -> WebAppManifestBuilder<'a> {
2230        WebAppManifestBuilder {
2231            backgroundColor: None,
2232            description: None,
2233            dir: None,
2234            display: None,
2235            displayOverrides: None,
2236            fileHandlers: None,
2237            icons: None,
2238            id: None,
2239            lang: None,
2240            launchHandler: None,
2241            name: None,
2242            orientation: None,
2243            preferRelatedApplications: None,
2244            protocolHandlers: None,
2245            relatedApplications: None,
2246            scope: None,
2247            scopeExtensions: None,
2248            screenshots: None,
2249            shareTarget: None,
2250            shortName: None,
2251            shortcuts: None,
2252            startUrl: None,
2253            themeColor: None,
2254        }
2255    }
2256    pub fn backgroundColor(&self) -> Option<&str> { self.backgroundColor.as_deref() }
2257    pub fn description(&self) -> Option<&str> { self.description.as_deref() }
2258    pub fn dir(&self) -> Option<&str> { self.dir.as_deref() }
2259    pub fn display(&self) -> Option<&str> { self.display.as_deref() }
2260    pub fn displayOverrides(&self) -> Option<&[Cow<'a, str>]> { self.displayOverrides.as_deref() }
2261    pub fn fileHandlers(&self) -> Option<&[FileHandler<'a>]> { self.fileHandlers.as_deref() }
2262    pub fn icons(&self) -> Option<&[ImageResource<'a>]> { self.icons.as_deref() }
2263    pub fn id(&self) -> Option<&str> { self.id.as_deref() }
2264    pub fn lang(&self) -> Option<&str> { self.lang.as_deref() }
2265    pub fn launchHandler(&self) -> Option<&LaunchHandler<'a>> { self.launchHandler.as_ref() }
2266    pub fn name(&self) -> Option<&str> { self.name.as_deref() }
2267    pub fn orientation(&self) -> Option<&str> { self.orientation.as_deref() }
2268    pub fn preferRelatedApplications(&self) -> Option<bool> { self.preferRelatedApplications }
2269    pub fn protocolHandlers(&self) -> Option<&[ProtocolHandler<'a>]> { self.protocolHandlers.as_deref() }
2270    pub fn relatedApplications(&self) -> Option<&[RelatedApplication<'a>]> { self.relatedApplications.as_deref() }
2271    pub fn scope(&self) -> Option<&str> { self.scope.as_deref() }
2272    pub fn scopeExtensions(&self) -> Option<&[ScopeExtension<'a>]> { self.scopeExtensions.as_deref() }
2273    pub fn screenshots(&self) -> Option<&[Screenshot<'a>]> { self.screenshots.as_deref() }
2274    pub fn shareTarget(&self) -> Option<&ShareTarget<'a>> { self.shareTarget.as_ref() }
2275    pub fn shortName(&self) -> Option<&str> { self.shortName.as_deref() }
2276    pub fn shortcuts(&self) -> Option<&[Shortcut<'a>]> { self.shortcuts.as_deref() }
2277    pub fn startUrl(&self) -> Option<&str> { self.startUrl.as_deref() }
2278    pub fn themeColor(&self) -> Option<&str> { self.themeColor.as_deref() }
2279}
2280
2281#[derive(Default)]
2282pub struct WebAppManifestBuilder<'a> {
2283    backgroundColor: Option<Cow<'a, str>>,
2284    description: Option<Cow<'a, str>>,
2285    dir: Option<Cow<'a, str>>,
2286    display: Option<Cow<'a, str>>,
2287    displayOverrides: Option<Vec<Cow<'a, str>>>,
2288    fileHandlers: Option<Vec<FileHandler<'a>>>,
2289    icons: Option<Vec<ImageResource<'a>>>,
2290    id: Option<Cow<'a, str>>,
2291    lang: Option<Cow<'a, str>>,
2292    launchHandler: Option<LaunchHandler<'a>>,
2293    name: Option<Cow<'a, str>>,
2294    orientation: Option<Cow<'a, str>>,
2295    preferRelatedApplications: Option<bool>,
2296    protocolHandlers: Option<Vec<ProtocolHandler<'a>>>,
2297    relatedApplications: Option<Vec<RelatedApplication<'a>>>,
2298    scope: Option<Cow<'a, str>>,
2299    scopeExtensions: Option<Vec<ScopeExtension<'a>>>,
2300    screenshots: Option<Vec<Screenshot<'a>>>,
2301    shareTarget: Option<ShareTarget<'a>>,
2302    shortName: Option<Cow<'a, str>>,
2303    shortcuts: Option<Vec<Shortcut<'a>>>,
2304    startUrl: Option<Cow<'a, str>>,
2305    themeColor: Option<Cow<'a, str>>,
2306}
2307
2308impl<'a> WebAppManifestBuilder<'a> {
2309    pub fn backgroundColor(mut self, backgroundColor: impl Into<Cow<'a, str>>) -> Self { self.backgroundColor = Some(backgroundColor.into()); self }
2310    /// The extra description provided by the manifest.
2311    pub fn description(mut self, description: impl Into<Cow<'a, str>>) -> Self { self.description = Some(description.into()); self }
2312    pub fn dir(mut self, dir: impl Into<Cow<'a, str>>) -> Self { self.dir = Some(dir.into()); self }
2313    pub fn display(mut self, display: impl Into<Cow<'a, str>>) -> Self { self.display = Some(display.into()); self }
2314    /// The overrided display mode controlled by the user.
2315    pub fn displayOverrides(mut self, displayOverrides: Vec<Cow<'a, str>>) -> Self { self.displayOverrides = Some(displayOverrides); self }
2316    /// The handlers to open files.
2317    pub fn fileHandlers(mut self, fileHandlers: Vec<FileHandler<'a>>) -> Self { self.fileHandlers = Some(fileHandlers); self }
2318    pub fn icons(mut self, icons: Vec<ImageResource<'a>>) -> Self { self.icons = Some(icons); self }
2319    pub fn id(mut self, id: impl Into<Cow<'a, str>>) -> Self { self.id = Some(id.into()); self }
2320    pub fn lang(mut self, lang: impl Into<Cow<'a, str>>) -> Self { self.lang = Some(lang.into()); self }
2321    /// TODO(crbug.com/1231886): This field is non-standard and part of a Chrome
2322    /// experiment. See:
2323    /// https://github.com/WICG/web-app-launch/blob/main/launch_handler.md
2324    pub fn launchHandler(mut self, launchHandler: LaunchHandler<'a>) -> Self { self.launchHandler = Some(launchHandler); self }
2325    pub fn name(mut self, name: impl Into<Cow<'a, str>>) -> Self { self.name = Some(name.into()); self }
2326    pub fn orientation(mut self, orientation: impl Into<Cow<'a, str>>) -> Self { self.orientation = Some(orientation.into()); self }
2327    pub fn preferRelatedApplications(mut self, preferRelatedApplications: bool) -> Self { self.preferRelatedApplications = Some(preferRelatedApplications); self }
2328    /// The handlers to open protocols.
2329    pub fn protocolHandlers(mut self, protocolHandlers: Vec<ProtocolHandler<'a>>) -> Self { self.protocolHandlers = Some(protocolHandlers); self }
2330    pub fn relatedApplications(mut self, relatedApplications: Vec<RelatedApplication<'a>>) -> Self { self.relatedApplications = Some(relatedApplications); self }
2331    pub fn scope(mut self, scope: impl Into<Cow<'a, str>>) -> Self { self.scope = Some(scope.into()); self }
2332    /// Non-standard, see
2333    /// https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md
2334    pub fn scopeExtensions(mut self, scopeExtensions: Vec<ScopeExtension<'a>>) -> Self { self.scopeExtensions = Some(scopeExtensions); self }
2335    /// The screenshots used by chromium.
2336    pub fn screenshots(mut self, screenshots: Vec<Screenshot<'a>>) -> Self { self.screenshots = Some(screenshots); self }
2337    pub fn shareTarget(mut self, shareTarget: ShareTarget<'a>) -> Self { self.shareTarget = Some(shareTarget); self }
2338    pub fn shortName(mut self, shortName: impl Into<Cow<'a, str>>) -> Self { self.shortName = Some(shortName.into()); self }
2339    pub fn shortcuts(mut self, shortcuts: Vec<Shortcut<'a>>) -> Self { self.shortcuts = Some(shortcuts); self }
2340    pub fn startUrl(mut self, startUrl: impl Into<Cow<'a, str>>) -> Self { self.startUrl = Some(startUrl.into()); self }
2341    pub fn themeColor(mut self, themeColor: impl Into<Cow<'a, str>>) -> Self { self.themeColor = Some(themeColor.into()); self }
2342    pub fn build(self) -> WebAppManifest<'a> {
2343        WebAppManifest {
2344            backgroundColor: self.backgroundColor,
2345            description: self.description,
2346            dir: self.dir,
2347            display: self.display,
2348            displayOverrides: self.displayOverrides,
2349            fileHandlers: self.fileHandlers,
2350            icons: self.icons,
2351            id: self.id,
2352            lang: self.lang,
2353            launchHandler: self.launchHandler,
2354            name: self.name,
2355            orientation: self.orientation,
2356            preferRelatedApplications: self.preferRelatedApplications,
2357            protocolHandlers: self.protocolHandlers,
2358            relatedApplications: self.relatedApplications,
2359            scope: self.scope,
2360            scopeExtensions: self.scopeExtensions,
2361            screenshots: self.screenshots,
2362            shareTarget: self.shareTarget,
2363            shortName: self.shortName,
2364            shortcuts: self.shortcuts,
2365            startUrl: self.startUrl,
2366            themeColor: self.themeColor,
2367        }
2368    }
2369}
2370
2371/// The type of a frameNavigated event.
2372
2373#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2374pub enum NavigationType {
2375    #[default]
2376    #[serde(rename = "Navigation")]
2377    Navigation,
2378    #[serde(rename = "BackForwardCacheRestore")]
2379    BackForwardCacheRestore,
2380}
2381
2382/// List of not restored reasons for back-forward cache.
2383
2384#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2385pub enum BackForwardCacheNotRestoredReason {
2386    #[default]
2387    #[serde(rename = "NotPrimaryMainFrame")]
2388    NotPrimaryMainFrame,
2389    #[serde(rename = "BackForwardCacheDisabled")]
2390    BackForwardCacheDisabled,
2391    #[serde(rename = "RelatedActiveContentsExist")]
2392    RelatedActiveContentsExist,
2393    #[serde(rename = "HTTPStatusNotOK")]
2394    HTTPStatusNotOK,
2395    #[serde(rename = "SchemeNotHTTPOrHTTPS")]
2396    SchemeNotHTTPOrHTTPS,
2397    #[serde(rename = "Loading")]
2398    Loading,
2399    #[serde(rename = "WasGrantedMediaAccess")]
2400    WasGrantedMediaAccess,
2401    #[serde(rename = "DisableForRenderFrameHostCalled")]
2402    DisableForRenderFrameHostCalled,
2403    #[serde(rename = "DomainNotAllowed")]
2404    DomainNotAllowed,
2405    #[serde(rename = "HTTPMethodNotGET")]
2406    HTTPMethodNotGET,
2407    #[serde(rename = "SubframeIsNavigating")]
2408    SubframeIsNavigating,
2409    #[serde(rename = "Timeout")]
2410    Timeout,
2411    #[serde(rename = "CacheLimit")]
2412    CacheLimit,
2413    #[serde(rename = "JavaScriptExecution")]
2414    JavaScriptExecution,
2415    #[serde(rename = "RendererProcessKilled")]
2416    RendererProcessKilled,
2417    #[serde(rename = "RendererProcessCrashed")]
2418    RendererProcessCrashed,
2419    #[serde(rename = "SchedulerTrackedFeatureUsed")]
2420    SchedulerTrackedFeatureUsed,
2421    #[serde(rename = "ConflictingBrowsingInstance")]
2422    ConflictingBrowsingInstance,
2423    #[serde(rename = "CacheFlushed")]
2424    CacheFlushed,
2425    #[serde(rename = "ServiceWorkerVersionActivation")]
2426    ServiceWorkerVersionActivation,
2427    #[serde(rename = "SessionRestored")]
2428    SessionRestored,
2429    #[serde(rename = "ServiceWorkerPostMessage")]
2430    ServiceWorkerPostMessage,
2431    #[serde(rename = "EnteredBackForwardCacheBeforeServiceWorkerHostAdded")]
2432    EnteredBackForwardCacheBeforeServiceWorkerHostAdded,
2433    #[serde(rename = "RenderFrameHostReused_SameSite")]
2434    RenderFrameHostReusedSameSite,
2435    #[serde(rename = "RenderFrameHostReused_CrossSite")]
2436    RenderFrameHostReusedCrossSite,
2437    #[serde(rename = "ServiceWorkerClaim")]
2438    ServiceWorkerClaim,
2439    #[serde(rename = "IgnoreEventAndEvict")]
2440    IgnoreEventAndEvict,
2441    #[serde(rename = "HaveInnerContents")]
2442    HaveInnerContents,
2443    #[serde(rename = "TimeoutPuttingInCache")]
2444    TimeoutPuttingInCache,
2445    #[serde(rename = "BackForwardCacheDisabledByLowMemory")]
2446    BackForwardCacheDisabledByLowMemory,
2447    #[serde(rename = "BackForwardCacheDisabledByCommandLine")]
2448    BackForwardCacheDisabledByCommandLine,
2449    #[serde(rename = "NetworkRequestDatapipeDrainedAsBytesConsumer")]
2450    NetworkRequestDatapipeDrainedAsBytesConsumer,
2451    #[serde(rename = "NetworkRequestRedirected")]
2452    NetworkRequestRedirected,
2453    #[serde(rename = "NetworkRequestTimeout")]
2454    NetworkRequestTimeout,
2455    #[serde(rename = "NetworkExceedsBufferLimit")]
2456    NetworkExceedsBufferLimit,
2457    #[serde(rename = "NavigationCancelledWhileRestoring")]
2458    NavigationCancelledWhileRestoring,
2459    #[serde(rename = "NotMostRecentNavigationEntry")]
2460    NotMostRecentNavigationEntry,
2461    #[serde(rename = "BackForwardCacheDisabledForPrerender")]
2462    BackForwardCacheDisabledForPrerender,
2463    #[serde(rename = "UserAgentOverrideDiffers")]
2464    UserAgentOverrideDiffers,
2465    #[serde(rename = "ForegroundCacheLimit")]
2466    ForegroundCacheLimit,
2467    #[serde(rename = "ForwardCacheDisabled")]
2468    ForwardCacheDisabled,
2469    #[serde(rename = "BrowsingInstanceNotSwapped")]
2470    BrowsingInstanceNotSwapped,
2471    #[serde(rename = "BackForwardCacheDisabledForDelegate")]
2472    BackForwardCacheDisabledForDelegate,
2473    #[serde(rename = "UnloadHandlerExistsInMainFrame")]
2474    UnloadHandlerExistsInMainFrame,
2475    #[serde(rename = "UnloadHandlerExistsInSubFrame")]
2476    UnloadHandlerExistsInSubFrame,
2477    #[serde(rename = "ServiceWorkerUnregistration")]
2478    ServiceWorkerUnregistration,
2479    #[serde(rename = "CacheControlNoStore")]
2480    CacheControlNoStore,
2481    #[serde(rename = "CacheControlNoStoreCookieModified")]
2482    CacheControlNoStoreCookieModified,
2483    #[serde(rename = "CacheControlNoStoreHTTPOnlyCookieModified")]
2484    CacheControlNoStoreHTTPOnlyCookieModified,
2485    #[serde(rename = "NoResponseHead")]
2486    NoResponseHead,
2487    #[serde(rename = "Unknown")]
2488    Unknown,
2489    #[serde(rename = "ActivationNavigationsDisallowedForBug1234857")]
2490    ActivationNavigationsDisallowedForBug1234857,
2491    #[serde(rename = "ErrorDocument")]
2492    ErrorDocument,
2493    #[serde(rename = "FencedFramesEmbedder")]
2494    FencedFramesEmbedder,
2495    #[serde(rename = "CookieDisabled")]
2496    CookieDisabled,
2497    #[serde(rename = "HTTPAuthRequired")]
2498    HTTPAuthRequired,
2499    #[serde(rename = "CookieFlushed")]
2500    CookieFlushed,
2501    #[serde(rename = "BroadcastChannelOnMessage")]
2502    BroadcastChannelOnMessage,
2503    #[serde(rename = "WebViewSettingsChanged")]
2504    WebViewSettingsChanged,
2505    #[serde(rename = "WebViewJavaScriptObjectChanged")]
2506    WebViewJavaScriptObjectChanged,
2507    #[serde(rename = "WebViewMessageListenerInjected")]
2508    WebViewMessageListenerInjected,
2509    #[serde(rename = "WebViewSafeBrowsingAllowlistChanged")]
2510    WebViewSafeBrowsingAllowlistChanged,
2511    #[serde(rename = "WebViewDocumentStartJavascriptChanged")]
2512    WebViewDocumentStartJavascriptChanged,
2513    #[serde(rename = "WebSocket")]
2514    WebSocket,
2515    #[serde(rename = "WebTransport")]
2516    WebTransport,
2517    #[serde(rename = "WebRTC")]
2518    WebRTC,
2519    #[serde(rename = "MainResourceHasCacheControlNoStore")]
2520    MainResourceHasCacheControlNoStore,
2521    #[serde(rename = "MainResourceHasCacheControlNoCache")]
2522    MainResourceHasCacheControlNoCache,
2523    #[serde(rename = "SubresourceHasCacheControlNoStore")]
2524    SubresourceHasCacheControlNoStore,
2525    #[serde(rename = "SubresourceHasCacheControlNoCache")]
2526    SubresourceHasCacheControlNoCache,
2527    #[serde(rename = "ContainsPlugins")]
2528    ContainsPlugins,
2529    #[serde(rename = "DocumentLoaded")]
2530    DocumentLoaded,
2531    #[serde(rename = "OutstandingNetworkRequestOthers")]
2532    OutstandingNetworkRequestOthers,
2533    #[serde(rename = "RequestedMIDIPermission")]
2534    RequestedMIDIPermission,
2535    #[serde(rename = "RequestedAudioCapturePermission")]
2536    RequestedAudioCapturePermission,
2537    #[serde(rename = "RequestedVideoCapturePermission")]
2538    RequestedVideoCapturePermission,
2539    #[serde(rename = "RequestedBackForwardCacheBlockedSensors")]
2540    RequestedBackForwardCacheBlockedSensors,
2541    #[serde(rename = "RequestedBackgroundWorkPermission")]
2542    RequestedBackgroundWorkPermission,
2543    #[serde(rename = "BroadcastChannel")]
2544    BroadcastChannel,
2545    #[serde(rename = "WebXR")]
2546    WebXR,
2547    #[serde(rename = "SharedWorker")]
2548    SharedWorker,
2549    #[serde(rename = "SharedWorkerMessage")]
2550    SharedWorkerMessage,
2551    #[serde(rename = "SharedWorkerWithNoActiveClient")]
2552    SharedWorkerWithNoActiveClient,
2553    #[serde(rename = "WebLocks")]
2554    WebLocks,
2555    #[serde(rename = "WebLocksContention")]
2556    WebLocksContention,
2557    #[serde(rename = "WebHID")]
2558    WebHID,
2559    #[serde(rename = "WebBluetooth")]
2560    WebBluetooth,
2561    #[serde(rename = "WebShare")]
2562    WebShare,
2563    #[serde(rename = "RequestedStorageAccessGrant")]
2564    RequestedStorageAccessGrant,
2565    #[serde(rename = "WebNfc")]
2566    WebNfc,
2567    #[serde(rename = "OutstandingNetworkRequestFetch")]
2568    OutstandingNetworkRequestFetch,
2569    #[serde(rename = "OutstandingNetworkRequestXHR")]
2570    OutstandingNetworkRequestXHR,
2571    #[serde(rename = "AppBanner")]
2572    AppBanner,
2573    #[serde(rename = "Printing")]
2574    Printing,
2575    #[serde(rename = "WebDatabase")]
2576    WebDatabase,
2577    #[serde(rename = "PictureInPicture")]
2578    PictureInPicture,
2579    #[serde(rename = "SpeechRecognizer")]
2580    SpeechRecognizer,
2581    #[serde(rename = "IdleManager")]
2582    IdleManager,
2583    #[serde(rename = "PaymentManager")]
2584    PaymentManager,
2585    #[serde(rename = "SpeechSynthesis")]
2586    SpeechSynthesis,
2587    #[serde(rename = "KeyboardLock")]
2588    KeyboardLock,
2589    #[serde(rename = "WebOTPService")]
2590    WebOTPService,
2591    #[serde(rename = "OutstandingNetworkRequestDirectSocket")]
2592    OutstandingNetworkRequestDirectSocket,
2593    #[serde(rename = "InjectedJavascript")]
2594    InjectedJavascript,
2595    #[serde(rename = "InjectedStyleSheet")]
2596    InjectedStyleSheet,
2597    #[serde(rename = "KeepaliveRequest")]
2598    KeepaliveRequest,
2599    #[serde(rename = "IndexedDBEvent")]
2600    IndexedDBEvent,
2601    #[serde(rename = "Dummy")]
2602    Dummy,
2603    #[serde(rename = "JsNetworkRequestReceivedCacheControlNoStoreResource")]
2604    JsNetworkRequestReceivedCacheControlNoStoreResource,
2605    #[serde(rename = "WebRTCUsedWithCCNS")]
2606    WebRTCUsedWithCCNS,
2607    #[serde(rename = "WebTransportUsedWithCCNS")]
2608    WebTransportUsedWithCCNS,
2609    #[serde(rename = "WebSocketUsedWithCCNS")]
2610    WebSocketUsedWithCCNS,
2611    #[serde(rename = "SmartCard")]
2612    SmartCard,
2613    #[serde(rename = "LiveMediaStreamTrack")]
2614    LiveMediaStreamTrack,
2615    #[serde(rename = "UnloadHandler")]
2616    UnloadHandler,
2617    #[serde(rename = "ParserAborted")]
2618    ParserAborted,
2619    #[serde(rename = "ContentSecurityHandler")]
2620    ContentSecurityHandler,
2621    #[serde(rename = "ContentWebAuthenticationAPI")]
2622    ContentWebAuthenticationAPI,
2623    #[serde(rename = "ContentFileChooser")]
2624    ContentFileChooser,
2625    #[serde(rename = "ContentSerial")]
2626    ContentSerial,
2627    #[serde(rename = "ContentFileSystemAccess")]
2628    ContentFileSystemAccess,
2629    #[serde(rename = "ContentMediaDevicesDispatcherHost")]
2630    ContentMediaDevicesDispatcherHost,
2631    #[serde(rename = "ContentWebBluetooth")]
2632    ContentWebBluetooth,
2633    #[serde(rename = "ContentWebUSB")]
2634    ContentWebUSB,
2635    #[serde(rename = "ContentMediaSessionService")]
2636    ContentMediaSessionService,
2637    #[serde(rename = "ContentScreenReader")]
2638    ContentScreenReader,
2639    #[serde(rename = "ContentDiscarded")]
2640    ContentDiscarded,
2641    #[serde(rename = "EmbedderPopupBlockerTabHelper")]
2642    EmbedderPopupBlockerTabHelper,
2643    #[serde(rename = "EmbedderSafeBrowsingTriggeredPopupBlocker")]
2644    EmbedderSafeBrowsingTriggeredPopupBlocker,
2645    #[serde(rename = "EmbedderSafeBrowsingThreatDetails")]
2646    EmbedderSafeBrowsingThreatDetails,
2647    #[serde(rename = "EmbedderAppBannerManager")]
2648    EmbedderAppBannerManager,
2649    #[serde(rename = "EmbedderDomDistillerViewerSource")]
2650    EmbedderDomDistillerViewerSource,
2651    #[serde(rename = "EmbedderDomDistillerSelfDeletingRequestDelegate")]
2652    EmbedderDomDistillerSelfDeletingRequestDelegate,
2653    #[serde(rename = "EmbedderOomInterventionTabHelper")]
2654    EmbedderOomInterventionTabHelper,
2655    #[serde(rename = "EmbedderOfflinePage")]
2656    EmbedderOfflinePage,
2657    #[serde(rename = "EmbedderChromePasswordManagerClientBindCredentialManager")]
2658    EmbedderChromePasswordManagerClientBindCredentialManager,
2659    #[serde(rename = "EmbedderPermissionRequestManager")]
2660    EmbedderPermissionRequestManager,
2661    #[serde(rename = "EmbedderModalDialog")]
2662    EmbedderModalDialog,
2663    #[serde(rename = "EmbedderExtensions")]
2664    EmbedderExtensions,
2665    #[serde(rename = "EmbedderExtensionMessaging")]
2666    EmbedderExtensionMessaging,
2667    #[serde(rename = "EmbedderExtensionMessagingForOpenPort")]
2668    EmbedderExtensionMessagingForOpenPort,
2669    #[serde(rename = "EmbedderExtensionSentMessageToCachedFrame")]
2670    EmbedderExtensionSentMessageToCachedFrame,
2671    #[serde(rename = "RequestedByWebViewClient")]
2672    RequestedByWebViewClient,
2673    #[serde(rename = "PostMessageByWebViewClient")]
2674    PostMessageByWebViewClient,
2675    #[serde(rename = "CacheControlNoStoreDeviceBoundSessionTerminated")]
2676    CacheControlNoStoreDeviceBoundSessionTerminated,
2677    #[serde(rename = "CacheLimitPrunedOnModerateMemoryPressure")]
2678    CacheLimitPrunedOnModerateMemoryPressure,
2679    #[serde(rename = "CacheLimitPrunedOnCriticalMemoryPressure")]
2680    CacheLimitPrunedOnCriticalMemoryPressure,
2681}
2682
2683/// Types of not restored reasons for back-forward cache.
2684
2685#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
2686pub enum BackForwardCacheNotRestoredReasonType {
2687    #[default]
2688    #[serde(rename = "SupportPending")]
2689    SupportPending,
2690    #[serde(rename = "PageSupportNeeded")]
2691    PageSupportNeeded,
2692    #[serde(rename = "Circumstantial")]
2693    Circumstantial,
2694}
2695
2696
2697#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2698#[serde(rename_all = "camelCase")]
2699pub struct BackForwardCacheBlockingDetails<'a> {
2700    /// Url of the file where blockage happened. Optional because of tests.
2701    #[serde(skip_serializing_if = "Option::is_none")]
2702    url: Option<Cow<'a, str>>,
2703    /// Function name where blockage happened. Optional because of anonymous functions and tests.
2704    #[serde(skip_serializing_if = "Option::is_none")]
2705    function: Option<Cow<'a, str>>,
2706    /// Line number in the script (0-based).
2707    lineNumber: i64,
2708    /// Column number in the script (0-based).
2709    columnNumber: i64,
2710}
2711
2712impl<'a> BackForwardCacheBlockingDetails<'a> {
2713    pub fn builder(lineNumber: i64, columnNumber: i64) -> BackForwardCacheBlockingDetailsBuilder<'a> {
2714        BackForwardCacheBlockingDetailsBuilder {
2715            url: None,
2716            function: None,
2717            lineNumber: lineNumber,
2718            columnNumber: columnNumber,
2719        }
2720    }
2721    pub fn url(&self) -> Option<&str> { self.url.as_deref() }
2722    pub fn function(&self) -> Option<&str> { self.function.as_deref() }
2723    pub fn lineNumber(&self) -> i64 { self.lineNumber }
2724    pub fn columnNumber(&self) -> i64 { self.columnNumber }
2725}
2726
2727
2728pub struct BackForwardCacheBlockingDetailsBuilder<'a> {
2729    url: Option<Cow<'a, str>>,
2730    function: Option<Cow<'a, str>>,
2731    lineNumber: i64,
2732    columnNumber: i64,
2733}
2734
2735impl<'a> BackForwardCacheBlockingDetailsBuilder<'a> {
2736    /// Url of the file where blockage happened. Optional because of tests.
2737    pub fn url(mut self, url: impl Into<Cow<'a, str>>) -> Self { self.url = Some(url.into()); self }
2738    /// Function name where blockage happened. Optional because of anonymous functions and tests.
2739    pub fn function(mut self, function: impl Into<Cow<'a, str>>) -> Self { self.function = Some(function.into()); self }
2740    pub fn build(self) -> BackForwardCacheBlockingDetails<'a> {
2741        BackForwardCacheBlockingDetails {
2742            url: self.url,
2743            function: self.function,
2744            lineNumber: self.lineNumber,
2745            columnNumber: self.columnNumber,
2746        }
2747    }
2748}
2749
2750
2751#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2752#[serde(rename_all = "camelCase")]
2753pub struct BackForwardCacheNotRestoredExplanation<'a> {
2754    /// Type of the reason
2755    #[serde(rename = "type")]
2756    type_: BackForwardCacheNotRestoredReasonType,
2757    /// Not restored reason
2758    reason: BackForwardCacheNotRestoredReason,
2759    /// Context associated with the reason. The meaning of this context is
2760    /// dependent on the reason:
2761    /// - EmbedderExtensionSentMessageToCachedFrame: the extension ID.
2762    #[serde(skip_serializing_if = "Option::is_none")]
2763    context: Option<Cow<'a, str>>,
2764    #[serde(skip_serializing_if = "Option::is_none")]
2765    details: Option<Vec<BackForwardCacheBlockingDetails<'a>>>,
2766}
2767
2768impl<'a> BackForwardCacheNotRestoredExplanation<'a> {
2769    pub fn builder(type_: BackForwardCacheNotRestoredReasonType, reason: BackForwardCacheNotRestoredReason) -> BackForwardCacheNotRestoredExplanationBuilder<'a> {
2770        BackForwardCacheNotRestoredExplanationBuilder {
2771            type_: type_,
2772            reason: reason,
2773            context: None,
2774            details: None,
2775        }
2776    }
2777    pub fn type_(&self) -> &BackForwardCacheNotRestoredReasonType { &self.type_ }
2778    pub fn reason(&self) -> &BackForwardCacheNotRestoredReason { &self.reason }
2779    pub fn context(&self) -> Option<&str> { self.context.as_deref() }
2780    pub fn details(&self) -> Option<&[BackForwardCacheBlockingDetails<'a>]> { self.details.as_deref() }
2781}
2782
2783
2784pub struct BackForwardCacheNotRestoredExplanationBuilder<'a> {
2785    type_: BackForwardCacheNotRestoredReasonType,
2786    reason: BackForwardCacheNotRestoredReason,
2787    context: Option<Cow<'a, str>>,
2788    details: Option<Vec<BackForwardCacheBlockingDetails<'a>>>,
2789}
2790
2791impl<'a> BackForwardCacheNotRestoredExplanationBuilder<'a> {
2792    /// Context associated with the reason. The meaning of this context is
2793    /// dependent on the reason:
2794    /// - EmbedderExtensionSentMessageToCachedFrame: the extension ID.
2795    pub fn context(mut self, context: impl Into<Cow<'a, str>>) -> Self { self.context = Some(context.into()); self }
2796    pub fn details(mut self, details: Vec<BackForwardCacheBlockingDetails<'a>>) -> Self { self.details = Some(details); self }
2797    pub fn build(self) -> BackForwardCacheNotRestoredExplanation<'a> {
2798        BackForwardCacheNotRestoredExplanation {
2799            type_: self.type_,
2800            reason: self.reason,
2801            context: self.context,
2802            details: self.details,
2803        }
2804    }
2805}
2806
2807
2808#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2809#[serde(rename_all = "camelCase")]
2810pub struct BackForwardCacheNotRestoredExplanationTree<'a> {
2811    /// URL of each frame
2812    url: Cow<'a, str>,
2813    /// Not restored reasons of each frame
2814    explanations: Vec<BackForwardCacheNotRestoredExplanation<'a>>,
2815    /// Array of children frame
2816    children: Vec<Box<BackForwardCacheNotRestoredExplanationTree<'a>>>,
2817}
2818
2819impl<'a> BackForwardCacheNotRestoredExplanationTree<'a> {
2820    pub fn builder(url: impl Into<Cow<'a, str>>, explanations: Vec<BackForwardCacheNotRestoredExplanation<'a>>, children: Vec<Box<BackForwardCacheNotRestoredExplanationTree<'a>>>) -> BackForwardCacheNotRestoredExplanationTreeBuilder<'a> {
2821        BackForwardCacheNotRestoredExplanationTreeBuilder {
2822            url: url.into(),
2823            explanations: explanations,
2824            children: children,
2825        }
2826    }
2827    pub fn url(&self) -> &str { self.url.as_ref() }
2828    pub fn explanations(&self) -> &[BackForwardCacheNotRestoredExplanation<'a>] { &self.explanations }
2829    pub fn children(&self) -> &[Box<BackForwardCacheNotRestoredExplanationTree<'a>>] { &self.children }
2830}
2831
2832
2833pub struct BackForwardCacheNotRestoredExplanationTreeBuilder<'a> {
2834    url: Cow<'a, str>,
2835    explanations: Vec<BackForwardCacheNotRestoredExplanation<'a>>,
2836    children: Vec<Box<BackForwardCacheNotRestoredExplanationTree<'a>>>,
2837}
2838
2839impl<'a> BackForwardCacheNotRestoredExplanationTreeBuilder<'a> {
2840    pub fn build(self) -> BackForwardCacheNotRestoredExplanationTree<'a> {
2841        BackForwardCacheNotRestoredExplanationTree {
2842            url: self.url,
2843            explanations: self.explanations,
2844            children: self.children,
2845        }
2846    }
2847}
2848
2849/// Deprecated, please use addScriptToEvaluateOnNewDocument instead.
2850
2851#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2852#[serde(rename_all = "camelCase")]
2853pub struct AddScriptToEvaluateOnLoadParams<'a> {
2854    scriptSource: Cow<'a, str>,
2855}
2856
2857impl<'a> AddScriptToEvaluateOnLoadParams<'a> {
2858    pub fn builder(scriptSource: impl Into<Cow<'a, str>>) -> AddScriptToEvaluateOnLoadParamsBuilder<'a> {
2859        AddScriptToEvaluateOnLoadParamsBuilder {
2860            scriptSource: scriptSource.into(),
2861        }
2862    }
2863    pub fn scriptSource(&self) -> &str { self.scriptSource.as_ref() }
2864}
2865
2866
2867pub struct AddScriptToEvaluateOnLoadParamsBuilder<'a> {
2868    scriptSource: Cow<'a, str>,
2869}
2870
2871impl<'a> AddScriptToEvaluateOnLoadParamsBuilder<'a> {
2872    pub fn build(self) -> AddScriptToEvaluateOnLoadParams<'a> {
2873        AddScriptToEvaluateOnLoadParams {
2874            scriptSource: self.scriptSource,
2875        }
2876    }
2877}
2878
2879/// Deprecated, please use addScriptToEvaluateOnNewDocument instead.
2880
2881#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2882#[serde(rename_all = "camelCase")]
2883pub struct AddScriptToEvaluateOnLoadReturns<'a> {
2884    /// Identifier of the added script.
2885    identifier: ScriptIdentifier<'a>,
2886}
2887
2888impl<'a> AddScriptToEvaluateOnLoadReturns<'a> {
2889    pub fn builder(identifier: ScriptIdentifier<'a>) -> AddScriptToEvaluateOnLoadReturnsBuilder<'a> {
2890        AddScriptToEvaluateOnLoadReturnsBuilder {
2891            identifier: identifier,
2892        }
2893    }
2894    pub fn identifier(&self) -> &ScriptIdentifier<'a> { &self.identifier }
2895}
2896
2897
2898pub struct AddScriptToEvaluateOnLoadReturnsBuilder<'a> {
2899    identifier: ScriptIdentifier<'a>,
2900}
2901
2902impl<'a> AddScriptToEvaluateOnLoadReturnsBuilder<'a> {
2903    pub fn build(self) -> AddScriptToEvaluateOnLoadReturns<'a> {
2904        AddScriptToEvaluateOnLoadReturns {
2905            identifier: self.identifier,
2906        }
2907    }
2908}
2909
2910impl<'a> AddScriptToEvaluateOnLoadParams<'a> { pub const METHOD: &'static str = "Page.addScriptToEvaluateOnLoad"; }
2911
2912impl<'a> crate::CdpCommand<'a> for AddScriptToEvaluateOnLoadParams<'a> {
2913    const METHOD: &'static str = "Page.addScriptToEvaluateOnLoad";
2914    type Response = AddScriptToEvaluateOnLoadReturns<'a>;
2915}
2916
2917/// Evaluates given script in every frame upon creation (before loading frame's scripts).
2918
2919#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2920#[serde(rename_all = "camelCase")]
2921pub struct AddScriptToEvaluateOnNewDocumentParams<'a> {
2922    source: Cow<'a, str>,
2923    /// If specified, creates an isolated world with the given name and evaluates given script in it.
2924    /// This world name will be used as the ExecutionContextDescription::name when the corresponding
2925    /// event is emitted.
2926    #[serde(skip_serializing_if = "Option::is_none")]
2927    worldName: Option<Cow<'a, str>>,
2928    /// Specifies whether command line API should be available to the script, defaults
2929    /// to false.
2930    #[serde(skip_serializing_if = "Option::is_none")]
2931    includeCommandLineAPI: Option<bool>,
2932    /// If true, runs the script immediately on existing execution contexts or worlds.
2933    /// Default: false.
2934    #[serde(skip_serializing_if = "Option::is_none")]
2935    runImmediately: Option<bool>,
2936}
2937
2938impl<'a> AddScriptToEvaluateOnNewDocumentParams<'a> {
2939    pub fn builder(source: impl Into<Cow<'a, str>>) -> AddScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
2940        AddScriptToEvaluateOnNewDocumentParamsBuilder {
2941            source: source.into(),
2942            worldName: None,
2943            includeCommandLineAPI: None,
2944            runImmediately: None,
2945        }
2946    }
2947    pub fn source(&self) -> &str { self.source.as_ref() }
2948    pub fn worldName(&self) -> Option<&str> { self.worldName.as_deref() }
2949    pub fn includeCommandLineAPI(&self) -> Option<bool> { self.includeCommandLineAPI }
2950    pub fn runImmediately(&self) -> Option<bool> { self.runImmediately }
2951}
2952
2953
2954pub struct AddScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
2955    source: Cow<'a, str>,
2956    worldName: Option<Cow<'a, str>>,
2957    includeCommandLineAPI: Option<bool>,
2958    runImmediately: Option<bool>,
2959}
2960
2961impl<'a> AddScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
2962    /// If specified, creates an isolated world with the given name and evaluates given script in it.
2963    /// This world name will be used as the ExecutionContextDescription::name when the corresponding
2964    /// event is emitted.
2965    pub fn worldName(mut self, worldName: impl Into<Cow<'a, str>>) -> Self { self.worldName = Some(worldName.into()); self }
2966    /// Specifies whether command line API should be available to the script, defaults
2967    /// to false.
2968    pub fn includeCommandLineAPI(mut self, includeCommandLineAPI: bool) -> Self { self.includeCommandLineAPI = Some(includeCommandLineAPI); self }
2969    /// If true, runs the script immediately on existing execution contexts or worlds.
2970    /// Default: false.
2971    pub fn runImmediately(mut self, runImmediately: bool) -> Self { self.runImmediately = Some(runImmediately); self }
2972    pub fn build(self) -> AddScriptToEvaluateOnNewDocumentParams<'a> {
2973        AddScriptToEvaluateOnNewDocumentParams {
2974            source: self.source,
2975            worldName: self.worldName,
2976            includeCommandLineAPI: self.includeCommandLineAPI,
2977            runImmediately: self.runImmediately,
2978        }
2979    }
2980}
2981
2982/// Evaluates given script in every frame upon creation (before loading frame's scripts).
2983
2984#[derive(Debug, Clone, Serialize, Deserialize, Default)]
2985#[serde(rename_all = "camelCase")]
2986pub struct AddScriptToEvaluateOnNewDocumentReturns<'a> {
2987    /// Identifier of the added script.
2988    identifier: ScriptIdentifier<'a>,
2989}
2990
2991impl<'a> AddScriptToEvaluateOnNewDocumentReturns<'a> {
2992    pub fn builder(identifier: ScriptIdentifier<'a>) -> AddScriptToEvaluateOnNewDocumentReturnsBuilder<'a> {
2993        AddScriptToEvaluateOnNewDocumentReturnsBuilder {
2994            identifier: identifier,
2995        }
2996    }
2997    pub fn identifier(&self) -> &ScriptIdentifier<'a> { &self.identifier }
2998}
2999
3000
3001pub struct AddScriptToEvaluateOnNewDocumentReturnsBuilder<'a> {
3002    identifier: ScriptIdentifier<'a>,
3003}
3004
3005impl<'a> AddScriptToEvaluateOnNewDocumentReturnsBuilder<'a> {
3006    pub fn build(self) -> AddScriptToEvaluateOnNewDocumentReturns<'a> {
3007        AddScriptToEvaluateOnNewDocumentReturns {
3008            identifier: self.identifier,
3009        }
3010    }
3011}
3012
3013impl<'a> AddScriptToEvaluateOnNewDocumentParams<'a> { pub const METHOD: &'static str = "Page.addScriptToEvaluateOnNewDocument"; }
3014
3015impl<'a> crate::CdpCommand<'a> for AddScriptToEvaluateOnNewDocumentParams<'a> {
3016    const METHOD: &'static str = "Page.addScriptToEvaluateOnNewDocument";
3017    type Response = AddScriptToEvaluateOnNewDocumentReturns<'a>;
3018}
3019
3020#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3021pub struct BringToFrontParams {}
3022
3023impl BringToFrontParams { pub const METHOD: &'static str = "Page.bringToFront"; }
3024
3025impl<'a> crate::CdpCommand<'a> for BringToFrontParams {
3026    const METHOD: &'static str = "Page.bringToFront";
3027    type Response = crate::EmptyReturns;
3028}
3029
3030/// Capture page screenshot.
3031
3032#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3033#[serde(rename_all = "camelCase")]
3034pub struct CaptureScreenshotParams<'a> {
3035    /// Image compression format (defaults to png).
3036    #[serde(skip_serializing_if = "Option::is_none")]
3037    format: Option<Cow<'a, str>>,
3038    /// Compression quality from range [0..100] (jpeg only).
3039    #[serde(skip_serializing_if = "Option::is_none")]
3040    quality: Option<i64>,
3041    /// Capture the screenshot of a given region only.
3042    #[serde(skip_serializing_if = "Option::is_none")]
3043    clip: Option<Viewport>,
3044    /// Capture the screenshot from the surface, rather than the view. Defaults to true.
3045    #[serde(skip_serializing_if = "Option::is_none")]
3046    fromSurface: Option<bool>,
3047    /// Capture the screenshot beyond the viewport. Defaults to false.
3048    #[serde(skip_serializing_if = "Option::is_none")]
3049    captureBeyondViewport: Option<bool>,
3050    /// Optimize image encoding for speed, not for resulting size (defaults to false)
3051    #[serde(skip_serializing_if = "Option::is_none")]
3052    optimizeForSpeed: Option<bool>,
3053}
3054
3055impl<'a> CaptureScreenshotParams<'a> {
3056    pub fn builder() -> CaptureScreenshotParamsBuilder<'a> {
3057        CaptureScreenshotParamsBuilder {
3058            format: None,
3059            quality: None,
3060            clip: None,
3061            fromSurface: None,
3062            captureBeyondViewport: None,
3063            optimizeForSpeed: None,
3064        }
3065    }
3066    pub fn format(&self) -> Option<&str> { self.format.as_deref() }
3067    pub fn quality(&self) -> Option<i64> { self.quality }
3068    pub fn clip(&self) -> Option<&Viewport> { self.clip.as_ref() }
3069    pub fn fromSurface(&self) -> Option<bool> { self.fromSurface }
3070    pub fn captureBeyondViewport(&self) -> Option<bool> { self.captureBeyondViewport }
3071    pub fn optimizeForSpeed(&self) -> Option<bool> { self.optimizeForSpeed }
3072}
3073
3074#[derive(Default)]
3075pub struct CaptureScreenshotParamsBuilder<'a> {
3076    format: Option<Cow<'a, str>>,
3077    quality: Option<i64>,
3078    clip: Option<Viewport>,
3079    fromSurface: Option<bool>,
3080    captureBeyondViewport: Option<bool>,
3081    optimizeForSpeed: Option<bool>,
3082}
3083
3084impl<'a> CaptureScreenshotParamsBuilder<'a> {
3085    /// Image compression format (defaults to png).
3086    pub fn format(mut self, format: impl Into<Cow<'a, str>>) -> Self { self.format = Some(format.into()); self }
3087    /// Compression quality from range [0..100] (jpeg only).
3088    pub fn quality(mut self, quality: i64) -> Self { self.quality = Some(quality); self }
3089    /// Capture the screenshot of a given region only.
3090    pub fn clip(mut self, clip: Viewport) -> Self { self.clip = Some(clip); self }
3091    /// Capture the screenshot from the surface, rather than the view. Defaults to true.
3092    pub fn fromSurface(mut self, fromSurface: bool) -> Self { self.fromSurface = Some(fromSurface); self }
3093    /// Capture the screenshot beyond the viewport. Defaults to false.
3094    pub fn captureBeyondViewport(mut self, captureBeyondViewport: bool) -> Self { self.captureBeyondViewport = Some(captureBeyondViewport); self }
3095    /// Optimize image encoding for speed, not for resulting size (defaults to false)
3096    pub fn optimizeForSpeed(mut self, optimizeForSpeed: bool) -> Self { self.optimizeForSpeed = Some(optimizeForSpeed); self }
3097    pub fn build(self) -> CaptureScreenshotParams<'a> {
3098        CaptureScreenshotParams {
3099            format: self.format,
3100            quality: self.quality,
3101            clip: self.clip,
3102            fromSurface: self.fromSurface,
3103            captureBeyondViewport: self.captureBeyondViewport,
3104            optimizeForSpeed: self.optimizeForSpeed,
3105        }
3106    }
3107}
3108
3109/// Capture page screenshot.
3110
3111#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3112#[serde(rename_all = "camelCase")]
3113pub struct CaptureScreenshotReturns<'a> {
3114    /// Base64-encoded image data. (Encoded as a base64 string when passed over JSON)
3115    data: Cow<'a, str>,
3116}
3117
3118impl<'a> CaptureScreenshotReturns<'a> {
3119    pub fn builder(data: impl Into<Cow<'a, str>>) -> CaptureScreenshotReturnsBuilder<'a> {
3120        CaptureScreenshotReturnsBuilder {
3121            data: data.into(),
3122        }
3123    }
3124    pub fn data(&self) -> &str { self.data.as_ref() }
3125}
3126
3127
3128pub struct CaptureScreenshotReturnsBuilder<'a> {
3129    data: Cow<'a, str>,
3130}
3131
3132impl<'a> CaptureScreenshotReturnsBuilder<'a> {
3133    pub fn build(self) -> CaptureScreenshotReturns<'a> {
3134        CaptureScreenshotReturns {
3135            data: self.data,
3136        }
3137    }
3138}
3139
3140impl<'a> CaptureScreenshotParams<'a> { pub const METHOD: &'static str = "Page.captureScreenshot"; }
3141
3142impl<'a> crate::CdpCommand<'a> for CaptureScreenshotParams<'a> {
3143    const METHOD: &'static str = "Page.captureScreenshot";
3144    type Response = CaptureScreenshotReturns<'a>;
3145}
3146
3147/// Returns a snapshot of the page as a string. For MHTML format, the serialization includes
3148/// iframes, shadow DOM, external resources, and element-inline styles.
3149
3150#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3151#[serde(rename_all = "camelCase")]
3152pub struct CaptureSnapshotParams<'a> {
3153    /// Format (defaults to mhtml).
3154    #[serde(skip_serializing_if = "Option::is_none")]
3155    format: Option<Cow<'a, str>>,
3156}
3157
3158impl<'a> CaptureSnapshotParams<'a> {
3159    pub fn builder() -> CaptureSnapshotParamsBuilder<'a> {
3160        CaptureSnapshotParamsBuilder {
3161            format: None,
3162        }
3163    }
3164    pub fn format(&self) -> Option<&str> { self.format.as_deref() }
3165}
3166
3167#[derive(Default)]
3168pub struct CaptureSnapshotParamsBuilder<'a> {
3169    format: Option<Cow<'a, str>>,
3170}
3171
3172impl<'a> CaptureSnapshotParamsBuilder<'a> {
3173    /// Format (defaults to mhtml).
3174    pub fn format(mut self, format: impl Into<Cow<'a, str>>) -> Self { self.format = Some(format.into()); self }
3175    pub fn build(self) -> CaptureSnapshotParams<'a> {
3176        CaptureSnapshotParams {
3177            format: self.format,
3178        }
3179    }
3180}
3181
3182/// Returns a snapshot of the page as a string. For MHTML format, the serialization includes
3183/// iframes, shadow DOM, external resources, and element-inline styles.
3184
3185#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3186#[serde(rename_all = "camelCase")]
3187pub struct CaptureSnapshotReturns<'a> {
3188    /// Serialized page data.
3189    data: Cow<'a, str>,
3190}
3191
3192impl<'a> CaptureSnapshotReturns<'a> {
3193    pub fn builder(data: impl Into<Cow<'a, str>>) -> CaptureSnapshotReturnsBuilder<'a> {
3194        CaptureSnapshotReturnsBuilder {
3195            data: data.into(),
3196        }
3197    }
3198    pub fn data(&self) -> &str { self.data.as_ref() }
3199}
3200
3201
3202pub struct CaptureSnapshotReturnsBuilder<'a> {
3203    data: Cow<'a, str>,
3204}
3205
3206impl<'a> CaptureSnapshotReturnsBuilder<'a> {
3207    pub fn build(self) -> CaptureSnapshotReturns<'a> {
3208        CaptureSnapshotReturns {
3209            data: self.data,
3210        }
3211    }
3212}
3213
3214impl<'a> CaptureSnapshotParams<'a> { pub const METHOD: &'static str = "Page.captureSnapshot"; }
3215
3216impl<'a> crate::CdpCommand<'a> for CaptureSnapshotParams<'a> {
3217    const METHOD: &'static str = "Page.captureSnapshot";
3218    type Response = CaptureSnapshotReturns<'a>;
3219}
3220
3221#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3222pub struct ClearDeviceMetricsOverrideParams {}
3223
3224impl ClearDeviceMetricsOverrideParams { pub const METHOD: &'static str = "Page.clearDeviceMetricsOverride"; }
3225
3226impl<'a> crate::CdpCommand<'a> for ClearDeviceMetricsOverrideParams {
3227    const METHOD: &'static str = "Page.clearDeviceMetricsOverride";
3228    type Response = crate::EmptyReturns;
3229}
3230
3231#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3232pub struct ClearDeviceOrientationOverrideParams {}
3233
3234impl ClearDeviceOrientationOverrideParams { pub const METHOD: &'static str = "Page.clearDeviceOrientationOverride"; }
3235
3236impl<'a> crate::CdpCommand<'a> for ClearDeviceOrientationOverrideParams {
3237    const METHOD: &'static str = "Page.clearDeviceOrientationOverride";
3238    type Response = crate::EmptyReturns;
3239}
3240
3241#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3242pub struct ClearGeolocationOverrideParams {}
3243
3244impl ClearGeolocationOverrideParams { pub const METHOD: &'static str = "Page.clearGeolocationOverride"; }
3245
3246impl<'a> crate::CdpCommand<'a> for ClearGeolocationOverrideParams {
3247    const METHOD: &'static str = "Page.clearGeolocationOverride";
3248    type Response = crate::EmptyReturns;
3249}
3250
3251/// Creates an isolated world for the given frame.
3252
3253#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3254#[serde(rename_all = "camelCase")]
3255pub struct CreateIsolatedWorldParams<'a> {
3256    /// Id of the frame in which the isolated world should be created.
3257    frameId: FrameId<'a>,
3258    /// An optional name which is reported in the Execution Context.
3259    #[serde(skip_serializing_if = "Option::is_none")]
3260    worldName: Option<Cow<'a, str>>,
3261    /// Whether or not universal access should be granted to the isolated world. This is a powerful
3262    /// option, use with caution.
3263    #[serde(skip_serializing_if = "Option::is_none")]
3264    grantUniveralAccess: Option<bool>,
3265}
3266
3267impl<'a> CreateIsolatedWorldParams<'a> {
3268    pub fn builder(frameId: FrameId<'a>) -> CreateIsolatedWorldParamsBuilder<'a> {
3269        CreateIsolatedWorldParamsBuilder {
3270            frameId: frameId,
3271            worldName: None,
3272            grantUniveralAccess: None,
3273        }
3274    }
3275    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
3276    pub fn worldName(&self) -> Option<&str> { self.worldName.as_deref() }
3277    pub fn grantUniveralAccess(&self) -> Option<bool> { self.grantUniveralAccess }
3278}
3279
3280
3281pub struct CreateIsolatedWorldParamsBuilder<'a> {
3282    frameId: FrameId<'a>,
3283    worldName: Option<Cow<'a, str>>,
3284    grantUniveralAccess: Option<bool>,
3285}
3286
3287impl<'a> CreateIsolatedWorldParamsBuilder<'a> {
3288    /// An optional name which is reported in the Execution Context.
3289    pub fn worldName(mut self, worldName: impl Into<Cow<'a, str>>) -> Self { self.worldName = Some(worldName.into()); self }
3290    /// Whether or not universal access should be granted to the isolated world. This is a powerful
3291    /// option, use with caution.
3292    pub fn grantUniveralAccess(mut self, grantUniveralAccess: bool) -> Self { self.grantUniveralAccess = Some(grantUniveralAccess); self }
3293    pub fn build(self) -> CreateIsolatedWorldParams<'a> {
3294        CreateIsolatedWorldParams {
3295            frameId: self.frameId,
3296            worldName: self.worldName,
3297            grantUniveralAccess: self.grantUniveralAccess,
3298        }
3299    }
3300}
3301
3302/// Creates an isolated world for the given frame.
3303
3304#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3305#[serde(rename_all = "camelCase")]
3306pub struct CreateIsolatedWorldReturns {
3307    /// Execution context of the isolated world.
3308    executionContextId: crate::runtime::ExecutionContextId,
3309}
3310
3311impl CreateIsolatedWorldReturns {
3312    pub fn builder(executionContextId: crate::runtime::ExecutionContextId) -> CreateIsolatedWorldReturnsBuilder {
3313        CreateIsolatedWorldReturnsBuilder {
3314            executionContextId: executionContextId,
3315        }
3316    }
3317    pub fn executionContextId(&self) -> &crate::runtime::ExecutionContextId { &self.executionContextId }
3318}
3319
3320
3321pub struct CreateIsolatedWorldReturnsBuilder {
3322    executionContextId: crate::runtime::ExecutionContextId,
3323}
3324
3325impl CreateIsolatedWorldReturnsBuilder {
3326    pub fn build(self) -> CreateIsolatedWorldReturns {
3327        CreateIsolatedWorldReturns {
3328            executionContextId: self.executionContextId,
3329        }
3330    }
3331}
3332
3333impl<'a> CreateIsolatedWorldParams<'a> { pub const METHOD: &'static str = "Page.createIsolatedWorld"; }
3334
3335impl<'a> crate::CdpCommand<'a> for CreateIsolatedWorldParams<'a> {
3336    const METHOD: &'static str = "Page.createIsolatedWorld";
3337    type Response = CreateIsolatedWorldReturns;
3338}
3339
3340/// Deletes browser cookie with given name, domain and path.
3341
3342#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3343#[serde(rename_all = "camelCase")]
3344pub struct DeleteCookieParams<'a> {
3345    /// Name of the cookie to remove.
3346    cookieName: Cow<'a, str>,
3347    /// URL to match cooke domain and path.
3348    url: Cow<'a, str>,
3349}
3350
3351impl<'a> DeleteCookieParams<'a> {
3352    pub fn builder(cookieName: impl Into<Cow<'a, str>>, url: impl Into<Cow<'a, str>>) -> DeleteCookieParamsBuilder<'a> {
3353        DeleteCookieParamsBuilder {
3354            cookieName: cookieName.into(),
3355            url: url.into(),
3356        }
3357    }
3358    pub fn cookieName(&self) -> &str { self.cookieName.as_ref() }
3359    pub fn url(&self) -> &str { self.url.as_ref() }
3360}
3361
3362
3363pub struct DeleteCookieParamsBuilder<'a> {
3364    cookieName: Cow<'a, str>,
3365    url: Cow<'a, str>,
3366}
3367
3368impl<'a> DeleteCookieParamsBuilder<'a> {
3369    pub fn build(self) -> DeleteCookieParams<'a> {
3370        DeleteCookieParams {
3371            cookieName: self.cookieName,
3372            url: self.url,
3373        }
3374    }
3375}
3376
3377impl<'a> DeleteCookieParams<'a> { pub const METHOD: &'static str = "Page.deleteCookie"; }
3378
3379impl<'a> crate::CdpCommand<'a> for DeleteCookieParams<'a> {
3380    const METHOD: &'static str = "Page.deleteCookie";
3381    type Response = crate::EmptyReturns;
3382}
3383
3384#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3385pub struct DisableParams {}
3386
3387impl DisableParams { pub const METHOD: &'static str = "Page.disable"; }
3388
3389impl<'a> crate::CdpCommand<'a> for DisableParams {
3390    const METHOD: &'static str = "Page.disable";
3391    type Response = crate::EmptyReturns;
3392}
3393
3394/// Enables page domain notifications.
3395
3396#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3397#[serde(rename_all = "camelCase")]
3398pub struct EnableParams {
3399    /// If true, the 'Page.fileChooserOpened' event will be emitted regardless of the state set by
3400    /// 'Page.setInterceptFileChooserDialog' command (default: false).
3401    #[serde(skip_serializing_if = "Option::is_none")]
3402    enableFileChooserOpenedEvent: Option<bool>,
3403}
3404
3405impl EnableParams {
3406    pub fn builder() -> EnableParamsBuilder {
3407        EnableParamsBuilder {
3408            enableFileChooserOpenedEvent: None,
3409        }
3410    }
3411    pub fn enableFileChooserOpenedEvent(&self) -> Option<bool> { self.enableFileChooserOpenedEvent }
3412}
3413
3414#[derive(Default)]
3415pub struct EnableParamsBuilder {
3416    enableFileChooserOpenedEvent: Option<bool>,
3417}
3418
3419impl EnableParamsBuilder {
3420    /// If true, the 'Page.fileChooserOpened' event will be emitted regardless of the state set by
3421    /// 'Page.setInterceptFileChooserDialog' command (default: false).
3422    pub fn enableFileChooserOpenedEvent(mut self, enableFileChooserOpenedEvent: bool) -> Self { self.enableFileChooserOpenedEvent = Some(enableFileChooserOpenedEvent); self }
3423    pub fn build(self) -> EnableParams {
3424        EnableParams {
3425            enableFileChooserOpenedEvent: self.enableFileChooserOpenedEvent,
3426        }
3427    }
3428}
3429
3430impl EnableParams { pub const METHOD: &'static str = "Page.enable"; }
3431
3432impl<'a> crate::CdpCommand<'a> for EnableParams {
3433    const METHOD: &'static str = "Page.enable";
3434    type Response = crate::EmptyReturns;
3435}
3436
3437/// Gets the processed manifest for this current document.
3438/// This API always waits for the manifest to be loaded.
3439/// If manifestId is provided, and it does not match the manifest of the
3440/// current document, this API errors out.
3441/// If there is not a loaded page, this API errors out immediately.
3442
3443#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3444#[serde(rename_all = "camelCase")]
3445pub struct GetAppManifestParams<'a> {
3446    #[serde(skip_serializing_if = "Option::is_none")]
3447    manifestId: Option<Cow<'a, str>>,
3448}
3449
3450impl<'a> GetAppManifestParams<'a> {
3451    pub fn builder() -> GetAppManifestParamsBuilder<'a> {
3452        GetAppManifestParamsBuilder {
3453            manifestId: None,
3454        }
3455    }
3456    pub fn manifestId(&self) -> Option<&str> { self.manifestId.as_deref() }
3457}
3458
3459#[derive(Default)]
3460pub struct GetAppManifestParamsBuilder<'a> {
3461    manifestId: Option<Cow<'a, str>>,
3462}
3463
3464impl<'a> GetAppManifestParamsBuilder<'a> {
3465    pub fn manifestId(mut self, manifestId: impl Into<Cow<'a, str>>) -> Self { self.manifestId = Some(manifestId.into()); self }
3466    pub fn build(self) -> GetAppManifestParams<'a> {
3467        GetAppManifestParams {
3468            manifestId: self.manifestId,
3469        }
3470    }
3471}
3472
3473/// Gets the processed manifest for this current document.
3474/// This API always waits for the manifest to be loaded.
3475/// If manifestId is provided, and it does not match the manifest of the
3476/// current document, this API errors out.
3477/// If there is not a loaded page, this API errors out immediately.
3478
3479#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3480#[serde(rename_all = "camelCase")]
3481pub struct GetAppManifestReturns<'a> {
3482    /// Manifest location.
3483    url: Cow<'a, str>,
3484    errors: Vec<AppManifestError<'a>>,
3485    /// Manifest content.
3486    #[serde(skip_serializing_if = "Option::is_none")]
3487    data: Option<Cow<'a, str>>,
3488    /// Parsed manifest properties. Deprecated, use manifest instead.
3489    #[serde(skip_serializing_if = "Option::is_none")]
3490    parsed: Option<AppManifestParsedProperties<'a>>,
3491    manifest: WebAppManifest<'a>,
3492}
3493
3494impl<'a> GetAppManifestReturns<'a> {
3495    pub fn builder(url: impl Into<Cow<'a, str>>, errors: Vec<AppManifestError<'a>>, manifest: WebAppManifest<'a>) -> GetAppManifestReturnsBuilder<'a> {
3496        GetAppManifestReturnsBuilder {
3497            url: url.into(),
3498            errors: errors,
3499            data: None,
3500            parsed: None,
3501            manifest: manifest,
3502        }
3503    }
3504    pub fn url(&self) -> &str { self.url.as_ref() }
3505    pub fn errors(&self) -> &[AppManifestError<'a>] { &self.errors }
3506    pub fn data(&self) -> Option<&str> { self.data.as_deref() }
3507    pub fn parsed(&self) -> Option<&AppManifestParsedProperties<'a>> { self.parsed.as_ref() }
3508    pub fn manifest(&self) -> &WebAppManifest<'a> { &self.manifest }
3509}
3510
3511
3512pub struct GetAppManifestReturnsBuilder<'a> {
3513    url: Cow<'a, str>,
3514    errors: Vec<AppManifestError<'a>>,
3515    data: Option<Cow<'a, str>>,
3516    parsed: Option<AppManifestParsedProperties<'a>>,
3517    manifest: WebAppManifest<'a>,
3518}
3519
3520impl<'a> GetAppManifestReturnsBuilder<'a> {
3521    /// Manifest content.
3522    pub fn data(mut self, data: impl Into<Cow<'a, str>>) -> Self { self.data = Some(data.into()); self }
3523    /// Parsed manifest properties. Deprecated, use manifest instead.
3524    pub fn parsed(mut self, parsed: AppManifestParsedProperties<'a>) -> Self { self.parsed = Some(parsed); self }
3525    pub fn build(self) -> GetAppManifestReturns<'a> {
3526        GetAppManifestReturns {
3527            url: self.url,
3528            errors: self.errors,
3529            data: self.data,
3530            parsed: self.parsed,
3531            manifest: self.manifest,
3532        }
3533    }
3534}
3535
3536impl<'a> GetAppManifestParams<'a> { pub const METHOD: &'static str = "Page.getAppManifest"; }
3537
3538impl<'a> crate::CdpCommand<'a> for GetAppManifestParams<'a> {
3539    const METHOD: &'static str = "Page.getAppManifest";
3540    type Response = GetAppManifestReturns<'a>;
3541}
3542
3543
3544#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3545#[serde(rename_all = "camelCase")]
3546pub struct GetInstallabilityErrorsReturns<'a> {
3547    installabilityErrors: Vec<InstallabilityError<'a>>,
3548}
3549
3550impl<'a> GetInstallabilityErrorsReturns<'a> {
3551    pub fn builder(installabilityErrors: Vec<InstallabilityError<'a>>) -> GetInstallabilityErrorsReturnsBuilder<'a> {
3552        GetInstallabilityErrorsReturnsBuilder {
3553            installabilityErrors: installabilityErrors,
3554        }
3555    }
3556    pub fn installabilityErrors(&self) -> &[InstallabilityError<'a>] { &self.installabilityErrors }
3557}
3558
3559
3560pub struct GetInstallabilityErrorsReturnsBuilder<'a> {
3561    installabilityErrors: Vec<InstallabilityError<'a>>,
3562}
3563
3564impl<'a> GetInstallabilityErrorsReturnsBuilder<'a> {
3565    pub fn build(self) -> GetInstallabilityErrorsReturns<'a> {
3566        GetInstallabilityErrorsReturns {
3567            installabilityErrors: self.installabilityErrors,
3568        }
3569    }
3570}
3571
3572#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3573pub struct GetInstallabilityErrorsParams {}
3574
3575impl GetInstallabilityErrorsParams { pub const METHOD: &'static str = "Page.getInstallabilityErrors"; }
3576
3577impl<'a> crate::CdpCommand<'a> for GetInstallabilityErrorsParams {
3578    const METHOD: &'static str = "Page.getInstallabilityErrors";
3579    type Response = GetInstallabilityErrorsReturns<'a>;
3580}
3581
3582/// Deprecated because it's not guaranteed that the returned icon is in fact the one used for PWA installation.
3583
3584#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3585#[serde(rename_all = "camelCase")]
3586pub struct GetManifestIconsReturns<'a> {
3587    #[serde(skip_serializing_if = "Option::is_none")]
3588    primaryIcon: Option<Cow<'a, str>>,
3589}
3590
3591impl<'a> GetManifestIconsReturns<'a> {
3592    pub fn builder() -> GetManifestIconsReturnsBuilder<'a> {
3593        GetManifestIconsReturnsBuilder {
3594            primaryIcon: None,
3595        }
3596    }
3597    pub fn primaryIcon(&self) -> Option<&str> { self.primaryIcon.as_deref() }
3598}
3599
3600#[derive(Default)]
3601pub struct GetManifestIconsReturnsBuilder<'a> {
3602    primaryIcon: Option<Cow<'a, str>>,
3603}
3604
3605impl<'a> GetManifestIconsReturnsBuilder<'a> {
3606    pub fn primaryIcon(mut self, primaryIcon: impl Into<Cow<'a, str>>) -> Self { self.primaryIcon = Some(primaryIcon.into()); self }
3607    pub fn build(self) -> GetManifestIconsReturns<'a> {
3608        GetManifestIconsReturns {
3609            primaryIcon: self.primaryIcon,
3610        }
3611    }
3612}
3613
3614#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3615pub struct GetManifestIconsParams {}
3616
3617impl GetManifestIconsParams { pub const METHOD: &'static str = "Page.getManifestIcons"; }
3618
3619impl<'a> crate::CdpCommand<'a> for GetManifestIconsParams {
3620    const METHOD: &'static str = "Page.getManifestIcons";
3621    type Response = GetManifestIconsReturns<'a>;
3622}
3623
3624/// Returns the unique (PWA) app id.
3625/// Only returns values if the feature flag 'WebAppEnableManifestId' is enabled
3626
3627#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3628#[serde(rename_all = "camelCase")]
3629pub struct GetAppIdReturns<'a> {
3630    /// App id, either from manifest's id attribute or computed from start_url
3631    #[serde(skip_serializing_if = "Option::is_none")]
3632    appId: Option<Cow<'a, str>>,
3633    /// Recommendation for manifest's id attribute to match current id computed from start_url
3634    #[serde(skip_serializing_if = "Option::is_none")]
3635    recommendedId: Option<Cow<'a, str>>,
3636}
3637
3638impl<'a> GetAppIdReturns<'a> {
3639    pub fn builder() -> GetAppIdReturnsBuilder<'a> {
3640        GetAppIdReturnsBuilder {
3641            appId: None,
3642            recommendedId: None,
3643        }
3644    }
3645    pub fn appId(&self) -> Option<&str> { self.appId.as_deref() }
3646    pub fn recommendedId(&self) -> Option<&str> { self.recommendedId.as_deref() }
3647}
3648
3649#[derive(Default)]
3650pub struct GetAppIdReturnsBuilder<'a> {
3651    appId: Option<Cow<'a, str>>,
3652    recommendedId: Option<Cow<'a, str>>,
3653}
3654
3655impl<'a> GetAppIdReturnsBuilder<'a> {
3656    /// App id, either from manifest's id attribute or computed from start_url
3657    pub fn appId(mut self, appId: impl Into<Cow<'a, str>>) -> Self { self.appId = Some(appId.into()); self }
3658    /// Recommendation for manifest's id attribute to match current id computed from start_url
3659    pub fn recommendedId(mut self, recommendedId: impl Into<Cow<'a, str>>) -> Self { self.recommendedId = Some(recommendedId.into()); self }
3660    pub fn build(self) -> GetAppIdReturns<'a> {
3661        GetAppIdReturns {
3662            appId: self.appId,
3663            recommendedId: self.recommendedId,
3664        }
3665    }
3666}
3667
3668#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3669pub struct GetAppIdParams {}
3670
3671impl GetAppIdParams { pub const METHOD: &'static str = "Page.getAppId"; }
3672
3673impl<'a> crate::CdpCommand<'a> for GetAppIdParams {
3674    const METHOD: &'static str = "Page.getAppId";
3675    type Response = GetAppIdReturns<'a>;
3676}
3677
3678
3679#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3680#[serde(rename_all = "camelCase")]
3681pub struct GetAdScriptAncestryParams<'a> {
3682    frameId: FrameId<'a>,
3683}
3684
3685impl<'a> GetAdScriptAncestryParams<'a> {
3686    pub fn builder(frameId: FrameId<'a>) -> GetAdScriptAncestryParamsBuilder<'a> {
3687        GetAdScriptAncestryParamsBuilder {
3688            frameId: frameId,
3689        }
3690    }
3691    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
3692}
3693
3694
3695pub struct GetAdScriptAncestryParamsBuilder<'a> {
3696    frameId: FrameId<'a>,
3697}
3698
3699impl<'a> GetAdScriptAncestryParamsBuilder<'a> {
3700    pub fn build(self) -> GetAdScriptAncestryParams<'a> {
3701        GetAdScriptAncestryParams {
3702            frameId: self.frameId,
3703        }
3704    }
3705}
3706
3707
3708#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3709#[serde(rename_all = "camelCase")]
3710pub struct GetAdScriptAncestryReturns<'a> {
3711    /// The ancestry chain of ad script identifiers leading to this frame's
3712    /// creation, along with the root script's filterlist rule. The ancestry
3713    /// chain is ordered from the most immediate script (in the frame creation
3714    /// stack) to more distant ancestors (that created the immediately preceding
3715    /// script). Only sent if frame is labelled as an ad and ids are available.
3716    #[serde(skip_serializing_if = "Option::is_none")]
3717    adScriptAncestry: Option<crate::network::AdAncestry<'a>>,
3718}
3719
3720impl<'a> GetAdScriptAncestryReturns<'a> {
3721    pub fn builder() -> GetAdScriptAncestryReturnsBuilder<'a> {
3722        GetAdScriptAncestryReturnsBuilder {
3723            adScriptAncestry: None,
3724        }
3725    }
3726    pub fn adScriptAncestry(&self) -> Option<&crate::network::AdAncestry<'a>> { self.adScriptAncestry.as_ref() }
3727}
3728
3729#[derive(Default)]
3730pub struct GetAdScriptAncestryReturnsBuilder<'a> {
3731    adScriptAncestry: Option<crate::network::AdAncestry<'a>>,
3732}
3733
3734impl<'a> GetAdScriptAncestryReturnsBuilder<'a> {
3735    /// The ancestry chain of ad script identifiers leading to this frame's
3736    /// creation, along with the root script's filterlist rule. The ancestry
3737    /// chain is ordered from the most immediate script (in the frame creation
3738    /// stack) to more distant ancestors (that created the immediately preceding
3739    /// script). Only sent if frame is labelled as an ad and ids are available.
3740    pub fn adScriptAncestry(mut self, adScriptAncestry: crate::network::AdAncestry<'a>) -> Self { self.adScriptAncestry = Some(adScriptAncestry); self }
3741    pub fn build(self) -> GetAdScriptAncestryReturns<'a> {
3742        GetAdScriptAncestryReturns {
3743            adScriptAncestry: self.adScriptAncestry,
3744        }
3745    }
3746}
3747
3748impl<'a> GetAdScriptAncestryParams<'a> { pub const METHOD: &'static str = "Page.getAdScriptAncestry"; }
3749
3750impl<'a> crate::CdpCommand<'a> for GetAdScriptAncestryParams<'a> {
3751    const METHOD: &'static str = "Page.getAdScriptAncestry";
3752    type Response = GetAdScriptAncestryReturns<'a>;
3753}
3754
3755/// Returns present frame tree structure.
3756
3757#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3758#[serde(rename_all = "camelCase")]
3759pub struct GetFrameTreeReturns<'a> {
3760    /// Present frame tree structure.
3761    frameTree: FrameTree<'a>,
3762}
3763
3764impl<'a> GetFrameTreeReturns<'a> {
3765    pub fn builder(frameTree: FrameTree<'a>) -> GetFrameTreeReturnsBuilder<'a> {
3766        GetFrameTreeReturnsBuilder {
3767            frameTree: frameTree,
3768        }
3769    }
3770    pub fn frameTree(&self) -> &FrameTree<'a> { &self.frameTree }
3771}
3772
3773
3774pub struct GetFrameTreeReturnsBuilder<'a> {
3775    frameTree: FrameTree<'a>,
3776}
3777
3778impl<'a> GetFrameTreeReturnsBuilder<'a> {
3779    pub fn build(self) -> GetFrameTreeReturns<'a> {
3780        GetFrameTreeReturns {
3781            frameTree: self.frameTree,
3782        }
3783    }
3784}
3785
3786#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3787pub struct GetFrameTreeParams {}
3788
3789impl GetFrameTreeParams { pub const METHOD: &'static str = "Page.getFrameTree"; }
3790
3791impl<'a> crate::CdpCommand<'a> for GetFrameTreeParams {
3792    const METHOD: &'static str = "Page.getFrameTree";
3793    type Response = GetFrameTreeReturns<'a>;
3794}
3795
3796/// Returns metrics relating to the layouting of the page, such as viewport bounds/scale.
3797
3798#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3799#[serde(rename_all = "camelCase")]
3800pub struct GetLayoutMetricsReturns {
3801    /// Deprecated metrics relating to the layout viewport. Is in device pixels. Use 'cssLayoutViewport' instead.
3802    layoutViewport: LayoutViewport,
3803    /// Deprecated metrics relating to the visual viewport. Is in device pixels. Use 'cssVisualViewport' instead.
3804    visualViewport: VisualViewport,
3805    /// Deprecated size of scrollable area. Is in DP. Use 'cssContentSize' instead.
3806    contentSize: crate::dom::Rect,
3807    /// Metrics relating to the layout viewport in CSS pixels.
3808    cssLayoutViewport: LayoutViewport,
3809    /// Metrics relating to the visual viewport in CSS pixels.
3810    cssVisualViewport: VisualViewport,
3811    /// Size of scrollable area in CSS pixels.
3812    cssContentSize: crate::dom::Rect,
3813}
3814
3815impl GetLayoutMetricsReturns {
3816    pub fn builder(layoutViewport: LayoutViewport, visualViewport: VisualViewport, contentSize: crate::dom::Rect, cssLayoutViewport: LayoutViewport, cssVisualViewport: VisualViewport, cssContentSize: crate::dom::Rect) -> GetLayoutMetricsReturnsBuilder {
3817        GetLayoutMetricsReturnsBuilder {
3818            layoutViewport: layoutViewport,
3819            visualViewport: visualViewport,
3820            contentSize: contentSize,
3821            cssLayoutViewport: cssLayoutViewport,
3822            cssVisualViewport: cssVisualViewport,
3823            cssContentSize: cssContentSize,
3824        }
3825    }
3826    pub fn layoutViewport(&self) -> &LayoutViewport { &self.layoutViewport }
3827    pub fn visualViewport(&self) -> &VisualViewport { &self.visualViewport }
3828    pub fn contentSize(&self) -> &crate::dom::Rect { &self.contentSize }
3829    pub fn cssLayoutViewport(&self) -> &LayoutViewport { &self.cssLayoutViewport }
3830    pub fn cssVisualViewport(&self) -> &VisualViewport { &self.cssVisualViewport }
3831    pub fn cssContentSize(&self) -> &crate::dom::Rect { &self.cssContentSize }
3832}
3833
3834
3835pub struct GetLayoutMetricsReturnsBuilder {
3836    layoutViewport: LayoutViewport,
3837    visualViewport: VisualViewport,
3838    contentSize: crate::dom::Rect,
3839    cssLayoutViewport: LayoutViewport,
3840    cssVisualViewport: VisualViewport,
3841    cssContentSize: crate::dom::Rect,
3842}
3843
3844impl GetLayoutMetricsReturnsBuilder {
3845    pub fn build(self) -> GetLayoutMetricsReturns {
3846        GetLayoutMetricsReturns {
3847            layoutViewport: self.layoutViewport,
3848            visualViewport: self.visualViewport,
3849            contentSize: self.contentSize,
3850            cssLayoutViewport: self.cssLayoutViewport,
3851            cssVisualViewport: self.cssVisualViewport,
3852            cssContentSize: self.cssContentSize,
3853        }
3854    }
3855}
3856
3857#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3858pub struct GetLayoutMetricsParams {}
3859
3860impl GetLayoutMetricsParams { pub const METHOD: &'static str = "Page.getLayoutMetrics"; }
3861
3862impl<'a> crate::CdpCommand<'a> for GetLayoutMetricsParams {
3863    const METHOD: &'static str = "Page.getLayoutMetrics";
3864    type Response = GetLayoutMetricsReturns;
3865}
3866
3867/// Returns navigation history for the current page.
3868
3869#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3870#[serde(rename_all = "camelCase")]
3871pub struct GetNavigationHistoryReturns<'a> {
3872    /// Index of the current navigation history entry.
3873    currentIndex: u64,
3874    /// Array of navigation history entries.
3875    entries: Vec<NavigationEntry<'a>>,
3876}
3877
3878impl<'a> GetNavigationHistoryReturns<'a> {
3879    pub fn builder(currentIndex: u64, entries: Vec<NavigationEntry<'a>>) -> GetNavigationHistoryReturnsBuilder<'a> {
3880        GetNavigationHistoryReturnsBuilder {
3881            currentIndex: currentIndex,
3882            entries: entries,
3883        }
3884    }
3885    pub fn currentIndex(&self) -> u64 { self.currentIndex }
3886    pub fn entries(&self) -> &[NavigationEntry<'a>] { &self.entries }
3887}
3888
3889
3890pub struct GetNavigationHistoryReturnsBuilder<'a> {
3891    currentIndex: u64,
3892    entries: Vec<NavigationEntry<'a>>,
3893}
3894
3895impl<'a> GetNavigationHistoryReturnsBuilder<'a> {
3896    pub fn build(self) -> GetNavigationHistoryReturns<'a> {
3897        GetNavigationHistoryReturns {
3898            currentIndex: self.currentIndex,
3899            entries: self.entries,
3900        }
3901    }
3902}
3903
3904#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3905pub struct GetNavigationHistoryParams {}
3906
3907impl GetNavigationHistoryParams { pub const METHOD: &'static str = "Page.getNavigationHistory"; }
3908
3909impl<'a> crate::CdpCommand<'a> for GetNavigationHistoryParams {
3910    const METHOD: &'static str = "Page.getNavigationHistory";
3911    type Response = GetNavigationHistoryReturns<'a>;
3912}
3913
3914#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3915pub struct ResetNavigationHistoryParams {}
3916
3917impl ResetNavigationHistoryParams { pub const METHOD: &'static str = "Page.resetNavigationHistory"; }
3918
3919impl<'a> crate::CdpCommand<'a> for ResetNavigationHistoryParams {
3920    const METHOD: &'static str = "Page.resetNavigationHistory";
3921    type Response = crate::EmptyReturns;
3922}
3923
3924/// Returns content of the given resource.
3925
3926#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3927#[serde(rename_all = "camelCase")]
3928pub struct GetResourceContentParams<'a> {
3929    /// Frame id to get resource for.
3930    frameId: FrameId<'a>,
3931    /// URL of the resource to get content for.
3932    url: Cow<'a, str>,
3933}
3934
3935impl<'a> GetResourceContentParams<'a> {
3936    pub fn builder(frameId: FrameId<'a>, url: impl Into<Cow<'a, str>>) -> GetResourceContentParamsBuilder<'a> {
3937        GetResourceContentParamsBuilder {
3938            frameId: frameId,
3939            url: url.into(),
3940        }
3941    }
3942    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
3943    pub fn url(&self) -> &str { self.url.as_ref() }
3944}
3945
3946
3947pub struct GetResourceContentParamsBuilder<'a> {
3948    frameId: FrameId<'a>,
3949    url: Cow<'a, str>,
3950}
3951
3952impl<'a> GetResourceContentParamsBuilder<'a> {
3953    pub fn build(self) -> GetResourceContentParams<'a> {
3954        GetResourceContentParams {
3955            frameId: self.frameId,
3956            url: self.url,
3957        }
3958    }
3959}
3960
3961/// Returns content of the given resource.
3962
3963#[derive(Debug, Clone, Serialize, Deserialize, Default)]
3964#[serde(rename_all = "camelCase")]
3965pub struct GetResourceContentReturns<'a> {
3966    /// Resource content.
3967    content: Cow<'a, str>,
3968    /// True, if content was served as base64.
3969    base64Encoded: bool,
3970}
3971
3972impl<'a> GetResourceContentReturns<'a> {
3973    pub fn builder(content: impl Into<Cow<'a, str>>, base64Encoded: bool) -> GetResourceContentReturnsBuilder<'a> {
3974        GetResourceContentReturnsBuilder {
3975            content: content.into(),
3976            base64Encoded: base64Encoded,
3977        }
3978    }
3979    pub fn content(&self) -> &str { self.content.as_ref() }
3980    pub fn base64Encoded(&self) -> bool { self.base64Encoded }
3981}
3982
3983
3984pub struct GetResourceContentReturnsBuilder<'a> {
3985    content: Cow<'a, str>,
3986    base64Encoded: bool,
3987}
3988
3989impl<'a> GetResourceContentReturnsBuilder<'a> {
3990    pub fn build(self) -> GetResourceContentReturns<'a> {
3991        GetResourceContentReturns {
3992            content: self.content,
3993            base64Encoded: self.base64Encoded,
3994        }
3995    }
3996}
3997
3998impl<'a> GetResourceContentParams<'a> { pub const METHOD: &'static str = "Page.getResourceContent"; }
3999
4000impl<'a> crate::CdpCommand<'a> for GetResourceContentParams<'a> {
4001    const METHOD: &'static str = "Page.getResourceContent";
4002    type Response = GetResourceContentReturns<'a>;
4003}
4004
4005/// Returns present frame / resource tree structure.
4006
4007#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4008#[serde(rename_all = "camelCase")]
4009pub struct GetResourceTreeReturns<'a> {
4010    /// Present frame / resource tree structure.
4011    frameTree: FrameResourceTree<'a>,
4012}
4013
4014impl<'a> GetResourceTreeReturns<'a> {
4015    pub fn builder(frameTree: FrameResourceTree<'a>) -> GetResourceTreeReturnsBuilder<'a> {
4016        GetResourceTreeReturnsBuilder {
4017            frameTree: frameTree,
4018        }
4019    }
4020    pub fn frameTree(&self) -> &FrameResourceTree<'a> { &self.frameTree }
4021}
4022
4023
4024pub struct GetResourceTreeReturnsBuilder<'a> {
4025    frameTree: FrameResourceTree<'a>,
4026}
4027
4028impl<'a> GetResourceTreeReturnsBuilder<'a> {
4029    pub fn build(self) -> GetResourceTreeReturns<'a> {
4030        GetResourceTreeReturns {
4031            frameTree: self.frameTree,
4032        }
4033    }
4034}
4035
4036#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4037pub struct GetResourceTreeParams {}
4038
4039impl GetResourceTreeParams { pub const METHOD: &'static str = "Page.getResourceTree"; }
4040
4041impl<'a> crate::CdpCommand<'a> for GetResourceTreeParams {
4042    const METHOD: &'static str = "Page.getResourceTree";
4043    type Response = GetResourceTreeReturns<'a>;
4044}
4045
4046/// Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).
4047
4048#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4049#[serde(rename_all = "camelCase")]
4050pub struct HandleJavaScriptDialogParams<'a> {
4051    /// Whether to accept or dismiss the dialog.
4052    accept: bool,
4053    /// The text to enter into the dialog prompt before accepting. Used only if this is a prompt
4054    /// dialog.
4055    #[serde(skip_serializing_if = "Option::is_none")]
4056    promptText: Option<Cow<'a, str>>,
4057}
4058
4059impl<'a> HandleJavaScriptDialogParams<'a> {
4060    pub fn builder(accept: bool) -> HandleJavaScriptDialogParamsBuilder<'a> {
4061        HandleJavaScriptDialogParamsBuilder {
4062            accept: accept,
4063            promptText: None,
4064        }
4065    }
4066    pub fn accept(&self) -> bool { self.accept }
4067    pub fn promptText(&self) -> Option<&str> { self.promptText.as_deref() }
4068}
4069
4070
4071pub struct HandleJavaScriptDialogParamsBuilder<'a> {
4072    accept: bool,
4073    promptText: Option<Cow<'a, str>>,
4074}
4075
4076impl<'a> HandleJavaScriptDialogParamsBuilder<'a> {
4077    /// The text to enter into the dialog prompt before accepting. Used only if this is a prompt
4078    /// dialog.
4079    pub fn promptText(mut self, promptText: impl Into<Cow<'a, str>>) -> Self { self.promptText = Some(promptText.into()); self }
4080    pub fn build(self) -> HandleJavaScriptDialogParams<'a> {
4081        HandleJavaScriptDialogParams {
4082            accept: self.accept,
4083            promptText: self.promptText,
4084        }
4085    }
4086}
4087
4088impl<'a> HandleJavaScriptDialogParams<'a> { pub const METHOD: &'static str = "Page.handleJavaScriptDialog"; }
4089
4090impl<'a> crate::CdpCommand<'a> for HandleJavaScriptDialogParams<'a> {
4091    const METHOD: &'static str = "Page.handleJavaScriptDialog";
4092    type Response = crate::EmptyReturns;
4093}
4094
4095/// Navigates current page to the given URL.
4096
4097#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4098#[serde(rename_all = "camelCase")]
4099pub struct NavigateParams<'a> {
4100    /// URL to navigate the page to.
4101    url: Cow<'a, str>,
4102    /// Referrer URL.
4103    #[serde(skip_serializing_if = "Option::is_none")]
4104    referrer: Option<Cow<'a, str>>,
4105    /// Intended transition type.
4106    #[serde(skip_serializing_if = "Option::is_none")]
4107    transitionType: Option<TransitionType>,
4108    /// Frame id to navigate, if not specified navigates the top frame.
4109    #[serde(skip_serializing_if = "Option::is_none")]
4110    frameId: Option<FrameId<'a>>,
4111    /// Referrer-policy used for the navigation.
4112    #[serde(skip_serializing_if = "Option::is_none")]
4113    referrerPolicy: Option<ReferrerPolicy>,
4114}
4115
4116impl<'a> NavigateParams<'a> {
4117    pub fn builder(url: impl Into<Cow<'a, str>>) -> NavigateParamsBuilder<'a> {
4118        NavigateParamsBuilder {
4119            url: url.into(),
4120            referrer: None,
4121            transitionType: None,
4122            frameId: None,
4123            referrerPolicy: None,
4124        }
4125    }
4126    pub fn url(&self) -> &str { self.url.as_ref() }
4127    pub fn referrer(&self) -> Option<&str> { self.referrer.as_deref() }
4128    pub fn transitionType(&self) -> Option<&TransitionType> { self.transitionType.as_ref() }
4129    pub fn frameId(&self) -> Option<&FrameId<'a>> { self.frameId.as_ref() }
4130    pub fn referrerPolicy(&self) -> Option<&ReferrerPolicy> { self.referrerPolicy.as_ref() }
4131}
4132
4133
4134pub struct NavigateParamsBuilder<'a> {
4135    url: Cow<'a, str>,
4136    referrer: Option<Cow<'a, str>>,
4137    transitionType: Option<TransitionType>,
4138    frameId: Option<FrameId<'a>>,
4139    referrerPolicy: Option<ReferrerPolicy>,
4140}
4141
4142impl<'a> NavigateParamsBuilder<'a> {
4143    /// Referrer URL.
4144    pub fn referrer(mut self, referrer: impl Into<Cow<'a, str>>) -> Self { self.referrer = Some(referrer.into()); self }
4145    /// Intended transition type.
4146    pub fn transitionType(mut self, transitionType: TransitionType) -> Self { self.transitionType = Some(transitionType); self }
4147    /// Frame id to navigate, if not specified navigates the top frame.
4148    pub fn frameId(mut self, frameId: FrameId<'a>) -> Self { self.frameId = Some(frameId); self }
4149    /// Referrer-policy used for the navigation.
4150    pub fn referrerPolicy(mut self, referrerPolicy: ReferrerPolicy) -> Self { self.referrerPolicy = Some(referrerPolicy); self }
4151    pub fn build(self) -> NavigateParams<'a> {
4152        NavigateParams {
4153            url: self.url,
4154            referrer: self.referrer,
4155            transitionType: self.transitionType,
4156            frameId: self.frameId,
4157            referrerPolicy: self.referrerPolicy,
4158        }
4159    }
4160}
4161
4162/// Navigates current page to the given URL.
4163
4164#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4165#[serde(rename_all = "camelCase")]
4166pub struct NavigateReturns<'a> {
4167    /// Frame id that has navigated (or failed to navigate)
4168    frameId: FrameId<'a>,
4169    /// Loader identifier. This is omitted in case of same-document navigation,
4170    /// as the previously committed loaderId would not change.
4171    #[serde(skip_serializing_if = "Option::is_none")]
4172    loaderId: Option<crate::network::LoaderId<'a>>,
4173    /// User friendly error message, present if and only if navigation has failed.
4174    #[serde(skip_serializing_if = "Option::is_none")]
4175    errorText: Option<Cow<'a, str>>,
4176    /// Whether the navigation resulted in a download.
4177    #[serde(skip_serializing_if = "Option::is_none")]
4178    isDownload: Option<bool>,
4179}
4180
4181impl<'a> NavigateReturns<'a> {
4182    pub fn builder(frameId: FrameId<'a>) -> NavigateReturnsBuilder<'a> {
4183        NavigateReturnsBuilder {
4184            frameId: frameId,
4185            loaderId: None,
4186            errorText: None,
4187            isDownload: None,
4188        }
4189    }
4190    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
4191    pub fn loaderId(&self) -> Option<&crate::network::LoaderId<'a>> { self.loaderId.as_ref() }
4192    pub fn errorText(&self) -> Option<&str> { self.errorText.as_deref() }
4193    pub fn isDownload(&self) -> Option<bool> { self.isDownload }
4194}
4195
4196
4197pub struct NavigateReturnsBuilder<'a> {
4198    frameId: FrameId<'a>,
4199    loaderId: Option<crate::network::LoaderId<'a>>,
4200    errorText: Option<Cow<'a, str>>,
4201    isDownload: Option<bool>,
4202}
4203
4204impl<'a> NavigateReturnsBuilder<'a> {
4205    /// Loader identifier. This is omitted in case of same-document navigation,
4206    /// as the previously committed loaderId would not change.
4207    pub fn loaderId(mut self, loaderId: crate::network::LoaderId<'a>) -> Self { self.loaderId = Some(loaderId); self }
4208    /// User friendly error message, present if and only if navigation has failed.
4209    pub fn errorText(mut self, errorText: impl Into<Cow<'a, str>>) -> Self { self.errorText = Some(errorText.into()); self }
4210    /// Whether the navigation resulted in a download.
4211    pub fn isDownload(mut self, isDownload: bool) -> Self { self.isDownload = Some(isDownload); self }
4212    pub fn build(self) -> NavigateReturns<'a> {
4213        NavigateReturns {
4214            frameId: self.frameId,
4215            loaderId: self.loaderId,
4216            errorText: self.errorText,
4217            isDownload: self.isDownload,
4218        }
4219    }
4220}
4221
4222impl<'a> NavigateParams<'a> { pub const METHOD: &'static str = "Page.navigate"; }
4223
4224impl<'a> crate::CdpCommand<'a> for NavigateParams<'a> {
4225    const METHOD: &'static str = "Page.navigate";
4226    type Response = NavigateReturns<'a>;
4227}
4228
4229/// Navigates current page to the given history entry.
4230
4231#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4232#[serde(rename_all = "camelCase")]
4233pub struct NavigateToHistoryEntryParams {
4234    /// Unique id of the entry to navigate to.
4235    entryId: u64,
4236}
4237
4238impl NavigateToHistoryEntryParams {
4239    pub fn builder(entryId: u64) -> NavigateToHistoryEntryParamsBuilder {
4240        NavigateToHistoryEntryParamsBuilder {
4241            entryId: entryId,
4242        }
4243    }
4244    pub fn entryId(&self) -> u64 { self.entryId }
4245}
4246
4247
4248pub struct NavigateToHistoryEntryParamsBuilder {
4249    entryId: u64,
4250}
4251
4252impl NavigateToHistoryEntryParamsBuilder {
4253    pub fn build(self) -> NavigateToHistoryEntryParams {
4254        NavigateToHistoryEntryParams {
4255            entryId: self.entryId,
4256        }
4257    }
4258}
4259
4260impl NavigateToHistoryEntryParams { pub const METHOD: &'static str = "Page.navigateToHistoryEntry"; }
4261
4262impl<'a> crate::CdpCommand<'a> for NavigateToHistoryEntryParams {
4263    const METHOD: &'static str = "Page.navigateToHistoryEntry";
4264    type Response = crate::EmptyReturns;
4265}
4266
4267/// Print page as PDF.
4268
4269#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4270#[serde(rename_all = "camelCase")]
4271pub struct PrintToPDFParams<'a> {
4272    /// Paper orientation. Defaults to false.
4273    #[serde(skip_serializing_if = "Option::is_none")]
4274    landscape: Option<bool>,
4275    /// Display header and footer. Defaults to false.
4276    #[serde(skip_serializing_if = "Option::is_none")]
4277    displayHeaderFooter: Option<bool>,
4278    /// Print background graphics. Defaults to false.
4279    #[serde(skip_serializing_if = "Option::is_none")]
4280    printBackground: Option<bool>,
4281    /// Scale of the webpage rendering. Defaults to 1.
4282    #[serde(skip_serializing_if = "Option::is_none")]
4283    scale: Option<f64>,
4284    /// Paper width in inches. Defaults to 8.5 inches.
4285    #[serde(skip_serializing_if = "Option::is_none")]
4286    paperWidth: Option<f64>,
4287    /// Paper height in inches. Defaults to 11 inches.
4288    #[serde(skip_serializing_if = "Option::is_none")]
4289    paperHeight: Option<f64>,
4290    /// Top margin in inches. Defaults to 1cm (~0.4 inches).
4291    #[serde(skip_serializing_if = "Option::is_none")]
4292    marginTop: Option<f64>,
4293    /// Bottom margin in inches. Defaults to 1cm (~0.4 inches).
4294    #[serde(skip_serializing_if = "Option::is_none")]
4295    marginBottom: Option<f64>,
4296    /// Left margin in inches. Defaults to 1cm (~0.4 inches).
4297    #[serde(skip_serializing_if = "Option::is_none")]
4298    marginLeft: Option<f64>,
4299    /// Right margin in inches. Defaults to 1cm (~0.4 inches).
4300    #[serde(skip_serializing_if = "Option::is_none")]
4301    marginRight: Option<f64>,
4302    /// Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are
4303    /// printed in the document order, not in the order specified, and no
4304    /// more than once.
4305    /// Defaults to empty string, which implies the entire document is printed.
4306    /// The page numbers are quietly capped to actual page count of the
4307    /// document, and ranges beyond the end of the document are ignored.
4308    /// If this results in no pages to print, an error is reported.
4309    /// It is an error to specify a range with start greater than end.
4310    #[serde(skip_serializing_if = "Option::is_none")]
4311    pageRanges: Option<Cow<'a, str>>,
4312    /// HTML template for the print header. Should be valid HTML markup with following
4313    /// classes used to inject printing values into them:
4314    /// - 'date': formatted print date
4315    /// - 'title': document title
4316    /// - 'url': document location
4317    /// - 'pageNumber': current page number
4318    /// - 'totalPages': total pages in the document
4319    /// 
4320    /// For example, '<span class=title></span>' would generate span containing the title.
4321    #[serde(skip_serializing_if = "Option::is_none")]
4322    headerTemplate: Option<Cow<'a, str>>,
4323    /// HTML template for the print footer. Should use the same format as the 'headerTemplate'.
4324    #[serde(skip_serializing_if = "Option::is_none")]
4325    footerTemplate: Option<Cow<'a, str>>,
4326    /// Whether or not to prefer page size as defined by css. Defaults to false,
4327    /// in which case the content will be scaled to fit the paper size.
4328    #[serde(skip_serializing_if = "Option::is_none")]
4329    preferCSSPageSize: Option<bool>,
4330    /// return as stream
4331    #[serde(skip_serializing_if = "Option::is_none")]
4332    transferMode: Option<Cow<'a, str>>,
4333    /// Whether or not to generate tagged (accessible) PDF. Defaults to embedder choice.
4334    #[serde(skip_serializing_if = "Option::is_none")]
4335    generateTaggedPDF: Option<bool>,
4336    /// Whether or not to embed the document outline into the PDF.
4337    #[serde(skip_serializing_if = "Option::is_none")]
4338    generateDocumentOutline: Option<bool>,
4339}
4340
4341impl<'a> PrintToPDFParams<'a> {
4342    pub fn builder() -> PrintToPDFParamsBuilder<'a> {
4343        PrintToPDFParamsBuilder {
4344            landscape: None,
4345            displayHeaderFooter: None,
4346            printBackground: None,
4347            scale: None,
4348            paperWidth: None,
4349            paperHeight: None,
4350            marginTop: None,
4351            marginBottom: None,
4352            marginLeft: None,
4353            marginRight: None,
4354            pageRanges: None,
4355            headerTemplate: None,
4356            footerTemplate: None,
4357            preferCSSPageSize: None,
4358            transferMode: None,
4359            generateTaggedPDF: None,
4360            generateDocumentOutline: None,
4361        }
4362    }
4363    pub fn landscape(&self) -> Option<bool> { self.landscape }
4364    pub fn displayHeaderFooter(&self) -> Option<bool> { self.displayHeaderFooter }
4365    pub fn printBackground(&self) -> Option<bool> { self.printBackground }
4366    pub fn scale(&self) -> Option<f64> { self.scale }
4367    pub fn paperWidth(&self) -> Option<f64> { self.paperWidth }
4368    pub fn paperHeight(&self) -> Option<f64> { self.paperHeight }
4369    pub fn marginTop(&self) -> Option<f64> { self.marginTop }
4370    pub fn marginBottom(&self) -> Option<f64> { self.marginBottom }
4371    pub fn marginLeft(&self) -> Option<f64> { self.marginLeft }
4372    pub fn marginRight(&self) -> Option<f64> { self.marginRight }
4373    pub fn pageRanges(&self) -> Option<&str> { self.pageRanges.as_deref() }
4374    pub fn headerTemplate(&self) -> Option<&str> { self.headerTemplate.as_deref() }
4375    pub fn footerTemplate(&self) -> Option<&str> { self.footerTemplate.as_deref() }
4376    pub fn preferCSSPageSize(&self) -> Option<bool> { self.preferCSSPageSize }
4377    pub fn transferMode(&self) -> Option<&str> { self.transferMode.as_deref() }
4378    pub fn generateTaggedPDF(&self) -> Option<bool> { self.generateTaggedPDF }
4379    pub fn generateDocumentOutline(&self) -> Option<bool> { self.generateDocumentOutline }
4380}
4381
4382#[derive(Default)]
4383pub struct PrintToPDFParamsBuilder<'a> {
4384    landscape: Option<bool>,
4385    displayHeaderFooter: Option<bool>,
4386    printBackground: Option<bool>,
4387    scale: Option<f64>,
4388    paperWidth: Option<f64>,
4389    paperHeight: Option<f64>,
4390    marginTop: Option<f64>,
4391    marginBottom: Option<f64>,
4392    marginLeft: Option<f64>,
4393    marginRight: Option<f64>,
4394    pageRanges: Option<Cow<'a, str>>,
4395    headerTemplate: Option<Cow<'a, str>>,
4396    footerTemplate: Option<Cow<'a, str>>,
4397    preferCSSPageSize: Option<bool>,
4398    transferMode: Option<Cow<'a, str>>,
4399    generateTaggedPDF: Option<bool>,
4400    generateDocumentOutline: Option<bool>,
4401}
4402
4403impl<'a> PrintToPDFParamsBuilder<'a> {
4404    /// Paper orientation. Defaults to false.
4405    pub fn landscape(mut self, landscape: bool) -> Self { self.landscape = Some(landscape); self }
4406    /// Display header and footer. Defaults to false.
4407    pub fn displayHeaderFooter(mut self, displayHeaderFooter: bool) -> Self { self.displayHeaderFooter = Some(displayHeaderFooter); self }
4408    /// Print background graphics. Defaults to false.
4409    pub fn printBackground(mut self, printBackground: bool) -> Self { self.printBackground = Some(printBackground); self }
4410    /// Scale of the webpage rendering. Defaults to 1.
4411    pub fn scale(mut self, scale: f64) -> Self { self.scale = Some(scale); self }
4412    /// Paper width in inches. Defaults to 8.5 inches.
4413    pub fn paperWidth(mut self, paperWidth: f64) -> Self { self.paperWidth = Some(paperWidth); self }
4414    /// Paper height in inches. Defaults to 11 inches.
4415    pub fn paperHeight(mut self, paperHeight: f64) -> Self { self.paperHeight = Some(paperHeight); self }
4416    /// Top margin in inches. Defaults to 1cm (~0.4 inches).
4417    pub fn marginTop(mut self, marginTop: f64) -> Self { self.marginTop = Some(marginTop); self }
4418    /// Bottom margin in inches. Defaults to 1cm (~0.4 inches).
4419    pub fn marginBottom(mut self, marginBottom: f64) -> Self { self.marginBottom = Some(marginBottom); self }
4420    /// Left margin in inches. Defaults to 1cm (~0.4 inches).
4421    pub fn marginLeft(mut self, marginLeft: f64) -> Self { self.marginLeft = Some(marginLeft); self }
4422    /// Right margin in inches. Defaults to 1cm (~0.4 inches).
4423    pub fn marginRight(mut self, marginRight: f64) -> Self { self.marginRight = Some(marginRight); self }
4424    /// Paper ranges to print, one based, e.g., '1-5, 8, 11-13'. Pages are
4425    /// printed in the document order, not in the order specified, and no
4426    /// more than once.
4427    /// Defaults to empty string, which implies the entire document is printed.
4428    /// The page numbers are quietly capped to actual page count of the
4429    /// document, and ranges beyond the end of the document are ignored.
4430    /// If this results in no pages to print, an error is reported.
4431    /// It is an error to specify a range with start greater than end.
4432    pub fn pageRanges(mut self, pageRanges: impl Into<Cow<'a, str>>) -> Self { self.pageRanges = Some(pageRanges.into()); self }
4433    /// HTML template for the print header. Should be valid HTML markup with following
4434    /// classes used to inject printing values into them:
4435    /// - 'date': formatted print date
4436    /// - 'title': document title
4437    /// - 'url': document location
4438    /// - 'pageNumber': current page number
4439    /// - 'totalPages': total pages in the document
4440    /// 
4441    /// For example, '<span class=title></span>' would generate span containing the title.
4442    pub fn headerTemplate(mut self, headerTemplate: impl Into<Cow<'a, str>>) -> Self { self.headerTemplate = Some(headerTemplate.into()); self }
4443    /// HTML template for the print footer. Should use the same format as the 'headerTemplate'.
4444    pub fn footerTemplate(mut self, footerTemplate: impl Into<Cow<'a, str>>) -> Self { self.footerTemplate = Some(footerTemplate.into()); self }
4445    /// Whether or not to prefer page size as defined by css. Defaults to false,
4446    /// in which case the content will be scaled to fit the paper size.
4447    pub fn preferCSSPageSize(mut self, preferCSSPageSize: bool) -> Self { self.preferCSSPageSize = Some(preferCSSPageSize); self }
4448    /// return as stream
4449    pub fn transferMode(mut self, transferMode: impl Into<Cow<'a, str>>) -> Self { self.transferMode = Some(transferMode.into()); self }
4450    /// Whether or not to generate tagged (accessible) PDF. Defaults to embedder choice.
4451    pub fn generateTaggedPDF(mut self, generateTaggedPDF: bool) -> Self { self.generateTaggedPDF = Some(generateTaggedPDF); self }
4452    /// Whether or not to embed the document outline into the PDF.
4453    pub fn generateDocumentOutline(mut self, generateDocumentOutline: bool) -> Self { self.generateDocumentOutline = Some(generateDocumentOutline); self }
4454    pub fn build(self) -> PrintToPDFParams<'a> {
4455        PrintToPDFParams {
4456            landscape: self.landscape,
4457            displayHeaderFooter: self.displayHeaderFooter,
4458            printBackground: self.printBackground,
4459            scale: self.scale,
4460            paperWidth: self.paperWidth,
4461            paperHeight: self.paperHeight,
4462            marginTop: self.marginTop,
4463            marginBottom: self.marginBottom,
4464            marginLeft: self.marginLeft,
4465            marginRight: self.marginRight,
4466            pageRanges: self.pageRanges,
4467            headerTemplate: self.headerTemplate,
4468            footerTemplate: self.footerTemplate,
4469            preferCSSPageSize: self.preferCSSPageSize,
4470            transferMode: self.transferMode,
4471            generateTaggedPDF: self.generateTaggedPDF,
4472            generateDocumentOutline: self.generateDocumentOutline,
4473        }
4474    }
4475}
4476
4477/// Print page as PDF.
4478
4479#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4480#[serde(rename_all = "camelCase")]
4481pub struct PrintToPDFReturns<'a> {
4482    /// Base64-encoded pdf data. Empty if |returnAsStream| is specified. (Encoded as a base64 string when passed over JSON)
4483    data: Cow<'a, str>,
4484    /// A handle of the stream that holds resulting PDF data.
4485    #[serde(skip_serializing_if = "Option::is_none")]
4486    stream: Option<crate::io::StreamHandle<'a>>,
4487}
4488
4489impl<'a> PrintToPDFReturns<'a> {
4490    pub fn builder(data: impl Into<Cow<'a, str>>) -> PrintToPDFReturnsBuilder<'a> {
4491        PrintToPDFReturnsBuilder {
4492            data: data.into(),
4493            stream: None,
4494        }
4495    }
4496    pub fn data(&self) -> &str { self.data.as_ref() }
4497    pub fn stream(&self) -> Option<&crate::io::StreamHandle<'a>> { self.stream.as_ref() }
4498}
4499
4500
4501pub struct PrintToPDFReturnsBuilder<'a> {
4502    data: Cow<'a, str>,
4503    stream: Option<crate::io::StreamHandle<'a>>,
4504}
4505
4506impl<'a> PrintToPDFReturnsBuilder<'a> {
4507    /// A handle of the stream that holds resulting PDF data.
4508    pub fn stream(mut self, stream: crate::io::StreamHandle<'a>) -> Self { self.stream = Some(stream); self }
4509    pub fn build(self) -> PrintToPDFReturns<'a> {
4510        PrintToPDFReturns {
4511            data: self.data,
4512            stream: self.stream,
4513        }
4514    }
4515}
4516
4517impl<'a> PrintToPDFParams<'a> { pub const METHOD: &'static str = "Page.printToPDF"; }
4518
4519impl<'a> crate::CdpCommand<'a> for PrintToPDFParams<'a> {
4520    const METHOD: &'static str = "Page.printToPDF";
4521    type Response = PrintToPDFReturns<'a>;
4522}
4523
4524/// Reloads given page optionally ignoring the cache.
4525
4526#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4527#[serde(rename_all = "camelCase")]
4528pub struct ReloadParams<'a> {
4529    /// If true, browser cache is ignored (as if the user pressed Shift+refresh).
4530    #[serde(skip_serializing_if = "Option::is_none")]
4531    ignoreCache: Option<bool>,
4532    /// If set, the script will be injected into all frames of the inspected page after reload.
4533    /// Argument will be ignored if reloading dataURL origin.
4534    #[serde(skip_serializing_if = "Option::is_none")]
4535    scriptToEvaluateOnLoad: Option<Cow<'a, str>>,
4536    /// If set, an error will be thrown if the target page's main frame's
4537    /// loader id does not match the provided id. This prevents accidentally
4538    /// reloading an unintended target in case there's a racing navigation.
4539    #[serde(skip_serializing_if = "Option::is_none")]
4540    loaderId: Option<crate::network::LoaderId<'a>>,
4541}
4542
4543impl<'a> ReloadParams<'a> {
4544    pub fn builder() -> ReloadParamsBuilder<'a> {
4545        ReloadParamsBuilder {
4546            ignoreCache: None,
4547            scriptToEvaluateOnLoad: None,
4548            loaderId: None,
4549        }
4550    }
4551    pub fn ignoreCache(&self) -> Option<bool> { self.ignoreCache }
4552    pub fn scriptToEvaluateOnLoad(&self) -> Option<&str> { self.scriptToEvaluateOnLoad.as_deref() }
4553    pub fn loaderId(&self) -> Option<&crate::network::LoaderId<'a>> { self.loaderId.as_ref() }
4554}
4555
4556#[derive(Default)]
4557pub struct ReloadParamsBuilder<'a> {
4558    ignoreCache: Option<bool>,
4559    scriptToEvaluateOnLoad: Option<Cow<'a, str>>,
4560    loaderId: Option<crate::network::LoaderId<'a>>,
4561}
4562
4563impl<'a> ReloadParamsBuilder<'a> {
4564    /// If true, browser cache is ignored (as if the user pressed Shift+refresh).
4565    pub fn ignoreCache(mut self, ignoreCache: bool) -> Self { self.ignoreCache = Some(ignoreCache); self }
4566    /// If set, the script will be injected into all frames of the inspected page after reload.
4567    /// Argument will be ignored if reloading dataURL origin.
4568    pub fn scriptToEvaluateOnLoad(mut self, scriptToEvaluateOnLoad: impl Into<Cow<'a, str>>) -> Self { self.scriptToEvaluateOnLoad = Some(scriptToEvaluateOnLoad.into()); self }
4569    /// If set, an error will be thrown if the target page's main frame's
4570    /// loader id does not match the provided id. This prevents accidentally
4571    /// reloading an unintended target in case there's a racing navigation.
4572    pub fn loaderId(mut self, loaderId: crate::network::LoaderId<'a>) -> Self { self.loaderId = Some(loaderId); self }
4573    pub fn build(self) -> ReloadParams<'a> {
4574        ReloadParams {
4575            ignoreCache: self.ignoreCache,
4576            scriptToEvaluateOnLoad: self.scriptToEvaluateOnLoad,
4577            loaderId: self.loaderId,
4578        }
4579    }
4580}
4581
4582impl<'a> ReloadParams<'a> { pub const METHOD: &'static str = "Page.reload"; }
4583
4584impl<'a> crate::CdpCommand<'a> for ReloadParams<'a> {
4585    const METHOD: &'static str = "Page.reload";
4586    type Response = crate::EmptyReturns;
4587}
4588
4589/// Deprecated, please use removeScriptToEvaluateOnNewDocument instead.
4590
4591#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4592#[serde(rename_all = "camelCase")]
4593pub struct RemoveScriptToEvaluateOnLoadParams<'a> {
4594    identifier: ScriptIdentifier<'a>,
4595}
4596
4597impl<'a> RemoveScriptToEvaluateOnLoadParams<'a> {
4598    pub fn builder(identifier: ScriptIdentifier<'a>) -> RemoveScriptToEvaluateOnLoadParamsBuilder<'a> {
4599        RemoveScriptToEvaluateOnLoadParamsBuilder {
4600            identifier: identifier,
4601        }
4602    }
4603    pub fn identifier(&self) -> &ScriptIdentifier<'a> { &self.identifier }
4604}
4605
4606
4607pub struct RemoveScriptToEvaluateOnLoadParamsBuilder<'a> {
4608    identifier: ScriptIdentifier<'a>,
4609}
4610
4611impl<'a> RemoveScriptToEvaluateOnLoadParamsBuilder<'a> {
4612    pub fn build(self) -> RemoveScriptToEvaluateOnLoadParams<'a> {
4613        RemoveScriptToEvaluateOnLoadParams {
4614            identifier: self.identifier,
4615        }
4616    }
4617}
4618
4619impl<'a> RemoveScriptToEvaluateOnLoadParams<'a> { pub const METHOD: &'static str = "Page.removeScriptToEvaluateOnLoad"; }
4620
4621impl<'a> crate::CdpCommand<'a> for RemoveScriptToEvaluateOnLoadParams<'a> {
4622    const METHOD: &'static str = "Page.removeScriptToEvaluateOnLoad";
4623    type Response = crate::EmptyReturns;
4624}
4625
4626/// Removes given script from the list.
4627
4628#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4629#[serde(rename_all = "camelCase")]
4630pub struct RemoveScriptToEvaluateOnNewDocumentParams<'a> {
4631    identifier: ScriptIdentifier<'a>,
4632}
4633
4634impl<'a> RemoveScriptToEvaluateOnNewDocumentParams<'a> {
4635    pub fn builder(identifier: ScriptIdentifier<'a>) -> RemoveScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
4636        RemoveScriptToEvaluateOnNewDocumentParamsBuilder {
4637            identifier: identifier,
4638        }
4639    }
4640    pub fn identifier(&self) -> &ScriptIdentifier<'a> { &self.identifier }
4641}
4642
4643
4644pub struct RemoveScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
4645    identifier: ScriptIdentifier<'a>,
4646}
4647
4648impl<'a> RemoveScriptToEvaluateOnNewDocumentParamsBuilder<'a> {
4649    pub fn build(self) -> RemoveScriptToEvaluateOnNewDocumentParams<'a> {
4650        RemoveScriptToEvaluateOnNewDocumentParams {
4651            identifier: self.identifier,
4652        }
4653    }
4654}
4655
4656impl<'a> RemoveScriptToEvaluateOnNewDocumentParams<'a> { pub const METHOD: &'static str = "Page.removeScriptToEvaluateOnNewDocument"; }
4657
4658impl<'a> crate::CdpCommand<'a> for RemoveScriptToEvaluateOnNewDocumentParams<'a> {
4659    const METHOD: &'static str = "Page.removeScriptToEvaluateOnNewDocument";
4660    type Response = crate::EmptyReturns;
4661}
4662
4663/// Acknowledges that a screencast frame has been received by the frontend.
4664
4665#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4666#[serde(rename_all = "camelCase")]
4667pub struct ScreencastFrameAckParams {
4668    /// Frame number.
4669    sessionId: u64,
4670}
4671
4672impl ScreencastFrameAckParams {
4673    pub fn builder(sessionId: u64) -> ScreencastFrameAckParamsBuilder {
4674        ScreencastFrameAckParamsBuilder {
4675            sessionId: sessionId,
4676        }
4677    }
4678    pub fn sessionId(&self) -> u64 { self.sessionId }
4679}
4680
4681
4682pub struct ScreencastFrameAckParamsBuilder {
4683    sessionId: u64,
4684}
4685
4686impl ScreencastFrameAckParamsBuilder {
4687    pub fn build(self) -> ScreencastFrameAckParams {
4688        ScreencastFrameAckParams {
4689            sessionId: self.sessionId,
4690        }
4691    }
4692}
4693
4694impl ScreencastFrameAckParams { pub const METHOD: &'static str = "Page.screencastFrameAck"; }
4695
4696impl<'a> crate::CdpCommand<'a> for ScreencastFrameAckParams {
4697    const METHOD: &'static str = "Page.screencastFrameAck";
4698    type Response = crate::EmptyReturns;
4699}
4700
4701/// Searches for given string in resource content.
4702
4703#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4704#[serde(rename_all = "camelCase")]
4705pub struct SearchInResourceParams<'a> {
4706    /// Frame id for resource to search in.
4707    frameId: FrameId<'a>,
4708    /// URL of the resource to search in.
4709    url: Cow<'a, str>,
4710    /// String to search for.
4711    query: Cow<'a, str>,
4712    /// If true, search is case sensitive.
4713    #[serde(skip_serializing_if = "Option::is_none")]
4714    caseSensitive: Option<bool>,
4715    /// If true, treats string parameter as regex.
4716    #[serde(skip_serializing_if = "Option::is_none")]
4717    isRegex: Option<bool>,
4718}
4719
4720impl<'a> SearchInResourceParams<'a> {
4721    pub fn builder(frameId: FrameId<'a>, url: impl Into<Cow<'a, str>>, query: impl Into<Cow<'a, str>>) -> SearchInResourceParamsBuilder<'a> {
4722        SearchInResourceParamsBuilder {
4723            frameId: frameId,
4724            url: url.into(),
4725            query: query.into(),
4726            caseSensitive: None,
4727            isRegex: None,
4728        }
4729    }
4730    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
4731    pub fn url(&self) -> &str { self.url.as_ref() }
4732    pub fn query(&self) -> &str { self.query.as_ref() }
4733    pub fn caseSensitive(&self) -> Option<bool> { self.caseSensitive }
4734    pub fn isRegex(&self) -> Option<bool> { self.isRegex }
4735}
4736
4737
4738pub struct SearchInResourceParamsBuilder<'a> {
4739    frameId: FrameId<'a>,
4740    url: Cow<'a, str>,
4741    query: Cow<'a, str>,
4742    caseSensitive: Option<bool>,
4743    isRegex: Option<bool>,
4744}
4745
4746impl<'a> SearchInResourceParamsBuilder<'a> {
4747    /// If true, search is case sensitive.
4748    pub fn caseSensitive(mut self, caseSensitive: bool) -> Self { self.caseSensitive = Some(caseSensitive); self }
4749    /// If true, treats string parameter as regex.
4750    pub fn isRegex(mut self, isRegex: bool) -> Self { self.isRegex = Some(isRegex); self }
4751    pub fn build(self) -> SearchInResourceParams<'a> {
4752        SearchInResourceParams {
4753            frameId: self.frameId,
4754            url: self.url,
4755            query: self.query,
4756            caseSensitive: self.caseSensitive,
4757            isRegex: self.isRegex,
4758        }
4759    }
4760}
4761
4762/// Searches for given string in resource content.
4763
4764#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4765#[serde(rename_all = "camelCase")]
4766pub struct SearchInResourceReturns {
4767    /// List of search matches.
4768    result: Vec<crate::debugger::SearchMatch>,
4769}
4770
4771impl SearchInResourceReturns {
4772    pub fn builder(result: Vec<crate::debugger::SearchMatch>) -> SearchInResourceReturnsBuilder {
4773        SearchInResourceReturnsBuilder {
4774            result: result,
4775        }
4776    }
4777    pub fn result(&self) -> &[crate::debugger::SearchMatch] { &self.result }
4778}
4779
4780
4781pub struct SearchInResourceReturnsBuilder {
4782    result: Vec<crate::debugger::SearchMatch>,
4783}
4784
4785impl SearchInResourceReturnsBuilder {
4786    pub fn build(self) -> SearchInResourceReturns {
4787        SearchInResourceReturns {
4788            result: self.result,
4789        }
4790    }
4791}
4792
4793impl<'a> SearchInResourceParams<'a> { pub const METHOD: &'static str = "Page.searchInResource"; }
4794
4795impl<'a> crate::CdpCommand<'a> for SearchInResourceParams<'a> {
4796    const METHOD: &'static str = "Page.searchInResource";
4797    type Response = SearchInResourceReturns;
4798}
4799
4800/// Enable Chrome's experimental ad filter on all sites.
4801
4802#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4803#[serde(rename_all = "camelCase")]
4804pub struct SetAdBlockingEnabledParams {
4805    /// Whether to block ads.
4806    enabled: bool,
4807}
4808
4809impl SetAdBlockingEnabledParams {
4810    pub fn builder(enabled: bool) -> SetAdBlockingEnabledParamsBuilder {
4811        SetAdBlockingEnabledParamsBuilder {
4812            enabled: enabled,
4813        }
4814    }
4815    pub fn enabled(&self) -> bool { self.enabled }
4816}
4817
4818
4819pub struct SetAdBlockingEnabledParamsBuilder {
4820    enabled: bool,
4821}
4822
4823impl SetAdBlockingEnabledParamsBuilder {
4824    pub fn build(self) -> SetAdBlockingEnabledParams {
4825        SetAdBlockingEnabledParams {
4826            enabled: self.enabled,
4827        }
4828    }
4829}
4830
4831impl SetAdBlockingEnabledParams { pub const METHOD: &'static str = "Page.setAdBlockingEnabled"; }
4832
4833impl<'a> crate::CdpCommand<'a> for SetAdBlockingEnabledParams {
4834    const METHOD: &'static str = "Page.setAdBlockingEnabled";
4835    type Response = crate::EmptyReturns;
4836}
4837
4838/// Enable page Content Security Policy by-passing.
4839
4840#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4841#[serde(rename_all = "camelCase")]
4842pub struct SetBypassCSPParams {
4843    /// Whether to bypass page CSP.
4844    enabled: bool,
4845}
4846
4847impl SetBypassCSPParams {
4848    pub fn builder(enabled: bool) -> SetBypassCSPParamsBuilder {
4849        SetBypassCSPParamsBuilder {
4850            enabled: enabled,
4851        }
4852    }
4853    pub fn enabled(&self) -> bool { self.enabled }
4854}
4855
4856
4857pub struct SetBypassCSPParamsBuilder {
4858    enabled: bool,
4859}
4860
4861impl SetBypassCSPParamsBuilder {
4862    pub fn build(self) -> SetBypassCSPParams {
4863        SetBypassCSPParams {
4864            enabled: self.enabled,
4865        }
4866    }
4867}
4868
4869impl SetBypassCSPParams { pub const METHOD: &'static str = "Page.setBypassCSP"; }
4870
4871impl<'a> crate::CdpCommand<'a> for SetBypassCSPParams {
4872    const METHOD: &'static str = "Page.setBypassCSP";
4873    type Response = crate::EmptyReturns;
4874}
4875
4876/// Get Permissions Policy state on given frame.
4877
4878#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4879#[serde(rename_all = "camelCase")]
4880pub struct GetPermissionsPolicyStateParams<'a> {
4881    frameId: FrameId<'a>,
4882}
4883
4884impl<'a> GetPermissionsPolicyStateParams<'a> {
4885    pub fn builder(frameId: FrameId<'a>) -> GetPermissionsPolicyStateParamsBuilder<'a> {
4886        GetPermissionsPolicyStateParamsBuilder {
4887            frameId: frameId,
4888        }
4889    }
4890    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
4891}
4892
4893
4894pub struct GetPermissionsPolicyStateParamsBuilder<'a> {
4895    frameId: FrameId<'a>,
4896}
4897
4898impl<'a> GetPermissionsPolicyStateParamsBuilder<'a> {
4899    pub fn build(self) -> GetPermissionsPolicyStateParams<'a> {
4900        GetPermissionsPolicyStateParams {
4901            frameId: self.frameId,
4902        }
4903    }
4904}
4905
4906/// Get Permissions Policy state on given frame.
4907
4908#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4909#[serde(rename_all = "camelCase")]
4910pub struct GetPermissionsPolicyStateReturns<'a> {
4911    states: Vec<PermissionsPolicyFeatureState<'a>>,
4912}
4913
4914impl<'a> GetPermissionsPolicyStateReturns<'a> {
4915    pub fn builder(states: Vec<PermissionsPolicyFeatureState<'a>>) -> GetPermissionsPolicyStateReturnsBuilder<'a> {
4916        GetPermissionsPolicyStateReturnsBuilder {
4917            states: states,
4918        }
4919    }
4920    pub fn states(&self) -> &[PermissionsPolicyFeatureState<'a>] { &self.states }
4921}
4922
4923
4924pub struct GetPermissionsPolicyStateReturnsBuilder<'a> {
4925    states: Vec<PermissionsPolicyFeatureState<'a>>,
4926}
4927
4928impl<'a> GetPermissionsPolicyStateReturnsBuilder<'a> {
4929    pub fn build(self) -> GetPermissionsPolicyStateReturns<'a> {
4930        GetPermissionsPolicyStateReturns {
4931            states: self.states,
4932        }
4933    }
4934}
4935
4936impl<'a> GetPermissionsPolicyStateParams<'a> { pub const METHOD: &'static str = "Page.getPermissionsPolicyState"; }
4937
4938impl<'a> crate::CdpCommand<'a> for GetPermissionsPolicyStateParams<'a> {
4939    const METHOD: &'static str = "Page.getPermissionsPolicyState";
4940    type Response = GetPermissionsPolicyStateReturns<'a>;
4941}
4942
4943/// Get Origin Trials on given frame.
4944
4945#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4946#[serde(rename_all = "camelCase")]
4947pub struct GetOriginTrialsParams<'a> {
4948    frameId: FrameId<'a>,
4949}
4950
4951impl<'a> GetOriginTrialsParams<'a> {
4952    pub fn builder(frameId: FrameId<'a>) -> GetOriginTrialsParamsBuilder<'a> {
4953        GetOriginTrialsParamsBuilder {
4954            frameId: frameId,
4955        }
4956    }
4957    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
4958}
4959
4960
4961pub struct GetOriginTrialsParamsBuilder<'a> {
4962    frameId: FrameId<'a>,
4963}
4964
4965impl<'a> GetOriginTrialsParamsBuilder<'a> {
4966    pub fn build(self) -> GetOriginTrialsParams<'a> {
4967        GetOriginTrialsParams {
4968            frameId: self.frameId,
4969        }
4970    }
4971}
4972
4973/// Get Origin Trials on given frame.
4974
4975#[derive(Debug, Clone, Serialize, Deserialize, Default)]
4976#[serde(rename_all = "camelCase")]
4977pub struct GetOriginTrialsReturns<'a> {
4978    originTrials: Vec<OriginTrial<'a>>,
4979}
4980
4981impl<'a> GetOriginTrialsReturns<'a> {
4982    pub fn builder(originTrials: Vec<OriginTrial<'a>>) -> GetOriginTrialsReturnsBuilder<'a> {
4983        GetOriginTrialsReturnsBuilder {
4984            originTrials: originTrials,
4985        }
4986    }
4987    pub fn originTrials(&self) -> &[OriginTrial<'a>] { &self.originTrials }
4988}
4989
4990
4991pub struct GetOriginTrialsReturnsBuilder<'a> {
4992    originTrials: Vec<OriginTrial<'a>>,
4993}
4994
4995impl<'a> GetOriginTrialsReturnsBuilder<'a> {
4996    pub fn build(self) -> GetOriginTrialsReturns<'a> {
4997        GetOriginTrialsReturns {
4998            originTrials: self.originTrials,
4999        }
5000    }
5001}
5002
5003impl<'a> GetOriginTrialsParams<'a> { pub const METHOD: &'static str = "Page.getOriginTrials"; }
5004
5005impl<'a> crate::CdpCommand<'a> for GetOriginTrialsParams<'a> {
5006    const METHOD: &'static str = "Page.getOriginTrials";
5007    type Response = GetOriginTrialsReturns<'a>;
5008}
5009
5010/// Overrides the values of device screen dimensions (window.screen.width, window.screen.height,
5011/// window.innerWidth, window.innerHeight, and "device-width"/"device-height"-related CSS media
5012/// query results).
5013
5014#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5015#[serde(rename_all = "camelCase")]
5016pub struct SetDeviceMetricsOverrideParams<'a> {
5017    /// Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override.
5018    width: u64,
5019    /// Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override.
5020    height: i64,
5021    /// Overriding device scale factor value. 0 disables the override.
5022    deviceScaleFactor: f64,
5023    /// Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text
5024    /// autosizing and more.
5025    mobile: bool,
5026    /// Scale to apply to resulting view image.
5027    #[serde(skip_serializing_if = "Option::is_none")]
5028    scale: Option<f64>,
5029    /// Overriding screen width value in pixels (minimum 0, maximum 10000000).
5030    #[serde(skip_serializing_if = "Option::is_none")]
5031    screenWidth: Option<u64>,
5032    /// Overriding screen height value in pixels (minimum 0, maximum 10000000).
5033    #[serde(skip_serializing_if = "Option::is_none")]
5034    screenHeight: Option<i64>,
5035    /// Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
5036    #[serde(skip_serializing_if = "Option::is_none")]
5037    positionX: Option<i64>,
5038    /// Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
5039    #[serde(skip_serializing_if = "Option::is_none")]
5040    positionY: Option<i64>,
5041    /// Do not set visible view size, rely upon explicit setVisibleSize call.
5042    #[serde(skip_serializing_if = "Option::is_none")]
5043    dontSetVisibleSize: Option<bool>,
5044    /// Screen orientation override.
5045    #[serde(skip_serializing_if = "Option::is_none")]
5046    screenOrientation: Option<crate::emulation::ScreenOrientation<'a>>,
5047    /// The viewport dimensions and scale. If not set, the override is cleared.
5048    #[serde(skip_serializing_if = "Option::is_none")]
5049    viewport: Option<Viewport>,
5050}
5051
5052impl<'a> SetDeviceMetricsOverrideParams<'a> {
5053    pub fn builder(width: u64, height: i64, deviceScaleFactor: f64, mobile: bool) -> SetDeviceMetricsOverrideParamsBuilder<'a> {
5054        SetDeviceMetricsOverrideParamsBuilder {
5055            width: width,
5056            height: height,
5057            deviceScaleFactor: deviceScaleFactor,
5058            mobile: mobile,
5059            scale: None,
5060            screenWidth: None,
5061            screenHeight: None,
5062            positionX: None,
5063            positionY: None,
5064            dontSetVisibleSize: None,
5065            screenOrientation: None,
5066            viewport: None,
5067        }
5068    }
5069    pub fn width(&self) -> u64 { self.width }
5070    pub fn height(&self) -> i64 { self.height }
5071    pub fn deviceScaleFactor(&self) -> f64 { self.deviceScaleFactor }
5072    pub fn mobile(&self) -> bool { self.mobile }
5073    pub fn scale(&self) -> Option<f64> { self.scale }
5074    pub fn screenWidth(&self) -> Option<u64> { self.screenWidth }
5075    pub fn screenHeight(&self) -> Option<i64> { self.screenHeight }
5076    pub fn positionX(&self) -> Option<i64> { self.positionX }
5077    pub fn positionY(&self) -> Option<i64> { self.positionY }
5078    pub fn dontSetVisibleSize(&self) -> Option<bool> { self.dontSetVisibleSize }
5079    pub fn screenOrientation(&self) -> Option<&crate::emulation::ScreenOrientation<'a>> { self.screenOrientation.as_ref() }
5080    pub fn viewport(&self) -> Option<&Viewport> { self.viewport.as_ref() }
5081}
5082
5083
5084pub struct SetDeviceMetricsOverrideParamsBuilder<'a> {
5085    width: u64,
5086    height: i64,
5087    deviceScaleFactor: f64,
5088    mobile: bool,
5089    scale: Option<f64>,
5090    screenWidth: Option<u64>,
5091    screenHeight: Option<i64>,
5092    positionX: Option<i64>,
5093    positionY: Option<i64>,
5094    dontSetVisibleSize: Option<bool>,
5095    screenOrientation: Option<crate::emulation::ScreenOrientation<'a>>,
5096    viewport: Option<Viewport>,
5097}
5098
5099impl<'a> SetDeviceMetricsOverrideParamsBuilder<'a> {
5100    /// Scale to apply to resulting view image.
5101    pub fn scale(mut self, scale: f64) -> Self { self.scale = Some(scale); self }
5102    /// Overriding screen width value in pixels (minimum 0, maximum 10000000).
5103    pub fn screenWidth(mut self, screenWidth: u64) -> Self { self.screenWidth = Some(screenWidth); self }
5104    /// Overriding screen height value in pixels (minimum 0, maximum 10000000).
5105    pub fn screenHeight(mut self, screenHeight: i64) -> Self { self.screenHeight = Some(screenHeight); self }
5106    /// Overriding view X position on screen in pixels (minimum 0, maximum 10000000).
5107    pub fn positionX(mut self, positionX: i64) -> Self { self.positionX = Some(positionX); self }
5108    /// Overriding view Y position on screen in pixels (minimum 0, maximum 10000000).
5109    pub fn positionY(mut self, positionY: i64) -> Self { self.positionY = Some(positionY); self }
5110    /// Do not set visible view size, rely upon explicit setVisibleSize call.
5111    pub fn dontSetVisibleSize(mut self, dontSetVisibleSize: bool) -> Self { self.dontSetVisibleSize = Some(dontSetVisibleSize); self }
5112    /// Screen orientation override.
5113    pub fn screenOrientation(mut self, screenOrientation: crate::emulation::ScreenOrientation<'a>) -> Self { self.screenOrientation = Some(screenOrientation); self }
5114    /// The viewport dimensions and scale. If not set, the override is cleared.
5115    pub fn viewport(mut self, viewport: Viewport) -> Self { self.viewport = Some(viewport); self }
5116    pub fn build(self) -> SetDeviceMetricsOverrideParams<'a> {
5117        SetDeviceMetricsOverrideParams {
5118            width: self.width,
5119            height: self.height,
5120            deviceScaleFactor: self.deviceScaleFactor,
5121            mobile: self.mobile,
5122            scale: self.scale,
5123            screenWidth: self.screenWidth,
5124            screenHeight: self.screenHeight,
5125            positionX: self.positionX,
5126            positionY: self.positionY,
5127            dontSetVisibleSize: self.dontSetVisibleSize,
5128            screenOrientation: self.screenOrientation,
5129            viewport: self.viewport,
5130        }
5131    }
5132}
5133
5134impl<'a> SetDeviceMetricsOverrideParams<'a> { pub const METHOD: &'static str = "Page.setDeviceMetricsOverride"; }
5135
5136impl<'a> crate::CdpCommand<'a> for SetDeviceMetricsOverrideParams<'a> {
5137    const METHOD: &'static str = "Page.setDeviceMetricsOverride";
5138    type Response = crate::EmptyReturns;
5139}
5140
5141/// Overrides the Device Orientation.
5142
5143#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5144#[serde(rename_all = "camelCase")]
5145pub struct SetDeviceOrientationOverrideParams {
5146    /// Mock alpha
5147    alpha: f64,
5148    /// Mock beta
5149    beta: f64,
5150    /// Mock gamma
5151    gamma: f64,
5152}
5153
5154impl SetDeviceOrientationOverrideParams {
5155    pub fn builder(alpha: f64, beta: f64, gamma: f64) -> SetDeviceOrientationOverrideParamsBuilder {
5156        SetDeviceOrientationOverrideParamsBuilder {
5157            alpha: alpha,
5158            beta: beta,
5159            gamma: gamma,
5160        }
5161    }
5162    pub fn alpha(&self) -> f64 { self.alpha }
5163    pub fn beta(&self) -> f64 { self.beta }
5164    pub fn gamma(&self) -> f64 { self.gamma }
5165}
5166
5167
5168pub struct SetDeviceOrientationOverrideParamsBuilder {
5169    alpha: f64,
5170    beta: f64,
5171    gamma: f64,
5172}
5173
5174impl SetDeviceOrientationOverrideParamsBuilder {
5175    pub fn build(self) -> SetDeviceOrientationOverrideParams {
5176        SetDeviceOrientationOverrideParams {
5177            alpha: self.alpha,
5178            beta: self.beta,
5179            gamma: self.gamma,
5180        }
5181    }
5182}
5183
5184impl SetDeviceOrientationOverrideParams { pub const METHOD: &'static str = "Page.setDeviceOrientationOverride"; }
5185
5186impl<'a> crate::CdpCommand<'a> for SetDeviceOrientationOverrideParams {
5187    const METHOD: &'static str = "Page.setDeviceOrientationOverride";
5188    type Response = crate::EmptyReturns;
5189}
5190
5191/// Set generic font families.
5192
5193#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5194#[serde(rename_all = "camelCase")]
5195pub struct SetFontFamiliesParams<'a> {
5196    /// Specifies font families to set. If a font family is not specified, it won't be changed.
5197    fontFamilies: FontFamilies<'a>,
5198    /// Specifies font families to set for individual scripts.
5199    #[serde(skip_serializing_if = "Option::is_none")]
5200    forScripts: Option<Vec<ScriptFontFamilies<'a>>>,
5201}
5202
5203impl<'a> SetFontFamiliesParams<'a> {
5204    pub fn builder(fontFamilies: FontFamilies<'a>) -> SetFontFamiliesParamsBuilder<'a> {
5205        SetFontFamiliesParamsBuilder {
5206            fontFamilies: fontFamilies,
5207            forScripts: None,
5208        }
5209    }
5210    pub fn fontFamilies(&self) -> &FontFamilies<'a> { &self.fontFamilies }
5211    pub fn forScripts(&self) -> Option<&[ScriptFontFamilies<'a>]> { self.forScripts.as_deref() }
5212}
5213
5214
5215pub struct SetFontFamiliesParamsBuilder<'a> {
5216    fontFamilies: FontFamilies<'a>,
5217    forScripts: Option<Vec<ScriptFontFamilies<'a>>>,
5218}
5219
5220impl<'a> SetFontFamiliesParamsBuilder<'a> {
5221    /// Specifies font families to set for individual scripts.
5222    pub fn forScripts(mut self, forScripts: Vec<ScriptFontFamilies<'a>>) -> Self { self.forScripts = Some(forScripts); self }
5223    pub fn build(self) -> SetFontFamiliesParams<'a> {
5224        SetFontFamiliesParams {
5225            fontFamilies: self.fontFamilies,
5226            forScripts: self.forScripts,
5227        }
5228    }
5229}
5230
5231impl<'a> SetFontFamiliesParams<'a> { pub const METHOD: &'static str = "Page.setFontFamilies"; }
5232
5233impl<'a> crate::CdpCommand<'a> for SetFontFamiliesParams<'a> {
5234    const METHOD: &'static str = "Page.setFontFamilies";
5235    type Response = crate::EmptyReturns;
5236}
5237
5238/// Set default font sizes.
5239
5240#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5241#[serde(rename_all = "camelCase")]
5242pub struct SetFontSizesParams {
5243    /// Specifies font sizes to set. If a font size is not specified, it won't be changed.
5244    fontSizes: FontSizes,
5245}
5246
5247impl SetFontSizesParams {
5248    pub fn builder(fontSizes: FontSizes) -> SetFontSizesParamsBuilder {
5249        SetFontSizesParamsBuilder {
5250            fontSizes: fontSizes,
5251        }
5252    }
5253    pub fn fontSizes(&self) -> &FontSizes { &self.fontSizes }
5254}
5255
5256
5257pub struct SetFontSizesParamsBuilder {
5258    fontSizes: FontSizes,
5259}
5260
5261impl SetFontSizesParamsBuilder {
5262    pub fn build(self) -> SetFontSizesParams {
5263        SetFontSizesParams {
5264            fontSizes: self.fontSizes,
5265        }
5266    }
5267}
5268
5269impl SetFontSizesParams { pub const METHOD: &'static str = "Page.setFontSizes"; }
5270
5271impl<'a> crate::CdpCommand<'a> for SetFontSizesParams {
5272    const METHOD: &'static str = "Page.setFontSizes";
5273    type Response = crate::EmptyReturns;
5274}
5275
5276/// Sets given markup as the document's HTML.
5277
5278#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5279#[serde(rename_all = "camelCase")]
5280pub struct SetDocumentContentParams<'a> {
5281    /// Frame id to set HTML for.
5282    frameId: FrameId<'a>,
5283    /// HTML content to set.
5284    html: Cow<'a, str>,
5285}
5286
5287impl<'a> SetDocumentContentParams<'a> {
5288    pub fn builder(frameId: FrameId<'a>, html: impl Into<Cow<'a, str>>) -> SetDocumentContentParamsBuilder<'a> {
5289        SetDocumentContentParamsBuilder {
5290            frameId: frameId,
5291            html: html.into(),
5292        }
5293    }
5294    pub fn frameId(&self) -> &FrameId<'a> { &self.frameId }
5295    pub fn html(&self) -> &str { self.html.as_ref() }
5296}
5297
5298
5299pub struct SetDocumentContentParamsBuilder<'a> {
5300    frameId: FrameId<'a>,
5301    html: Cow<'a, str>,
5302}
5303
5304impl<'a> SetDocumentContentParamsBuilder<'a> {
5305    pub fn build(self) -> SetDocumentContentParams<'a> {
5306        SetDocumentContentParams {
5307            frameId: self.frameId,
5308            html: self.html,
5309        }
5310    }
5311}
5312
5313impl<'a> SetDocumentContentParams<'a> { pub const METHOD: &'static str = "Page.setDocumentContent"; }
5314
5315impl<'a> crate::CdpCommand<'a> for SetDocumentContentParams<'a> {
5316    const METHOD: &'static str = "Page.setDocumentContent";
5317    type Response = crate::EmptyReturns;
5318}
5319
5320/// Set the behavior when downloading a file.
5321
5322#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5323#[serde(rename_all = "camelCase")]
5324pub struct SetDownloadBehaviorParams<'a> {
5325    /// Whether to allow all or deny all download requests, or use default Chrome behavior if
5326    /// available (otherwise deny).
5327    behavior: Cow<'a, str>,
5328    /// The default path to save downloaded files to. This is required if behavior is set to 'allow'
5329    #[serde(skip_serializing_if = "Option::is_none")]
5330    downloadPath: Option<Cow<'a, str>>,
5331}
5332
5333impl<'a> SetDownloadBehaviorParams<'a> {
5334    pub fn builder(behavior: impl Into<Cow<'a, str>>) -> SetDownloadBehaviorParamsBuilder<'a> {
5335        SetDownloadBehaviorParamsBuilder {
5336            behavior: behavior.into(),
5337            downloadPath: None,
5338        }
5339    }
5340    pub fn behavior(&self) -> &str { self.behavior.as_ref() }
5341    pub fn downloadPath(&self) -> Option<&str> { self.downloadPath.as_deref() }
5342}
5343
5344
5345pub struct SetDownloadBehaviorParamsBuilder<'a> {
5346    behavior: Cow<'a, str>,
5347    downloadPath: Option<Cow<'a, str>>,
5348}
5349
5350impl<'a> SetDownloadBehaviorParamsBuilder<'a> {
5351    /// The default path to save downloaded files to. This is required if behavior is set to 'allow'
5352    pub fn downloadPath(mut self, downloadPath: impl Into<Cow<'a, str>>) -> Self { self.downloadPath = Some(downloadPath.into()); self }
5353    pub fn build(self) -> SetDownloadBehaviorParams<'a> {
5354        SetDownloadBehaviorParams {
5355            behavior: self.behavior,
5356            downloadPath: self.downloadPath,
5357        }
5358    }
5359}
5360
5361impl<'a> SetDownloadBehaviorParams<'a> { pub const METHOD: &'static str = "Page.setDownloadBehavior"; }
5362
5363impl<'a> crate::CdpCommand<'a> for SetDownloadBehaviorParams<'a> {
5364    const METHOD: &'static str = "Page.setDownloadBehavior";
5365    type Response = crate::EmptyReturns;
5366}
5367
5368/// Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position
5369/// unavailable.
5370
5371#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5372#[serde(rename_all = "camelCase")]
5373pub struct SetGeolocationOverrideParams {
5374    /// Mock latitude
5375    #[serde(skip_serializing_if = "Option::is_none")]
5376    latitude: Option<f64>,
5377    /// Mock longitude
5378    #[serde(skip_serializing_if = "Option::is_none")]
5379    longitude: Option<f64>,
5380    /// Mock accuracy
5381    #[serde(skip_serializing_if = "Option::is_none")]
5382    accuracy: Option<f64>,
5383}
5384
5385impl SetGeolocationOverrideParams {
5386    pub fn builder() -> SetGeolocationOverrideParamsBuilder {
5387        SetGeolocationOverrideParamsBuilder {
5388            latitude: None,
5389            longitude: None,
5390            accuracy: None,
5391        }
5392    }
5393    pub fn latitude(&self) -> Option<f64> { self.latitude }
5394    pub fn longitude(&self) -> Option<f64> { self.longitude }
5395    pub fn accuracy(&self) -> Option<f64> { self.accuracy }
5396}
5397
5398#[derive(Default)]
5399pub struct SetGeolocationOverrideParamsBuilder {
5400    latitude: Option<f64>,
5401    longitude: Option<f64>,
5402    accuracy: Option<f64>,
5403}
5404
5405impl SetGeolocationOverrideParamsBuilder {
5406    /// Mock latitude
5407    pub fn latitude(mut self, latitude: f64) -> Self { self.latitude = Some(latitude); self }
5408    /// Mock longitude
5409    pub fn longitude(mut self, longitude: f64) -> Self { self.longitude = Some(longitude); self }
5410    /// Mock accuracy
5411    pub fn accuracy(mut self, accuracy: f64) -> Self { self.accuracy = Some(accuracy); self }
5412    pub fn build(self) -> SetGeolocationOverrideParams {
5413        SetGeolocationOverrideParams {
5414            latitude: self.latitude,
5415            longitude: self.longitude,
5416            accuracy: self.accuracy,
5417        }
5418    }
5419}
5420
5421impl SetGeolocationOverrideParams { pub const METHOD: &'static str = "Page.setGeolocationOverride"; }
5422
5423impl<'a> crate::CdpCommand<'a> for SetGeolocationOverrideParams {
5424    const METHOD: &'static str = "Page.setGeolocationOverride";
5425    type Response = crate::EmptyReturns;
5426}
5427
5428/// Controls whether page will emit lifecycle events.
5429
5430#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5431#[serde(rename_all = "camelCase")]
5432pub struct SetLifecycleEventsEnabledParams {
5433    /// If true, starts emitting lifecycle events.
5434    enabled: bool,
5435}
5436
5437impl SetLifecycleEventsEnabledParams {
5438    pub fn builder(enabled: bool) -> SetLifecycleEventsEnabledParamsBuilder {
5439        SetLifecycleEventsEnabledParamsBuilder {
5440            enabled: enabled,
5441        }
5442    }
5443    pub fn enabled(&self) -> bool { self.enabled }
5444}
5445
5446
5447pub struct SetLifecycleEventsEnabledParamsBuilder {
5448    enabled: bool,
5449}
5450
5451impl SetLifecycleEventsEnabledParamsBuilder {
5452    pub fn build(self) -> SetLifecycleEventsEnabledParams {
5453        SetLifecycleEventsEnabledParams {
5454            enabled: self.enabled,
5455        }
5456    }
5457}
5458
5459impl SetLifecycleEventsEnabledParams { pub const METHOD: &'static str = "Page.setLifecycleEventsEnabled"; }
5460
5461impl<'a> crate::CdpCommand<'a> for SetLifecycleEventsEnabledParams {
5462    const METHOD: &'static str = "Page.setLifecycleEventsEnabled";
5463    type Response = crate::EmptyReturns;
5464}
5465
5466/// Toggles mouse event-based touch event emulation.
5467
5468#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5469#[serde(rename_all = "camelCase")]
5470pub struct SetTouchEmulationEnabledParams<'a> {
5471    /// Whether the touch event emulation should be enabled.
5472    enabled: bool,
5473    /// Touch/gesture events configuration. Default: current platform.
5474    #[serde(skip_serializing_if = "Option::is_none")]
5475    configuration: Option<Cow<'a, str>>,
5476}
5477
5478impl<'a> SetTouchEmulationEnabledParams<'a> {
5479    pub fn builder(enabled: bool) -> SetTouchEmulationEnabledParamsBuilder<'a> {
5480        SetTouchEmulationEnabledParamsBuilder {
5481            enabled: enabled,
5482            configuration: None,
5483        }
5484    }
5485    pub fn enabled(&self) -> bool { self.enabled }
5486    pub fn configuration(&self) -> Option<&str> { self.configuration.as_deref() }
5487}
5488
5489
5490pub struct SetTouchEmulationEnabledParamsBuilder<'a> {
5491    enabled: bool,
5492    configuration: Option<Cow<'a, str>>,
5493}
5494
5495impl<'a> SetTouchEmulationEnabledParamsBuilder<'a> {
5496    /// Touch/gesture events configuration. Default: current platform.
5497    pub fn configuration(mut self, configuration: impl Into<Cow<'a, str>>) -> Self { self.configuration = Some(configuration.into()); self }
5498    pub fn build(self) -> SetTouchEmulationEnabledParams<'a> {
5499        SetTouchEmulationEnabledParams {
5500            enabled: self.enabled,
5501            configuration: self.configuration,
5502        }
5503    }
5504}
5505
5506impl<'a> SetTouchEmulationEnabledParams<'a> { pub const METHOD: &'static str = "Page.setTouchEmulationEnabled"; }
5507
5508impl<'a> crate::CdpCommand<'a> for SetTouchEmulationEnabledParams<'a> {
5509    const METHOD: &'static str = "Page.setTouchEmulationEnabled";
5510    type Response = crate::EmptyReturns;
5511}
5512
5513/// Starts sending each frame using the 'screencastFrame' event.
5514
5515#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5516#[serde(rename_all = "camelCase")]
5517pub struct StartScreencastParams<'a> {
5518    /// Image compression format.
5519    #[serde(skip_serializing_if = "Option::is_none")]
5520    format: Option<Cow<'a, str>>,
5521    /// Compression quality from range [0..100].
5522    #[serde(skip_serializing_if = "Option::is_none")]
5523    quality: Option<i64>,
5524    /// Maximum screenshot width.
5525    #[serde(skip_serializing_if = "Option::is_none")]
5526    maxWidth: Option<u64>,
5527    /// Maximum screenshot height.
5528    #[serde(skip_serializing_if = "Option::is_none")]
5529    maxHeight: Option<i64>,
5530    /// Send every n-th frame.
5531    #[serde(skip_serializing_if = "Option::is_none")]
5532    everyNthFrame: Option<i64>,
5533}
5534
5535impl<'a> StartScreencastParams<'a> {
5536    pub fn builder() -> StartScreencastParamsBuilder<'a> {
5537        StartScreencastParamsBuilder {
5538            format: None,
5539            quality: None,
5540            maxWidth: None,
5541            maxHeight: None,
5542            everyNthFrame: None,
5543        }
5544    }
5545    pub fn format(&self) -> Option<&str> { self.format.as_deref() }
5546    pub fn quality(&self) -> Option<i64> { self.quality }
5547    pub fn maxWidth(&self) -> Option<u64> { self.maxWidth }
5548    pub fn maxHeight(&self) -> Option<i64> { self.maxHeight }
5549    pub fn everyNthFrame(&self) -> Option<i64> { self.everyNthFrame }
5550}
5551
5552#[derive(Default)]
5553pub struct StartScreencastParamsBuilder<'a> {
5554    format: Option<Cow<'a, str>>,
5555    quality: Option<i64>,
5556    maxWidth: Option<u64>,
5557    maxHeight: Option<i64>,
5558    everyNthFrame: Option<i64>,
5559}
5560
5561impl<'a> StartScreencastParamsBuilder<'a> {
5562    /// Image compression format.
5563    pub fn format(mut self, format: impl Into<Cow<'a, str>>) -> Self { self.format = Some(format.into()); self }
5564    /// Compression quality from range [0..100].
5565    pub fn quality(mut self, quality: i64) -> Self { self.quality = Some(quality); self }
5566    /// Maximum screenshot width.
5567    pub fn maxWidth(mut self, maxWidth: u64) -> Self { self.maxWidth = Some(maxWidth); self }
5568    /// Maximum screenshot height.
5569    pub fn maxHeight(mut self, maxHeight: i64) -> Self { self.maxHeight = Some(maxHeight); self }
5570    /// Send every n-th frame.
5571    pub fn everyNthFrame(mut self, everyNthFrame: i64) -> Self { self.everyNthFrame = Some(everyNthFrame); self }
5572    pub fn build(self) -> StartScreencastParams<'a> {
5573        StartScreencastParams {
5574            format: self.format,
5575            quality: self.quality,
5576            maxWidth: self.maxWidth,
5577            maxHeight: self.maxHeight,
5578            everyNthFrame: self.everyNthFrame,
5579        }
5580    }
5581}
5582
5583impl<'a> StartScreencastParams<'a> { pub const METHOD: &'static str = "Page.startScreencast"; }
5584
5585impl<'a> crate::CdpCommand<'a> for StartScreencastParams<'a> {
5586    const METHOD: &'static str = "Page.startScreencast";
5587    type Response = crate::EmptyReturns;
5588}
5589
5590#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5591pub struct StopLoadingParams {}
5592
5593impl StopLoadingParams { pub const METHOD: &'static str = "Page.stopLoading"; }
5594
5595impl<'a> crate::CdpCommand<'a> for StopLoadingParams {
5596    const METHOD: &'static str = "Page.stopLoading";
5597    type Response = crate::EmptyReturns;
5598}
5599
5600#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5601pub struct CrashParams {}
5602
5603impl CrashParams { pub const METHOD: &'static str = "Page.crash"; }
5604
5605impl<'a> crate::CdpCommand<'a> for CrashParams {
5606    const METHOD: &'static str = "Page.crash";
5607    type Response = crate::EmptyReturns;
5608}
5609
5610#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5611pub struct CloseParams {}
5612
5613impl CloseParams { pub const METHOD: &'static str = "Page.close"; }
5614
5615impl<'a> crate::CdpCommand<'a> for CloseParams {
5616    const METHOD: &'static str = "Page.close";
5617    type Response = crate::EmptyReturns;
5618}
5619
5620/// Tries to update the web lifecycle state of the page.
5621/// It will transition the page to the given state according to:
5622/// https://github.com/WICG/web-lifecycle/
5623
5624#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5625#[serde(rename_all = "camelCase")]
5626pub struct SetWebLifecycleStateParams<'a> {
5627    /// Target lifecycle state
5628    state: Cow<'a, str>,
5629}
5630
5631impl<'a> SetWebLifecycleStateParams<'a> {
5632    pub fn builder(state: impl Into<Cow<'a, str>>) -> SetWebLifecycleStateParamsBuilder<'a> {
5633        SetWebLifecycleStateParamsBuilder {
5634            state: state.into(),
5635        }
5636    }
5637    pub fn state(&self) -> &str { self.state.as_ref() }
5638}
5639
5640
5641pub struct SetWebLifecycleStateParamsBuilder<'a> {
5642    state: Cow<'a, str>,
5643}
5644
5645impl<'a> SetWebLifecycleStateParamsBuilder<'a> {
5646    pub fn build(self) -> SetWebLifecycleStateParams<'a> {
5647        SetWebLifecycleStateParams {
5648            state: self.state,
5649        }
5650    }
5651}
5652
5653impl<'a> SetWebLifecycleStateParams<'a> { pub const METHOD: &'static str = "Page.setWebLifecycleState"; }
5654
5655impl<'a> crate::CdpCommand<'a> for SetWebLifecycleStateParams<'a> {
5656    const METHOD: &'static str = "Page.setWebLifecycleState";
5657    type Response = crate::EmptyReturns;
5658}
5659
5660#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5661pub struct StopScreencastParams {}
5662
5663impl StopScreencastParams { pub const METHOD: &'static str = "Page.stopScreencast"; }
5664
5665impl<'a> crate::CdpCommand<'a> for StopScreencastParams {
5666    const METHOD: &'static str = "Page.stopScreencast";
5667    type Response = crate::EmptyReturns;
5668}
5669
5670/// Requests backend to produce compilation cache for the specified scripts.
5671/// 'scripts' are appended to the list of scripts for which the cache
5672/// would be produced. The list may be reset during page navigation.
5673/// When script with a matching URL is encountered, the cache is optionally
5674/// produced upon backend discretion, based on internal heuristics.
5675/// See also: 'Page.compilationCacheProduced'.
5676
5677#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5678#[serde(rename_all = "camelCase")]
5679pub struct ProduceCompilationCacheParams<'a> {
5680    scripts: Vec<CompilationCacheParams<'a>>,
5681}
5682
5683impl<'a> ProduceCompilationCacheParams<'a> {
5684    pub fn builder(scripts: Vec<CompilationCacheParams<'a>>) -> ProduceCompilationCacheParamsBuilder<'a> {
5685        ProduceCompilationCacheParamsBuilder {
5686            scripts: scripts,
5687        }
5688    }
5689    pub fn scripts(&self) -> &[CompilationCacheParams<'a>] { &self.scripts }
5690}
5691
5692
5693pub struct ProduceCompilationCacheParamsBuilder<'a> {
5694    scripts: Vec<CompilationCacheParams<'a>>,
5695}
5696
5697impl<'a> ProduceCompilationCacheParamsBuilder<'a> {
5698    pub fn build(self) -> ProduceCompilationCacheParams<'a> {
5699        ProduceCompilationCacheParams {
5700            scripts: self.scripts,
5701        }
5702    }
5703}
5704
5705impl<'a> ProduceCompilationCacheParams<'a> { pub const METHOD: &'static str = "Page.produceCompilationCache"; }
5706
5707impl<'a> crate::CdpCommand<'a> for ProduceCompilationCacheParams<'a> {
5708    const METHOD: &'static str = "Page.produceCompilationCache";
5709    type Response = crate::EmptyReturns;
5710}
5711
5712/// Seeds compilation cache for given url. Compilation cache does not survive
5713/// cross-process navigation.
5714
5715#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5716#[serde(rename_all = "camelCase")]
5717pub struct AddCompilationCacheParams<'a> {
5718    url: Cow<'a, str>,
5719    /// Base64-encoded data (Encoded as a base64 string when passed over JSON)
5720    data: Cow<'a, str>,
5721}
5722
5723impl<'a> AddCompilationCacheParams<'a> {
5724    pub fn builder(url: impl Into<Cow<'a, str>>, data: impl Into<Cow<'a, str>>) -> AddCompilationCacheParamsBuilder<'a> {
5725        AddCompilationCacheParamsBuilder {
5726            url: url.into(),
5727            data: data.into(),
5728        }
5729    }
5730    pub fn url(&self) -> &str { self.url.as_ref() }
5731    pub fn data(&self) -> &str { self.data.as_ref() }
5732}
5733
5734
5735pub struct AddCompilationCacheParamsBuilder<'a> {
5736    url: Cow<'a, str>,
5737    data: Cow<'a, str>,
5738}
5739
5740impl<'a> AddCompilationCacheParamsBuilder<'a> {
5741    pub fn build(self) -> AddCompilationCacheParams<'a> {
5742        AddCompilationCacheParams {
5743            url: self.url,
5744            data: self.data,
5745        }
5746    }
5747}
5748
5749impl<'a> AddCompilationCacheParams<'a> { pub const METHOD: &'static str = "Page.addCompilationCache"; }
5750
5751impl<'a> crate::CdpCommand<'a> for AddCompilationCacheParams<'a> {
5752    const METHOD: &'static str = "Page.addCompilationCache";
5753    type Response = crate::EmptyReturns;
5754}
5755
5756#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5757pub struct ClearCompilationCacheParams {}
5758
5759impl ClearCompilationCacheParams { pub const METHOD: &'static str = "Page.clearCompilationCache"; }
5760
5761impl<'a> crate::CdpCommand<'a> for ClearCompilationCacheParams {
5762    const METHOD: &'static str = "Page.clearCompilationCache";
5763    type Response = crate::EmptyReturns;
5764}
5765
5766/// Sets the Secure Payment Confirmation transaction mode.
5767/// https://w3c.github.io/secure-payment-confirmation/#sctn-automation-set-spc-transaction-mode
5768
5769#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5770#[serde(rename_all = "camelCase")]
5771pub struct SetSPCTransactionModeParams<'a> {
5772    mode: Cow<'a, str>,
5773}
5774
5775impl<'a> SetSPCTransactionModeParams<'a> {
5776    pub fn builder(mode: impl Into<Cow<'a, str>>) -> SetSPCTransactionModeParamsBuilder<'a> {
5777        SetSPCTransactionModeParamsBuilder {
5778            mode: mode.into(),
5779        }
5780    }
5781    pub fn mode(&self) -> &str { self.mode.as_ref() }
5782}
5783
5784
5785pub struct SetSPCTransactionModeParamsBuilder<'a> {
5786    mode: Cow<'a, str>,
5787}
5788
5789impl<'a> SetSPCTransactionModeParamsBuilder<'a> {
5790    pub fn build(self) -> SetSPCTransactionModeParams<'a> {
5791        SetSPCTransactionModeParams {
5792            mode: self.mode,
5793        }
5794    }
5795}
5796
5797impl<'a> SetSPCTransactionModeParams<'a> { pub const METHOD: &'static str = "Page.setSPCTransactionMode"; }
5798
5799impl<'a> crate::CdpCommand<'a> for SetSPCTransactionModeParams<'a> {
5800    const METHOD: &'static str = "Page.setSPCTransactionMode";
5801    type Response = crate::EmptyReturns;
5802}
5803
5804/// Extensions for Custom Handlers API:
5805/// https://html.spec.whatwg.org/multipage/system-state.html#rph-automation
5806
5807#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5808#[serde(rename_all = "camelCase")]
5809pub struct SetRPHRegistrationModeParams<'a> {
5810    mode: Cow<'a, str>,
5811}
5812
5813impl<'a> SetRPHRegistrationModeParams<'a> {
5814    pub fn builder(mode: impl Into<Cow<'a, str>>) -> SetRPHRegistrationModeParamsBuilder<'a> {
5815        SetRPHRegistrationModeParamsBuilder {
5816            mode: mode.into(),
5817        }
5818    }
5819    pub fn mode(&self) -> &str { self.mode.as_ref() }
5820}
5821
5822
5823pub struct SetRPHRegistrationModeParamsBuilder<'a> {
5824    mode: Cow<'a, str>,
5825}
5826
5827impl<'a> SetRPHRegistrationModeParamsBuilder<'a> {
5828    pub fn build(self) -> SetRPHRegistrationModeParams<'a> {
5829        SetRPHRegistrationModeParams {
5830            mode: self.mode,
5831        }
5832    }
5833}
5834
5835impl<'a> SetRPHRegistrationModeParams<'a> { pub const METHOD: &'static str = "Page.setRPHRegistrationMode"; }
5836
5837impl<'a> crate::CdpCommand<'a> for SetRPHRegistrationModeParams<'a> {
5838    const METHOD: &'static str = "Page.setRPHRegistrationMode";
5839    type Response = crate::EmptyReturns;
5840}
5841
5842/// Generates a report for testing.
5843
5844#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5845#[serde(rename_all = "camelCase")]
5846pub struct GenerateTestReportParams<'a> {
5847    /// Message to be displayed in the report.
5848    message: Cow<'a, str>,
5849    /// Specifies the endpoint group to deliver the report to.
5850    #[serde(skip_serializing_if = "Option::is_none")]
5851    group: Option<Cow<'a, str>>,
5852}
5853
5854impl<'a> GenerateTestReportParams<'a> {
5855    pub fn builder(message: impl Into<Cow<'a, str>>) -> GenerateTestReportParamsBuilder<'a> {
5856        GenerateTestReportParamsBuilder {
5857            message: message.into(),
5858            group: None,
5859        }
5860    }
5861    pub fn message(&self) -> &str { self.message.as_ref() }
5862    pub fn group(&self) -> Option<&str> { self.group.as_deref() }
5863}
5864
5865
5866pub struct GenerateTestReportParamsBuilder<'a> {
5867    message: Cow<'a, str>,
5868    group: Option<Cow<'a, str>>,
5869}
5870
5871impl<'a> GenerateTestReportParamsBuilder<'a> {
5872    /// Specifies the endpoint group to deliver the report to.
5873    pub fn group(mut self, group: impl Into<Cow<'a, str>>) -> Self { self.group = Some(group.into()); self }
5874    pub fn build(self) -> GenerateTestReportParams<'a> {
5875        GenerateTestReportParams {
5876            message: self.message,
5877            group: self.group,
5878        }
5879    }
5880}
5881
5882impl<'a> GenerateTestReportParams<'a> { pub const METHOD: &'static str = "Page.generateTestReport"; }
5883
5884impl<'a> crate::CdpCommand<'a> for GenerateTestReportParams<'a> {
5885    const METHOD: &'static str = "Page.generateTestReport";
5886    type Response = crate::EmptyReturns;
5887}
5888
5889#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5890pub struct WaitForDebuggerParams {}
5891
5892impl WaitForDebuggerParams { pub const METHOD: &'static str = "Page.waitForDebugger"; }
5893
5894impl<'a> crate::CdpCommand<'a> for WaitForDebuggerParams {
5895    const METHOD: &'static str = "Page.waitForDebugger";
5896    type Response = crate::EmptyReturns;
5897}
5898
5899/// Intercept file chooser requests and transfer control to protocol clients.
5900/// When file chooser interception is enabled, native file chooser dialog is not shown.
5901/// Instead, a protocol event 'Page.fileChooserOpened' is emitted.
5902
5903#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5904#[serde(rename_all = "camelCase")]
5905pub struct SetInterceptFileChooserDialogParams {
5906    enabled: bool,
5907    /// If true, cancels the dialog by emitting relevant events (if any)
5908    /// in addition to not showing it if the interception is enabled
5909    /// (default: false).
5910    #[serde(skip_serializing_if = "Option::is_none")]
5911    cancel: Option<bool>,
5912}
5913
5914impl SetInterceptFileChooserDialogParams {
5915    pub fn builder(enabled: bool) -> SetInterceptFileChooserDialogParamsBuilder {
5916        SetInterceptFileChooserDialogParamsBuilder {
5917            enabled: enabled,
5918            cancel: None,
5919        }
5920    }
5921    pub fn enabled(&self) -> bool { self.enabled }
5922    pub fn cancel(&self) -> Option<bool> { self.cancel }
5923}
5924
5925
5926pub struct SetInterceptFileChooserDialogParamsBuilder {
5927    enabled: bool,
5928    cancel: Option<bool>,
5929}
5930
5931impl SetInterceptFileChooserDialogParamsBuilder {
5932    /// If true, cancels the dialog by emitting relevant events (if any)
5933    /// in addition to not showing it if the interception is enabled
5934    /// (default: false).
5935    pub fn cancel(mut self, cancel: bool) -> Self { self.cancel = Some(cancel); self }
5936    pub fn build(self) -> SetInterceptFileChooserDialogParams {
5937        SetInterceptFileChooserDialogParams {
5938            enabled: self.enabled,
5939            cancel: self.cancel,
5940        }
5941    }
5942}
5943
5944impl SetInterceptFileChooserDialogParams { pub const METHOD: &'static str = "Page.setInterceptFileChooserDialog"; }
5945
5946impl<'a> crate::CdpCommand<'a> for SetInterceptFileChooserDialogParams {
5947    const METHOD: &'static str = "Page.setInterceptFileChooserDialog";
5948    type Response = crate::EmptyReturns;
5949}
5950
5951/// Enable/disable prerendering manually.
5952/// 
5953/// This command is a short-term solution for https://crbug.com/1440085.
5954/// See https://docs.google.com/document/d/12HVmFxYj5Jc-eJr5OmWsa2bqTJsbgGLKI6ZIyx0_wpA
5955/// for more details.
5956/// 
5957/// TODO(https://crbug.com/1440085): Remove this once Puppeteer supports tab targets.
5958
5959#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5960#[serde(rename_all = "camelCase")]
5961pub struct SetPrerenderingAllowedParams {
5962    isAllowed: bool,
5963}
5964
5965impl SetPrerenderingAllowedParams {
5966    pub fn builder(isAllowed: bool) -> SetPrerenderingAllowedParamsBuilder {
5967        SetPrerenderingAllowedParamsBuilder {
5968            isAllowed: isAllowed,
5969        }
5970    }
5971    pub fn isAllowed(&self) -> bool { self.isAllowed }
5972}
5973
5974
5975pub struct SetPrerenderingAllowedParamsBuilder {
5976    isAllowed: bool,
5977}
5978
5979impl SetPrerenderingAllowedParamsBuilder {
5980    pub fn build(self) -> SetPrerenderingAllowedParams {
5981        SetPrerenderingAllowedParams {
5982            isAllowed: self.isAllowed,
5983        }
5984    }
5985}
5986
5987impl SetPrerenderingAllowedParams { pub const METHOD: &'static str = "Page.setPrerenderingAllowed"; }
5988
5989impl<'a> crate::CdpCommand<'a> for SetPrerenderingAllowedParams {
5990    const METHOD: &'static str = "Page.setPrerenderingAllowed";
5991    type Response = crate::EmptyReturns;
5992}
5993
5994/// Get the annotated page content for the main frame.
5995/// This is an experimental command that is subject to change.
5996
5997#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5998#[serde(rename_all = "camelCase")]
5999pub struct GetAnnotatedPageContentParams {
6000    /// Whether to include actionable information. Defaults to true.
6001    #[serde(skip_serializing_if = "Option::is_none")]
6002    includeActionableInformation: Option<bool>,
6003}
6004
6005impl GetAnnotatedPageContentParams {
6006    pub fn builder() -> GetAnnotatedPageContentParamsBuilder {
6007        GetAnnotatedPageContentParamsBuilder {
6008            includeActionableInformation: None,
6009        }
6010    }
6011    pub fn includeActionableInformation(&self) -> Option<bool> { self.includeActionableInformation }
6012}
6013
6014#[derive(Default)]
6015pub struct GetAnnotatedPageContentParamsBuilder {
6016    includeActionableInformation: Option<bool>,
6017}
6018
6019impl GetAnnotatedPageContentParamsBuilder {
6020    /// Whether to include actionable information. Defaults to true.
6021    pub fn includeActionableInformation(mut self, includeActionableInformation: bool) -> Self { self.includeActionableInformation = Some(includeActionableInformation); self }
6022    pub fn build(self) -> GetAnnotatedPageContentParams {
6023        GetAnnotatedPageContentParams {
6024            includeActionableInformation: self.includeActionableInformation,
6025        }
6026    }
6027}
6028
6029/// Get the annotated page content for the main frame.
6030/// This is an experimental command that is subject to change.
6031
6032#[derive(Debug, Clone, Serialize, Deserialize, Default)]
6033#[serde(rename_all = "camelCase")]
6034pub struct GetAnnotatedPageContentReturns<'a> {
6035    /// The annotated page content as a base64 encoded protobuf.
6036    /// The format is defined by the 'AnnotatedPageContent' message in
6037    /// components/optimization_guide/proto/features/common_quality_data.proto (Encoded as a base64 string when passed over JSON)
6038    content: Cow<'a, str>,
6039}
6040
6041impl<'a> GetAnnotatedPageContentReturns<'a> {
6042    pub fn builder(content: impl Into<Cow<'a, str>>) -> GetAnnotatedPageContentReturnsBuilder<'a> {
6043        GetAnnotatedPageContentReturnsBuilder {
6044            content: content.into(),
6045        }
6046    }
6047    pub fn content(&self) -> &str { self.content.as_ref() }
6048}
6049
6050
6051pub struct GetAnnotatedPageContentReturnsBuilder<'a> {
6052    content: Cow<'a, str>,
6053}
6054
6055impl<'a> GetAnnotatedPageContentReturnsBuilder<'a> {
6056    pub fn build(self) -> GetAnnotatedPageContentReturns<'a> {
6057        GetAnnotatedPageContentReturns {
6058            content: self.content,
6059        }
6060    }
6061}
6062
6063impl GetAnnotatedPageContentParams { pub const METHOD: &'static str = "Page.getAnnotatedPageContent"; }
6064
6065impl<'a> crate::CdpCommand<'a> for GetAnnotatedPageContentParams {
6066    const METHOD: &'static str = "Page.getAnnotatedPageContent";
6067    type Response = GetAnnotatedPageContentReturns<'a>;
6068}