CefriumNavigator

External navigation control for a CefriumView, created with rememberCefriumNavigator and passed to the composable. It operates on the CefriumBrowser owned by the bound CefriumViewState.

Covers load / loadHtml / postUrl / back / forward / reload / stopLoading / evaluateJavaScript (fire-and-forget), plus cookies, HTTP cache, print-to-PDF, dynamic web settings, a request interceptor and web permissions. Only a result-returning JS bridge is deferred to a later release.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard

Whether the browser can navigate back.

Link copied to clipboard

Whether the browser can navigate forward.

Link copied to clipboard

Whether page audio is muted via setAudioMuted.

Functions

Link copied to clipboard
fun captureBitmap(onBitmap: (Bitmap?) -> Unit)

Captures the current page to a Bitmap, delivered on the main thread (onBitmap receives null on failure). Off-screen mode returns the next painted frame; Surface mode copies the visible surface.

Link copied to clipboard

Clears the browser's HTTP cache.

Link copied to clipboard

Convenience: disable proxying (direct connection).

Link copied to clipboard
fun contextMenuCommand(commandId: Int)

Invokes a context-menu command id (from CefriumViewState.contextMenu's serialized items) after the user picks one.

Link copied to clipboard
fun deleteCookies(url: String, name: String? = null)

Deletes cookies for url; name null = all cookies for the URL.

Link copied to clipboard

Executes script in the main frame (fire-and-forget). The return value is not delivered back; a result-returning bridge is planned for a later release.

Link copied to clipboard
fun find(text: String, forward: Boolean = true, matchCase: Boolean = false, findNext: Boolean = false)

Starts/continues a find-in-page for text. Results arrive on CefriumViewState.findActiveMatch / CefriumViewState.findMatchCount. Set findNext true to step to the next match of the same query.

Link copied to clipboard

Persists the cookie store to disk.

Link copied to clipboard
fun getCookies(url: String, callback: CefriumBrowser.CookieCallback)

Reads cookies visible to url; callback fires on the UI thread.

Link copied to clipboard
fun loadDataWithBaseUrl(baseUrl: String, data: String, mimeType: String = "text/html", encoding: String = "utf-8", historyUrl: String = baseUrl)

Loads a data string with an explicit base URL (full control over mime type, encoding and history URL). See loadHtmlWithBaseUrl for the common case.

Link copied to clipboard
fun loadHtml(html: String)

Loads an HTML string directly.

Link copied to clipboard
fun loadHtmlWithBaseUrl(html: String, baseUrl: String)

Loads an HTML string with an explicit base-URL origin, mirroring Android WebView's loadDataWithBaseURL. Unlike WebView, Cefrium serves the content as a GENUINE network response at baseUrl (not a data: document), so the document has a real network origin and inline embedded players that require a network-served parent -- e.g. the YouTube IFrame player -- PLAY (a data: document is rejected with Error 152, which is why WebView's loadDataWithBaseURL fails here).

Link copied to clipboard
fun loadUrl(url: String)

Navigates to url. No-op before the browser is ready.

Link copied to clipboard

Navigates back if canGoBack.

Link copied to clipboard

Navigates forward if canGoForward.

Link copied to clipboard

"Host is backgrounding": hide the page, suspend media and mute audio so inline audio/video actually stops. Resumable via onHostResume. Usually automatic via CefriumView's backgroundMediaPolicy; call manually only for a custom lifecycle setup.

Link copied to clipboard

"Host is foregrounding": unmute, show the page and resume suspended media.

Link copied to clipboard
fun postUrl(url: String, postData: ByteArray)

Loads url with an HTTP POST body.

Link copied to clipboard
fun printToPdf(filePath: String, callback: CefriumBrowser.PdfCallback)

Renders the current page to a PDF at filePath (async).

Link copied to clipboard
fun reload()

Reloads the current page.

Link copied to clipboard

Resumes media suspended by suspendMedia / onHostPause.

Link copied to clipboard

Serializes this tab's back/forward navigation stack for session restore (see CefriumBrowser.serializeNavigationState); null if nothing to save. Restore by constructing a CefriumViewState with the bytes as navigationState.

Link copied to clipboard

Mutes/unmutes all page audio (media keeps playing, just silenced).

Link copied to clipboard
fun setContentSetting(requestingUrl: String, permission: Int, value: Int)

Pre-grants (or blocks) a per-origin web permission without a prompt — e.g. allow Web Notifications for your own origin so service-worker showNotification() works without asking. permission is one of CefriumBrowser.PERMISSION_*; value one of CefriumBrowser.SETTING_*.

Link copied to clipboard
fun setCookie(url: String, name: String, value: String)

Sets a session cookie for url (domain/path inferred from the URL).

fun setCookie(url: String, name: String, value: String, secure: Boolean, httpOnly: Boolean = false, sameSite: Int = com.cefrium.CefriumBrowser.SAME_SITE_UNSPECIFIED)

Sets a session cookie for url with explicit attributes. For a cookie a cross-site/embedded iframe must send (e.g. a consent cookie), pass secure = true and sameSite = com.cefrium.CefriumBrowser.SAME_SITE_NONE (Chromium rejects SameSite=None without Secure).

Link copied to clipboard
fun setDarkMode(dark: Boolean)

Forces dark mode for page rendering (prefers-color-scheme).

Link copied to clipboard
fun setDeviceChooserHandler(handler: CefriumBrowser.DeviceChooserHandler?)

Sets the device chooser handler for the frontier device APIs (Web Bluetooth, WebUSB, Web Serial). When a page calls requestDevice() / requestPort() the handler presents a picker and resolves it via the com.cefrium.CefriumBrowser.DeviceChooserSession. Null = cancel all device requests (the page promise rejects).

Link copied to clipboard
fun setHttpAuthHandler(handler: CefriumBrowser.HttpAuthHandler?)

Sets the HTTP auth handler (supply credentials/cancel; null = cancel all).

Link copied to clipboard

Enables/disables JavaScript at runtime.

Link copied to clipboard

Enables the lock-screen / shade media-session controls for this browser.

Link copied to clipboard
fun setPageVisible(visible: Boolean)

Sets page visibility (compositor + document.hidden); does not stop audio.

Link copied to clipboard
fun setPermissionHandler(handler: CefriumBrowser.PermissionHandler?)

Sets the web permission handler (geolocation, camera, mic; null = deny all).

Link copied to clipboard
fun setProxy(server: String): Boolean

Convenience: route through a fixed proxy "host:port".

fun setProxy(mode: String, server: String?): Boolean

Configures the proxy for this browser's request context. mode is one of CefriumBrowser.PROXY_*; server is "host:port" for fixed servers, the PAC URL for PROXY_PAC, ignored otherwise. Returns false if not applied.

Link copied to clipboard

Enable pull-to-refresh (an overscroll-down at the page top reloads). Call before the page loads; the handler binds once when the WebContents connects.

Link copied to clipboard
fun setRequestInterceptor(interceptor: CefriumBrowser.RequestInterceptor?)

Sets a programmatic request interceptor (block decisions; null clears).

Link copied to clipboard
fun setSslErrorHandler(handler: CefriumBrowser.SslErrorHandler?)

Sets the SSL/certificate error handler (proceed/cancel; null = cancel all).

Link copied to clipboard

Overrides the User-Agent at runtime.

Link copied to clipboard
fun setZoomLevel(zoomLevel: Double)

Sets the zoom level (0 = 100%; factor = 1.2^level).

Link copied to clipboard

Hard-stops all media (not resumable) and mutes; for "release audio on background".

Link copied to clipboard
fun stopFinding(clearSelection: Boolean = true)

Ends the active find session (clearSelection clears the highlight).

Link copied to clipboard

Stops the current load.

Link copied to clipboard

Stops the page's media session and dismisses its media notification (also stops media in cross-origin iframes, e.g. a YouTube embed). Use on navigate-away when stopAllMedia (pause + mute) isn't enough because you want the tray notification gone.

Link copied to clipboard

Suspends active media (pause; position preserved). See resumeMedia.