viewpoint_cdp/protocol/page/
params.rs

1//! Page domain parameter types.
2
3use serde::Serialize;
4
5use super::types::{ScreenshotFormat, Viewport};
6
7/// Parameters for Page.navigate.
8#[derive(Debug, Clone, Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct NavigateParams {
11    /// URL to navigate the page to.
12    pub url: String,
13    /// Referrer URL.
14    #[serde(skip_serializing_if = "Option::is_none")]
15    pub referrer: Option<String>,
16    /// Intended transition type.
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub transition_type: Option<String>,
19    /// Frame id to navigate.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub frame_id: Option<String>,
22}
23
24/// Parameters for Page.reload.
25#[derive(Debug, Clone, Serialize, Default)]
26#[serde(rename_all = "camelCase")]
27pub struct ReloadParams {
28    /// If true, browser cache is ignored.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub ignore_cache: Option<bool>,
31    /// Script to inject into all frames.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub script_to_evaluate_on_load: Option<String>,
34}
35
36/// Parameters for Page.setLifecycleEventsEnabled.
37#[derive(Debug, Clone, Serialize)]
38pub struct SetLifecycleEventsEnabledParams {
39    /// Whether to enable lifecycle events.
40    pub enabled: bool,
41}
42
43/// Parameters for Page.captureScreenshot.
44#[derive(Debug, Clone, Serialize, Default)]
45#[serde(rename_all = "camelCase")]
46pub struct CaptureScreenshotParams {
47    /// Image compression format.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    pub format: Option<ScreenshotFormat>,
50    /// Compression quality from range [0..100] (jpeg/webp only).
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub quality: Option<u8>,
53    /// Capture the screenshot of a given region only.
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub clip: Option<Viewport>,
56    /// Capture the screenshot from the surface, rather than the view.
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub from_surface: Option<bool>,
59    /// Capture the screenshot beyond the viewport.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    pub capture_beyond_viewport: Option<bool>,
62    /// Optimize image encoding for speed, not for resulting size.
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub optimize_for_speed: Option<bool>,
65}
66
67/// Parameters for Page.printToPDF.
68#[derive(Debug, Clone, Serialize, Default)]
69#[serde(rename_all = "camelCase")]
70pub struct PrintToPdfParams {
71    /// Paper orientation (default: false = portrait).
72    #[serde(skip_serializing_if = "Option::is_none")]
73    pub landscape: Option<bool>,
74    /// Display header and footer (default: false).
75    #[serde(skip_serializing_if = "Option::is_none")]
76    pub display_header_footer: Option<bool>,
77    /// Print background graphics (default: false).
78    #[serde(skip_serializing_if = "Option::is_none")]
79    pub print_background: Option<bool>,
80    /// Scale of the webpage rendering (default: 1).
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub scale: Option<f64>,
83    /// Paper width in inches (default: 8.5).
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub paper_width: Option<f64>,
86    /// Paper height in inches (default: 11).
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub paper_height: Option<f64>,
89    /// Top margin in inches (default: 0.4).
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub margin_top: Option<f64>,
92    /// Bottom margin in inches (default: 0.4).
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub margin_bottom: Option<f64>,
95    /// Left margin in inches (default: 0.4).
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub margin_left: Option<f64>,
98    /// Right margin in inches (default: 0.4).
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub margin_right: Option<f64>,
101    /// Paper ranges to print, e.g., '1-5, 8, 11-13'.
102    #[serde(skip_serializing_if = "Option::is_none")]
103    pub page_ranges: Option<String>,
104    /// HTML template for the print header.
105    #[serde(skip_serializing_if = "Option::is_none")]
106    pub header_template: Option<String>,
107    /// HTML template for the print footer.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub footer_template: Option<String>,
110    /// Whether or not to prefer page size as defined by css.
111    #[serde(skip_serializing_if = "Option::is_none")]
112    pub prefer_css_page_size: Option<bool>,
113    /// Return as stream (experimental).
114    #[serde(skip_serializing_if = "Option::is_none")]
115    pub transfer_mode: Option<String>,
116    /// Whether to generate tagged PDF. Default: true.
117    #[serde(skip_serializing_if = "Option::is_none")]
118    pub generate_tagged_pdf: Option<bool>,
119    /// Whether to generate document outline. Default: false.
120    #[serde(skip_serializing_if = "Option::is_none")]
121    pub generate_document_outline: Option<bool>,
122}
123
124/// Parameters for Page.navigateToHistoryEntry.
125#[derive(Debug, Clone, Serialize)]
126#[serde(rename_all = "camelCase")]
127pub struct NavigateToHistoryEntryParams {
128    /// Unique id of the entry to navigate to.
129    pub entry_id: i32,
130}
131
132/// Parameters for Page.addScriptToEvaluateOnNewDocument.
133#[derive(Debug, Clone, Serialize)]
134#[serde(rename_all = "camelCase")]
135pub struct AddScriptToEvaluateOnNewDocumentParams {
136    /// JavaScript source code to evaluate.
137    pub source: String,
138    /// If specified, creates an isolated world and evaluates given script in it.
139    #[serde(skip_serializing_if = "Option::is_none")]
140    pub world_name: Option<String>,
141    /// Whether this script should be injected into all frames.
142    #[serde(skip_serializing_if = "Option::is_none")]
143    pub include_command_line_api: Option<bool>,
144    /// If true, this script will run in utility world.
145    #[serde(skip_serializing_if = "Option::is_none")]
146    pub run_immediately: Option<bool>,
147}
148
149/// Parameters for Page.removeScriptToEvaluateOnNewDocument.
150#[derive(Debug, Clone, Serialize)]
151pub struct RemoveScriptToEvaluateOnNewDocumentParams {
152    /// Identifier of the script to remove.
153    pub identifier: String,
154}
155
156/// Parameters for Page.bringToFront (empty).
157#[derive(Debug, Clone, Serialize, Default)]
158pub struct BringToFrontParams {}
159
160/// Parameters for Page.setDocumentContent.
161#[derive(Debug, Clone, Serialize)]
162#[serde(rename_all = "camelCase")]
163pub struct SetDocumentContentParams {
164    /// Frame id to set HTML for.
165    pub frame_id: String,
166    /// HTML content to set.
167    pub html: String,
168}
169
170/// Parameters for Page.setInterceptFileChooserDialog.
171#[derive(Debug, Clone, Serialize)]
172pub struct SetInterceptFileChooserDialogParams {
173    /// Whether to intercept file chooser dialogs.
174    pub enabled: bool,
175}
176
177/// Parameters for Page.createIsolatedWorld.
178#[derive(Debug, Clone, Serialize)]
179#[serde(rename_all = "camelCase")]
180pub struct CreateIsolatedWorldParams {
181    /// Id of the frame in which the isolated world should be created.
182    pub frame_id: String,
183    /// An optional name which is reported in the Execution Context.
184    #[serde(skip_serializing_if = "Option::is_none")]
185    pub world_name: Option<String>,
186    /// Whether or not universal access should be granted to the isolated world.
187    /// This is a powerful option, use with caution.
188    #[serde(skip_serializing_if = "Option::is_none")]
189    pub grant_univeral_access: Option<bool>,
190}