1use serde::{Serialize, Deserialize};
2use serde_json::Value as JsonValue;
3
4pub type RuleSetId = String;
7
8#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11#[serde(rename_all = "camelCase")]
12pub struct RuleSet {
13
14 pub id: RuleSetId,
15 pub loaderId: crate::network::LoaderId,
18 pub sourceText: String,
27 #[serde(skip_serializing_if = "Option::is_none")]
39 pub backendNodeId: Option<crate::dom::BackendNodeId>,
40
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub url: Option<String>,
43
44 #[serde(skip_serializing_if = "Option::is_none")]
45 pub requestId: Option<crate::network::RequestId>,
46 #[serde(skip_serializing_if = "Option::is_none")]
50 pub errorType: Option<RuleSetErrorType>,
51 #[serde(skip_serializing_if = "Option::is_none")]
54 pub errorMessage: Option<String>,
55 #[serde(skip_serializing_if = "Option::is_none")]
59 pub tag: Option<String>,
60}
61
62
63#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
64pub enum RuleSetErrorType {
65 #[default]
66 SourceIsNotJsonObject,
67 InvalidRulesSkipped,
68 InvalidRulesetLevelTag,
69}
70
71#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
76pub enum SpeculationAction {
77 #[default]
78 Prefetch,
79 Prerender,
80 PrerenderUntilScript,
81}
82
83#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
87pub enum SpeculationTargetHint {
88 #[default]
89 Blank,
90 SelfValue,
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize, Default)]
101#[serde(rename_all = "camelCase")]
102pub struct PreloadingAttemptKey {
103
104 pub loaderId: crate::network::LoaderId,
105
106 pub action: SpeculationAction,
107
108 pub url: String,
109
110 #[serde(skip_serializing_if = "Option::is_none")]
111 pub formSubmission: Option<bool>,
112
113 #[serde(skip_serializing_if = "Option::is_none")]
114 pub targetHint: Option<SpeculationTargetHint>,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize, Default)]
124#[serde(rename_all = "camelCase")]
125pub struct PreloadingAttemptSource {
126
127 pub key: PreloadingAttemptKey,
128
129 pub ruleSetIds: Vec<RuleSetId>,
130
131 pub nodeIds: Vec<crate::dom::BackendNodeId>,
132}
133
134pub type PreloadPipelineId = String;
143
144#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
147pub enum PrerenderFinalStatus {
148 #[default]
149 Activated,
150 Destroyed,
151 LowEndDevice,
152 InvalidSchemeRedirect,
153 InvalidSchemeNavigation,
154 NavigationRequestBlockedByCsp,
155 MojoBinderPolicy,
156 RendererProcessCrashed,
157 RendererProcessKilled,
158 Download,
159 TriggerDestroyed,
160 NavigationNotCommitted,
161 NavigationBadHttpStatus,
162 ClientCertRequested,
163 NavigationRequestNetworkError,
164 CancelAllHostsForTesting,
165 DidFailLoad,
166 Stop,
167 SslCertificateError,
168 LoginAuthRequested,
169 UaChangeRequiresReload,
170 BlockedByClient,
171 AudioOutputDeviceRequested,
172 MixedContent,
173 TriggerBackgrounded,
174 MemoryLimitExceeded,
175 DataSaverEnabled,
176 TriggerUrlHasEffectiveUrl,
177 ActivatedBeforeStarted,
178 InactivePageRestriction,
179 StartFailed,
180 TimeoutBackgrounded,
181 CrossSiteRedirectInInitialNavigation,
182 CrossSiteNavigationInInitialNavigation,
183 SameSiteCrossOriginRedirectNotOptInInInitialNavigation,
184 SameSiteCrossOriginNavigationNotOptInInInitialNavigation,
185 ActivationNavigationParameterMismatch,
186 ActivatedInBackground,
187 EmbedderHostDisallowed,
188 ActivationNavigationDestroyedBeforeSuccess,
189 TabClosedByUserGesture,
190 TabClosedWithoutUserGesture,
191 PrimaryMainFrameRendererProcessCrashed,
192 PrimaryMainFrameRendererProcessKilled,
193 ActivationFramePolicyNotCompatible,
194 PreloadingDisabled,
195 BatterySaverEnabled,
196 ActivatedDuringMainFrameNavigation,
197 PreloadingUnsupportedByWebContents,
198 CrossSiteRedirectInMainFrameNavigation,
199 CrossSiteNavigationInMainFrameNavigation,
200 SameSiteCrossOriginRedirectNotOptInInMainFrameNavigation,
201 SameSiteCrossOriginNavigationNotOptInInMainFrameNavigation,
202 MemoryPressureOnTrigger,
203 MemoryPressureAfterTriggered,
204 PrerenderingDisabledByDevTools,
205 SpeculationRuleRemoved,
206 ActivatedWithAuxiliaryBrowsingContexts,
207 MaxNumOfRunningEagerPrerendersExceeded,
208 MaxNumOfRunningNonEagerPrerendersExceeded,
209 MaxNumOfRunningEmbedderPrerendersExceeded,
210 PrerenderingUrlHasEffectiveUrl,
211 RedirectedPrerenderingUrlHasEffectiveUrl,
212 ActivationUrlHasEffectiveUrl,
213 JavaScriptInterfaceAdded,
214 JavaScriptInterfaceRemoved,
215 AllPrerenderingCanceled,
216 WindowClosed,
217 SlowNetwork,
218 OtherPrerenderedPageActivated,
219 V8OptimizerDisabled,
220 PrerenderFailedDuringPrefetch,
221 BrowsingDataRemoved,
222 PrerenderHostReused,
223 FormSubmitWhenPrerendering,
224}
225
226#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
230pub enum PreloadingStatus {
231 #[default]
232 Pending,
233 Running,
234 Ready,
235 Success,
236 Failure,
237 NotSupported,
238}
239
240#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
244pub enum PrefetchStatus {
245 #[default]
246 PrefetchAllowed,
247 PrefetchFailedIneligibleRedirect,
248 PrefetchFailedInvalidRedirect,
249 PrefetchFailedMIMENotSupported,
250 PrefetchFailedNetError,
251 PrefetchFailedNon2XX,
252 PrefetchEvictedAfterBrowsingDataRemoved,
253 PrefetchEvictedAfterCandidateRemoved,
254 PrefetchEvictedForNewerPrefetch,
255 PrefetchHeldback,
256 PrefetchIneligibleRetryAfter,
257 PrefetchIsPrivacyDecoy,
258 PrefetchIsStale,
259 PrefetchNotEligibleBrowserContextOffTheRecord,
260 PrefetchNotEligibleDataSaverEnabled,
261 PrefetchNotEligibleExistingProxy,
262 PrefetchNotEligibleHostIsNonUnique,
263 PrefetchNotEligibleNonDefaultStoragePartition,
264 PrefetchNotEligibleSameSiteCrossOriginPrefetchRequiredProxy,
265 PrefetchNotEligibleSchemeIsNotHttps,
266 PrefetchNotEligibleUserHasCookies,
267 PrefetchNotEligibleUserHasServiceWorker,
268 PrefetchNotEligibleUserHasServiceWorkerNoFetchHandler,
269 PrefetchNotEligibleRedirectFromServiceWorker,
270 PrefetchNotEligibleRedirectToServiceWorker,
271 PrefetchNotEligibleBatterySaverEnabled,
272 PrefetchNotEligiblePreloadingDisabled,
273 PrefetchNotFinishedInTime,
274 PrefetchNotStarted,
275 PrefetchNotUsedCookiesChanged,
276 PrefetchProxyNotAvailable,
277 PrefetchResponseUsed,
278 PrefetchSuccessfulButNotUsed,
279 PrefetchNotUsedProbeFailed,
280}
281
282#[derive(Debug, Clone, Serialize, Deserialize, Default)]
285#[serde(rename_all = "camelCase")]
286pub struct PrerenderMismatchedHeaders {
287
288 pub headerName: String,
289
290 #[serde(skip_serializing_if = "Option::is_none")]
291 pub initialValue: Option<String>,
292
293 #[serde(skip_serializing_if = "Option::is_none")]
294 pub activationValue: Option<String>,
295}
296
297#[derive(Debug, Clone, Serialize, Deserialize, Default)]
298pub struct EnableParams {}
299
300impl EnableParams { pub const METHOD: &'static str = "Preload.enable"; }
301
302impl crate::CdpCommand for EnableParams {
303 const METHOD: &'static str = "Preload.enable";
304 type Response = crate::EmptyReturns;
305}
306
307#[derive(Debug, Clone, Serialize, Deserialize, Default)]
308pub struct DisableParams {}
309
310impl DisableParams { pub const METHOD: &'static str = "Preload.disable"; }
311
312impl crate::CdpCommand for DisableParams {
313 const METHOD: &'static str = "Preload.disable";
314 type Response = crate::EmptyReturns;
315}