Interface CefriumChromeClient
Called on the UI thread. What a page asks of the app around it, like
android.webkit.WebChromeClient. Set it with
CefriumBrowser.setChromeClient(CefriumChromeClient); every method has a default, so
implement only the ones you need. The browser is the first parameter, so one
client can serve several browsers.-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanonBeforeUnloadDialog(CefriumBrowser browser, String message, boolean isReload, CefriumBrowser.JsDialogCallback callback) A page asks whether to leave it (beforeunload, for example a form with unsaved changes).default voidonCloseWindow(CefriumBrowser browser, CefriumBrowser popup) A window fromonCreateWindow(CefriumBrowser, CefriumBrowser, String, boolean)calledwindow.close(): remove it from the UI.default voidonConsoleMessage(CefriumBrowser browser, CefriumConsoleMessage message) The page wrote to its console.default booleanonContextMenu(CefriumBrowser browser, CefriumContextMenu menu) The page asks for a context menu (a long press or a right click on a link or an image).default booleanonCreateWindow(CefriumBrowser browser, CefriumBrowser popup, String url, boolean userGesture) The page opened a window (window.open,target=_blank).default voidonFaviconUrlsChanged(CefriumBrowser browser, List<String> urls) The page's icon URLs changed, best first (may be empty).default voidonFindResult(CefriumBrowser browser, int activeMatch, int matches) A result ofCefriumBrowser.find(String, boolean, boolean, boolean): the active match (1-based, 0 when none) and the number of matches.default voidonFullscreenChanged(CefriumBrowser browser, boolean fullscreen) The page entered or left fullscreen (element.requestFullscreen()).default booleanonJsDialog(CefriumBrowser browser, CefriumJsDialogType type, String message, String defaultText, CefriumBrowser.JsDialogCallback callback) A page openedalert(),confirm()orprompt().default voidonMediaAccessChanged(CefriumBrowser browser, boolean camera, boolean microphone) The page started or stopped using the camera or the microphone.default voidonPermissionRequest(CefriumBrowser browser, CefriumPermissionRequest request) A page asks for permissions.default voidonPermissionRequestCanceled(CefriumBrowser browser, CefriumPermissionRequest request) A request that was not answered yet is no longer wanted (the page navigated away): close any prompt shown for it.default booleanonShowFileChooser(CefriumBrowser browser, CefriumFileChooserParams params, CefriumFileChooserCallback callback) A file input (<input type=file>) asks for files.default voidonStatusMessage(CefriumBrowser browser, String text) The text to show for the link under the pointer; empty when it leaves the link.default voidonTitleChanged(CefriumBrowser browser, String title) The page's title changed.default voidonUnhandledKeyEvent(CefriumBrowser browser, android.view.KeyEvent event) The page did not handle a key (nopreventDefault), so the app may: for example a shortcut.default booleanshouldOverrideKeyEvent(CefriumBrowser browser, android.view.KeyEvent event) A key is about to reach the page.
-
Method Details
-
onTitleChanged
The page's title changed. -
onFaviconUrlsChanged
The page's icon URLs changed, best first (may be empty). Fetch one withCefriumBrowser.downloadImage(String, int, CefriumBrowser.ImageCallback). -
onFullscreenChanged
The page entered or left fullscreen (element.requestFullscreen()). -
onConsoleMessage
The page wrote to its console. -
onStatusMessage
The text to show for the link under the pointer; empty when it leaves the link. -
onMediaAccessChanged
The page started or stopped using the camera or the microphone. -
onFindResult
A result ofCefriumBrowser.find(String, boolean, boolean, boolean): the active match (1-based, 0 when none) and the number of matches. -
onJsDialog
default boolean onJsDialog(CefriumBrowser browser, CefriumJsDialogType type, String message, String defaultText, CefriumBrowser.JsDialogCallback callback) A page openedalert(),confirm()orprompt(). Return true to show your own dialog and answer throughcallback(now or later, from any thread; the first answer counts):successis OK,userInputthe prompt's text. Return false for the engine's own dialog. The page waits until there is an answer.- Parameters:
defaultText- a prompt's initial text, empty otherwise
-
onBeforeUnloadDialog
default boolean onBeforeUnloadDialog(CefriumBrowser browser, String message, boolean isReload, CefriumBrowser.JsDialogCallback callback) A page asks whether to leave it (beforeunload, for example a form with unsaved changes). Return true to ask the user and answer throughcallback:successleaves the page. Return false to leave without asking.- Parameters:
isReload- whether the page is being reloaded rather than left
-
onShowFileChooser
default boolean onShowFileChooser(CefriumBrowser browser, CefriumFileChooserParams params, CefriumFileChooserCallback callback) A file input (<input type=file>) asks for files. Return true to show your own chooser and answer throughcallback;params.createIntent()gives the system picker's intent. Return false for the SDK's chooser: the engine's on a surface browser (camera, photo picker, filtered byaccept), the system picker on an off-screen browser's dialog activity. -
onContextMenu
The page asks for a context menu (a long press or a right click on a link or an image). Return true to show your own and answer throughmenu. Return false to leave it to a context-menu listener set the old way, or to close it. -
shouldOverrideKeyEvent
A key is about to reach the page. Return true to take it yourself: the page does not get it. LikeWebViewClient.shouldOverrideKeyEvent, with the Android key code and meta state. Keys an input method composes (no key code of their own) are not reported. -
onUnhandledKeyEvent
The page did not handle a key (nopreventDefault), so the app may: for example a shortcut. LikeWebViewClient.onUnhandledKeyEvent. -
onCreateWindow
default boolean onCreateWindow(CefriumBrowser browser, CefriumBrowser popup, String url, boolean userGesture) The page opened a window (window.open,target=_blank).popupis a new browser in this browser's mode and profile that loadsurlas that window: the page keepswindow.opener, so a sign-in popup can post its result back. Show it (its surface container, or its frames off-screen) and return true; it is yours to close. Return false and it is closed: then aPopupHandlerset the old way decides, and without one the URL loads in this browser. LikeWebChromeClient.onCreateWindow. -
onCloseWindow
A window fromonCreateWindow(CefriumBrowser, CefriumBrowser, String, boolean)calledwindow.close(): remove it from the UI. It closes itself. -
onPermissionRequest
A page asks for permissions. Answer withrequest.grant()orrequest.deny(), now or later (after asking the user). The default denies.Some requests never get here because the platform refuses them first: geolocation when the app does not hold the location permission or location is off, clipboard reads from a page that is not focused (an off-screen browser needs
CefriumBrowser.setFocus(boolean)), and any permission of a page with an opaque origin (CefriumBrowser.loadHtml(String)). -
onPermissionRequestCanceled
A request that was not answered yet is no longer wanted (the page navigated away): close any prompt shown for it. Answering it now does nothing.
-