CEF4Delphi

repository·master·Indexed 23 days ago

https://github.com/salvadordf/cef4delphi

An open source project to embed Chromium-based web browsers into Delphi and Lazarus/FPC applications. It supports Windows, Linux, and macOS, providing components for VCL, FireMonkey (FMX), and Lazarus. The current version uses CEF 151.3.14 (Chromium 151.0.7922.72). It includes specialized tools like TCEFWorkScheduler for managing the CEF message loop, particularly on macOS.

Tokens
3.4K
Snippets
2
Records
27
Agent score
74%

What's inside CEF4Delphi

  1. Overview of CEF4Delphi

    master

    CEF4Delphi is an open source project designed to embed Chromium-based browsers into applications developed with Delphi or Lazarus/FPC. It supports multiple platforms including Windows, Linux, and MacOS.

    Key features include:

    • Support for VCL, FireMonkey (FMX), and Lazarus components.
    • Based on DCEF3 and fpCEF3.
    • Current version uses CEF 151.3.14 (Chromium 151.0.7922.72).
  2. How TCEFWorkScheduler and TCEFLinkedWindowParent work together

    master

    This pattern is used to manage the CEF message loop, specifically for environments like macOS where manual message loop pumping is required.

    • TCEFWorkScheduler is responsible for feeding the CEF message loop by calling DoMessageLoopWork().
    • TCEFLinkedWindowParent is used in conjunction with the scheduler to handle window parenting/linking.

    On macOS, using TCEFWorkScheduler to call DoMessageLoopWork() is currently the only way to run the CEF message loop.

  3. Setup CEF4Delphi on Linux

    master

    To run a project using CEF4Delphi on Linux, follow these steps:

    1. Download the CEF framework.
    2. Place the contents of the CEF "Release" folder into the same directory as your application executable. Alternatively, you can point GlobalCEFApp.FrameworkDirPath to the location of the libraries.

    Important Implementation Requirements for Linux:

    • Subprocess Initialization: You must modify your project source (.lpr) to add InitSubProcess to the uses clause. This must be placed before the Interfaces unit.
    • Cleanup: The call to DestroyGlobalCEFApp must be located in a unit that is not used by the InitSubProcess unit (including any nested dependencies).
  4. Download CEF Binaries for CEF4Delphi

    master

    To use CEF4Delphi, you must download the corresponding CEF binaries from Spotify. Ensure you select the version that matches your target platform and architecture:

    • Windows 32 bits
    • Windows 64 bits
    • Linux x86 64 bits
    • Linux ARM 32 bits
    • Linux ARM 64 bits
    • MacOS x86 64 bits
  5. Setup CEF4Delphi on Windows

    master

    To run a project using CEF4Delphi on Windows, you must provide the CEF framework binaries:

    1. Download the CEF framework.
    2. Place the contents of the CEF "Release" folder into the same directory as your application executable.

    Alternatively, you can configure the application to look in a specific location by setting the GlobalCEFApp.FrameworkDirPath property to the path containing the libraries.

  6. Configure macOS application entitlements and dock behavior

    master

    When developing for macOS, you may need to perform the following configurations:

    1. Network Access: Sign your application with an Outgoing network socket entitlement in the helpers to ensure network connectivity.
    2. Hide Helpers from Dock: To prevent helper processes from appearing in the macOS Dock, set LSUIElement=1 in the application's info.plist.
  7. Set up CEF framework for macOS

    master

    Setting up a macOS application requires creating an App Bundle and placing the framework in a specific location:

    1. In your project options, create an App Bundle.
    2. Download the CEF framework and place the contents of the CEF "Release" folder into: ExternalPumpBrowser.app/Contents/Frameworks/Chromium Embedded Framework.framework. The directory structure should contain:
      • Chromium Embedded Framework
      • Libraries/*
      • Resources/*
    3. Open the AppHelper project, create an App Bundle, and compile AppHelper.
    4. Run the create_mac_helper.sh script.
    5. Open the ExternalPumpBrowser project, compile, and run.