pub struct BrowserContext { /* private fields */ }Expand description
Represents an isolated browser context (similar to an incognito profile).
Implementations§
Source§impl BrowserContext
impl BrowserContext
pub fn id(&self) -> &str
Sourcepub async fn new_page(&self) -> Result<Arc<Page>>
pub async fn new_page(&self) -> Result<Arc<Page>>
Creates a new page within this specific browser context.
§Examples
use cdp_core::Browser;
let browser = Browser::launcher().launch().await?;
let context = browser.new_context().await?;
let page = context.new_page().await?;Sourcepub async fn grant_permissions(
&self,
origin: Option<&str>,
permissions: &[PermissionType],
) -> Result<()>
pub async fn grant_permissions( &self, origin: Option<&str>, permissions: &[PermissionType], ) -> Result<()>
Grants the provided permissions for the optional origin.
Each PermissionType is sent as a separate Browser.setPermission call
because PermissionDescriptor accepts a single permission name string.
Sourcepub async fn apply_permission_grant(
&self,
grant: &PermissionGrant,
) -> Result<()>
pub async fn apply_permission_grant( &self, grant: &PermissionGrant, ) -> Result<()>
Applies a permission grant described by PermissionGrant.
Sourcepub async fn set_permission_override(
&self,
permission: &PermissionOverride,
) -> Result<()>
pub async fn set_permission_override( &self, permission: &PermissionOverride, ) -> Result<()>
Sets a fine-grained permission override.
Sourcepub async fn reset_permissions(&self) -> Result<()>
pub async fn reset_permissions(&self) -> Result<()>
Resets all permission overrides that have been applied to this context.
Sourcepub async fn set_download_behavior(
&self,
options: &DownloadOptions,
) -> Result<()>
pub async fn set_download_behavior( &self, options: &DownloadOptions, ) -> Result<()>
Configures how downloads should be handled within this context.
Sourcepub async fn clear_download_behavior(&self) -> Result<()>
pub async fn clear_download_behavior(&self) -> Result<()>
Resets download handling back to Chrome defaults.
Sourcepub async fn set_emulation_config(&self, config: EmulationConfig) -> Result<()>
pub async fn set_emulation_config(&self, config: EmulationConfig) -> Result<()>
Applies the provided emulation configuration to all existing pages and stores it for future pages.
Sourcepub async fn clear_emulation_config(&self) -> Result<()>
pub async fn clear_emulation_config(&self) -> Result<()>
Clears the stored emulation configuration and best-effort resets overrides on existing pages.