cef
Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
Top Related Projects
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
JavaScript API for Chrome and Firefox
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
Quick Overview
The Chromium Embedded Framework (CEF) is an open-source project that enables developers to embed the Chromium web browser into their applications. It provides a framework for creating desktop applications with web-based user interfaces, combining the power of web technologies with native application capabilities.
Pros
- Cross-platform compatibility (Windows, macOS, Linux)
- Rich set of features inherited from Chromium, including modern web standards support
- Extensive API for integrating web content with native applications
- Active community and regular updates
Cons
- Large binary size due to bundling Chromium
- Steep learning curve for developers new to the framework
- Resource-intensive, especially for smaller applications
- Complexity in building and distributing applications
Code Examples
- Basic application setup:
#include <cef_app.h>
#include <cef_client.h>
class SimpleApp : public CefApp, public CefBrowserProcessHandler {
public:
SimpleApp() {}
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler() override { return this; }
virtual void OnContextInitialized() override {
// Create browser window
}
IMPLEMENT_REFCOUNTING(SimpleApp);
};
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
CefRefPtr<SimpleApp> app(new SimpleApp);
return CefExecuteProcess(main_args, app.get(), nullptr);
}
- Loading a URL:
CefBrowserSettings browser_settings;
CefWindowInfo window_info;
window_info.SetAsPopup(nullptr, "CEF Example");
CefRefPtr<CefClient> client(new SimpleClient);
CefBrowserHost::CreateBrowser(window_info, client, "https://www.example.com", browser_settings, nullptr, nullptr);
- Executing JavaScript:
CefRefPtr<CefFrame> frame = browser->GetMainFrame();
frame->ExecuteJavaScript("alert('Hello from CEF!');", frame->GetURL(), 0);
Getting Started
- Download CEF binary distribution for your platform from the official website.
- Set up your development environment (Visual Studio for Windows, Xcode for macOS, or GCC for Linux).
- Include CEF headers and link against CEF libraries in your project.
- Implement a basic application structure (see code example 1).
- Build and run your application.
For detailed instructions, refer to the CEF project documentation and wiki on GitHub.
Competitor Comparisons
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Pros of Electron
- Easier to develop with, using familiar web technologies (HTML, CSS, JavaScript)
- Built-in support for automatic updates and crash reporting
- Larger community and ecosystem with more resources and third-party packages
Cons of Electron
- Larger application size due to bundling Chromium and Node.js
- Higher memory usage compared to native applications
- Less flexibility in terms of low-level customization and integration
Code Comparison
CEF (C++):
#include <cef_app.h>
class SimpleApp : public CefApp {
// Implement required methods
};
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
return CefExecuteProcess(main_args, nullptr, nullptr);
}
Electron (JavaScript):
const { app, BrowserWindow } = require('electron')
function createWindow () {
const win = new BrowserWindow({ width: 800, height: 600 })
win.loadFile('index.html')
}
app.whenReady().then(createWindow)
Both CEF and Electron allow developers to create desktop applications using web technologies, but they differ in their approach and target audience. CEF provides more fine-grained control and is better suited for integrating web content into existing applications, while Electron offers a more streamlined development experience for building standalone applications with web technologies.
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Pros of Playwright
- Cross-browser support (Chromium, Firefox, WebKit) out of the box
- Modern, async/await-based API for easier test scripting
- Built-in test runner and assertion library
Cons of Playwright
- Limited to testing and automation scenarios
- Newer project with potentially less stability and community support
Code Comparison
Playwright:
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await browser.close();
})();
CEF:
#include <cef_app.h>
#include <cef_client.h>
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
CefSettings settings;
CefInitialize(main_args, settings, nullptr, nullptr);
CefRunMessageLoop();
CefShutdown();
return 0;
}
Summary
Playwright focuses on browser automation and testing, offering a user-friendly API and cross-browser support. CEF, on the other hand, provides a more comprehensive solution for embedding web content in desktop applications, with greater flexibility but a steeper learning curve. Choose Playwright for web testing and automation tasks, and CEF for building web-based desktop applications or integrating web content into existing software.
JavaScript API for Chrome and Firefox
Pros of Puppeteer
- Higher-level API, making it easier to automate browser interactions
- Built-in support for headless Chrome/Chromium, simplifying setup
- Better suited for web scraping and testing modern web applications
Cons of Puppeteer
- Limited to Chrome/Chromium, lacking cross-browser support
- Less control over low-level browser functionality
- Not suitable for embedding a browser in desktop applications
Code Comparison
Puppeteer:
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'screenshot.png'});
await browser.close();
CEF:
CefRefPtr<SimpleHandler> handler(new SimpleHandler());
CefMainArgs main_args(hInstance);
CefSettings settings;
CefInitialize(main_args, settings, handler.get(), nullptr);
CefRunMessageLoop();
CefShutdown();
Key Differences
- Puppeteer is JavaScript-based, while CEF uses C++
- Puppeteer focuses on automation and testing, CEF on embedding browsers
- CEF offers more flexibility for custom browser implementations
- Puppeteer provides a simpler API for common web automation tasks
- CEF is better suited for desktop applications requiring embedded web content
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Pros of Tauri
- Smaller application size due to using native OS webviews
- Better performance and lower resource usage
- Cross-platform development with Rust and web technologies
Cons of Tauri
- Less mature ecosystem compared to CEF
- Limited to web technologies for UI development
- Potential compatibility issues with some web APIs
Code Comparison
Tauri (Rust):
#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
CEF (C++):
#include <cef_app.h>
class SimpleApp : public CefApp {
public:
SimpleApp() {}
};
int main(int argc, char* argv[]) {
CefMainArgs main_args(argc, argv);
CefRefPtr<SimpleApp> app(new SimpleApp);
return CefExecuteProcess(main_args, app.get(), nullptr);
}
Both frameworks allow developers to create desktop applications using web technologies, but they differ in their approach and implementation. Tauri uses Rust and native OS webviews, resulting in smaller, more efficient applications. CEF, based on Chromium, offers a more mature ecosystem and broader web compatibility at the cost of larger application size and higher resource usage.
Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
Pros of NW.js
- Easier to develop desktop applications using web technologies
- Direct access to Node.js APIs and npm packages
- Simpler packaging and distribution process
Cons of NW.js
- Larger application size due to bundled Node.js runtime
- Less fine-grained control over the browser engine
- Limited support for some advanced Chromium features
Code Comparison
NW.js:
const gui = require('nw.gui');
const win = gui.Window.get();
win.maximize();
CEF:
#include <cef_app.h>
CefBrowserSettings settings;
CefWindowInfo window_info;
CefBrowserHost::CreateBrowser(window_info, client, url, settings, nullptr);
Key Differences
- NW.js allows developers to use Node.js APIs directly in the application's context, while CEF requires separate processes for Node.js integration.
- CEF provides more granular control over the browser engine and supports a wider range of programming languages.
- NW.js is more suited for rapid development of desktop applications using web technologies, while CEF is better for embedding web content in existing applications.
Use Cases
- NW.js: Desktop applications, cross-platform tools, and rapid prototyping
- CEF: Embedding web content in native applications, custom browser implementations, and applications requiring fine-grained control over the browser engine
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
The Chromium Embedded Framework (CEF) is a simple framework for embedding Chromium-based browsers in other applications.
Quick Links
- Project Page - https://bitbucket.org/chromiumembedded/cef
- Tutorial - https://bitbucket.org/chromiumembedded/cef/wiki/Tutorial
- General Usage - https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage
- Master Build Quick-Start - https://bitbucket.org/chromiumembedded/cef/wiki/MasterBuildQuickStart
- Branches and Building - https://bitbucket.org/chromiumembedded/cef/wiki/BranchesAndBuilding
- Announcements - https://groups.google.com/forum/#!forum/cef-announce
- Support Forum - http://www.magpcss.org/ceforum/
- Issue Tracker - https://github.com/chromiumembedded/cef/issues
- C++ API Docs - Stable release docs / Beta release docs
- Downloads - https://cef-builds.spotifycdn.com/index.html
- Donations - http://www.magpcss.org/ceforum/donate.php
Introduction
CEF is a BSD-licensed open source project founded by Marshall Greenblatt in 2008 and based on the Google Chromium project. Unlike the Chromium project itself, which focuses mainly on Google Chrome application development, CEF focuses on facilitating embedded browser use cases in third-party applications. CEF insulates the user from the underlying Chromium and Blink code complexity by offering production-quality stable APIs, release branches tracking specific Chromium releases, and binary distributions. Most features in CEF have default implementations that provide rich functionality while requiring little or no integration work from the user. There are currently over 100 million installed instances of CEF around the world embedded in products from a wide range of companies and industries. A partial list of companies and products using CEF is available on the CEF Wikipedia page. Some use cases for CEF include:
- Embedding an HTML5-compliant Web browser control in an existing native application.
- Creating a light-weight native âshellâ application that hosts a user interface developed primarily using Web technologies.
- Rendering Web content âoff-screenâ in applications that have their own custom drawing frameworks.
- Acting as a host for automated testing of existing Web properties and applications.
CEF supports a wide range of programming languages and operating systems and can be easily integrated into both new and existing applications. It was designed from the ground up with both performance and ease of use in mind. The base framework includes C and C++ programming interfaces exposed via native libraries that insulate the host application from Chromium and Blink implementation details. It provides close integration between the browser and the host application including support for custom plugins, protocols, JavaScript objects and JavaScript extensions. The host application can optionally control resource loading, navigation, context menus, printing and more, while taking advantage of the same performance and HTML5 technologies available in the Google Chrome Web browser.
Numerous individuals and organizations contribute time and resources to support CEF development, but more involvement from the community is always welcome. This includes support for both the core CEF project and external projects that integrate CEF with additional programming languages and frameworks (see the "External Projects" section below). If you are interested in donating time to help with CEF development please see the "Helping Out" section below. If you are interested in donating money to support general CEF development and infrastructure efforts please visit the CEF Donations page.
Getting Started
Users new to CEF development should start by reading the Tutorial Wiki page for an overview of CEF usage and then proceed to the GeneralUsage Wiki page for a more in-depth discussion or architectural and usage issues. Complete API documentation is available here. CEF support and related discussion is available on the CEF Forum.
Binary Distributions
Binary distributions, which include all files necessary to build a CEF-based application, are available on the Downloads page. Binary distributions are stand-alone and do not require the download of CEF or Chromium source code. Symbol files for debugging binary distributions of libcef can also be downloaded from the above links.
Source Distributions
The CEF project is an extension of the Chromium project. CEF maintains development and release branches that track Chromium branches. CEF source code can be downloaded, built and packaged manually or with automated tools. Visit the BranchesAndBuilding Wiki page for more information.
External Projects
The base CEF framework includes support for the C and C++ programming languages. Thanks to the hard work of external maintainers CEF can integrate with a number of other programming languages and frameworks. These external projects are not maintained by CEF so please contact the respective project maintainer if you have any questions or issues.
- .Net (CEF3) - https://github.com/cefsharp/CefSharp
- .Net (CEF1) - https://bitbucket.org/fddima/cefglue
- .Net/Mono (CEF3) - https://gitlab.com/xiliumhq/chromiumembedded/cefglue
- Delphi - https://github.com/hgourvest/dcef3
- Delphi - https://github.com/salvadordf/CEF4Delphi
- Go - https://github.com/CzarekTomczak/cef2go
- Go - https://github.com/energye/energy
- Java - https://bitbucket.org/chromiumembedded/java-cef
- Python - http://code.google.com/p/cefpython/
If you're the maintainer of a project not listed above and would like your project listed here please either post to the CEF Forum or contact Marshall directly.
Helping Out
CEF is still very much a work in progress. Some ways that you can help out:
- Vote for issues in the CEF issue tracker that are important to you. This helps with development prioritization.
- Report any bugs that you find or feature requests that are important to you. Make sure to first search for existing issues before creating new ones. Please use the CEF Forum and not the issue tracker for usage questions. Each CEF issue should:
- Include the CEF revision or binary distribution version.
- Include information about your OS and compiler version.
- If the issue is a bug please provide detailed reproduction information.
- If the issue is a feature please describe why the feature is beneficial.
- Write unit tests for new or existing functionality.
- Pull requests and patches are welcome. View open issues in the CEF issue tracker or search for TODO(cef) in the source code for ideas.
If you would like to contribute source code changes to CEF please follow the below guidelines:
- Create or find an appropriate issue for each distinct bug, feature or change.
- Submit a pull request or create a patch with your changes and attach it to the CEF issue. Changes should:
- Be submitted against the current CEF master branch unless explicitly fixing a bug in a CEF release branch.
- Follow the style of existing CEF source files. In general CEF uses the Chromium C++ style guide.
- Include new or modified unit tests as appropriate to the functionality.
- Not include unnecessary or unrelated changes.
Top Related Projects
:electron: Build cross-platform desktop apps with JavaScript, HTML, and CSS
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
JavaScript API for Chrome and Firefox
Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
Call all Node.js modules directly from DOM/WebWorker and enable a new way of writing applications with all Web technologies.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot