Package org.cef
Class CefClient
- java.lang.Object
-
- org.cef.handler.CefClientHandler
-
- org.cef.CefClient
-
- All Implemented Interfaces:
CefNative,CefContextMenuHandler,CefDialogHandler,CefDisplayHandler,CefDownloadHandler,CefDragHandler,CefFocusHandler,CefJSDialogHandler,CefKeyboardHandler,CefLifeSpanHandler,CefLoadHandler,CefRenderHandler,CefRequestHandler,CefWindowHandler
public class CefClient extends CefClientHandler implements CefContextMenuHandler, CefDialogHandler, CefDisplayHandler, CefDownloadHandler, CefDragHandler, CefFocusHandler, CefJSDialogHandler, CefKeyboardHandler, CefLifeSpanHandler, CefLoadHandler, CefRenderHandler, CefRequestHandler, CefWindowHandler
Client that owns a browser and renderer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.cef.handler.CefDialogHandler
CefDialogHandler.FileDialogMode
-
Nested classes/interfaces inherited from interface org.cef.handler.CefDragHandler
CefDragHandler.DragOperationMask
-
Nested classes/interfaces inherited from interface org.cef.handler.CefFocusHandler
CefFocusHandler.FocusSource
-
Nested classes/interfaces inherited from interface org.cef.handler.CefJSDialogHandler
CefJSDialogHandler.JSDialogType
-
Nested classes/interfaces inherited from interface org.cef.handler.CefKeyboardHandler
CefKeyboardHandler.CefKeyEvent
-
Nested classes/interfaces inherited from interface org.cef.handler.CefLoadHandler
CefLoadHandler.ErrorCode
-
Nested classes/interfaces inherited from interface org.cef.handler.CefRequestHandler
CefRequestHandler.TerminationStatus
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CefClientaddContextMenuHandler(CefContextMenuHandler handler)CefClientaddDialogHandler(CefDialogHandler handler)CefClientaddDisplayHandler(CefDisplayHandler handler)CefClientaddDownloadHandler(CefDownloadHandler handler)CefClientaddDragHandler(CefDragHandler handler)CefClientaddFocusHandler(CefFocusHandler handler)CefClientaddJSDialogHandler(CefJSDialogHandler handler)CefClientaddKeyboardHandler(CefKeyboardHandler handler)CefClientaddLifeSpanHandler(CefLifeSpanHandler handler)CefClientaddLoadHandler(CefLoadHandler handler)voidaddMessageRouter(CefMessageRouter messageRouter)CefClientaddRequestHandler(CefRequestHandler handler)CefBrowsercreateBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent)CefBrowsercreateBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent, CefRequestContext context)voiddispose()booleandoClose(CefBrowser browser)Called when a browser has received a request to close.protected java.lang.Object[]getAllBrowser()Returns a list of all browser instances.booleangetAuthCredentials(CefBrowser browser, java.lang.String origin_url, boolean isProxy, java.lang.String host, int port, java.lang.String realm, java.lang.String scheme, CefAuthCallback callback)Called on the IO thread when the browser needs credentials from the user.protected CefBrowsergetBrowser(int identifier)Returns the java part of the browser implementation.protected CefContextMenuHandlergetContextMenuHandler()Return the handler for context menus.protected CefDialogHandlergetDialogHandler()Return the handler for dialogs.protected CefDisplayHandlergetDisplayHandler()Return the handler for browser display state events.protected CefDownloadHandlergetDownloadHandler()Return the handler for download events.protected CefDragHandlergetDragHandler()Return the handler for drag events.protected CefFocusHandlergetFocusHandler()Return the handler for focus events.protected CefJSDialogHandlergetJSDialogHandler()Return the handler for javascript dialog requests.protected CefKeyboardHandlergetKeyboardHandler()Return the handler for keyboard events.protected CefLifeSpanHandlergetLifeSpanHandler()Return the handler for browser life span events.protected CefLoadHandlergetLoadHandler()Return the handler for browser load status events.java.awt.RectanglegetRect(CefBrowser browser)Retrieve the view rectangle.protected CefRenderHandlergetRenderHandler()Return the handler for off-screen rendering events.protected CefRequestHandlergetRequestHandler()Return the handler for browser request events.CefResourceRequestHandlergetResourceRequestHandler(CefBrowser browser, CefFrame frame, CefRequest request, boolean isNavigation, boolean isDownload, java.lang.String requestInitiator, BoolRef disableDefaultHandling)Called on the IO thread before a resource request is initiated.booleangetScreenInfo(CefBrowser arg0, CefScreenInfo arg1)Retrieve the screen info.java.awt.PointgetScreenPoint(CefBrowser browser, java.awt.Point viewPoint)Retrieve the screen point for the specified view point.java.awt.RectanglegetViewRect(CefBrowser browser)Retrieve the view rectangle.protected CefWindowHandlergetWindowHandler()Return the handler for windowed rendering events.voidonAddressChange(CefBrowser browser, CefFrame frame, java.lang.String url)Handle address changes.voidonAfterCreated(CefBrowser browser)Handle creation of a new browser window.voidonAfterParentChanged(CefBrowser browser)Called after a browser's native parent window has changed.booleanonBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect)Called on the UI thread before browser navigation.voidonBeforeClose(CefBrowser browser)Called just before a browser is destroyed.voidonBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams params, CefMenuModel model)Called before a context menu is displayed.voidonBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, java.lang.String suggestedName, CefBeforeDownloadCallback callback)Called before a download begins.booleanonBeforePopup(CefBrowser browser, CefFrame frame, java.lang.String target_url, java.lang.String target_frame_name)Called on the IO thread before a new popup window is created.booleanonBeforeUnloadDialog(CefBrowser browser, java.lang.String message_text, boolean is_reload, CefJSDialogCallback callback)Called to run a dialog asking the user if they want to leave a page.booleanonCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_error, java.lang.String request_url, CefRequestCallback callback)Called on the UI thread to handle requests for URLs with an invalid SSL certificate.booleanonConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, java.lang.String message, java.lang.String source, int line)Called to display a console message.booleanonContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams params, int commandId, int eventFlags)Called to execute a command selected from the context menu.voidonContextMenuDismissed(CefBrowser browser, CefFrame frame)Called when the context menu is dismissed irregardless of whether the menu was empty or a command was selected.voidonCursorChange(CefBrowser browser, int cursorType)Handle cursor changes.voidonDialogClosed(CefBrowser browser)Called when the default implementation dialog is closed.voidonDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)Called when a download's status or progress information has been updated.booleanonDragEnter(CefBrowser browser, CefDragData dragData, int mask)Called when an external drag event enters the browser window.booleanonFileDialog(CefBrowser browser, CefDialogHandler.FileDialogMode mode, java.lang.String title, java.lang.String defaultFilePath, java.util.Vector<java.lang.String> acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback)Called to run a file chooser dialog.voidonGotFocus(CefBrowser browser)Called when the browser component has received focus.booleanonJSDialog(CefBrowser browser, java.lang.String origin_url, CefJSDialogHandler.JSDialogType dialog_type, java.lang.String message_text, java.lang.String default_prompt_text, CefJSDialogCallback callback, BoolRef suppress_message)Called to run a JavaScript dialog.booleanonKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event)Called after the renderer and JavaScript in the page has had a chance to handle the event.voidonLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)Called when the browser is done loading a frame.voidonLoadError(CefBrowser browser, CefFrame frame, CefLoadHandler.ErrorCode errorCode, java.lang.String errorText, java.lang.String failedUrl)Called when the resource load for a navigation fails or is canceled.voidonLoadingStateChange(CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward)Called when the loading state has changed.voidonLoadStart(CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType)Called when the browser begins loading a frame.voidonMouseEvent(CefBrowser browser, int event, int screenX, int screenY, int modifier, int button)Implement this method to handle mouse events on Windows.voidonPaint(CefBrowser browser, boolean popup, java.awt.Rectangle[] dirtyRects, java.nio.ByteBuffer buffer, int width, int height)Handle painting.voidonPluginCrashed(CefBrowser browser, java.lang.String pluginPath)Called on the browser process UI thread when a plugin has crashed.voidonPopupShow(CefBrowser browser, boolean show)Show or hide the popup window.voidonPopupSize(CefBrowser browser, java.awt.Rectangle size)Size the popup window.booleanonPreKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event, BoolRef is_keyboard_shortcut)Called before a keyboard event is sent to the renderer.booleanonQuotaRequest(CefBrowser browser, java.lang.String origin_url, long new_size, CefRequestCallback callback)Called on the IO thread when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota function.voidonRenderProcessTerminated(CefBrowser browser, CefRequestHandler.TerminationStatus status)Called on the browser process UI thread when the render process terminates unexpectedly.voidonResetDialogState(CefBrowser browser)Called to cancel any pending dialogs and reset any saved dialog state.booleanonSetFocus(CefBrowser browser, CefFocusHandler.FocusSource source)Called when the browser component is requesting focus.voidonStatusMessage(CefBrowser browser, java.lang.String value)Called when the browser receives a status message.voidonTakeFocus(CefBrowser browser, boolean next)Called when the browser component is about to loose focus.voidonTitleChange(CefBrowser browser, java.lang.String title)Handle title changes.booleanonTooltip(CefBrowser browser, java.lang.String text)Called when the browser is about to display a tooltip.voidremoveContextMenuHandler()voidremoveDialogHandler()voidremoveDisplayHandler()voidremoveDownloadHandler()voidremoveDragHandler()voidremoveFocusHandler()voidremoveJSDialogHandler()voidremoveKeyboardHandler()voidremoveLifeSpanHandler()voidremoveLoadHandler()voidremoveMessageRouter(CefMessageRouter messageRouter)voidremoveRequestHandler()booleanstartDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y)Called when the user starts dragging content in the web view.voidupdateDragCursor(CefBrowser browser, int operation)Called when the web view wants to update the mouse cursor during a drag & drop operation.-
Methods inherited from class org.cef.handler.CefClientHandler
getNativeRef, removeContextMenuHandler, removeDialogHandler, removeDisplayHandler, removeDownloadHandler, removeDragHandler, removeFocusHandler, removeJSDialogHandler, removeKeyboardHandler, removeLifeSpanHandler, removeLoadHandler, removeRenderHandler, removeRequestHandler, removeWindowHandler, setNativeRef
-
-
-
-
Method Detail
-
dispose
public void dispose()
- Overrides:
disposein classCefClientHandler
-
createBrowser
public CefBrowser createBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent)
-
createBrowser
public CefBrowser createBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent, CefRequestContext context)
-
getBrowser
protected CefBrowser getBrowser(int identifier)
Description copied from class:CefClientHandlerReturns the java part of the browser implementation.- Specified by:
getBrowserin classCefClientHandler- Returns:
- The found browser or null if none is found.
-
getAllBrowser
protected java.lang.Object[] getAllBrowser()
Description copied from class:CefClientHandlerReturns a list of all browser instances.- Specified by:
getAllBrowserin classCefClientHandler- Returns:
- an array of browser Instances.
-
getContextMenuHandler
protected CefContextMenuHandler getContextMenuHandler()
Description copied from class:CefClientHandlerReturn the handler for context menus. If no handler is provided the default implementation will be used.- Specified by:
getContextMenuHandlerin classCefClientHandler
-
getDialogHandler
protected CefDialogHandler getDialogHandler()
Description copied from class:CefClientHandlerReturn the handler for dialogs. If no handler is provided the default implementation will be used.- Specified by:
getDialogHandlerin classCefClientHandler
-
getDisplayHandler
protected CefDisplayHandler getDisplayHandler()
Description copied from class:CefClientHandlerReturn the handler for browser display state events. This method is a callback method and is called by the native code.- Specified by:
getDisplayHandlerin classCefClientHandler
-
getDownloadHandler
protected CefDownloadHandler getDownloadHandler()
Description copied from class:CefClientHandlerReturn the handler for download events. This method is a callback method and is called by the native code.- Specified by:
getDownloadHandlerin classCefClientHandler
-
getDragHandler
protected CefDragHandler getDragHandler()
Description copied from class:CefClientHandlerReturn the handler for drag events. This method is a callback method and is called by the native code.- Specified by:
getDragHandlerin classCefClientHandler
-
getFocusHandler
protected CefFocusHandler getFocusHandler()
Description copied from class:CefClientHandlerReturn the handler for focus events. This method is a callback method and is called by the native code.- Specified by:
getFocusHandlerin classCefClientHandler
-
getJSDialogHandler
protected CefJSDialogHandler getJSDialogHandler()
Description copied from class:CefClientHandlerReturn the handler for javascript dialog requests. This method is a callback method and is called by the native code.- Specified by:
getJSDialogHandlerin classCefClientHandler
-
getKeyboardHandler
protected CefKeyboardHandler getKeyboardHandler()
Description copied from class:CefClientHandlerReturn the handler for keyboard events. This method is a callback method and is called by the native code.- Specified by:
getKeyboardHandlerin classCefClientHandler
-
getLifeSpanHandler
protected CefLifeSpanHandler getLifeSpanHandler()
Description copied from class:CefClientHandlerReturn the handler for browser life span events. This method is a callback method and is called by the native code.- Specified by:
getLifeSpanHandlerin classCefClientHandler
-
getLoadHandler
protected CefLoadHandler getLoadHandler()
Description copied from class:CefClientHandlerReturn the handler for browser load status events. This method is a callback method and is called by the native code.- Specified by:
getLoadHandlerin classCefClientHandler
-
getRenderHandler
protected CefRenderHandler getRenderHandler()
Description copied from class:CefClientHandlerReturn the handler for off-screen rendering events. This method is a callback method and is called by the native code.- Specified by:
getRenderHandlerin classCefClientHandler
-
getRequestHandler
protected CefRequestHandler getRequestHandler()
Description copied from class:CefClientHandlerReturn the handler for browser request events. This method is a callback method and is called by the native code.- Specified by:
getRequestHandlerin classCefClientHandler
-
getWindowHandler
protected CefWindowHandler getWindowHandler()
Description copied from class:CefClientHandlerReturn the handler for windowed rendering events. This method is a callback method and is called by the native code.- Specified by:
getWindowHandlerin classCefClientHandler
-
addContextMenuHandler
public CefClient addContextMenuHandler(CefContextMenuHandler handler)
-
removeContextMenuHandler
public void removeContextMenuHandler()
-
onBeforeContextMenu
public void onBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams params, CefMenuModel model)
Description copied from interface:CefContextMenuHandlerCalled before a context menu is displayed.- Specified by:
onBeforeContextMenuin interfaceCefContextMenuHandler- Parameters:
browser- The browser generating the event.frame- The frame generating the event. Instance only valid within the scope of this method.params- Provides information about the context menu state. Instance only valid within the scope of this method.model- Can be cleared to show no context menu or modified to show a custom menu. Instance only valid within the scope of this method.
-
onContextMenuCommand
public boolean onContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams params, int commandId, int eventFlags)
Description copied from interface:CefContextMenuHandlerCalled to execute a command selected from the context menu. Return true if the command was handled or false for the default implementation. See cef_menu_id_t for the command ids that have default implementations. All user-defined command ids should be between MENU_ID_USER_FIRST and- Specified by:
onContextMenuCommandin interfaceCefContextMenuHandler- Parameters:
browser- The browser generating the event.frame- The frame generating the event. Instance only valid within the scope of this method.params- Will have the same values that were passed to onBeforeContextMenu(). Instance only valid within the scope of this method.commandId- The id of the command.eventFlags- A combination of event flags defined in EventFlags- Returns:
- true if the command was handled or false for the default implementation.
-
onContextMenuDismissed
public void onContextMenuDismissed(CefBrowser browser, CefFrame frame)
Description copied from interface:CefContextMenuHandlerCalled when the context menu is dismissed irregardless of whether the menu was empty or a command was selected.- Specified by:
onContextMenuDismissedin interfaceCefContextMenuHandler- Parameters:
browser- The browser generating the event.frame- The corresponding frame. Instance only valid within the scope of this method.
-
addDialogHandler
public CefClient addDialogHandler(CefDialogHandler handler)
-
removeDialogHandler
public void removeDialogHandler()
-
onFileDialog
public boolean onFileDialog(CefBrowser browser, CefDialogHandler.FileDialogMode mode, java.lang.String title, java.lang.String defaultFilePath, java.util.Vector<java.lang.String> acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback)
Description copied from interface:CefDialogHandlerCalled to run a file chooser dialog.- Specified by:
onFileDialogin interfaceCefDialogHandlermode- represents the type of dialog to display.title- to be used for the dialog and may be empty to show the default title ("Open" or "Save" depending on the mode).defaultFilePath- is the path with optional directory and/or file name component that should be initially selected in the dialog.acceptFilters- are used to restrict the selectable file types and may any combination of (a) valid lower-cased MIME types (e.g. "text/*" or "image/*"), (b) individual file extensions (e.g. ".txt" or ".png"), or (c) combined description and file extension delimited using "|" and ";" (e.g. "Image Types|.png;.gif;.jpg").selectedAcceptFilter- is the 0-based index of the filter that should be selected by default.callback- is a callback handler for handling own file dialogs.- Returns:
- To display a custom dialog return true and execute callback. To display the default dialog return false.
-
addDisplayHandler
public CefClient addDisplayHandler(CefDisplayHandler handler)
-
removeDisplayHandler
public void removeDisplayHandler()
-
onAddressChange
public void onAddressChange(CefBrowser browser, CefFrame frame, java.lang.String url)
Description copied from interface:CefDisplayHandlerHandle address changes.- Specified by:
onAddressChangein interfaceCefDisplayHandler- Parameters:
browser- The browser generating the event.frame- The frame generating the event.url- The new address.
-
onTitleChange
public void onTitleChange(CefBrowser browser, java.lang.String title)
Description copied from interface:CefDisplayHandlerHandle title changes.- Specified by:
onTitleChangein interfaceCefDisplayHandler- Parameters:
browser- The browser generating the event.title- The new title.
-
onTooltip
public boolean onTooltip(CefBrowser browser, java.lang.String text)
Description copied from interface:CefDisplayHandlerCalled when the browser is about to display a tooltip.- Specified by:
onTooltipin interfaceCefDisplayHandler- Parameters:
browser- The browser generating the event.text- Contains the text that will be displayed in the tooltip.- Returns:
- To handle the display of the tooltip yourself return true.
-
onStatusMessage
public void onStatusMessage(CefBrowser browser, java.lang.String value)
Description copied from interface:CefDisplayHandlerCalled when the browser receives a status message.- Specified by:
onStatusMessagein interfaceCefDisplayHandler- Parameters:
browser- The browser generating the event.value- Contains the text that will be displayed in the status message.
-
onConsoleMessage
public boolean onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, java.lang.String message, java.lang.String source, int line)
Description copied from interface:CefDisplayHandlerCalled to display a console message.- Specified by:
onConsoleMessagein interfaceCefDisplayHandler- Parameters:
browser- The browser generating the event.- Returns:
- true to stop the message from being output to the console.
-
addDownloadHandler
public CefClient addDownloadHandler(CefDownloadHandler handler)
-
removeDownloadHandler
public void removeDownloadHandler()
-
onBeforeDownload
public void onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, java.lang.String suggestedName, CefBeforeDownloadCallback callback)
Description copied from interface:CefDownloadHandlerCalled before a download begins. By default the download will be canceled. Execute callback either asynchronously or in this method to continue the download if desired.- Specified by:
onBeforeDownloadin interfaceCefDownloadHandler- Parameters:
browser- The desired browser.downloadItem- The item to be downloaded. Do not keep a reference to it outside this method.suggestedName- is the suggested name for the download file.callback- start the download by calling the Continue method
-
onDownloadUpdated
public void onDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)
Description copied from interface:CefDownloadHandlerCalled when a download's status or progress information has been updated.- Specified by:
onDownloadUpdatedin interfaceCefDownloadHandler- Parameters:
browser- The desired browser.downloadItem- The downloading item.callback- Execute callback to cancel the download
-
addDragHandler
public CefClient addDragHandler(CefDragHandler handler)
-
removeDragHandler
public void removeDragHandler()
-
onDragEnter
public boolean onDragEnter(CefBrowser browser, CefDragData dragData, int mask)
Description copied from interface:CefDragHandlerCalled when an external drag event enters the browser window.- Specified by:
onDragEnterin interfaceCefDragHandler- Parameters:
browser- The browser generating the event.dragData- Contains the drag event data. Instance only valid within the scope of this method.mask- Represents the type of drag operation. See DragOperationMask for possible values.- Returns:
- False for default drag handling behavior or true to cancel the drag event.
-
addFocusHandler
public CefClient addFocusHandler(CefFocusHandler handler)
-
removeFocusHandler
public void removeFocusHandler()
-
onTakeFocus
public void onTakeFocus(CefBrowser browser, boolean next)
Description copied from interface:CefFocusHandlerCalled when the browser component is about to loose focus. For instance, if focus was on the last HTML element and the user pressed the TAB key.- Specified by:
onTakeFocusin interfaceCefFocusHandler- Parameters:
browser- The browser generating the event.next- will be true if the browser is giving focus to the next component and false if the browser is giving focus to the previous component.
-
onSetFocus
public boolean onSetFocus(CefBrowser browser, CefFocusHandler.FocusSource source)
Description copied from interface:CefFocusHandlerCalled when the browser component is requesting focus.- Specified by:
onSetFocusin interfaceCefFocusHandler- Parameters:
browser- The browser generating the event.source- indicates/ where the focus request is originating from.- Returns:
- false to allow the focus to be set or true to cancel setting the focus.
-
onGotFocus
public void onGotFocus(CefBrowser browser)
Description copied from interface:CefFocusHandlerCalled when the browser component has received focus.- Specified by:
onGotFocusin interfaceCefFocusHandler- Parameters:
browser- The browser generating the event.
-
addJSDialogHandler
public CefClient addJSDialogHandler(CefJSDialogHandler handler)
-
removeJSDialogHandler
public void removeJSDialogHandler()
-
onJSDialog
public boolean onJSDialog(CefBrowser browser, java.lang.String origin_url, CefJSDialogHandler.JSDialogType dialog_type, java.lang.String message_text, java.lang.String default_prompt_text, CefJSDialogCallback callback, BoolRef suppress_message)
Description copied from interface:CefJSDialogHandlerCalled to run a JavaScript dialog. Set suppress_message to true and return false to suppress the message (suppressing messages is preferable to immediately executing the callback as this is used to detect presumably malicious behavior like spamming alert messages in onbeforeunload). Set suppress_message to false and return false to use the default implementation (the default implementation will show one modal dialog at a time and suppress any additional dialog requests until the displayed dialog is dismissed). Return true if the application will use a custom dialog or if the callback has been executed immediately. Custom dialogs may be either modal or modeless. If a custom dialog is used the application must execute callback once the custom dialog is dismissed.- Specified by:
onJSDialogin interfaceCefJSDialogHandler- Parameters:
browser- The corresponding browser.origin_url- The originating url.dialog_type- the dialog type.message_text- the text to be displayed.default_prompt_text- value will be specified for prompt dialogs only.callback- execute callback once the custom dialog is dismissed.suppress_message- set to true to suppress displaying the message.- Returns:
- false to use the default dialog implementation. Return true if the application will use a custom dialog.
-
onBeforeUnloadDialog
public boolean onBeforeUnloadDialog(CefBrowser browser, java.lang.String message_text, boolean is_reload, CefJSDialogCallback callback)
Description copied from interface:CefJSDialogHandlerCalled to run a dialog asking the user if they want to leave a page. Return false to use the default dialog implementation. Return true if the application will use a custom dialog or if the callback has been executed immediately. Custom dialogs may be either modal or modeless. If a custom dialog is used the application must execute callback once the custom dialog is dismissed.- Specified by:
onBeforeUnloadDialogin interfaceCefJSDialogHandler- Parameters:
browser- The corresponding browser.message_text- The text to be displayed.is_reload- true if the page is reloaded.callback- execute callback once the custom dialog is dismissed.- Returns:
- false to use the default dialog implementation. Return true if the application will use a custom dialog.
-
onResetDialogState
public void onResetDialogState(CefBrowser browser)
Description copied from interface:CefJSDialogHandlerCalled to cancel any pending dialogs and reset any saved dialog state. Will be called due to events like page navigation irregardless of whether any dialogs are currently pending.- Specified by:
onResetDialogStatein interfaceCefJSDialogHandler
-
onDialogClosed
public void onDialogClosed(CefBrowser browser)
Description copied from interface:CefJSDialogHandlerCalled when the default implementation dialog is closed.- Specified by:
onDialogClosedin interfaceCefJSDialogHandler
-
addKeyboardHandler
public CefClient addKeyboardHandler(CefKeyboardHandler handler)
-
removeKeyboardHandler
public void removeKeyboardHandler()
-
onPreKeyEvent
public boolean onPreKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event, BoolRef is_keyboard_shortcut)
Description copied from interface:CefKeyboardHandlerCalled before a keyboard event is sent to the renderer.- Specified by:
onPreKeyEventin interfaceCefKeyboardHandler- Parameters:
browser- the corresponding browser.event- contains information about the keyboard event.is_keyboard_shortcut- set to true and return false, if the event will be handled in OnKeyEvent() as a keyboard shortcut.- Returns:
- true if the event was handled or false otherwise.
-
onKeyEvent
public boolean onKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event)
Description copied from interface:CefKeyboardHandlerCalled after the renderer and JavaScript in the page has had a chance to handle the event.- Specified by:
onKeyEventin interfaceCefKeyboardHandler- Parameters:
browser- the corresponding browser.event- contains information about the keyboard event.- Returns:
- true if the keyboard event was handled or false otherwise.
-
addLifeSpanHandler
public CefClient addLifeSpanHandler(CefLifeSpanHandler handler)
-
removeLifeSpanHandler
public void removeLifeSpanHandler()
-
onBeforePopup
public boolean onBeforePopup(CefBrowser browser, CefFrame frame, java.lang.String target_url, java.lang.String target_frame_name)
Description copied from interface:CefLifeSpanHandlerCalled on the IO thread before a new popup window is created.- Specified by:
onBeforePopupin interfaceCefLifeSpanHandler- Parameters:
browser- The source of the popup request.frame- The source of the popup request. Instance only valid within the scope of this method.target_url- May be empty if none is specified with the request.target_frame_name- May be empty if none is specified with the request.- Returns:
- True to cancel creation of the popup window or false to proceed.
-
onAfterCreated
public void onAfterCreated(CefBrowser browser)
Description copied from interface:CefLifeSpanHandlerHandle creation of a new browser window.- Specified by:
onAfterCreatedin interfaceCefLifeSpanHandler- Parameters:
browser- The browser generating the event.
-
onAfterParentChanged
public void onAfterParentChanged(CefBrowser browser)
Description copied from interface:CefLifeSpanHandlerCalled after a browser's native parent window has changed.- Specified by:
onAfterParentChangedin interfaceCefLifeSpanHandler- Parameters:
browser- The browser generating the event.
-
doClose
public boolean doClose(CefBrowser browser)
Description copied from interface:CefLifeSpanHandlerCalled when a browser has received a request to close. If CEF created an OS window for the browser returning false will send an OS close notification to the browser window's top-level owner (e.g. WM_CLOSE on Windows, performClose: on OS-X and "delete_event" on Linux). If no OS window exists (window rendering disabled) returning false will cause the browser object to be destroyed immediately. Return true if the browser is parented to another window and that other window needs to receive close notification via some non-standard technique.- Specified by:
doClosein interfaceCefLifeSpanHandler- Parameters:
browser- The browser generating the event.- Returns:
- False to send an OS close notification to the browser window's top-level owner.
-
onBeforeClose
public void onBeforeClose(CefBrowser browser)
Description copied from interface:CefLifeSpanHandlerCalled just before a browser is destroyed. Release all references to the browser object and do not attempt to execute any methods on the browser object after this callback returns. If this is a modal window and a custom modal loop implementation was provided in runModal() this callback should be used to exit the custom modal loop. See doClose() documentation for additional usage information.- Specified by:
onBeforeClosein interfaceCefLifeSpanHandler- Parameters:
browser- The browser generating the event.
-
addLoadHandler
public CefClient addLoadHandler(CefLoadHandler handler)
-
removeLoadHandler
public void removeLoadHandler()
-
onLoadingStateChange
public void onLoadingStateChange(CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward)
Description copied from interface:CefLoadHandlerCalled when the loading state has changed. This callback will be executed twice -- once when loading is initiated either programmatically or by user action, and once when loading is terminated due to completion, cancellation of failure.- Specified by:
onLoadingStateChangein interfaceCefLoadHandler- Parameters:
browser- The corresponding browser.isLoading- true if it is loading.canGoBack- true if you can navigate back.canGoForward- true if you can navigate forward.
-
onLoadStart
public void onLoadStart(CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType)
Description copied from interface:CefLoadHandlerCalled when the browser begins loading a frame. The frameIdentifer value will never be empty. Multiple frames may be loading at the same time. Sub-frames may start or continue loading after the main frame load has ended. This method may not be called for a particular frame if the load request for that frame fails. For notification of overall browser load status use onLoadingStateChange instead.- Specified by:
onLoadStartin interfaceCefLoadHandler- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this method.transitionType- The transition type.
-
onLoadEnd
public void onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
Description copied from interface:CefLoadHandlerCalled when the browser is done loading a frame. The frameIdentifer value will never be empty. Multiple frames may be loading at the same time. Sub-frames may start or continue loading after the main frame load has ended. This method will always be called for all frames irrespective of whether the request completes successfully.- Specified by:
onLoadEndin interfaceCefLoadHandler- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this method.httpStatusCode- The status code of the load.
-
onLoadError
public void onLoadError(CefBrowser browser, CefFrame frame, CefLoadHandler.ErrorCode errorCode, java.lang.String errorText, java.lang.String failedUrl)
Description copied from interface:CefLoadHandlerCalled when the resource load for a navigation fails or is canceled.- Specified by:
onLoadErrorin interfaceCefLoadHandler- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this method.errorCode- The error code number.errorText- The error text.failedUrl- The URL that failed to load.
-
addMessageRouter
public void addMessageRouter(CefMessageRouter messageRouter)
- Overrides:
addMessageRouterin classCefClientHandler
-
removeMessageRouter
public void removeMessageRouter(CefMessageRouter messageRouter)
- Overrides:
removeMessageRouterin classCefClientHandler
-
getViewRect
public java.awt.Rectangle getViewRect(CefBrowser browser)
Description copied from interface:CefRenderHandlerRetrieve the view rectangle.- Specified by:
getViewRectin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.- Returns:
- The view rectangle.
-
getScreenPoint
public java.awt.Point getScreenPoint(CefBrowser browser, java.awt.Point viewPoint)
Description copied from interface:CefRenderHandlerRetrieve the screen point for the specified view point.- Specified by:
getScreenPointin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.viewPoint- The point in the view.- Returns:
- The screen point.
-
onPopupShow
public void onPopupShow(CefBrowser browser, boolean show)
Description copied from interface:CefRenderHandlerShow or hide the popup window.- Specified by:
onPopupShowin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.show- True if the popup window is being shown.
-
onPopupSize
public void onPopupSize(CefBrowser browser, java.awt.Rectangle size)
Description copied from interface:CefRenderHandlerSize the popup window.- Specified by:
onPopupSizein interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.size- Size of the popup window.
-
onPaint
public void onPaint(CefBrowser browser, boolean popup, java.awt.Rectangle[] dirtyRects, java.nio.ByteBuffer buffer, int width, int height)
Description copied from interface:CefRenderHandlerHandle painting.- Specified by:
onPaintin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.popup- True if painting a popup window.dirtyRects- Array of dirty regions.buffer- Pixel buffer for the whole window.width- Width of the buffer.height- Height of the buffer.
-
onCursorChange
public void onCursorChange(CefBrowser browser, int cursorType)
Description copied from interface:CefRenderHandlerHandle cursor changes.- Specified by:
onCursorChangein interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.cursorType- The new cursor.
-
startDragging
public boolean startDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y)
Description copied from interface:CefRenderHandlerCalled when the user starts dragging content in the web view. Contextual information about the dragged content is supplied by dragData. OS APIs that run a system message loop may be used within the StartDragging call. Return false to abort the drag operation. Don't call any of CefBrowser-dragSource*Ended* methods after returning false. Return true to handle the drag operation. Call CefBrowser.dragSourceEndedAt and CefBrowser.ragSourceSystemDragEnded either synchronously or asynchronously to inform the web view that the drag operation has ended.- Specified by:
startDraggingin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.dragData- Contextual information about the dragged contentmask- Describes the allowed operation (none, move, copy, link).x- Coordinate within CefBrowsery- Coordinate within CefBrowser- Returns:
- false to abort the drag operation or true to handle the drag operation.
-
updateDragCursor
public void updateDragCursor(CefBrowser browser, int operation)
Description copied from interface:CefRenderHandlerCalled when the web view wants to update the mouse cursor during a drag & drop operation.- Specified by:
updateDragCursorin interfaceCefRenderHandler- Parameters:
browser- The browser generating the event.operation- Describes the allowed operation (none, move, copy, link).
-
addRequestHandler
public CefClient addRequestHandler(CefRequestHandler handler)
-
removeRequestHandler
public void removeRequestHandler()
-
onBeforeBrowse
public boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect)
Description copied from interface:CefRequestHandlerCalled on the UI thread before browser navigation. CefLoadHandler.onLoadingStateChange() will be called twice in all cases. If the navigation is allowed CefLoadHandler.onLoadStart() and CefLoadHandler.onLoadEnd() will be called. If the navigation is canceled CefLoadHandler.onLoadError() will be called with an errorCode value of ERR_ABORTED.- Specified by:
onBeforeBrowsein interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this method.request- The request itself. Cannot be modified in this callback. Instance only valid within the scope of this method.user_gesture- True if the request was initiated by a user gesture.is_redirect- True if the request was redirected.- Returns:
- True to cancel the navigation or false to continue.
-
getResourceRequestHandler
public CefResourceRequestHandler getResourceRequestHandler(CefBrowser browser, CefFrame frame, CefRequest request, boolean isNavigation, boolean isDownload, java.lang.String requestInitiator, BoolRef disableDefaultHandling)
Description copied from interface:CefRequestHandlerCalled on the IO thread before a resource request is initiated. The |browser| and |frame| values represent the source of the request. If this callback returns null the same method will be called on the associated CefRequestContextHandler, if any.- Specified by:
getResourceRequestHandlerin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this method.request- The request itself. Cannot be modified in this callback. Instance only valid within the scope of this method.isNavigation- True if the resource request is a navigation.isDownload- True if the resource request is a download.requestInitiator- The origin (scheme + domain) of the page that initiated the request.disableDefaultHandling- Set to true to disable default handling of the request, in which case it will need to be handled via CefResourceRequestHandler.getResourceHandler or it will be canceled.- Returns:
- A CefResourceRequestHandler instance or null.
-
getAuthCredentials
public boolean getAuthCredentials(CefBrowser browser, java.lang.String origin_url, boolean isProxy, java.lang.String host, int port, java.lang.String realm, java.lang.String scheme, CefAuthCallback callback)
Description copied from interface:CefRequestHandlerCalled on the IO thread when the browser needs credentials from the user.- Specified by:
getAuthCredentialsin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.origin_url- The origin making this authentication request.isProxy- True if the host is a proxy server.host- Hostname.port- Port number.realm- Realm of the request.scheme- Scheme of the request.callback- Call CefAuthCallback.Continue() when the authentication information is available.- Returns:
- True to continue the request (callback must be executed) or false to cancel.
-
onQuotaRequest
public boolean onQuotaRequest(CefBrowser browser, java.lang.String origin_url, long new_size, CefRequestCallback callback)
Description copied from interface:CefRequestHandlerCalled on the IO thread when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota function.- Specified by:
onQuotaRequestin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.origin_url- Origin of the page making the request.new_size- Requested quota size in bytes.callback- Call CefRequestCallback.Continue() either in this method or at a later time to grant or deny the request.- Returns:
- True to handle the request (callback must be executed) or false to cancel.
-
onCertificateError
public boolean onCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_error, java.lang.String request_url, CefRequestCallback callback)
Description copied from interface:CefRequestHandlerCalled on the UI thread to handle requests for URLs with an invalid SSL certificate. If "ignore-certificate-errors" command-line switch is set all invalid certificates will be accepted without calling this method.- Specified by:
onCertificateErrorin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.cert_error- Error code describing the error.request_url- The requesting URL.callback- Call CefRequestCallback.Continue() either in this method or at a later time to continue or cancel the request. If null the error cannot be recovered from and the request will be canceled automatically.- Returns:
- True to handle the request (callback must be executed) or false to reject it.
-
onPluginCrashed
public void onPluginCrashed(CefBrowser browser, java.lang.String pluginPath)
Description copied from interface:CefRequestHandlerCalled on the browser process UI thread when a plugin has crashed.- Specified by:
onPluginCrashedin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.pluginPath- The path of the plugin that crashed.
-
onRenderProcessTerminated
public void onRenderProcessTerminated(CefBrowser browser, CefRequestHandler.TerminationStatus status)
Description copied from interface:CefRequestHandlerCalled on the browser process UI thread when the render process terminates unexpectedly.- Specified by:
onRenderProcessTerminatedin interfaceCefRequestHandler- Parameters:
browser- The corresponding browser.status- Indicates how the process was terminated.
-
getRect
public java.awt.Rectangle getRect(CefBrowser browser)
Description copied from interface:CefWindowHandlerRetrieve the view rectangle.- Specified by:
getRectin interfaceCefWindowHandler- Parameters:
browser- The browser generating the event.- Returns:
- The view rectangle.
-
onMouseEvent
public void onMouseEvent(CefBrowser browser, int event, int screenX, int screenY, int modifier, int button)
Description copied from interface:CefWindowHandlerImplement this method to handle mouse events on Windows. The method is called in case of the following events: MOUSE_MOVED, MOUSE_PRESSED, MOUSE_RELEASED and MOUSE_WHEEL for a horizontal wheel movement.- Specified by:
onMouseEventin interfaceCefWindowHandler- Parameters:
browser- The browser generating the event.event- A mouse event like MouseEvent.MOUSE_MOVED.screenX- The absolute X position on the screen.screenY- The absolute Y position on the screen.modifier- The modifier keys down during event (e.g. Shift, Ctrl).button- An integer indicating which mouse button state changed. If parameter event is set to MouseEvent.MOUSE_WHEEL, the value of this parameter specifies the rotation indicator (negative value for left scroll and positive value for right scroll).
-
getScreenInfo
public boolean getScreenInfo(CefBrowser arg0, CefScreenInfo arg1)
Description copied from interface:CefRenderHandlerRetrieve the screen info.- Specified by:
getScreenInfoin interfaceCefRenderHandler- Parameters:
arg0- The browser generating the event.arg1- The screenInfo- Returns:
- True if this callback was handled. False to fallback to defaults.
-
-