Class CefriumContentServers

java.lang.Object
com.cefrium.CefriumContentServers

public final class CefriumContentServers extends Object
Ready-made CefriumContentServers for the app's assets, files and resources, and the MIME types they use. Combine them under path prefixes with CefriumPathContentServer.

Each serves index.html for a path that ends in /, gives 404 for anything missing, and refuses a path that leaves its directory (..).

  • Field Details

    • WEBVIEW_ASSET_LOADER_ORIGIN

      public static final String WEBVIEW_ASSET_LOADER_ORIGIN
      The origin androidx.webkit.WebViewAssetLoader uses by default. Register it to keep a migrating app's URLs, and so its pages' storage origin, unchanged in form; the data itself does not move from WebView.
      See Also:
  • Method Details

    • assets

      public static CefriumContentServer assets(android.content.Context context, String directory)
      Serves assets/<directory>: /index.html is assets/<directory>/index.html. Pass "" for the whole assets folder.

      Range requests need the length, which Android gives only for assets stored uncompressed: list the extensions in the app's androidResources { noCompress += [...] } (media types are uncompressed by default).

    • files

      public static CefriumContentServer files(File directory)
      Serves a directory of files, e.g. context.getFilesDir() or a downloaded game: /a/b.png is <directory>/a/b.png.
    • resources

      public static CefriumContentServer resources(android.content.Context context)
      Serves the app's resources as /<type>/<name>.<ext>: for example /raw/intro.mp4 is R.raw.intro, /drawable/logo.png R.drawable.logo. The counterpart of WebViewAssetLoader's ResourcesPathHandler.
    • mimeTypeOf

      public static String mimeTypeOf(String path)
      The MIME type for a file name or path, by its extension: application/octet-stream when unknown.