rustenium_cdp_definitions/browser_protocol/fed_cm/
commands.rs1use serde::{Deserialize, Serialize};
2#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
3pub struct EnableParams {
4 #[doc = "Allows callers to disable the promise rejection delay that would\nnormally happen, if this is unimportant to what's being tested.\n(step 4 of https://fedidcg.github.io/FedCM/#browser-api-rp-sign-in)"]
5 #[serde(rename = "disableRejectionDelay")]
6 #[serde(skip_serializing_if = "Option::is_none")]
7 #[serde(default)]
8 pub disable_rejection_delay: Option<bool>,
9}
10#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub enum EnableMethod {
12 #[serde(rename = "FedCm.enable")]
13 Enable,
14}
15#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
16pub struct Enable {
17 pub method: EnableMethod,
18 pub params: EnableParams,
19}
20impl Enable {
21 pub const IDENTIFIER: &'static str = "FedCm.enable";
22 pub fn identifier(&self) -> &'static str {
23 Self::IDENTIFIER
24 }
25}
26impl crate::CommandResult for Enable {
27 type Result = super::results::EnableResult;
28}
29#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
30pub struct DisableParams {}
31#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
32pub enum DisableMethod {
33 #[serde(rename = "FedCm.disable")]
34 Disable,
35}
36#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
37pub struct Disable {
38 pub method: DisableMethod,
39 pub params: DisableParams,
40}
41impl Disable {
42 pub const IDENTIFIER: &'static str = "FedCm.disable";
43 pub fn identifier(&self) -> &'static str {
44 Self::IDENTIFIER
45 }
46}
47impl crate::CommandResult for Disable {
48 type Result = super::results::DisableResult;
49}
50#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
51pub struct SelectAccountParams {
52 #[serde(rename = "dialogId")]
53 pub dialog_id: String,
54 #[serde(rename = "accountIndex")]
55 pub account_index: i64,
56}
57impl SelectAccountParams {
58 pub fn new(dialog_id: impl Into<String>, account_index: impl Into<i64>) -> Self {
59 Self {
60 dialog_id: dialog_id.into(),
61 account_index: account_index.into(),
62 }
63 }
64}
65#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
66pub enum SelectAccountMethod {
67 #[serde(rename = "FedCm.selectAccount")]
68 SelectAccount,
69}
70#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
71pub struct SelectAccount {
72 pub method: SelectAccountMethod,
73 pub params: SelectAccountParams,
74}
75impl SelectAccount {
76 pub const IDENTIFIER: &'static str = "FedCm.selectAccount";
77 pub fn identifier(&self) -> &'static str {
78 Self::IDENTIFIER
79 }
80}
81impl crate::CommandResult for SelectAccount {
82 type Result = super::results::SelectAccountResult;
83}
84#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
85pub struct ClickDialogButtonParams {
86 #[serde(rename = "dialogId")]
87 pub dialog_id: String,
88 #[serde(rename = "dialogButton")]
89 pub dialog_button: super::types::DialogButton,
90}
91impl ClickDialogButtonParams {
92 pub fn new(
93 dialog_id: impl Into<String>,
94 dialog_button: impl Into<super::types::DialogButton>,
95 ) -> Self {
96 Self {
97 dialog_id: dialog_id.into(),
98 dialog_button: dialog_button.into(),
99 }
100 }
101}
102#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
103pub enum ClickDialogButtonMethod {
104 #[serde(rename = "FedCm.clickDialogButton")]
105 ClickDialogButton,
106}
107#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
108pub struct ClickDialogButton {
109 pub method: ClickDialogButtonMethod,
110 pub params: ClickDialogButtonParams,
111}
112impl ClickDialogButton {
113 pub const IDENTIFIER: &'static str = "FedCm.clickDialogButton";
114 pub fn identifier(&self) -> &'static str {
115 Self::IDENTIFIER
116 }
117}
118impl crate::CommandResult for ClickDialogButton {
119 type Result = super::results::ClickDialogButtonResult;
120}
121#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
122pub struct OpenUrlParams {
123 #[serde(rename = "dialogId")]
124 pub dialog_id: String,
125 #[serde(rename = "accountIndex")]
126 pub account_index: i64,
127 #[serde(rename = "accountUrlType")]
128 pub account_url_type: super::types::AccountUrlType,
129}
130impl OpenUrlParams {
131 pub fn new(
132 dialog_id: impl Into<String>,
133 account_index: impl Into<i64>,
134 account_url_type: impl Into<super::types::AccountUrlType>,
135 ) -> Self {
136 Self {
137 dialog_id: dialog_id.into(),
138 account_index: account_index.into(),
139 account_url_type: account_url_type.into(),
140 }
141 }
142}
143#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
144pub enum OpenUrlMethod {
145 #[serde(rename = "FedCm.openUrl")]
146 OpenUrl,
147}
148#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
149pub struct OpenUrl {
150 pub method: OpenUrlMethod,
151 pub params: OpenUrlParams,
152}
153impl OpenUrl {
154 pub const IDENTIFIER: &'static str = "FedCm.openUrl";
155 pub fn identifier(&self) -> &'static str {
156 Self::IDENTIFIER
157 }
158}
159impl crate::CommandResult for OpenUrl {
160 type Result = super::results::OpenUrlResult;
161}
162#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
163pub struct DismissDialogParams {
164 #[serde(rename = "dialogId")]
165 pub dialog_id: String,
166 #[serde(rename = "triggerCooldown")]
167 #[serde(skip_serializing_if = "Option::is_none")]
168 #[serde(default)]
169 pub trigger_cooldown: Option<bool>,
170}
171impl DismissDialogParams {
172 pub fn new(dialog_id: impl Into<String>) -> Self {
173 Self {
174 dialog_id: dialog_id.into(),
175 trigger_cooldown: None,
176 }
177 }
178}
179impl<T: Into<String>> From<T> for DismissDialogParams {
180 fn from(url: T) -> Self {
181 DismissDialogParams::new(url)
182 }
183}
184#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
185pub enum DismissDialogMethod {
186 #[serde(rename = "FedCm.dismissDialog")]
187 DismissDialog,
188}
189#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
190pub struct DismissDialog {
191 pub method: DismissDialogMethod,
192 pub params: DismissDialogParams,
193}
194impl DismissDialog {
195 pub const IDENTIFIER: &'static str = "FedCm.dismissDialog";
196 pub fn identifier(&self) -> &'static str {
197 Self::IDENTIFIER
198 }
199}
200impl crate::CommandResult for DismissDialog {
201 type Result = super::results::DismissDialogResult;
202}
203#[doc = "Resets the cooldown time, if any, to allow the next FedCM call to show\na dialog even if one was recently dismissed by the user.\n[resetCooldown](https://chromedevtools.github.io/devtools-protocol/tot/FedCm/#method-resetCooldown)"]
204#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
205pub struct ResetCooldownParams {}
206#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
207pub enum ResetCooldownMethod {
208 #[serde(rename = "FedCm.resetCooldown")]
209 ResetCooldown,
210}
211#[doc = "Resets the cooldown time, if any, to allow the next FedCM call to show\na dialog even if one was recently dismissed by the user.\n[resetCooldown](https://chromedevtools.github.io/devtools-protocol/tot/FedCm/#method-resetCooldown)"]
212#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
213pub struct ResetCooldown {
214 pub method: ResetCooldownMethod,
215 pub params: ResetCooldownParams,
216}
217impl ResetCooldown {
218 pub const IDENTIFIER: &'static str = "FedCm.resetCooldown";
219 pub fn identifier(&self) -> &'static str {
220 Self::IDENTIFIER
221 }
222}
223impl crate::CommandResult for ResetCooldown {
224 type Result = super::results::ResetCooldownResult;
225}
226group_enum ! (FedCmCommands { Enable (Enable) , Disable (Disable) , SelectAccount (SelectAccount) , ClickDialogButton (ClickDialogButton) , OpenUrl (OpenUrl) , DismissDialog (DismissDialog) , ResetCooldown (ResetCooldown) } + identifiable);