CEF Installer Library Documentation

repository·master·Indexed 26 days ago

https://github.com/chromiumembedded/cef

Documentation for the CEF Installer Library, a system for automatic CEF version management. Includes guides on integrating the library into clients, configuring installer_config.json, using command-line flags for updates and uninstallation, and utilizing the RunInstaller API for background updates and launch health confirmation.

Tokens
115.2K
Snippets
227
Records
484
Agent score
89%

What's inside CEF Installer Library

  1. Overview of the C++ Rewriter Tool

    master

    The C++ Rewriter Tool is a clang-based AST rewriter designed for C++20 modernization. It performs type-aware code transformations that go beyond simple regex, such as converting map.find(x) != map.end() to map.contains(x).

    It is distributed as a self-contained package including:

    • bin/cpp_rewriter: The core rewriter tool.
    • lib/clang/<version>/: Bundled clang headers to ensure compatibility without requiring a matching system clang.
    • scripts/: Python wrapper scripts (run_rewriter.py, apply_edits.py, process_edits.py) for executing and applying transformations.
  2. Overview of cef_cpp_rewriter

    master

    The cef_cpp_rewriter is a clang AST-based tool designed to automate C++20 modernization for CEF code. It performs several specific transformations to modernize the codebase.

    Supported transformations:

    • .contains() for associative containers
    • Structured bindings for range-for loops
    • Iterator loops to range-for
    • DISALLOW_COPY_AND_ASSIGN replacement

    For a complete list of transformations, command-line flags, and examples, refer to TRANSFORMS.md.

  3. Understand the CEF macOS Distribution Contents

    master

    The macOS distribution of CEF contains the following key components:

    • include: All required CEF header files.
    • libcef_dll: Source code for the libcef_dll_wrapper static library. All applications using the CEF C++ API must link against this library.
    • Release: Contains Chromium Embedded Framework.framework and other components required to run the release version of CEF-based applications.
    • cmake: CMake configuration files shared by all targets.
    • bazel: Bazel configuration files shared by all targets.
  4. Understand the CEF Binary Distribution structure

    master

    A standard CEF binary distribution contains the following key components:

    • include/: CEF header files (cef_*.h for C++ and capi/ for C API).
    • libcef_dll/: C++ wrapper implementation.
    • Release/ or Debug/: Build artifacts containing the main library (libcef.so/.dylib/.dll), binary data files (*.bin), and other required files.
    • Resources/: Resource files (e.g., *.pak).
    • tests/: Example applications including cefsimple (C++), cefsimple_capi (C), cefclient (comprehensive), and ceftests (unit tests).
  5. Quick Start for libcef development

    master

    When working with the libcef codebase (the implementation layer between Chromium and the CEF public API), common tasks include:

    • Adding new APIs: Exposing new functionality to CEF clients.
    • Implementing handlers: Creating implementations for WebContentsDelegate and other Chromium delegates.
    • Fixing bugs: Debugging and fixing issues within the CEF implementation layer.
    • Updating for Chromium changes: Adapting CEF to accommodate upstream Chromium API changes.
  6. Understand the CEF Architecture Overview

    master

    A basic CEF application using the Views framework consists of several key components:

    • SimpleApp (Application-level handler): Created when CEF initializes. It manages the browser and window creation using the Views framework.
    • SimpleHandler (Browser-level event handler): Manages browser lifecycle events (e.g., OnBeforeClose). It typically implements a singleton pattern to be accessible by platform entry points.
    • Views Framework Delegates:
      • SimpleWindowDelegate: Controls window properties like size, close behavior, and runtime style.
      • SimpleBrowserViewDelegate: Specifies the browser's runtime style (e.g., Alloy).
    • Platform Entry Point Methods: Methods like GetInstance(), CloseAllBrowsers(), IsClosing(), and ShowMainWindow() are used by platform-specific code (like macOS dock interactions) to communicate with the application instance.
  7. Understand CEF3 Architecture and Runtimes

    master

    CEF3 is the current recommended version of CEF. It uses a multi-process architecture similar to the Chromium browser. It supports two main runtimes:

    1. Alloy Runtime: Based on the Chromium 'content' layer. Note that starting with M128 (mid-2024), the Alloy bootstrap has been removed. Alloy style is now supported using the Chrome runtime bootstrap.
    2. Chrome Runtime: Based on the 'chrome' layer. It includes advanced features like extensions, gamepad, webhid, and webmidi, along with standard Chrome UI toolbars and dialogs. The Chrome runtime requires the use of the Views framework and does not support off-screen rendering.

    For detailed instructions on process and threading models, refer to the General Usage guide.

  8. Understand the CEF Installer Security Model

    master

    The CEF Installer uses a security model based on durable registration identity and integrity-valid launch evidence. It does not infer ownership from executable paths or ACLs.

    Key Security Principles:

    • Registration: Only source-derived per-user-default and custom install_path stores are eligible. HKLM and Program Files roles are considered provisioning-owned and are ineligible for user-level registration.
    • Fail-Closed Design: Missing, malformed, non-canonical, mismatched, zero, or future-dated evidence results in a 'fail closed' state (unknown/protected).
    • Integrity: Cleanup processes use exact, same-file-object comparisons to prevent symlink or junction redirection attacks during deletion.
  9. Understand CEF Multi-Process Architecture and Threading

    master

    CEF utilizes a multi-process architecture:

    • Browser process: Main process handling UI, navigation, and coordination.
    • Renderer process: Handles web content (isolated/sandboxed).
    • GPU process: Handles graphics acceleration.
    • Other processes: Network service, audio service, etc.

    Threading Model:

    • TID_UI: Browser process main thread.
    • TID_IO: Network operations.
    • TID_RENDERER: Renderer process main thread (JavaScript execution).

    Thread Safety: Use assertions to ensure code runs on the correct thread:

    • CEF_REQUIRE_UI_THREAD()
    • CEF_REQUIRE_RENDERER_THREAD()

    To post tasks across threads, use CefPostTask:

    #include "include/base/cef_callback.h"
    #include "include/wrapper/cef_closure_task.h"
    
    CefPostTask(TID_UI, base::BindOnce(&MyClass::MyMethod, this, arg));
  10. Understand the CEF Application Architecture

    master

    A basic CEF application consists of three primary components:

    1. SimpleApp (Application-level handler): Inherits from CefApp and CefBrowserProcessHandler. It handles OnContextInitialized(), which is called when CEF is ready to create browsers. This is where you typically create the browser and window using the Views framework.
    2. SimpleHandler (Browser-level event handler): Inherits from CefClient and CefLifeSpanHandler. It manages browser lifecycle events via GetLifeSpanHandler() and OnBeforeClose().
    3. Views Framework Delegates: Cross-platform delegates like SimpleWindowDelegate (controls window size, close behavior, style) and SimpleBrowserViewDelegate (specifies browser style).

    Execution Flow:

    1. main() starts.
    2. CefInitialize() initializes CEF with a CefApp instance.
    3. SimpleApp::OnContextInitialized() is triggered, creating the SimpleHandler, CefBrowserView, and CefWindow.
    4. CefRunMessageLoop() enters the event loop.
    5. User closes window $\rightarrow$ SimpleWindowDelegate::CanClose() $\rightarrow$ TryCloseBrowser().
    6. SimpleHandler::OnBeforeClose() is called $\rightarrow$ CefQuitMessageLoop() is called.
    7. CefShutdown() cleans up CEF.
    8. main() exits.
  11. Understand host architecture requirements for CEF tools

    master

    CEF/Chromium builds are tied to specific host architectures. You must run the tools binaries on the supported host OS/architecture, even if your target application is for a different architecture.

    Supported host architectures:

    • Linux: x86-64 (Intel/AMD)
    • Windows: x86-64 (Intel/AMD)
    • MacOS: ARM64 (Apple Silicon)

    Example: To create files for a MacOS 64-bit (Intel) application, you must use the MacOS 64-bit (Intel) tools distribution running on a MacOS ARM64 (Apple Silicon) host system.