### Install Visual Studio components Source: https://github.com/chromiumembedded/cef/blob/master/docs/automated_build_setup.md Use these arguments with the Visual Studio installer to set up the required native desktop and ATL/MFC components. ```sh $ PATH_TO_INSTALLER.EXE ^ --add Microsoft.VisualStudio.Workload.NativeDesktop ^ --add Microsoft.VisualStudio.Component.VC.ATLMFC ^ --includeRecommended ``` ```sh $ PATH_TO_INSTALLER.EXE ^ --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^ --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 ^ --includeRecommended ``` -------------------------------- ### JavaScript: Initialize Server Setup Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/server.html Performs initial setup by querying the server state and updating button states and port input. This function should only be run from the 'https://tests' origin. ```javascript function setup() { if (location.origin != 'https://tests') { document.getElementById('warning').style.display = 'block'; return; } // Query the current server state. sendMessage({'action':'query'}, function(response) { if (response['result'] == 'success') { var running = (response['status'] == 'running') setButtonState(!running, running); var port_element = document.getElementById('port'); port_element.value = response['port']; port_element.disabled = false; } }); } ``` -------------------------------- ### Initial Setup and Interval Timer Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/hang.html Sets up the initial state of the test page by disabling form elements, updating the time, and starting an interval timer to refresh the time every second. It also conditionally calls `setupTest` if the page is loaded from 'tests' or 'localhost'. ```JavaScript function setup() { // Disable all elements. setFormEnabled(false); updateTime(); setInterval(updateTime, 1000); if (location.hostname == 'tests' || location.hostname == 'localhost') { setupTest(); return; } alert('This page can only be run from tests or localhost.'); } ``` -------------------------------- ### Install websocket-client Source: https://github.com/chromiumembedded/cef/blob/master/tools/debug/ax_viewport_collapse/README.md Install the necessary Python package for websocket communication. ```bash python3 -m pip install websocket-client ``` -------------------------------- ### Example Directory Structure Source: https://github.com/chromiumembedded/cef/blob/master/docs/using_chrome_driver.md Expected file layout for the automation project. ```text c:\temp\ cef_binary_3.2171.1979_windows32_client\ Release\ cefclient.exe (and other files) chromedriver.exe Example.java selenium-server-standalone-2.44.0.jar ``` -------------------------------- ### Setup VSCode Environment Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Initialize the preconfigured VSCode environment for CEF development. ```sh cd /path/to/code/chromium_git/chromium/src/cef python3 tools/setup_vscode.py ``` -------------------------------- ### Example Verification Command Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_PATCH_INSTRUCTIONS.md An example of the verify_patch.py command with specific parameters for patch name and version numbers. ```bash # From chromium/src/cef/tools/claude directory: python3 verify_patch.py patch_output.txt --patch views_widget \ --old-version 142.0.7444.0 --new-version 143.0.7491.0 ``` -------------------------------- ### Prepare Sync Directories Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_BASE_SYNC_INSTRUCTIONS.md Initialize the necessary working directories and capture current repository state before starting the sync process. ```bash # Create working directories mkdir -p cef/tmp/backup mkdir -p cef/tmp/diffs # Note the current Chromium commit git log -1 --format='%H' HEAD cat chrome/VERSION ``` -------------------------------- ### WebSocket Client Setup and Connection Logic Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/websocket.html This JavaScript code handles the initial setup of the WebSocket client, including determining the server URL and managing the connection state. It's designed to be run in a browser environment. ```javascript var ws = null; function setup() { // Match the secure state of the current origin. var origin = location.origin; if (origin.indexOf('http://') == 0) { origin = origin.replace('http://', 'ws://'); } else if (origin.indexOf('https://') == 0) { origin = origin.replace('https://', 'wss://'); } else { origin = ''; } if (origin.length > 0) document.getElementById('server').value = origin; document.getElementById('server').disabled = false; if (location.hostname != 'localhost') document.getElementById('warning').style.display = 'block'; setConnected(false); } function setConnected(connected) { document.getElementById('connect').disabled = connected; document.getElementById('disconnect').disabled = !connected; document.getElementById('message').disabled = !connected; document.getElementById('response').disabled = !connected; document.getElementById('send').disabled = !connected; } function doConnect() { var url = document.getElementById('server').value; if (url.indexOf('ws://') < 0 && url.indexOf('wss://') < 0) { alert('Specify a valid WebSocket server URL.'); return; } if (ws) { alert('WebSocket is already connected.'); return; } ws = new WebSocket(url); ws.onopen = function() { setConnected(true); }; ws.onmessage = function(event) { document.getElementById('response').value = event.data; }; ws.onclose = function(event) { setConnected(false); ws = null; }; ws.onerror = function(event) { if (ws.readyState == 3) alert('WebSocket connection failed.'); } } function doDisconnect() { if (!ws) { alert('WebSocket is not currently connected.'); return; } ws.close(); } function doSend() { if (!ws) { alert('WebSocket is not currently connected.'); return; } var value = document.getElementById('message').value; if (value.length > 0) ws.send(value); } ``` -------------------------------- ### cef-project Examples Source: https://github.com/chromiumembedded/cef/blob/master/docs/hands_on_tutorial.md Discover focused example applications within the cef-project repository that demonstrate specific CEF features like message routing, resource management, and custom scheme handlers. ```url https://github.com/chromiumembedded/cef-project ``` -------------------------------- ### Launch VSCode Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Open the current directory in VSCode after the environment setup is complete. ```sh cd /path/to/code/chromium_git/chromium/src code . ``` -------------------------------- ### Install and Update depot_tools Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Navigate to the depot_tools directory and run the update script to install Python and Git. This script also handles auto-updating depot_tools. ```bash cd c:\code\depot_tools update_depot_tools.bat ``` -------------------------------- ### Configure Tool Arguments Source: https://github.com/chromiumembedded/cef/blob/master/tools/clang/README.md Examples of passing specific transformation flags to the rewriter. ```bash # Run only iterator-loops transformation --tool-args="--only=iterator-loops" # Run only contains and structured-bindings --tool-args="--only=contains,structured-bindings" # Disable specific transformation (all others still run) --tool-args="--contains=false" ``` -------------------------------- ### Install Build Dependencies Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Installs required build dependencies using apt-get and a Python script. Ensure you answer 'Y' to all prompts during the script execution. This step is crucial for a successful build. ```sh cd ~/code sudo apt-get install curl file lsb-release procps python3 python3-pip curl 'https://chromium.googlesource.com/chromium/src/+/main/build/install-build-deps.py?format=TEXT' | base64 -d > install-build-deps.py sudo python3 ./install-build-deps.py --no-arm --no-chromeos-fonts --no-nacl python3 -m pip install dataclasses importlib_metadata ``` -------------------------------- ### Full Cherry-Pick Workflow Example Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CHERRY_PICK_INSTRUCTIONS.md Demonstrates a complete workflow for cherry-picking a commit, including fetching, applying, extracting, and resaving patches. ```bash # Setup cd /path/to/chromium/src/cef git fetch upstream master # Cherry-pick commit that modifies views_widget.patch git cherry-pick abc123 --no-commit # Check what source file changes are needed git diff abc123^..abc123 -- patch/patches/views_widget.patch # Extract and apply the source changes git show abc123:patch/patches/views_widget.patch > /tmp/vw.patch sed -n '/^diff --git ui/views/widget/widget.cc/,/^diff --git /p' /tmp/vw.patch | head -n -1 > /tmp/widget.patch cd /path/to/chromium/src patch -p0 < /tmp/widget.patch # Resave and commit cd cef python3 tools/patch_updater.py --resave --patch views_widget git add patch/patches/views_widget.patch git commit -m "$(git log -1 --format='%B' abc123)" ``` -------------------------------- ### Example crash_reporter.cfg file contents Source: https://github.com/chromiumembedded/cef/blob/master/docs/crash_reporting.md A sample configuration file demonstrating the [Config] and [CrashKeys] sections for enabling crash reporting. ```ini [Config] # Product information. ProductName=cefclient ProductVersion=1.0.0 # Required to enable crash dump upload. ServerURL=http://localhost:8080 # Disable rate limiting so that all crashes are uploaded. RateLimitEnabled=false MaxUploadsPerDay=0 [CrashKeys] ``` -------------------------------- ### JavaScript Setup Function Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/window.html Initializes the page by disabling form elements if not running on 'tests' or 'localhost'. ```javascript function setup() { if (location.hostname == 'tests' || location.hostname == 'localhost') return; alert('This page can only be run from tests or localhost.'); // Disable all elements. var elements = document.getElementById("form").elements; for (var i = 0, element; element = elements[i++]; ) { element.disabled = true; } } ``` -------------------------------- ### Prompt for Custom Scheme Handler Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Example prompt for implementing a custom protocol handler. ```text I have a CEF binary distribution at /path/to/cef_binary__. Please add support for a custom "myscheme://" protocol to cefsimple that serves static HTML pages from an in-memory map. Use @cef/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md for guidance. ``` -------------------------------- ### Bootstrap Clang Rewriter Source: https://github.com/chromiumembedded/cef/blob/master/tools/clang/README.md Initial one-time setup to build the clang rewriter tool. ```bash # From chromium/src directory ./cef/tools/clang/scripts/build_clang_rewriter.sh ``` -------------------------------- ### Build cefclient with Bazel Source: https://github.com/chromiumembedded/cef/blob/master/tools/distrib/mac/README.standard.txt Use this command to build the bundled cefclient sample application using Bazel. Ensure Bazelisk is installed. ```bash bazel build //tests/cefclient ``` -------------------------------- ### Remote Configuration Output Source: https://github.com/chromiumembedded/cef/blob/master/docs/contributing_with_git.md Example output showing the expected configuration of origin, public, and upstream remotes. ```cpp origin https://@github.com//cef_private.git (fetch) origin https://@github.com//cef_private.git (push) public https://@github.com//cef.git (fetch) public https://@github.com//cef.git (push) upstream https://github.com/chromiumembedded/cef.git (fetch) upstream https://github.com/chromiumembedded/cef.git (push) ``` -------------------------------- ### Prompt for Customizing Popup Windows Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Example prompt for setting a specific size for popup windows. ```text I have a CEF binary distribution at /path/to/cef_binary__windows64. Please make cefsimple popup windows open at 600x400 instead of the default size. Follow the instructions in @cef/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md ``` -------------------------------- ### Run cefclient with Bazel Source: https://github.com/chromiumembedded/cef/blob/master/tools/distrib/mac/README.standard.txt Use this command to run the bundled cefclient sample application using Bazel. Ensure Bazelisk is installed. ```bash bazel run //tests/cefclient ``` -------------------------------- ### Image Transparency Example Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/transparency.html Demonstrates how to make an image fully opaque on hover using CSS opacity. No specific setup is required beyond including the CSS. ```css body { font-family: Verdana, Arial; } img { opacity:0.4; } img:hover { opacity:1.0; } ``` -------------------------------- ### Incremental Prompting for Chromium Updates Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/README.md Guide Claude Code through large tasks like Chromium updates by using incremental prompts. Start with one instruction file, allow Claude to work, and then provide the next step. ```text 1. "Start fixing patches using @CLAUDE_PATCH_INSTRUCTIONS.md" 2. [Claude works for a while] 3. "Good progress. Continue with the remaining patches." 4. [Claude finishes] 5. "Now let's fix build errors using @CLAUDE_BUILD_INSTRUCTIONS.md" ``` -------------------------------- ### Main Function Setup - C Source: https://github.com/chromiumembedded/cef/blob/master/docs/using_the_capi.md Initializes CEF and sets up the main application structure. This function configures the API version, handles main arguments, and prepares the application for execution. ```c // Complete main() function (Windows/Linux pattern) // NOTE: On macOS, you must call cef_load_library() first, then cef_api_hash(). // See cefsimple_capi/cefsimple_mac.m for the macOS implementation. int main(int argc, char* argv[]) { // Configure the CEF API version. This must be called before any other CEF // API functions. cef_api_hash(CEF_API_VERSION, 0); cef_main_args_t main_args = {}; #ifdef _WIN32 main_args.instance = GetModuleHandle(NULL); #else main_args.argc = argc; main_args.argv = argv; #endif // Create app with browser process handler (with 1 reference) my_app_complete_t* app = create_app_complete(); // Add a reference before cef_execute_process. Both cef_execute_process and // cef_initialize will take ownership of a reference, so we need 2 total. app->app.base.add_ref(&app->app.base); // Execute sub-processes if needed ``` -------------------------------- ### JavaScript: Start Server Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/server.html Starts the server with a specified port number. Validates the port to be between 1025 and 65535. Updates button states based on the start operation's success or failure. ```javascript function startServer() { var port = parseInt(document.getElementById('port').value); if (port < 1025 || port > 65535) { alert('Specify a port number between 1025 and 65535'); return; } setButtonState(false, false); sendMessage({'action':'start', 'port':port}, function(response) { if (response['result'] == 'success') { setButtonState(false, true); } else { setButtonState(true, false); alert(response['message']); } }); } ``` -------------------------------- ### Run sample applications Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Launch the compiled sample applications from the build output directory. ```sh cd ~/code/chromium_git/chromium/src open out/Debug_GN_x64/cefclient.app # Or run directly in the console to see log output: ./out/Debug_GN_x64/cefclient.app/Contents/MacOS/cefclient ``` -------------------------------- ### Install Python 3.12 on macOS Source: https://github.com/chromiumembedded/cef/blob/master/tools/clang/README.md Commands to install the required Python version via Homebrew and update the shell path. ```bash brew install python@3.12 ln -s /opt/homebrew/opt/python@3.12/bin/python3.12 /opt/homebrew/opt/python@3.12/bin/python3 export PATH="/opt/homebrew/opt/python@3.12/bin:$PATH" python3 --version # Should show 3.12.x ``` -------------------------------- ### Setup Test Environment Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/hang.html Initializes the test environment by retrieving the currently configured command and enabling form elements. It uses `window.cefQuery` to communicate with the browser process. ```JavaScript function setupTest() { // Retrieve the currently configured command. // Results in a call to the OnQuery method in hang_test.cc window.cefQuery({ request: 'HangTest:getcommand', onSuccess: function(response) { document.getElementById(response).checked = true; setFormEnabled(true); }, }); } ``` -------------------------------- ### Build and Run CEF Sample Applications Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_BASE_SYNC_INSTRUCTIONS.md Compile the 'cefsimple' and 'cefclient' sample applications. After compilation, run these applications to test CEF integration. ```bash autoninja -C out/Debug_GN_x64 cefsimple cefclient out/Debug_GN_x64/cefsimple out/Debug_GN_x64/cefclient ``` -------------------------------- ### CEF Crash Report Console Output Example Source: https://github.com/chromiumembedded/cef/blob/master/docs/crash_reporting.md This is an example of the console output observed when a crash report is successfully received and processed by CEF. ```text 01/10/2017 12:31:23: Dump ``` -------------------------------- ### C++ Reference Counting Example Source: https://github.com/chromiumembedded/cef/blob/master/docs/using_the_capi.md This C++ example demonstrates how reference counting is typically handled for classes inheriting from CefApp and CefBrowserProcessHandler, serving as a comparison to C API structure management. ```cpp // A new class is defined and specific handlers are overridden class SimpleApp: public CefApp, public CefBrowserProcessHandler { public: SimpleApp() {} CefRefPtr GetBrowserProcessHandler() override { return this; } void OnContextInitialized() override; CefRefPtr GetDefaultClient() override; private: // A default RC implementation can be used IMPLEMENT_REFCOUNTING(SimpleApp); } ``` -------------------------------- ### Page Setup and Hostname Check Source: https://github.com/chromiumembedded/cef/blob/master/tests/cefclient/resources/dialogs.html Initializes the page by updating the time and setting up an interval for time updates. It also checks if the page is running on 'tests' or 'localhost' and alerts the user otherwise. ```javascript function setup() { update_time(); setInterval(update_time, 1000); if (location.hostname != 'tests' && location.hostname != 'localhost') { alert('Parts of this page can only be run from tests or localhost.'); return; } // Enable all elements. var elements = document.getElementById("form").elements; for (var i = 0, element; element = elements[i++]; ) { element.disabled = false; } } window.addEventListener('load', setup, false); ``` -------------------------------- ### Browser Process Crash Metadata Example (JSON) Source: https://github.com/chromiumembedded/cef/blob/master/docs/crash_reporting.md Example JSON structure of metadata collected for a browser process crash, including system information, command-line switches, and custom crash keys. ```json { "LOG_FATAL": "debug_urls.cc:208: Check failed: false. \n0 Chromium Embedded Framework 0x00000001161a1a0e _ZN4base5debug10StackTraceC2Ev + 30\n1 Chromium Embedded Framework 0x00000001161a1a75 _ZN4base5debug10StackTraceC1Ev + 21\n2 Chromium Embedded Fr", "guid": "6ada20da-7306-477e-a715-ada36448a23f", "num-switches": "3", "pid": "2073", "platform": "macos", "product": "cefclient", "ptype": "browser", "switch-1": "--url=chrome://inducebrowsercrashforrealz", "switch-2": "--lang=en-US", "testkey_large1": "value1_large_browser", "testkey_large2": "value2_large_browser", "testkey_medium1": "value1_medium_browser", "testkey_medium2": "value2_medium_browser", "testkey_small1": "value1_small_browser", "testkey_small2": "value2_small_browser", "version": "1.0.0" } ``` -------------------------------- ### Starting Build Error Fixing with Raw Output Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CHROMIUM_UPDATE.md Use this prompt structure when providing raw build output, ensuring the analysis script is run first. ```text Please fix build errors for the 139.0.7258.0 to 140.0.7339.0 update using the instructions in @cef/tools/claude/CLAUDE_BUILD_INSTRUCTIONS.md Raw build output: @cef/tools/claude/build_output.txt Target: cef Out dir: Debug_GN_x64 Please run analyze_build_output.py first to understand what failed. ``` -------------------------------- ### Example Compile Error Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_BUILD_INSTRUCTIONS.md Illustrates a common compile error where a struct member is missing. This example shows the file, line number, column, error message, and the specific line of code causing the issue. ```cpp cef/libcef/browser/browser_host_impl.cc:123:45: error: 'CreateParams' has no member named 'initial_size' params.initial_size = gfx::Size(800, 600); ^ ``` -------------------------------- ### Run CEF Simple with Local or Data URLs Source: https://github.com/chromiumembedded/cef/blob/master/docs/hands_on_tutorial.md Examples for loading local files or inline data URLs via command line. ```bash cefsimple --url=file:///home/user/test.html ``` ```bash cefsimple --url="data:text/html,

Hello!

" ``` -------------------------------- ### Build and run CEF sample applications with Bazel Source: https://github.com/chromiumembedded/cef/blob/master/tools/distrib/linux/README.standard.txt Commands to compile and execute the cefclient sample application. ```bash $ bazel build //tests/cefclient ``` ```bash $ bazel run //tests/cefclient ``` -------------------------------- ### C API Manual Reference Counting Example Source: https://github.com/chromiumembedded/cef/blob/master/docs/using_the_capi.md Illustrates manual reference counting in the CEF C API, mirroring the C++ CefRefPtr behavior. This example requires explicit calls to release objects when they are no longer needed. ```c void use_frame_in_c(cef_browser_t* browser) { // browser parameter: CEF already added a reference before calling us cef_frame_t* frame = browser->get_main_frame(browser); // frame: get_main_frame() returns a pointer with a reference cef_string_t url = {}; cef_string_from_ascii("https://example.com", 19, &url); frame->load_url(frame, &url); cef_string_clear(&url); // Exiting function - MUST manually release: frame->base.release(&frame->base); // Manual (CefRefPtr does automatically) browser->base.release(&browser->base); // Manual (CefRefPtr does automatically) } ``` -------------------------------- ### Create Linux/Mac Build Configuration Helper Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CHROMIUM_UPDATE.md Create this script on Linux/Mac to simplify regenerating build files after .gn changes. Ensure to replace the placeholder with your platform's build config. ```bash #!/bin/bash export GN_OUT_CONFIGS=Debug_GN_arm64 ./cef_create_projects.sh ``` -------------------------------- ### Build cefsimple on Linux Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md Commands to configure and build the test application on Linux. ```bash cmake -B build cmake --build build --target cefsimple build/tests/cefsimple/cefsimple ``` -------------------------------- ### Run CEF Sample Browser Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_SRC_PATCH_INSTRUCTIONS.md Launch the CEF sample browser application to manually test the changes and verify the patch works as intended. ```bash # Or test manually with the sample browser out/Debug_GN_x64/cefclient ``` -------------------------------- ### Get Full Commit Message Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CHERRY_PICK_INSTRUCTIONS.md Retrieves the complete commit message for a given SHA. ```git git log -1 --format='%B' ``` -------------------------------- ### Build cefsimple on Windows Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md Commands to configure and build the test application using Visual Studio. ```bash cmake -B build -G "Visual Studio 17 2022" -A x64 -DUSE_SANDBOX=OFF cmake --build build --config Release --target cefsimple build\tests\cefsimple\Release\cefsimple.exe ``` -------------------------------- ### Get Patch File from Commit Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CHERRY_PICK_INSTRUCTIONS.md Retrieves the patch file associated with a specific commit. ```git git show :patch/patches/.patch ``` -------------------------------- ### Install patchelf dependency for Bazel Source: https://github.com/chromiumembedded/cef/blob/master/tools/distrib/linux/README.standard.txt Required system package for building CEF with Bazel on Linux. ```bash $ sudo apt install patchelf ``` -------------------------------- ### Run Initial CEF Build Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_BUILD_INSTRUCTIONS.md Execute this command from the chromium/src directory to perform an initial build and capture all output. The -k 0 flag ensures the build continues on errors, allowing all failures to be collected. Redirect output to a file for analysis. ```bash autoninja -k 0 -C out/Debug_GN_x64 cef 2>&1 | tee cef/tools/claude/build_output.txt ``` -------------------------------- ### Prompt for Intercepting Network Requests Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Example prompt for logging image request URLs to the console. ```text I have a CEF binary distribution at /path/to/cef_binary__linux64. Please modify cefsimple to intercept all image requests and log their URLs to the console. Use @cef/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md for guidance. ``` -------------------------------- ### Run cefclient Sample Application Source: https://github.com/chromiumembedded/cef/blob/master/docs/chromium_update.md Command-line arguments for testing various runtime modes of the cefclient application. ```sh # Chrome bootstrap: $ cefclient # Chrome bootstrap + Alloy style: $ cefclient --use-alloy-style $ cefclient --use-alloy-style --use-native $ cefclient --off-screen-rendering-enabled # Multi-threaded message loop (Windows/Linux only): $ cefclient --multi-threaded-message-loop $ cefclient --use-alloy-style --multi-threaded-message-loop # Chrome style + native parent (Windows/Linux only): $ cefclient --use-native ``` -------------------------------- ### Prompt for JavaScript-to-C++ Communication Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Example prompt for adding a JS function that sends messages to C++. ```text I have a CEF binary distribution at /path/to/cef_binary__macosarm64. Please add a JavaScript function window.sendToApp(message) to cefsimple that sends messages to C++ and displays them via LOG(). Use @cef/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md for guidance. ``` -------------------------------- ### Prompt for Custom URL Scheme Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Example prompt for adding a custom URL scheme to cefsimple. ```text I have a CEF binary distribution at /path/to/cef_binary__. Please add a custom "myapp://" URL scheme to cefsimple that serves HTML content from C++. Use the instructions in @cef/tools/claude/CLAUDE_CLIENT_INSTRUCTIONS.md The CEF wiki is available at /path/to/cef_wiki (if cloned locally) ``` -------------------------------- ### Generate and Build Breakpad Tools Source: https://github.com/chromiumembedded/cef/blob/master/docs/crash_reporting.md Use GN to generate the build files and Ninja to compile the necessary crash analysis utilities. ```sh gn gen out/Release ninja -C out/Release dump_syms minidump_stackwalk ``` -------------------------------- ### Create project directories Source: https://github.com/chromiumembedded/cef/blob/master/docs/master_build_quick_start.md Initialize the required directory structure for the CEF build environment. ```sh mkdir ~/code mkdir ~/code/automate mkdir ~/code/chromium_git ``` -------------------------------- ### Retrieve JS Value Source: https://github.com/chromiumembedded/cef/blob/master/docs/javascript_integration.md Extract the underlying value from a CefV8Value using the Get*Value methods. ```cpp CefString strVal = val.GetStringValue(); ``` -------------------------------- ### Initiate a CefURLRequest Source: https://github.com/chromiumembedded/cef/blob/master/docs/general_usage.md Create and start a network request using a CefRequest object and the custom client implementation. ```cpp // Set up the CefRequest object. CefRefPtr request = CefRequest::Create(); // Populate |request| as shown above... // Create the client instance. CefRefPtr client = new MyRequestClient(); // Start the request. MyRequestClient callbacks will be executed asynchronously. CefRefPtr url_request = CefURLRequest::Create(request, client.get(), nullptr); // To cancel the request: url_request->Cancel(); ``` -------------------------------- ### Complete Update Workflow Steps Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CHROMIUM_UPDATE.md Provides a step-by-step guide for the complete update workflow, including updating Chromium, running patch_updater.py, fixing patches with Claude, building CEF, fixing build errors, testing, and submitting changes. ```text 1. Update Chromium checkout to new version └─> automate-git.py or manual git commands 2. Run patch_updater.py └─> Captures failures in patch_output.txt 3. Fix patches with Claude ├─> Analyze output with analyze_patch_output.py → patch_analysis.txt ├─> Prompt: "@CLAUDE_PATCH_INSTRUCTIONS.md" with @patch_analysis.txt ├─> Claude fixes patches one by one └─> Verify: patch_updater.py runs clean 4. Build CEF └─> Captures errors in build_output.txt 5. Fix build errors with Claude ├─> Analyze output with analyze_build_output.py → build_analysis.txt ├─> Prompt: "@CLAUDE_BUILD_INSTRUCTIONS.md" with @build_analysis.txt ├─> Claude fixes errors one by one └─> Verify: Build succeeds 6. Test CEF └─> Run ceftests, cefclient, manual testing 7. Submit changes └─> Create PR with updated patches and fixes ``` -------------------------------- ### Debug Test Failures Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_TEST_INSTRUCTIONS.md Example log entry documenting the investigation, cause, and resolution of a test timeout. ```text Investigating NavigationTest.BackForward: Issue: Test timeout (60s) Cause: DestroyTest() not called after back navigation Fix: Added DestroyTest() call in navigation complete handler Verification: Ran 5 times, all passed (avg 234ms) ``` -------------------------------- ### Build Bootstrap Executables (Windows) Source: https://github.com/chromiumembedded/cef/blob/master/docs/sandbox_setup.md Builds the bootstrap and bootstrapc targets using Ninja and creates a binary distribution. Ensure you have a local Chromium/CEF checkout and have set up the build environment. ```sh # Discover what `args.gn` contents are required: cd c:\path\to\chromium\src\cef set GN_DEFINES=is_official_build=true set GN_OUT_CONFIGS=Debug_GN_x64 python3 tools\gn_args.py # Create or update the `chromium\src\out\Debug_GN_x64\args.gn` file with the specified contents. # Build the bootstrap targets in the output directory: cd c:\path\to\chromium\src set DEPOT_TOOLS_WIN_TOOLCHAIN=0 gn gen out\Debug_GN_x64 ninja -C out\Debug_GN_x64 bootstrap bootstrapc # Create a binary distribution for the bootstrap build: cd c:\path\to\chromium\src\cef\tools make_distrib.bat --allow-partial --sandbox --ninja-build --x64-build --no-archive --no-symbols --no-docs ``` -------------------------------- ### Create Windows Build Configuration Helper Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CHROMIUM_UPDATE.md Create this batch script on Windows to simplify regenerating build files after .gn changes. Ensure to replace the placeholder with your platform's build config. ```bat set GN_OUT_CONFIGS=Debug_GN_x64 call cef_create_projects.bat ``` -------------------------------- ### Auto-Generated Function Implementation Source: https://github.com/chromiumembedded/cef/blob/master/tools/translator.README.txt Example of an auto-generated function body containing a warning message for manual implementation. ```cpp size_t CEF_CALLBACK frame_new_func(struct _cef_frame_t* self) { // BEGIN DELETE BEFORE MODIFYING // AUTO-GENERATED CONTENT #pragma message("Warning: " __FILE__ ": frame_new_func is not implemented") // END DELETE BEFORE MODIFYING } ``` -------------------------------- ### Prototype Change Warning Source: https://github.com/chromiumembedded/cef/blob/master/tools/translator.README.txt Example of warning messages inserted into generated files when function prototypes change. ```cpp // WARNING - CHANGED ATTRIBUTES // REMOVED: const wchar_t* key // ADDED: int index // WARNING - CHANGED RETURN VALUE // WAS: void // NOW: int #pragma message("Warning: " __FILE__ ": MyFunction prototype has changed") ``` -------------------------------- ### JavaScript Execution Examples Source: https://github.com/chromiumembedded/cef/blob/master/docs/hands_on_tutorial.md Various ways to use ExecuteJavaScript for alerts, DOM manipulation, and console logging. ```cpp // Alert box frame->ExecuteJavaScript("alert('Hello from C++!');", frame->GetURL(), 0); // DOM manipulation frame->ExecuteJavaScript( "var h1 = document.createElement('h1');" "h1.textContent = 'Added by CEF!';" "document.body.insertBefore(h1, document.body.firstChild);", frame->GetURL(), 0); // Console log frame->ExecuteJavaScript("console.log('CEF executed this');", frame->GetURL(), 0); ``` -------------------------------- ### View patch failure output Source: https://github.com/chromiumembedded/cef/blob/master/docs/chromium_update.md Example of the error output displayed when patch files have unresolved conflicts. ```text -------------------------------------------------------------------------------- !!!! FAILED PATCHES, fix manually and run with --resave content_2015: Hunk #4 FAILED at 4220. 1 out of 5 hunks FAILED -- saving rejects to file content/browser/frame_host/render_frame_host_impl.cc.rej storage_partition_1973: Hunk #1 FAILED at 167. 1 out of 1 hunk FAILED -- saving rejects to file content/browser/shared_worker/shared_worker_service_impl.cc.rej -------------------------------------------------------------------------------- ``` -------------------------------- ### Interpret Test Results Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_TEST_INSTRUCTIONS.md Example output format when running ceftests, showing pass/fail status and execution time. ```text ✓ Built ceftests (4m 12s) Running: NavigationTest.* Results: ✓ PASSED: NavigationTest.LoadURL (234 ms) ✓ PASSED: NavigationTest.Redirect (156 ms) ✗ FAILED: NavigationTest.BackForward (timeout 60s) Summary: 2/3 passed Investigating failure... ``` -------------------------------- ### Initialize CEF Repository Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLAUDE_CHERRY_PICK_INSTRUCTIONS.md Navigate to the CEF directory and fetch the latest upstream changes. ```bash cd /path/to/chromium/src/cef git fetch upstream master ``` -------------------------------- ### View missing file error output Source: https://github.com/chromiumembedded/cef/blob/master/docs/chromium_update.md Example of the error output displayed when a patched file has been moved or deleted. ```cpp --> Reading patch file /path/to/chromium_git/chromium/src/cef/patch/patches/content_mojo_3123.patch --> Skipping non-existing file /path/to/chromium_git/chromium/src/content/public/browser/document_service_base.h --> Applying patch to /path/to/chromium_git/chromium/src (Stripping trailing CRs from patch; use --binary to disable.) can't find file to patch at input line 5 ... Skip this patch? [y] Skipping patch. 2 out of 2 hunks ignored --> Saving changes to /path/to/chromium_git/chromium/src/cef/patch/patches/content_mojo_3123.patch Traceback (most recent call last): File "/path/to/chromium_git/chromium/src/cef/tools/patch_updater.py", line 294, in raise Exception('Failed to add paths: %s' % result['err']) Exception: Failed to add paths: fatal: pathspec '/path/to/chromium_git/chromium/src/content/public/browser/document_service_base.h' did not match any files ``` -------------------------------- ### Build Commands by Platform Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CLIENT_DEVELOPMENT.md Standard CMake build and execution commands for Windows, Linux, and macOS. ```bash cmake -B build -G "Visual Studio 17 2022" -A x64 -DUSE_SANDBOX=OFF cmake --build build --config Release --target cefsimple build\tests\cefsimple\Release\cefsimple.exe ``` ```bash cmake -B build cmake --build build --target cefsimple build/tests/cefsimple/cefsimple ``` ```bash cmake -B build -G Xcode cmake --build build --config Release --target cefsimple open build/tests/cefsimple/Release/cefsimple.app ``` -------------------------------- ### Starting Build Error Fixing with Analysis Source: https://github.com/chromiumembedded/cef/blob/master/tools/claude/CHROMIUM_UPDATE.md Use this prompt structure when patches are resolved and build error analysis is available. ```text The patches are all fixed. Now please fix the build errors using the instructions in @cef/tools/claude/CLAUDE_BUILD_INSTRUCTIONS.md Build error analysis: @cef/tools/claude/build_analysis.txt Target: cef Out dir: Debug_GN_x64 ```