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 CefClient
addContextMenuHandler(CefContextMenuHandler handler)
CefClient
addDialogHandler(CefDialogHandler handler)
CefClient
addDisplayHandler(CefDisplayHandler handler)
CefClient
addDownloadHandler(CefDownloadHandler handler)
CefClient
addDragHandler(CefDragHandler handler)
CefClient
addFocusHandler(CefFocusHandler handler)
CefClient
addJSDialogHandler(CefJSDialogHandler handler)
CefClient
addKeyboardHandler(CefKeyboardHandler handler)
CefClient
addLifeSpanHandler(CefLifeSpanHandler handler)
CefClient
addLoadHandler(CefLoadHandler handler)
void
addMessageRouter(CefMessageRouter messageRouter)
CefClient
addRequestHandler(CefRequestHandler handler)
CefBrowser
createBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent)
CefBrowser
createBrowser(java.lang.String url, boolean isOffscreenRendered, boolean isTransparent, CefRequestContext context)
void
dispose()
boolean
doClose(CefBrowser browser)
Called when a browser has received a request to close.protected java.lang.Object[]
getAllBrowser()
Returns a list of all browser instances.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)
Called on the IO thread when the browser needs credentials from the user.protected CefBrowser
getBrowser(int identifier)
Returns the java part of the browser implementation.protected CefContextMenuHandler
getContextMenuHandler()
Return the handler for context menus.protected CefDialogHandler
getDialogHandler()
Return the handler for dialogs.protected CefDisplayHandler
getDisplayHandler()
Return the handler for browser display state events.protected CefDownloadHandler
getDownloadHandler()
Return the handler for download events.protected CefDragHandler
getDragHandler()
Return the handler for drag events.protected CefFocusHandler
getFocusHandler()
Return the handler for focus events.protected CefJSDialogHandler
getJSDialogHandler()
Return the handler for javascript dialog requests.protected CefKeyboardHandler
getKeyboardHandler()
Return the handler for keyboard events.protected CefLifeSpanHandler
getLifeSpanHandler()
Return the handler for browser life span events.protected CefLoadHandler
getLoadHandler()
Return the handler for browser load status events.java.awt.Rectangle
getRect(CefBrowser browser)
Retrieve the view rectangle.protected CefRenderHandler
getRenderHandler()
Return the handler for off-screen rendering events.protected CefRequestHandler
getRequestHandler()
Return the handler for browser request events.CefResourceRequestHandler
getResourceRequestHandler(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.boolean
getScreenInfo(CefBrowser arg0, CefScreenInfo arg1)
Retrieve the screen info.java.awt.Point
getScreenPoint(CefBrowser browser, java.awt.Point viewPoint)
Retrieve the screen point for the specified view point.java.awt.Rectangle
getViewRect(CefBrowser browser)
Retrieve the view rectangle.protected CefWindowHandler
getWindowHandler()
Return the handler for windowed rendering events.void
onAddressChange(CefBrowser browser, CefFrame frame, java.lang.String url)
Handle address changes.void
onAfterCreated(CefBrowser browser)
Handle creation of a new browser window.void
onAfterParentChanged(CefBrowser browser)
Called after a browser's native parent window has changed.boolean
onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect)
Called on the UI thread before browser navigation.void
onBeforeClose(CefBrowser browser)
Called just before a browser is destroyed.void
onBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams params, CefMenuModel model)
Called before a context menu is displayed.void
onBeforeDownload(CefBrowser browser, CefDownloadItem downloadItem, java.lang.String suggestedName, CefBeforeDownloadCallback callback)
Called before a download begins.boolean
onBeforePopup(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.boolean
onBeforeUnloadDialog(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.boolean
onCertificateError(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.boolean
onConsoleMessage(CefBrowser browser, CefSettings.LogSeverity level, java.lang.String message, java.lang.String source, int line)
Called to display a console message.boolean
onContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams params, int commandId, int eventFlags)
Called to execute a command selected from the context menu.void
onContextMenuDismissed(CefBrowser browser, CefFrame frame)
Called when the context menu is dismissed irregardless of whether the menu was empty or a command was selected.void
onCursorChange(CefBrowser browser, int cursorType)
Handle cursor changes.void
onDialogClosed(CefBrowser browser)
Called when the default implementation dialog is closed.void
onDownloadUpdated(CefBrowser browser, CefDownloadItem downloadItem, CefDownloadItemCallback callback)
Called when a download's status or progress information has been updated.boolean
onDragEnter(CefBrowser browser, CefDragData dragData, int mask)
Called when an external drag event enters the browser window.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)
Called to run a file chooser dialog.void
onGotFocus(CefBrowser browser)
Called when the browser component has received focus.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)
Called to run a JavaScript dialog.boolean
onKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event)
Called after the renderer and JavaScript in the page has had a chance to handle the event.void
onLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode)
Called when the browser is done loading a frame.void
onLoadError(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.void
onLoadingStateChange(CefBrowser browser, boolean isLoading, boolean canGoBack, boolean canGoForward)
Called when the loading state has changed.void
onLoadStart(CefBrowser browser, CefFrame frame, CefRequest.TransitionType transitionType)
Called when the browser begins loading a frame.void
onMouseEvent(CefBrowser browser, int event, int screenX, int screenY, int modifier, int button)
Implement this method to handle mouse events on Windows.void
onPaint(CefBrowser browser, boolean popup, java.awt.Rectangle[] dirtyRects, java.nio.ByteBuffer buffer, int width, int height)
Handle painting.void
onPluginCrashed(CefBrowser browser, java.lang.String pluginPath)
Called on the browser process UI thread when a plugin has crashed.void
onPopupShow(CefBrowser browser, boolean show)
Show or hide the popup window.void
onPopupSize(CefBrowser browser, java.awt.Rectangle size)
Size the popup window.boolean
onPreKeyEvent(CefBrowser browser, CefKeyboardHandler.CefKeyEvent event, BoolRef is_keyboard_shortcut)
Called before a keyboard event is sent to the renderer.boolean
onQuotaRequest(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.void
onRenderProcessTerminated(CefBrowser browser, CefRequestHandler.TerminationStatus status)
Called on the browser process UI thread when the render process terminates unexpectedly.void
onResetDialogState(CefBrowser browser)
Called to cancel any pending dialogs and reset any saved dialog state.boolean
onSetFocus(CefBrowser browser, CefFocusHandler.FocusSource source)
Called when the browser component is requesting focus.void
onStatusMessage(CefBrowser browser, java.lang.String value)
Called when the browser receives a status message.void
onTakeFocus(CefBrowser browser, boolean next)
Called when the browser component is about to loose focus.void
onTitleChange(CefBrowser browser, java.lang.String title)
Handle title changes.boolean
onTooltip(CefBrowser browser, java.lang.String text)
Called when the browser is about to display a tooltip.void
removeContextMenuHandler()
void
removeDialogHandler()
void
removeDisplayHandler()
void
removeDownloadHandler()
void
removeDragHandler()
void
removeFocusHandler()
void
removeJSDialogHandler()
void
removeKeyboardHandler()
void
removeLifeSpanHandler()
void
removeLoadHandler()
void
removeMessageRouter(CefMessageRouter messageRouter)
void
removeRequestHandler()
boolean
startDragging(CefBrowser browser, CefDragData dragData, int mask, int x, int y)
Called when the user starts dragging content in the web view.void
updateDragCursor(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:
dispose
in 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:CefClientHandler
Returns the java part of the browser implementation.- Specified by:
getBrowser
in classCefClientHandler
- Returns:
- The found browser or null if none is found.
-
getAllBrowser
protected java.lang.Object[] getAllBrowser()
Description copied from class:CefClientHandler
Returns a list of all browser instances.- Specified by:
getAllBrowser
in classCefClientHandler
- Returns:
- an array of browser Instances.
-
getContextMenuHandler
protected CefContextMenuHandler getContextMenuHandler()
Description copied from class:CefClientHandler
Return the handler for context menus. If no handler is provided the default implementation will be used.- Specified by:
getContextMenuHandler
in classCefClientHandler
-
getDialogHandler
protected CefDialogHandler getDialogHandler()
Description copied from class:CefClientHandler
Return the handler for dialogs. If no handler is provided the default implementation will be used.- Specified by:
getDialogHandler
in classCefClientHandler
-
getDisplayHandler
protected CefDisplayHandler getDisplayHandler()
Description copied from class:CefClientHandler
Return the handler for browser display state events. This method is a callback method and is called by the native code.- Specified by:
getDisplayHandler
in classCefClientHandler
-
getDownloadHandler
protected CefDownloadHandler getDownloadHandler()
Description copied from class:CefClientHandler
Return the handler for download events. This method is a callback method and is called by the native code.- Specified by:
getDownloadHandler
in classCefClientHandler
-
getDragHandler
protected CefDragHandler getDragHandler()
Description copied from class:CefClientHandler
Return the handler for drag events. This method is a callback method and is called by the native code.- Specified by:
getDragHandler
in classCefClientHandler
-
getFocusHandler
protected CefFocusHandler getFocusHandler()
Description copied from class:CefClientHandler
Return the handler for focus events. This method is a callback method and is called by the native code.- Specified by:
getFocusHandler
in classCefClientHandler
-
getJSDialogHandler
protected CefJSDialogHandler getJSDialogHandler()
Description copied from class:CefClientHandler
Return the handler for javascript dialog requests. This method is a callback method and is called by the native code.- Specified by:
getJSDialogHandler
in classCefClientHandler
-
getKeyboardHandler
protected CefKeyboardHandler getKeyboardHandler()
Description copied from class:CefClientHandler
Return the handler for keyboard events. This method is a callback method and is called by the native code.- Specified by:
getKeyboardHandler
in classCefClientHandler
-
getLifeSpanHandler
protected CefLifeSpanHandler getLifeSpanHandler()
Description copied from class:CefClientHandler
Return the handler for browser life span events. This method is a callback method and is called by the native code.- Specified by:
getLifeSpanHandler
in classCefClientHandler
-
getLoadHandler
protected CefLoadHandler getLoadHandler()
Description copied from class:CefClientHandler
Return the handler for browser load status events. This method is a callback method and is called by the native code.- Specified by:
getLoadHandler
in classCefClientHandler
-
getRenderHandler
protected CefRenderHandler getRenderHandler()
Description copied from class:CefClientHandler
Return the handler for off-screen rendering events. This method is a callback method and is called by the native code.- Specified by:
getRenderHandler
in classCefClientHandler
-
getRequestHandler
protected CefRequestHandler getRequestHandler()
Description copied from class:CefClientHandler
Return the handler for browser request events. This method is a callback method and is called by the native code.- Specified by:
getRequestHandler
in classCefClientHandler
-
getWindowHandler
protected CefWindowHandler getWindowHandler()
Description copied from class:CefClientHandler
Return the handler for windowed rendering events. This method is a callback method and is called by the native code.- Specified by:
getWindowHandler
in 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:CefContextMenuHandler
Called before a context menu is displayed.- Specified by:
onBeforeContextMenu
in 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:CefContextMenuHandler
Called 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:
onContextMenuCommand
in 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:CefContextMenuHandler
Called when the context menu is dismissed irregardless of whether the menu was empty or a command was selected.- Specified by:
onContextMenuDismissed
in 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:CefDialogHandler
Called to run a file chooser dialog.- Specified by:
onFileDialog
in interfaceCefDialogHandler
mode
- 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:CefDisplayHandler
Handle address changes.- Specified by:
onAddressChange
in 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:CefDisplayHandler
Handle title changes.- Specified by:
onTitleChange
in 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:CefDisplayHandler
Called when the browser is about to display a tooltip.- Specified by:
onTooltip
in 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:CefDisplayHandler
Called when the browser receives a status message.- Specified by:
onStatusMessage
in 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:CefDisplayHandler
Called to display a console message.- Specified by:
onConsoleMessage
in 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:CefDownloadHandler
Called 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:
onBeforeDownload
in 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:CefDownloadHandler
Called when a download's status or progress information has been updated.- Specified by:
onDownloadUpdated
in 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:CefDragHandler
Called when an external drag event enters the browser window.- Specified by:
onDragEnter
in 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:CefFocusHandler
Called 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:
onTakeFocus
in 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:CefFocusHandler
Called when the browser component is requesting focus.- Specified by:
onSetFocus
in 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:CefFocusHandler
Called when the browser component has received focus.- Specified by:
onGotFocus
in 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:CefJSDialogHandler
Called 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:
onJSDialog
in 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:CefJSDialogHandler
Called 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:
onBeforeUnloadDialog
in 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:CefJSDialogHandler
Called 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:
onResetDialogState
in interfaceCefJSDialogHandler
-
onDialogClosed
public void onDialogClosed(CefBrowser browser)
Description copied from interface:CefJSDialogHandler
Called when the default implementation dialog is closed.- Specified by:
onDialogClosed
in 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:CefKeyboardHandler
Called before a keyboard event is sent to the renderer.- Specified by:
onPreKeyEvent
in 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:CefKeyboardHandler
Called after the renderer and JavaScript in the page has had a chance to handle the event.- Specified by:
onKeyEvent
in 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:CefLifeSpanHandler
Called on the IO thread before a new popup window is created.- Specified by:
onBeforePopup
in 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:CefLifeSpanHandler
Handle creation of a new browser window.- Specified by:
onAfterCreated
in interfaceCefLifeSpanHandler
- Parameters:
browser
- The browser generating the event.
-
onAfterParentChanged
public void onAfterParentChanged(CefBrowser browser)
Description copied from interface:CefLifeSpanHandler
Called after a browser's native parent window has changed.- Specified by:
onAfterParentChanged
in interfaceCefLifeSpanHandler
- Parameters:
browser
- The browser generating the event.
-
doClose
public boolean doClose(CefBrowser browser)
Description copied from interface:CefLifeSpanHandler
Called 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:
doClose
in 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:CefLifeSpanHandler
Called 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:
onBeforeClose
in 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:CefLoadHandler
Called 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:
onLoadingStateChange
in 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:CefLoadHandler
Called 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:
onLoadStart
in 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:CefLoadHandler
Called 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:
onLoadEnd
in 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:CefLoadHandler
Called when the resource load for a navigation fails or is canceled.- Specified by:
onLoadError
in 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:
addMessageRouter
in classCefClientHandler
-
removeMessageRouter
public void removeMessageRouter(CefMessageRouter messageRouter)
- Overrides:
removeMessageRouter
in classCefClientHandler
-
getViewRect
public java.awt.Rectangle getViewRect(CefBrowser browser)
Description copied from interface:CefRenderHandler
Retrieve the view rectangle.- Specified by:
getViewRect
in 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:CefRenderHandler
Retrieve the screen point for the specified view point.- Specified by:
getScreenPoint
in 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:CefRenderHandler
Show or hide the popup window.- Specified by:
onPopupShow
in 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:CefRenderHandler
Size the popup window.- Specified by:
onPopupSize
in 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:CefRenderHandler
Handle painting.- Specified by:
onPaint
in 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:CefRenderHandler
Handle cursor changes.- Specified by:
onCursorChange
in 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:CefRenderHandler
Called 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:
startDragging
in 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:CefRenderHandler
Called when the web view wants to update the mouse cursor during a drag & drop operation.- Specified by:
updateDragCursor
in 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:CefRequestHandler
Called 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:
onBeforeBrowse
in 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:CefRequestHandler
Called 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:
getResourceRequestHandler
in 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:CefRequestHandler
Called on the IO thread when the browser needs credentials from the user.- Specified by:
getAuthCredentials
in 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:CefRequestHandler
Called on the IO thread when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota function.- Specified by:
onQuotaRequest
in 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:CefRequestHandler
Called 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:
onCertificateError
in 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:CefRequestHandler
Called on the browser process UI thread when a plugin has crashed.- Specified by:
onPluginCrashed
in 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:CefRequestHandler
Called on the browser process UI thread when the render process terminates unexpectedly.- Specified by:
onRenderProcessTerminated
in 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:CefWindowHandler
Retrieve the view rectangle.- Specified by:
getRect
in 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:CefWindowHandler
Implement 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:
onMouseEvent
in 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:CefRenderHandler
Retrieve the screen info.- Specified by:
getScreenInfo
in interfaceCefRenderHandler
- Parameters:
arg0
- The browser generating the event.arg1
- The screenInfo- Returns:
- True if this callback was handled. False to fallback to defaults.
-
-