Class CefAppHandlerAdapter

  • All Implemented Interfaces:
    CefAppHandler
    Direct Known Subclasses:
    CefApp

    public abstract class CefAppHandlerAdapter
    extends java.lang.Object
    implements CefAppHandler
    An abstract adapter class for managing app handler events. The methods in this class are using a default implementation. This class exists as convenience for creating handler objects.
    • Constructor Summary

      Constructors 
      Constructor Description
      CefAppHandlerAdapter​(java.lang.String[] args)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean onAlreadyRunningAppRelaunch​(CefCommandLine command_line, java.lang.String current_directory)
      Implement this method to provide app-specific behavior when an already running app is relaunched with the same CefSettings.root_cache_path value.
      void onBeforeCommandLineProcessing​(java.lang.String process_type, CefCommandLine command_line)
      Provides an opportunity to view and/or modify command-line arguments before processing by CEF and Chromium.
      boolean onBeforeTerminate()
      Provides an opportunity to hook into the native shutdown process.
      void onContextInitialized()
      Called on the browser process UI thread immediately after the CEF context has been initialized.
      void onRegisterCustomSchemes​(CefSchemeRegistrar registrar)
      Provides an opportunity to register custom schemes.
      void onScheduleMessagePumpWork​(long delay_ms)
      Called from any thread when work has been scheduled for the browser process main (UI) thread.
      void stateHasChanged​(CefApp.CefAppState state)
      Implement this method to get state changes of the CefApp.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CefAppHandlerAdapter

        public CefAppHandlerAdapter​(java.lang.String[] args)
    • Method Detail

      • onBeforeCommandLineProcessing

        public void onBeforeCommandLineProcessing​(java.lang.String process_type,
                                                  CefCommandLine command_line)
        Description copied from interface: CefAppHandler
        Provides an opportunity to view and/or modify command-line arguments before processing by CEF and Chromium. The |process_type| value will be empty for the browser process. Be cautious when using this method to modify command-line arguments for non-browser processes as this may result in undefined behavior including crashes.
        Specified by:
        onBeforeCommandLineProcessing in interface CefAppHandler
        Parameters:
        process_type - type of process (empty for browser process).
        command_line - values of the command line.
      • onBeforeTerminate

        public boolean onBeforeTerminate()
        Description copied from interface: CefAppHandler
        Provides an opportunity to hook into the native shutdown process. This method is invoked if the user tries to terminate the app by sending the corresponding key code (e.g. on Mac: CMD+Q) or something similar. If you want to proceed with the default behavior of the native system, return false. If you want to abort the terminate or if you want to implement your own shutdown sequence return true and do the cleanup on your own.
        Specified by:
        onBeforeTerminate in interface CefAppHandler
        Returns:
        false to proceed with the default behavior, true to abort terminate.
      • stateHasChanged

        public void stateHasChanged​(CefApp.CefAppState state)
        Description copied from interface: CefAppHandler
        Implement this method to get state changes of the CefApp. See CefApp.CefAppState for a complete list of possible states. For example, this method can be used e.g. to get informed if CefApp has completed its initialization or its shutdown process.
        Specified by:
        stateHasChanged in interface CefAppHandler
        Parameters:
        state - The current state of CefApp.
      • onRegisterCustomSchemes

        public void onRegisterCustomSchemes​(CefSchemeRegistrar registrar)
        Description copied from interface: CefAppHandler
        Provides an opportunity to register custom schemes. Do not keep a reference to the |registrar| object. This method is called on the main thread for each process and the registered schemes should be the same across all processes.
        Specified by:
        onRegisterCustomSchemes in interface CefAppHandler
      • onContextInitialized

        public void onContextInitialized()
        Description copied from interface: CefAppHandler
        Called on the browser process UI thread immediately after the CEF context has been initialized.
        Specified by:
        onContextInitialized in interface CefAppHandler
      • onScheduleMessagePumpWork

        public void onScheduleMessagePumpWork​(long delay_ms)
        Description copied from interface: CefAppHandler
        Called from any thread when work has been scheduled for the browser process main (UI) thread. This callback should schedule a CefApp.DoMessageLoopWork() call to happen on the main (UI) thread. |delay_ms| is the requested delay in milliseconds. If |delay_ms| is <= 0 then the call should happen reasonably soon. If |delay_ms| is > 0 then the call should be scheduled to happen after the specified delay and any currently pending scheduled call should be cancelled.
        Specified by:
        onScheduleMessagePumpWork in interface CefAppHandler
      • onAlreadyRunningAppRelaunch

        public boolean onAlreadyRunningAppRelaunch​(CefCommandLine command_line,
                                                   java.lang.String current_directory)
        Description copied from interface: CefAppHandler
        Implement this method to provide app-specific behavior when an already running app is relaunched with the same CefSettings.root_cache_path value. For example, activate an existing app window or create a new app window. |command_line| will be read-only. Do not keep a reference to |command_line| outside of this method. Return true if the relaunch is handled or false for default relaunch behavior. Default behavior will create a new default styled Chrome window. To avoid cache corruption only a single app instance is allowed to run for a given CefSettings.root_cache_path value. On relaunch the app checks a process singleton lock and then forwards the new launch arguments to the already running app process before exiting early. Client apps should therefore check the CefInitialize() return value for early exit before proceeding.
        Specified by:
        onAlreadyRunningAppRelaunch in interface CefAppHandler