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.
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.
Auto Trait Implementations§
impl !Freeze for BrowserContext
impl !RefUnwindSafe for BrowserContext
impl Send for BrowserContext
impl Sync for BrowserContext
impl Unpin for BrowserContext
impl !UnwindSafe for BrowserContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more