cbf_chrome/ffi/event.rs
1use cursor_icon::CursorIcon;
2
3use cbf::data::dialog::DialogType;
4
5use crate::data::{
6 choice_menu::ChromeChoiceMenu,
7 context_menu::ChromeContextMenu,
8 download::{ChromeDownloadCompletion, ChromeDownloadProgress, ChromeDownloadSnapshot},
9 drag::ChromeDragStartRequest,
10 extension::ChromeExtensionInfo,
11 ids::{PopupId, TabId},
12 ime::ChromeImeBoundsUpdate,
13 lifecycle::ChromeBeforeUnloadReason,
14 prompt_ui::{PromptUiCloseReason, PromptUiId, PromptUiKind, PromptUiResolution},
15 surface::SurfaceHandle,
16 tab_open::{TabOpenHint, TabOpenResult},
17};
18
19/// Low-level IPC events emitted by the Chromium bridge.
20#[derive(Debug, Clone, PartialEq)]
21pub enum IpcEvent {
22 /// The rendering surface handle for a page was updated.
23 ///
24 /// **Note**: This event does not map to `BrowserEvent` because surface handles
25 /// are a Chrome-specific rendering implementation detail. Applications needing
26 /// this information should subscribe to the raw `ChromeEvent` stream.
27 SurfaceHandleUpdated {
28 profile_id: String,
29 browsing_context_id: TabId,
30 handle: SurfaceHandle,
31 },
32 /// An extension action popup lifecycle started.
33 ExtensionPopupOpened {
34 profile_id: String,
35 browsing_context_id: TabId,
36 popup_id: u64,
37 extension_id: String,
38 title: String,
39 },
40 /// The rendering surface handle for an extension popup was updated.
41 ExtensionPopupSurfaceHandleUpdated {
42 profile_id: String,
43 browsing_context_id: TabId,
44 popup_id: u64,
45 handle: SurfaceHandle,
46 },
47 /// The effective popup size changed after Chromium-side clamping.
48 ExtensionPopupPreferredSizeChanged {
49 profile_id: String,
50 browsing_context_id: TabId,
51 popup_id: u64,
52 width: u32,
53 height: u32,
54 },
55 /// A context menu was requested for an extension popup.
56 ExtensionPopupContextMenuRequested {
57 profile_id: String,
58 browsing_context_id: TabId,
59 popup_id: PopupId,
60 menu: ChromeContextMenu,
61 },
62 /// A host-owned choice menu was requested for an extension popup.
63 ExtensionPopupChoiceMenuRequested {
64 profile_id: String,
65 browsing_context_id: TabId,
66 popup_id: PopupId,
67 request_id: u64,
68 menu: ChromeChoiceMenu,
69 },
70 /// The cursor appearance changed for an extension popup.
71 ExtensionPopupCursorChanged {
72 profile_id: String,
73 browsing_context_id: TabId,
74 popup_id: PopupId,
75 cursor_type: CursorIcon,
76 },
77 /// The title changed for an extension popup.
78 ExtensionPopupTitleUpdated {
79 profile_id: String,
80 browsing_context_id: TabId,
81 popup_id: PopupId,
82 title: String,
83 },
84 /// A JavaScript dialog was requested for an extension popup.
85 ExtensionPopupJavaScriptDialogRequested {
86 profile_id: String,
87 browsing_context_id: TabId,
88 popup_id: PopupId,
89 request_id: u64,
90 r#type: DialogType,
91 message: String,
92 default_prompt_text: Option<String>,
93 reason: ChromeBeforeUnloadReason,
94 },
95 /// The extension popup requested to close.
96 ExtensionPopupCloseRequested {
97 profile_id: String,
98 browsing_context_id: TabId,
99 popup_id: PopupId,
100 },
101 /// The extension popup renderer exited or crashed.
102 ExtensionPopupRenderProcessGone {
103 profile_id: String,
104 browsing_context_id: TabId,
105 popup_id: PopupId,
106 crashed: bool,
107 },
108 /// An extension action popup closed.
109 ExtensionPopupClosed {
110 profile_id: String,
111 browsing_context_id: TabId,
112 popup_id: u64,
113 },
114 /// A new tab was created by the backend.
115 ///
116 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::Created`.
117 TabCreated {
118 profile_id: String,
119 browsing_context_id: TabId,
120 request_id: u64,
121 },
122 /// DevTools was opened for a page.
123 ///
124 /// **Note**: This event does not map to `BrowserEvent` because DevTools is
125 /// currently exposed via the Chrome-specific raw event stream only.
126 DevToolsOpened {
127 profile_id: String,
128 browsing_context_id: TabId,
129 inspected_browsing_context_id: TabId,
130 },
131 /// IME bounds information changed.
132 ///
133 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::ImeBoundsUpdated`.
134 ImeBoundsUpdated {
135 profile_id: String,
136 browsing_context_id: TabId,
137 update: ChromeImeBoundsUpdate,
138 },
139 /// IME bounds information changed for an extension popup.
140 ///
141 /// Maps to `BrowserEvent::TransientBrowsingContext` with
142 /// `TransientBrowsingContextEvent::ImeBoundsUpdated`.
143 ExtensionPopupImeBoundsUpdated {
144 profile_id: String,
145 browsing_context_id: TabId,
146 popup_id: PopupId,
147 update: ChromeImeBoundsUpdate,
148 },
149 /// The backend requested a context menu.
150 ///
151 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::ContextMenuRequested`.
152 ContextMenuRequested {
153 profile_id: String,
154 browsing_context_id: TabId,
155 menu: ChromeContextMenu,
156 },
157 /// The backend requested a host-owned choice menu.
158 ChoiceMenuRequested {
159 profile_id: String,
160 browsing_context_id: TabId,
161 request_id: u64,
162 menu: ChromeChoiceMenu,
163 },
164 /// Host-mediated open request for tab.
165 ///
166 /// Maps to `BrowserEvent::BrowsingContextOpenRequested`.
167 TabOpenRequested {
168 profile_id: String,
169 request_id: u64,
170 source_tab_id: Option<TabId>,
171 target_url: String,
172 open_hint: TabOpenHint,
173 user_gesture: bool,
174 },
175 /// Result for host-mediated open request.
176 ///
177 /// Maps to `BrowserEvent::BrowsingContextOpenResolved`.
178 TabOpenResolved {
179 profile_id: String,
180 request_id: u64,
181 result: TabOpenResult,
182 },
183 /// Navigation state changed for a page.
184 ///
185 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::NavigationStateChanged`.
186 NavigationStateChanged {
187 profile_id: String,
188 browsing_context_id: TabId,
189 url: String,
190 can_go_back: bool,
191 can_go_forward: bool,
192 is_loading: bool,
193 },
194 /// Cursor appearance changed for a page.
195 ///
196 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::CursorChanged`.
197 CursorChanged {
198 profile_id: String,
199 browsing_context_id: TabId,
200 cursor_type: CursorIcon,
201 },
202 /// The page title changed for a page.
203 ///
204 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::TitleUpdated`.
205 TitleUpdated {
206 profile_id: String,
207 browsing_context_id: TabId,
208 title: String,
209 },
210 /// The page favicon URL changed for a page.
211 ///
212 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::FaviconUrlUpdated`.
213 FaviconUrlUpdated {
214 profile_id: String,
215 browsing_context_id: TabId,
216 url: String,
217 },
218 /// A beforeunload dialog was requested.
219 ///
220 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::JavaScriptDialogRequested`
221 /// with `DialogType::BeforeUnload`.
222 BeforeUnloadDialogRequested {
223 profile_id: String,
224 browsing_context_id: TabId,
225 request_id: u64,
226 reason: ChromeBeforeUnloadReason,
227 },
228 /// A JavaScript dialog was requested for a tab.
229 JavaScriptDialogRequested {
230 profile_id: String,
231 browsing_context_id: TabId,
232 request_id: u64,
233 r#type: DialogType,
234 message: String,
235 default_prompt_text: Option<String>,
236 reason: ChromeBeforeUnloadReason,
237 },
238 /// A tab closed event was observed.
239 ///
240 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::Closed`.
241 TabClosed {
242 profile_id: String,
243 browsing_context_id: TabId,
244 },
245 /// A resize acknowledgement was received for a page.
246 ///
247 /// **Note**: This event does not map to `BrowserEvent` because it is an internal
248 /// acknowledgement with no semantic value for browser-generic consumers.
249 TabResizeAcknowledged {
250 profile_id: String,
251 browsing_context_id: TabId,
252 },
253 /// The DOM HTML was read for a page.
254 ///
255 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::DomHtmlRead`.
256 TabDomHtmlRead {
257 profile_id: String,
258 browsing_context_id: TabId,
259 request_id: u64,
260 html: String,
261 },
262 /// Host-owned drag start request from renderer.
263 ///
264 /// Maps to `BrowserEvent::BrowsingContext` with `BrowsingContextEvent::DragStartRequested`.
265 DragStartRequested {
266 profile_id: String,
267 browsing_context_id: TabId,
268 request: ChromeDragStartRequest,
269 },
270 /// Shutdown is blocked by dirty pages.
271 ///
272 /// Maps to `BrowserEvent::ShutdownBlocked`.
273 ShutdownBlocked {
274 request_id: u64,
275 dirty_browsing_context_ids: Vec<TabId>,
276 },
277 /// Shutdown has started.
278 ///
279 /// Maps to `BrowserEvent::ShutdownProceeding`.
280 ShutdownProceeding { request_id: u64 },
281 /// Shutdown was cancelled.
282 ///
283 /// Maps to `BrowserEvent::ShutdownCancelled`.
284 ShutdownCancelled { request_id: u64 },
285 /// Installed extensions were listed for a profile.
286 ///
287 /// Maps to `BrowserEvent::ExtensionsListed`.
288 ExtensionsListed {
289 profile_id: String,
290 extensions: Vec<ChromeExtensionInfo>,
291 },
292 /// Prompt UI open was requested and host must choose flow.
293 PromptUiOpenRequested {
294 profile_id: String,
295 source_tab_id: Option<TabId>,
296 request_id: u64,
297 kind: PromptUiKind,
298 },
299 /// Prompt UI request was resolved.
300 PromptUiResolved {
301 profile_id: String,
302 source_tab_id: Option<TabId>,
303 request_id: u64,
304 resolution: PromptUiResolution,
305 },
306 /// Non-fatal extension runtime warning.
307 ///
308 /// Maps to `BrowsingContextEvent::ExtensionRuntimeWarning`.
309 ExtensionRuntimeWarning {
310 profile_id: String,
311 browsing_context_id: TabId,
312 detail: String,
313 },
314 /// Backend-managed prompt UI surface was opened.
315 PromptUiOpened {
316 profile_id: String,
317 source_tab_id: Option<TabId>,
318 prompt_ui_id: PromptUiId,
319 kind: PromptUiKind,
320 title: Option<String>,
321 modal: bool,
322 },
323 /// Backend-managed prompt UI surface was closed.
324 PromptUiClosed {
325 profile_id: String,
326 source_tab_id: Option<TabId>,
327 prompt_ui_id: PromptUiId,
328 kind: PromptUiKind,
329 reason: PromptUiCloseReason,
330 },
331 /// Download lifecycle became visible to the host.
332 DownloadCreated {
333 profile_id: String,
334 download: ChromeDownloadSnapshot,
335 },
336 /// Download state changed.
337 DownloadUpdated {
338 profile_id: String,
339 download: ChromeDownloadProgress,
340 },
341 /// Download reached a terminal state.
342 DownloadCompleted {
343 profile_id: String,
344 download: ChromeDownloadCompletion,
345 },
346}