cdp-driver 0.5.0

Chrome DevTools Protocol (CDP) client for Rust: every command, event and type generated from the schema, with sessions, for browser automation and AI agents
Documentation
// @generated by `just generate-methods` from protocol/*.json.
// Do not edit by hand; edit xtask/ and regenerate.

//! Defines commands and events for browser extensions.
//!
//! Types, command parameters and event payloads for the `Extensions`
//! domain. The method-name constants for the same domain are in
//! [`crate::methods`].
//!
//! This domain is experimental and may change without notice.

use serde::{Deserialize, Serialize};

/// Storage areas.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum StorageArea {
    /// `session`
    #[serde(rename = "session")]
    Session,
    /// `local`
    #[serde(rename = "local")]
    Local,
    /// `sync`
    #[serde(rename = "sync")]
    Sync,
    /// `managed`
    #[serde(rename = "managed")]
    Managed,
    /// A value this vendored schema does not list. Chrome adds values ahead of
    /// the published protocol, so an unrecognised one is kept as it arrived
    /// rather than failing the payload it came in.
    #[serde(untagged)]
    Unrecognized(String),
}

/// Detailed information about an extension.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct ExtensionInfo {
    /// Extension id.
    pub id: String,
    /// Extension name.
    pub name: String,
    /// Extension version.
    pub version: String,
    /// The path from which the extension was loaded.
    pub path: String,
    /// Extension enabled status.
    pub enabled: bool,
}

/// Runs an extension default action.
///
/// Parameters of `Extensions.triggerAction`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct TriggerActionParams {
    /// Extension id.
    pub id: String,
    /// A tab target ID to trigger the default extension action on.
    #[serde(rename = "targetId")]
    pub target_id: String,
}

impl crate::typed::Command for TriggerActionParams {
    const METHOD: &'static str = "Extensions.triggerAction";
    type Returns = crate::typed::NoReturns;
}

/// Installs an unpacked extension from the filesystem similar to
/// --load-extension CLI flags. Returns extension ID once the extension has
/// been installed.
///
/// Parameters of `Extensions.loadUnpacked`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct LoadUnpackedParams {
    /// Absolute file path.
    pub path: String,
    /// Enable the extension in incognito
    #[serde(
        rename = "enableInIncognito",
        default,
        skip_serializing_if = "Option::is_none"
    )]
    pub enable_in_incognito: Option<bool>,
}

/// What `Extensions.loadUnpacked` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct LoadUnpackedReturns {
    /// Extension id.
    pub id: String,
}

impl crate::typed::Command for LoadUnpackedParams {
    const METHOD: &'static str = "Extensions.loadUnpacked";
    type Returns = LoadUnpackedReturns;
}

/// Gets a list of all unpacked extensions.
///
/// Parameters of `Extensions.getExtensions`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetExtensionsParams {}

/// What `Extensions.getExtensions` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetExtensionsReturns {
    pub extensions: Vec<ExtensionInfo>,
}

impl crate::typed::Command for GetExtensionsParams {
    const METHOD: &'static str = "Extensions.getExtensions";
    type Returns = GetExtensionsReturns;
}

/// Uninstalls an unpacked extension (others not supported) from the profile.
///
/// Parameters of `Extensions.uninstall`.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct UninstallParams {
    /// Extension id.
    pub id: String,
}

impl crate::typed::Command for UninstallParams {
    const METHOD: &'static str = "Extensions.uninstall";
    type Returns = crate::typed::NoReturns;
}

/// Gets data from extension storage in the given `storageArea`. If `keys` is
/// specified, these are used to filter the result.
///
/// Parameters of `Extensions.getStorageItems`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct GetStorageItemsParams {
    /// ID of extension.
    pub id: String,
    /// StorageArea to retrieve data from.
    #[serde(rename = "storageArea")]
    pub storage_area: StorageArea,
    /// Keys to retrieve.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub keys: Option<Vec<String>>,
}

/// What `Extensions.getStorageItems` answers with.
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct GetStorageItemsReturns {
    pub data: serde_json::Value,
}

impl crate::typed::Command for GetStorageItemsParams {
    const METHOD: &'static str = "Extensions.getStorageItems";
    type Returns = GetStorageItemsReturns;
}

/// Removes `keys` from extension storage in the given `storageArea`.
///
/// Parameters of `Extensions.removeStorageItems`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RemoveStorageItemsParams {
    /// ID of extension.
    pub id: String,
    /// StorageArea to remove data from.
    #[serde(rename = "storageArea")]
    pub storage_area: StorageArea,
    /// Keys to remove.
    pub keys: Vec<String>,
}

impl crate::typed::Command for RemoveStorageItemsParams {
    const METHOD: &'static str = "Extensions.removeStorageItems";
    type Returns = crate::typed::NoReturns;
}

/// Clears extension storage in the given `storageArea`.
///
/// Parameters of `Extensions.clearStorageItems`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ClearStorageItemsParams {
    /// ID of extension.
    pub id: String,
    /// StorageArea to remove data from.
    #[serde(rename = "storageArea")]
    pub storage_area: StorageArea,
}

impl crate::typed::Command for ClearStorageItemsParams {
    const METHOD: &'static str = "Extensions.clearStorageItems";
    type Returns = crate::typed::NoReturns;
}

/// Sets `values` in extension storage in the given `storageArea`. The
/// provided `values` will be merged with existing values in the storage area.
///
/// Parameters of `Extensions.setStorageItems`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct SetStorageItemsParams {
    /// ID of extension.
    pub id: String,
    /// StorageArea to set data in.
    #[serde(rename = "storageArea")]
    pub storage_area: StorageArea,
    /// Values to set.
    pub values: serde_json::Value,
}

impl crate::typed::Command for SetStorageItemsParams {
    const METHOD: &'static str = "Extensions.setStorageItems";
    type Returns = crate::typed::NoReturns;
}