use super::*;
#[non_exhaustive]
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum PermissionDescriptor {
Camera,
Microphone,
Geolocation,
Notifications,
ClipboardRead,
Midi { sysex: bool },
PointerLock,
KeyboardLock,
IdleDetection,
LocalFonts,
StorageAccess,
ProtectedMediaIdentifier,
DisplayCapture { audio: bool, video: bool },
Other(String),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub enum PermissionState {
Prompt,
Granted,
Denied,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub enum PermissionAnswer {
Grant,
Deny,
Dismiss,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PermissionRequest {
pub id: UserAgentRequestId,
pub origin: String,
pub descriptors: Vec<PermissionDescriptor>,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct HttpProtectionSpace {
pub origin_url: String,
pub host: String,
pub port: u16,
pub realm: Option<String>,
pub scheme: String,
pub is_proxy: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct HttpAuthenticationChallenge {
pub id: UserAgentRequestId,
pub protection_space: HttpProtectionSpace,
}
#[derive(Clone, PartialEq, Eq)]
pub struct HttpCredentials {
pub username: String,
pub password: String,
}
impl fmt::Debug for HttpCredentials {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("HttpCredentials")
.field("username", &"<redacted>")
.field("password", &"<redacted>")
.finish()
}
}
#[derive(Clone, PartialEq, Eq)]
pub enum HttpAuthenticationAnswer {
Credentials(HttpCredentials),
Cancel,
}
impl fmt::Debug for HttpAuthenticationAnswer {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Credentials(_) => f.write_str("Credentials(<redacted>)"),
Self::Cancel => f.write_str("Cancel"),
}
}
}