pub struct BrowserContext { /* private fields */ }Expand description
BrowserContext 本地状态。
@trace REQ-BAO-API-006 [class:BrowserContext]
Implementations§
Source§impl BrowserContext
impl BrowserContext
Sourcepub fn new(browser: Weak<Browser>, opts: ContextOptions) -> BrowserContext
pub fn new(browser: Weak<Browser>, opts: ContextOptions) -> BrowserContext
构造 BrowserContext。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn browser(&self) -> Rc<Browser>
pub fn browser(&self) -> Rc<Browser>
所属 Browser(weak upgrade)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn pages(&self) -> Vec<Rc<Page>>
pub fn pages(&self) -> Vec<Rc<Page>>
Pages 列表(克隆)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn pages_count(&self) -> usize
pub fn pages_count(&self) -> usize
Page 数量。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn is_incognito(&self) -> bool
pub fn is_incognito(&self) -> bool
是否 incognito(从 opts 读)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn options(&self) -> ContextOptions
pub fn options(&self) -> ContextOptions
Context options(克隆)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn set_context_id(&self, id: impl Into<String>)
pub fn set_context_id(&self, id: impl Into<String>)
设置 context id(CDP Browser.createBrowserContext 响应填入)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn context_id(&self) -> Option<String>
pub fn context_id(&self) -> Option<String>
Context ID。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn override_permissions(
&self,
origin: impl Into<String>,
perms: Vec<PermissionOverride>,
)
pub fn override_permissions( &self, origin: impl Into<String>, perms: Vec<PermissionOverride>, )
覆盖指定 origin 的 permissions(本地状态)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn clear_permission_overrides(&self)
pub fn clear_permission_overrides(&self)
清除所有 permission overrides(本地状态)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn permission_overrides(&self) -> HashMap<String, Vec<PermissionOverride>>
pub fn permission_overrides(&self) -> HashMap<String, Vec<PermissionOverride>>
返回所有 permission overrides(克隆)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn permissions_for(&self, origin: &str) -> Vec<PermissionOverride>
pub fn permissions_for(&self, origin: &str) -> Vec<PermissionOverride>
查找 origin 的 permission overrides(克隆)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn add_page(&self, p: Rc<Page>)
pub fn add_page(&self, p: Rc<Page>)
添加 Page(由 BrowserContext::new_page 调用)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn remove_page(&self, target_id: &str)
pub fn remove_page(&self, target_id: &str)
移除 Page(targetDestroyed / Page.close 后调用)。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn page_by_target(&self, target_id: &str) -> Option<Rc<Page>>
pub fn page_by_target(&self, target_id: &str) -> Option<Rc<Page>>
按 target_id 查找 Page。
@trace REQ-BAO-API-006 [class:BrowserContext]
Sourcepub fn events_inner(&self) -> &Rc<EventEmitterInner>
pub fn events_inner(&self) -> &Rc<EventEmitterInner>
EventEmitter inner 引用。
@trace REQ-BAO-API-006 [class:BrowserContext]
Trait Implementations§
Source§impl Debug for BrowserContext
impl Debug for BrowserContext
Source§impl EventEmitter for BrowserContext
impl EventEmitter for BrowserContext
Source§fn on(&self, event: &str, handler: Arc<dyn Fn(&[Value])>) -> u64
fn on(&self, event: &str, handler: Arc<dyn Fn(&[Value])>) -> u64
Source§fn off(&self, event: &str, handler_id: u64) -> SubscriptionResult
fn off(&self, event: &str, handler_id: u64) -> SubscriptionResult
Source§fn remove_all_listeners(&self, event: Option<&str>)
fn remove_all_listeners(&self, event: Option<&str>)
event=None 时清空所有事件的所有 handler。Source§fn listener_count(&self, event: &str) -> usize
fn listener_count(&self, event: &str) -> usize
Auto Trait Implementations§
impl !Freeze for BrowserContext
impl !RefUnwindSafe for BrowserContext
impl !Send for BrowserContext
impl !Sync for BrowserContext
impl !UnwindSafe for BrowserContext
impl Unpin for BrowserContext
impl UnsafeUnpin for BrowserContext
Blanket Implementations§
Source§impl<T> AsCtxPtr for Twhere
T: ?Sized,
impl<T> AsCtxPtr for Twhere
T: ?Sized,
Source§fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
fn as_ctx_ptr(&self) -> *mut Selfwhere
Self: Sized,
self’s address as *mut Self for deferred-task / scopeguard /
ref_guard ctx slots. The closures/trampolines deref it as shared
(&*p) — every method they reach is &self post-R-2, so no write
provenance is required; the *mut spelling is purely to match the
existing DerefOnDrop / HasAutoFlush / RefCount ABI.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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Filterable for T
impl<T> Filterable for T
Source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(DataRequest<'_>) -> bool>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more