Package com.cefrium

Class Cefrium

java.lang.Object
com.cefrium.Cefrium

public final class Cefrium extends Object
Entry point for the Cefrium SDK. Initialize once before creating browsers.

User-Agent

Cefrium identifies itself as Chrome (because it IS Chromium) with a Cefrium product token appended:

 Mozilla/5.0 (Linux; Android ...) AppleWebKit/537.36 (KHTML, like Gecko)
     Chrome/149.0.7827.102 Cefrium/1.0 Mobile Safari/537.36
 

This ensures full site compatibility while transparently identifying the client. The User-Agent is configured via CefSettings.user_agent_product in the native layer. To customize it, use the --user-agent-product command-line switch before calling initialize():

 // Custom product string (replaces the default):
 CommandLine.getInstance().appendSwitchWithValue(
     "user-agent-product",
     "Chrome/149.0.7827.102 MyApp/2.0 Mobile");
 Cefrium.initialize(context);
 

Basic usage

No setup is required: the SDK's CefriumInitProvider performs the per-process plumbing at app launch, and the engine initializes lazily the first time a browser is created. Just create one:

 CefriumBrowser browser = CefriumBrowser.createWithSurface(activity);
 browser.loadUrl("https://example.com");

 // When done:
 Cefrium.shutdown();
 

Advanced: to control init timing (e.g. to pass command-line switches before native init) call initialize(Context) yourself before the first browser. It is idempotent and self-sufficient — no custom Application needed.

  • Field Details

  • Method Details

    • setupProcess

      public static void setupProcess(android.content.Context context)
      Run the per-process Chromium setup the browser process needs before native init. Idempotent and safe to call from any process: it is a no-op in Chromium child processes (sandboxed renderer/GPU/utility), which self-init via ChildProcessService. The SDK's CefriumInitProvider calls this automatically at app launch, and initialize(Context) calls it too, so consumers normally never call it directly.
      Parameters:
      context - Any context (its application context is used).
    • initialize

      public static boolean initialize()
      Initialize the Cefrium engine using the application context captured during per-process setup. Equivalent to initialize(Context) but for callers that have no Context handy (e.g. off-screen browser creation). Requires that setupProcess(Context) has run — which the SDK's CefriumInitProvider guarantees at app launch.
      Returns:
      true if initialization succeeded.
    • initialize

      public static boolean initialize(android.content.Context context)
      Initialize the Cefrium engine. Safe to call more than once (idempotent) and self-sufficient: it runs setupProcess(Context) itself, so no Application boilerplate is required. Must be called on the main thread (the SDK does this lazily on first browser creation).
      Parameters:
      context - Application context.
      Returns:
      true if initialization succeeded.
    • shutdown

      public static void shutdown()
      Shut down the Cefrium engine. Call when the app is finishing. After this call, no Cefrium APIs may be used.
    • isInitialized

      public static boolean isInitialized()
      Returns:
      true if Cefrium has been initialized.
    • getVersion

      public static String getVersion()
      Returns:
      the Cefrium SDK version, e.g. "0.5.0".
    • getChromiumVersion

      public static String getChromiumVersion()
      Returns:
      the bundled Chromium engine version, e.g. "149.0.7827.102".
    • loadAdBlockList

      public static int loadAdBlockList(String path)
      Load ad-blocking filter rules from an EasyList-format file. Can be called multiple times to load additional lists.
      Parameters:
      path - Absolute path to the filter list file.
      Returns:
      Number of rules loaded.
    • downloadAndLoadEasyList

      public static void downloadAndLoadEasyList(android.content.Context context)
      Download and load EasyList from the internet. Call from a background thread — performs network I/O.
      Parameters:
      context - Application context for file storage.