Package org.cef.handler
Interface CefRequestHandler
-
- All Known Implementing Classes:
CefClient,CefRequestHandlerAdapter
public interface CefRequestHandlerImplement this interface to handle events related to browser requests. The methods of this class will be called on the thread indicated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classCefRequestHandler.TerminationStatusProcess termination status values.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description 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.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.booleanonBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect)Called on the UI thread before browser navigation.booleanonCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_error, java.lang.String request_url, CefCallback callback)Called on the UI thread to handle requests for URLs with an invalid SSL certificate.booleanonOpenURLFromTab(CefBrowser browser, CefFrame frame, java.lang.String target_url, boolean user_gesture)Called on the UI thread before OnBeforeBrowse in certain limited cases where navigating a new or different browser might be desirable.voidonRenderProcessTerminated(CefBrowser browser, CefRequestHandler.TerminationStatus status, int error_code, java.lang.String error_string)Called on the browser process UI thread when the render process terminates unexpectedly.
-
-
-
Method Detail
-
onBeforeBrowse
boolean onBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, boolean user_gesture, boolean is_redirect)
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.- 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.
-
onOpenURLFromTab
boolean onOpenURLFromTab(CefBrowser browser, CefFrame frame, java.lang.String target_url, boolean user_gesture)
Called on the UI thread before OnBeforeBrowse in certain limited cases where navigating a new or different browser might be desirable. This includes user-initiated navigation that might open in a special way (e.g. links clicked via middle-click or ctrl + left-click) and certain types of cross-origin navigation initiated from the renderer process (e.g. navigating the top-level frame to/from a file URL).- Parameters:
browser- The corresponding browser.frame- The frame generating the event. Instance only valid within the scope of this methoduser_gesture- True if the request was initiated by a user gesture.- Returns:
- True to cancel navigation or false to continue
-
getResourceRequestHandler
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. 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.- 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
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.- 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.
-
onCertificateError
boolean onCertificateError(CefBrowser browser, CefLoadHandler.ErrorCode cert_error, java.lang.String request_url, CefCallback callback)
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.- Parameters:
browser- The corresponding browser.cert_error- Error code describing the error.request_url- The requesting URL.callback- Call CefCallback.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.
-
onRenderProcessTerminated
void onRenderProcessTerminated(CefBrowser browser, CefRequestHandler.TerminationStatus status, int error_code, java.lang.String error_string)
Called on the browser process UI thread when the render process terminates unexpectedly.- Parameters:
browser- The corresponding browser.status- Indicates how the process was terminated.error_code- The process error code.error_string- A string description of the error.
-
-