pub struct IpcClient { /* private fields */ }Expand description
Client wrapper for the CBF IPC bridge.
Implementations§
Source§impl IpcClient
impl IpcClient
Sourcepub fn prepare_channel() -> Result<(i32, String), Error>
pub fn prepare_channel() -> Result<(i32, String), Error>
Prepare the Mojo channel before spawning the Chromium process.
Returns (remote_fd, switch_arg) where:
remote_fdis the file descriptor of the remote channel endpoint that must be inherited by the child process (Unix only; -1 on other platforms).switch_argis the command-line switch that Chromium needs to recover the endpoint (e.g.--cbf-ipc-handle=...).
Sourcepub fn pass_child_pid(pid: u32)
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.
Sourcepub unsafe fn connect_inherited(
inner: *mut CbfBridgeClientHandle,
) -> Result<Self, Error>
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.
Sourcepub fn authenticate(&self, token: &str) -> Result<(), Error>
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.
Sourcepub fn wait_for_event(
&self,
timeout: Option<Duration>,
) -> Result<EventWaitResult, Error>
pub fn wait_for_event( &self, timeout: Option<Duration>, ) -> Result<EventWaitResult, Error>
Wait until an event is available or the bridge closes.
Sourcepub fn poll_event(&mut self) -> Option<Result<IpcEvent, Error>>
pub fn poll_event(&mut self) -> Option<Result<IpcEvent, Error>>
Poll the next IPC event, if any, from the backend.
Sourcepub fn list_profiles(&mut self) -> Result<Vec<ChromeProfileInfo>, Error>
pub fn list_profiles(&mut self) -> Result<Vec<ChromeProfileInfo>, Error>
Retrieve the list of browser profiles from the backend.
Sourcepub fn list_extensions(
&mut self,
profile_id: &str,
) -> Result<Vec<ChromeExtensionInfo>, Error>
pub fn list_extensions( &mut self, profile_id: &str, ) -> Result<Vec<ChromeExtensionInfo>, Error>
Retrieve the list of extensions from the backend.
pub fn activate_extension_action( &mut self, browsing_context_id: TabId, extension_id: &str, ) -> Result<(), Error>
Sourcepub fn create_tab(
&mut self,
request_id: u64,
initial_url: &str,
profile_id: &str,
) -> Result<(), Error>
pub fn create_tab( &mut self, request_id: u64, initial_url: &str, profile_id: &str, ) -> Result<(), Error>
Create a tab via the IPC bridge.
Sourcepub fn request_close_tab(
&mut self,
browsing_context_id: TabId,
) -> Result<(), Error>
pub fn request_close_tab( &mut self, browsing_context_id: TabId, ) -> Result<(), Error>
Request closing the specified tab.
Sourcepub fn set_tab_size(
&mut self,
browsing_context_id: TabId,
width: u32,
height: u32,
) -> Result<(), Error>
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.
Sourcepub fn set_tab_focus(
&mut self,
browsing_context_id: TabId,
focused: bool,
) -> Result<(), Error>
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.
Sourcepub fn confirm_beforeunload(
&mut self,
browsing_context_id: TabId,
request_id: u64,
proceed: bool,
) -> Result<(), Error>
pub fn confirm_beforeunload( &mut self, browsing_context_id: TabId, request_id: u64, proceed: bool, ) -> Result<(), Error>
Respond to a beforeunload confirmation request.
Sourcepub fn respond_javascript_dialog(
&mut self,
browsing_context_id: TabId,
request_id: u64,
accept: bool,
prompt_text: Option<&str>,
) -> Result<(), Error>
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.
Sourcepub fn respond_extension_popup_javascript_dialog(
&mut self,
popup_id: PopupId,
request_id: u64,
accept: bool,
prompt_text: Option<&str>,
) -> Result<(), Error>
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.
Navigate the page to the provided URL.
Sourcepub fn go_back(&mut self, browsing_context_id: TabId) -> Result<(), Error>
pub fn go_back(&mut self, browsing_context_id: TabId) -> Result<(), Error>
Navigate back in history for the page.
Sourcepub fn go_forward(&mut self, browsing_context_id: TabId) -> Result<(), Error>
pub fn go_forward(&mut self, browsing_context_id: TabId) -> Result<(), Error>
Navigate forward in history for the page.
Sourcepub fn reload(
&mut self,
browsing_context_id: TabId,
ignore_cache: bool,
) -> Result<(), Error>
pub fn reload( &mut self, browsing_context_id: TabId, ignore_cache: bool, ) -> Result<(), Error>
Reload the page, optionally ignoring caches.
Sourcepub fn print_preview(&mut self, browsing_context_id: TabId) -> Result<(), Error>
pub fn print_preview(&mut self, browsing_context_id: TabId) -> Result<(), Error>
Open print preview for the page.
Sourcepub fn open_dev_tools(
&mut self,
browsing_context_id: TabId,
) -> Result<(), Error>
pub fn open_dev_tools( &mut self, browsing_context_id: TabId, ) -> Result<(), Error>
Open DevTools for the specified page.
Sourcepub fn inspect_element(
&mut self,
browsing_context_id: TabId,
x: i32,
y: i32,
) -> Result<(), Error>
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.
Sourcepub fn get_tab_dom_html(
&mut self,
browsing_context_id: TabId,
request_id: u64,
) -> Result<(), Error>
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.
Sourcepub fn open_default_prompt_ui(
&mut self,
profile_id: &str,
request_id: u64,
) -> Result<(), Error>
pub fn open_default_prompt_ui( &mut self, profile_id: &str, request_id: u64, ) -> Result<(), Error>
Open Chromium default PromptUi for pending request.
Sourcepub fn respond_prompt_ui(
&mut self,
profile_id: &str,
request_id: u64,
response: &PromptUiResponse,
) -> Result<(), Error>
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.
Sourcepub fn respond_prompt_ui_for_tab(
&mut self,
browsing_context_id: TabId,
request_id: u64,
response: &PromptUiResponse,
) -> Result<(), Error>
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.
Sourcepub fn close_prompt_ui(
&mut self,
profile_id: &str,
prompt_ui_id: PromptUiId,
) -> Result<(), Error>
pub fn close_prompt_ui( &mut self, profile_id: &str, prompt_ui_id: PromptUiId, ) -> Result<(), Error>
Close a backend-managed PromptUi surface.
Sourcepub fn pause_download(
&mut self,
download_id: ChromeDownloadId,
) -> Result<(), Error>
pub fn pause_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>
Pause an in-progress download.
Sourcepub fn resume_download(
&mut self,
download_id: ChromeDownloadId,
) -> Result<(), Error>
pub fn resume_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>
Resume a paused download.
Sourcepub fn cancel_download(
&mut self,
download_id: ChromeDownloadId,
) -> Result<(), Error>
pub fn cancel_download( &mut self, download_id: ChromeDownloadId, ) -> Result<(), Error>
Cancel an active download.
Sourcepub fn respond_tab_open(
&mut self,
request_id: u64,
response: &ChromeBrowsingContextOpenResponse,
) -> Result<(), Error>
pub fn respond_tab_open( &mut self, request_id: u64, response: &ChromeBrowsingContextOpenResponse, ) -> Result<(), Error>
Respond to host-mediated tab-open request.
Sourcepub fn respond_window_open(
&mut self,
request_id: u64,
response: &WindowOpenResponse,
) -> Result<(), Error>
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.
Sourcepub fn send_key_event_raw(
&mut self,
browsing_context_id: TabId,
event: &ChromeKeyEvent,
commands: &[String],
) -> Result<(), Error>
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.
Sourcepub fn send_extension_popup_key_event_raw(
&mut self,
popup_id: PopupId,
event: &ChromeKeyEvent,
commands: &[String],
) -> Result<(), Error>
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.
Sourcepub fn send_mouse_event(
&mut self,
browsing_context_id: TabId,
event: &ChromeMouseEvent,
) -> Result<(), Error>
pub fn send_mouse_event( &mut self, browsing_context_id: TabId, event: &ChromeMouseEvent, ) -> Result<(), Error>
Send a mouse event to the page.
Sourcepub fn send_extension_popup_mouse_event(
&mut self,
popup_id: PopupId,
event: &ChromeMouseEvent,
) -> Result<(), Error>
pub fn send_extension_popup_mouse_event( &mut self, popup_id: PopupId, event: &ChromeMouseEvent, ) -> Result<(), Error>
Send a mouse event to an extension popup.
Sourcepub fn send_mouse_wheel_event_raw(
&mut self,
browsing_context_id: TabId,
event: &ChromeMouseWheelEvent,
) -> Result<(), Error>
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.
Sourcepub fn send_extension_popup_mouse_wheel_event_raw(
&mut self,
popup_id: PopupId,
event: &ChromeMouseWheelEvent,
) -> Result<(), Error>
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.
Sourcepub fn send_drag_update(
&mut self,
update: &ChromeDragUpdate,
) -> Result<(), Error>
pub fn send_drag_update( &mut self, update: &ChromeDragUpdate, ) -> Result<(), Error>
Send a drag update event for host-owned drag session.
Sourcepub fn send_drag_drop(&mut self, drop: &ChromeDragDrop) -> Result<(), Error>
pub fn send_drag_drop(&mut self, drop: &ChromeDragDrop) -> Result<(), Error>
Send a drag drop event for host-owned drag session.
Sourcepub fn send_drag_cancel(
&mut self,
session_id: u64,
browsing_context_id: TabId,
) -> Result<(), Error>
pub fn send_drag_cancel( &mut self, session_id: u64, browsing_context_id: TabId, ) -> Result<(), Error>
Cancel a host-owned drag session.
Sourcepub fn set_composition(
&mut self,
composition: &ChromeImeComposition,
) -> Result<(), Error>
pub fn set_composition( &mut self, composition: &ChromeImeComposition, ) -> Result<(), Error>
Update the IME composition state.
Sourcepub fn set_extension_popup_composition(
&mut self,
composition: &ChromeTransientImeComposition,
) -> Result<(), Error>
pub fn set_extension_popup_composition( &mut self, composition: &ChromeTransientImeComposition, ) -> Result<(), Error>
Update the IME composition state for an extension popup.
Sourcepub fn commit_text(&mut self, commit: &ChromeImeCommitText) -> Result<(), Error>
pub fn commit_text(&mut self, commit: &ChromeImeCommitText) -> Result<(), Error>
Commit IME text input to the page.
Sourcepub fn commit_extension_popup_text(
&mut self,
commit: &ChromeTransientImeCommitText,
) -> Result<(), Error>
pub fn commit_extension_popup_text( &mut self, commit: &ChromeTransientImeCommitText, ) -> Result<(), Error>
Commit IME text input to an extension popup.
Sourcepub fn finish_composing_text(
&mut self,
browsing_context_id: TabId,
behavior: ChromeConfirmCompositionBehavior,
) -> Result<(), Error>
pub fn finish_composing_text( &mut self, browsing_context_id: TabId, behavior: ChromeConfirmCompositionBehavior, ) -> Result<(), Error>
Finish composing IME text with the specified behavior.
Sourcepub fn finish_extension_popup_composing_text(
&mut self,
popup_id: PopupId,
behavior: ChromeConfirmCompositionBehavior,
) -> Result<(), Error>
pub fn finish_extension_popup_composing_text( &mut self, popup_id: PopupId, behavior: ChromeConfirmCompositionBehavior, ) -> Result<(), Error>
Finish composing IME text inside an extension popup.
pub fn set_extension_popup_focus( &mut self, popup_id: PopupId, focused: bool, ) -> Result<(), Error>
pub fn set_extension_popup_size( &mut self, popup_id: PopupId, width: u32, height: u32, ) -> Result<(), Error>
pub fn close_extension_popup(&mut self, popup_id: PopupId) -> Result<(), Error>
Sourcepub fn execute_edit_action(
&mut self,
browsing_context_id: TabId,
action: EditAction,
) -> Result<(), Error>
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.
Sourcepub fn execute_extension_popup_edit_action(
&mut self,
popup_id: PopupId,
action: EditAction,
) -> Result<(), Error>
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.
Execute a context menu command for the given menu.
Accept a host-owned choice menu selection.
Dismiss a host-owned choice menu without a selection.
Dismiss the context menu with the given id.
Sourcepub fn request_shutdown(&mut self, request_id: u64) -> Result<(), Error>
pub fn request_shutdown(&mut self, request_id: u64) -> Result<(), Error>
Request a graceful shutdown from the backend.
Sourcepub fn confirm_shutdown(
&mut self,
request_id: u64,
proceed: bool,
) -> Result<(), Error>
pub fn confirm_shutdown( &mut self, request_id: u64, proceed: bool, ) -> Result<(), Error>
Respond to a shutdown confirmation request.
Sourcepub fn force_shutdown(&mut self) -> Result<(), Error>
pub fn force_shutdown(&mut self) -> Result<(), Error>
Force an immediate shutdown without confirmations.