Skip to main content

IpcClient

Struct IpcClient 

Source
pub struct IpcClient { /* private fields */ }
Expand description

Client wrapper for the CBF IPC bridge.

Implementations§

Source§

impl IpcClient

Source

pub fn prepare_channel() -> Result<(i32, String), Error>

Prepare the Mojo channel before spawning the Chromium process.

Returns (remote_fd, switch_arg) where:

  • remote_fd is the file descriptor of the remote channel endpoint that must be inherited by the child process (Unix only; -1 on other platforms).
  • switch_arg is the command-line switch that Chromium needs to recover the endpoint (e.g. --cbf-ipc-handle=...).
Source

pub fn pass_child_pid(pid: u32)

Notify the bridge of the spawned child’s PID.

Must be called after spawning the Chromium process and before connect_inherited. On macOS this registers the Mach port with the rendezvous server; on other platforms it completes channel bookkeeping.

Source

pub unsafe fn connect_inherited( inner: *mut CbfBridgeClientHandle, ) -> Result<Self, Error>

Wrap a pre-created bridge client handle and complete the Mojo connection.

inner must have been created by cbf_bridge_client_create() and the channel must have been prepared with prepare_channel() before calling this function (after the child process has been spawned).

§Safety

inner must be a valid, live CbfBridgeClientHandle allocated by cbf_bridge_client_create(). Ownership is transferred to the returned IpcClient on success and consumed by this function on failure.

Source

pub fn authenticate(&self, token: &str) -> Result<(), Error>

Authenticate with the session token and set up the browser observer.

Must be called once after connect_inherited and before any other method.

Source

pub fn wait_for_event( &self, timeout: Option<Duration>, ) -> Result<EventWaitResult, Error>

Wait until an event is available or the bridge closes.

Source

pub fn poll_event(&mut self) -> Option<Result<IpcEvent, Error>>

Poll the next IPC event, if any, from the backend.

Source

pub fn list_profiles(&mut self) -> Result<Vec<ChromeProfileInfo>, Error>

Retrieve the list of browser profiles from the backend.

Source

pub fn list_extensions( &mut self, profile_id: &str, ) -> Result<Vec<ChromeExtensionInfo>, Error>

Retrieve the list of extensions from the backend.

Source

pub fn activate_extension_action( &mut self, browsing_context_id: TabId, extension_id: &str, ) -> Result<(), Error>

Source

pub fn create_tab( &mut self, request_id: u64, initial_url: &str, profile_id: &str, ) -> Result<(), Error>

Create a tab via the IPC bridge.

Source

pub fn request_close_tab( &mut self, browsing_context_id: TabId, ) -> Result<(), Error>

Request closing the specified tab.

Source

pub fn set_tab_size( &mut self, browsing_context_id: TabId, width: u32, height: u32, ) -> Result<(), Error>

Update the surface size of the specified tab.

Source

pub fn set_tab_focus( &mut self, browsing_context_id: TabId, focused: bool, ) -> Result<(), Error>

Update whether the specified tab should receive text input focus.

Source

pub fn confirm_beforeunload( &mut self, browsing_context_id: TabId, request_id: u64, proceed: bool, ) -> Result<(), Error>

Respond to a beforeunload confirmation request.

Source

pub fn respond_javascript_dialog( &mut self, browsing_context_id: TabId, request_id: u64, accept: bool, prompt_text: Option<&str>, ) -> Result<(), Error>

Respond to a JavaScript dialog request for a tab.

Source

pub fn respond_extension_popup_javascript_dialog( &mut self, popup_id: PopupId, request_id: u64, accept: bool, prompt_text: Option<&str>, ) -> Result<(), Error>

Respond to a JavaScript dialog request for an extension popup.

Source

pub fn navigate( &mut self, browsing_context_id: TabId, url: &str, ) -> Result<(), Error>

Navigate the page to the provided URL.

Source

pub fn go_back(&mut self, browsing_context_id: TabId) -> Result<(), Error>

Navigate back in history for the page.

Source

pub fn go_forward(&mut self, browsing_context_id: TabId) -> Result<(), Error>

Navigate forward in history for the page.

Source

pub fn reload( &mut self, browsing_context_id: TabId, ignore_cache: bool, ) -> Result<(), Error>

Reload the page, optionally ignoring caches.

Source

pub fn print_preview(&mut self, browsing_context_id: TabId) -> Result<(), Error>

Open print preview for the page.

Source

pub fn open_dev_tools( &mut self, browsing_context_id: TabId, ) -> Result<(), Error>

Open DevTools for the specified page.

Source

pub fn inspect_element( &mut self, browsing_context_id: TabId, x: i32, y: i32, ) -> Result<(), Error>

Open DevTools and inspect the element at the given coordinates.

Source

pub fn get_tab_dom_html( &mut self, browsing_context_id: TabId, request_id: u64, ) -> Result<(), Error>

Request the DOM HTML for the specified page.

Source

pub fn open_default_prompt_ui( &mut self, profile_id: &str, request_id: u64, ) -> Result<(), Error>

Open Chromium default PromptUi for pending request.

Source

pub fn respond_prompt_ui( &mut self, profile_id: &str, request_id: u64, response: &PromptUiResponse, ) -> Result<(), Error>

Respond to a pending chrome-specific PromptUi request.

Source

pub fn respond_prompt_ui_for_tab( &mut self, browsing_context_id: TabId, request_id: u64, response: &PromptUiResponse, ) -> Result<(), Error>

Respond to a page-originated prompt by resolving profile on the bridge side.

Source

pub fn close_prompt_ui( &mut self, profile_id: &str, prompt_ui_id: PromptUiId, ) -> Result<(), Error>

Close a backend-managed PromptUi surface.

Source

pub fn pause_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>

Pause an in-progress download.

Source

pub fn resume_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>

Resume a paused download.

Source

pub fn cancel_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>

Cancel an active download.

Source

pub fn respond_tab_open( &mut self, request_id: u64, response: &ChromeBrowsingContextOpenResponse, ) -> Result<(), Error>

Respond to host-mediated tab-open request.

Source

pub fn respond_window_open( &mut self, request_id: u64, response: &WindowOpenResponse, ) -> Result<(), Error>

Respond to host-mediated window open request.

Current bridge path reuses tab-open response semantics.

Source

pub fn send_key_event_raw( &mut self, browsing_context_id: TabId, event: &ChromeKeyEvent, commands: &[String], ) -> Result<(), Error>

Send a Chromium-shaped keyboard event to the page.

Source

pub fn send_extension_popup_key_event_raw( &mut self, popup_id: PopupId, event: &ChromeKeyEvent, commands: &[String], ) -> Result<(), Error>

Send a Chromium-shaped keyboard event to an extension popup.

Source

pub fn send_mouse_event( &mut self, browsing_context_id: TabId, event: &ChromeMouseEvent, ) -> Result<(), Error>

Send a mouse event to the page.

Source

pub fn send_extension_popup_mouse_event( &mut self, popup_id: PopupId, event: &ChromeMouseEvent, ) -> Result<(), Error>

Send a mouse event to an extension popup.

Source

pub fn send_mouse_wheel_event_raw( &mut self, browsing_context_id: TabId, event: &ChromeMouseWheelEvent, ) -> Result<(), Error>

Send a Chromium-shaped mouse wheel event to the page.

Source

pub fn send_extension_popup_mouse_wheel_event_raw( &mut self, popup_id: PopupId, event: &ChromeMouseWheelEvent, ) -> Result<(), Error>

Send a Chromium-shaped mouse wheel event to an extension popup.

Source

pub fn send_drag_update( &mut self, update: &ChromeDragUpdate, ) -> Result<(), Error>

Send a drag update event for host-owned drag session.

Source

pub fn send_drag_drop(&mut self, drop: &ChromeDragDrop) -> Result<(), Error>

Send a drag drop event for host-owned drag session.

Source

pub fn send_drag_cancel( &mut self, session_id: u64, browsing_context_id: TabId, ) -> Result<(), Error>

Cancel a host-owned drag session.

Source

pub fn set_composition( &mut self, composition: &ChromeImeComposition, ) -> Result<(), Error>

Update the IME composition state.

Source

pub fn set_extension_popup_composition( &mut self, composition: &ChromeTransientImeComposition, ) -> Result<(), Error>

Update the IME composition state for an extension popup.

Source

pub fn commit_text(&mut self, commit: &ChromeImeCommitText) -> Result<(), Error>

Commit IME text input to the page.

Source

pub fn commit_extension_popup_text( &mut self, commit: &ChromeTransientImeCommitText, ) -> Result<(), Error>

Commit IME text input to an extension popup.

Source

pub fn finish_composing_text( &mut self, browsing_context_id: TabId, behavior: ChromeConfirmCompositionBehavior, ) -> Result<(), Error>

Finish composing IME text with the specified behavior.

Source

pub fn finish_extension_popup_composing_text( &mut self, popup_id: PopupId, behavior: ChromeConfirmCompositionBehavior, ) -> Result<(), Error>

Finish composing IME text inside an extension popup.

Source

pub fn set_extension_popup_focus( &mut self, popup_id: PopupId, focused: bool, ) -> Result<(), Error>

Source

pub fn set_extension_popup_size( &mut self, popup_id: PopupId, width: u32, height: u32, ) -> Result<(), Error>

Source

pub fn close_extension_popup(&mut self, popup_id: PopupId) -> Result<(), Error>

Source

pub fn execute_edit_action( &mut self, browsing_context_id: TabId, action: EditAction, ) -> Result<(), Error>

Execute a browser-generic edit action for the given page.

Source

pub fn execute_extension_popup_edit_action( &mut self, popup_id: PopupId, action: EditAction, ) -> Result<(), Error>

Execute a browser-generic edit action for the given extension popup.

Source

pub fn execute_context_menu_command( &mut self, menu_id: u64, command_id: i32, event_flags: i32, ) -> Result<(), Error>

Execute a context menu command for the given menu.

Source

pub fn accept_choice_menu_selection( &mut self, request_id: u64, indices: &[i32], ) -> Result<(), Error>

Accept a host-owned choice menu selection.

Source

pub fn dismiss_choice_menu(&mut self, request_id: u64) -> Result<(), Error>

Dismiss a host-owned choice menu without a selection.

Source

pub fn dismiss_context_menu(&mut self, menu_id: u64) -> Result<(), Error>

Dismiss the context menu with the given id.

Source

pub fn request_shutdown(&mut self, request_id: u64) -> Result<(), Error>

Request a graceful shutdown from the backend.

Source

pub fn confirm_shutdown( &mut self, request_id: u64, proceed: bool, ) -> Result<(), Error>

Respond to a shutdown confirmation request.

Source

pub fn force_shutdown(&mut self) -> Result<(), Error>

Force an immediate shutdown without confirmations.

Source

pub fn shutdown(&mut self)

Tear down the IPC client and free native resources.

Trait Implementations§

Source§

impl Debug for IpcClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for IpcClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Send for IpcClient

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,