CefBrowser
Header: cef_browser.h
Interfaces: CefBrowser, CefRunFileDialogCallback, CefNavigationEntryVisitor, CefPdfPrintCallback, CefDownloadImageCallback, CefBrowserHost
Category: Core APIs
Overview
Foundational interfaces: process bootstrap, browser lifecycle, frames, DOM, requests, and data objects.
CefBrowser
Source File: include/cef_browser.h
Process / Thread Context: "When used in the browser process the methods of this class may be called on any thread unless otherwise indicated in the comments. When used in the render process the methods of this class may only be called on the main thread."
Purpose: "Class used to represent a browser." The cross-process handle to a single browser window. Provides navigation, frame lookup, and basic state queries. Lifetime: valid until CefLifeSpanHandler::OnBeforeClose.
Methods
virtual bool IsValid() = 0
Return Value: "True if this object is currently valid. This will return false after CefLifeSpanHandler::OnBeforeClose is called."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefBrowserHost> GetHost() = 0
Return Value: "Returns the browser host object. This method can only be called in the browser process."
Threading Constraint: Threading constraint not specified in source.
virtual bool CanGoBack() = 0
Return Value: "Returns true if the browser can navigate backwards."
Threading Constraint: Threading constraint not specified in source.
virtual void GoBack() = 0
Return Value: "Navigate backwards."
Threading Constraint: Threading constraint not specified in source.
virtual bool CanGoForward() = 0
Return Value: "Returns true if the browser can navigate forwards."
Threading Constraint: Threading constraint not specified in source.
virtual void GoForward() = 0
Return Value: "Navigate forwards."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsLoading() = 0
Return Value: "Returns true if the browser is currently loading."
Threading Constraint: Threading constraint not specified in source.
virtual void Reload() = 0
Return Value: "Reload the current page."
Threading Constraint: Threading constraint not specified in source.
virtual void ReloadIgnoreCache() = 0
Return Value: "Reload the current page ignoring any cached data."
Threading Constraint: Threading constraint not specified in source.
virtual void StopLoad() = 0
Return Value: "Stop loading the page."
Threading Constraint: Threading constraint not specified in source.
virtual int GetIdentifier() = 0
Return Value: "Returns the globally unique identifier for this browser. This value is also used as the tabId for extension APIs."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsSame(CefRefPtr<CefBrowser> that) = 0
Return Value: "Returns true if this object is pointing to the same handle as |that| object."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsPopup() = 0
Return Value: "Returns true if the browser is a popup."
Threading Constraint: Threading constraint not specified in source.
virtual bool HasDocument() = 0
Return Value: "Returns true if a document has been loaded in the browser."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefFrame> GetMainFrame() = 0
Return Value: "Returns the main (top-level) frame for the browser. In the browser process this will return a valid object until after CefLifeSpanHandler::OnBeforeClose is called. In the renderer process this will return NULL if the main frame is hosted in a different renderer process (e.g. for cross-origin sub-frames). The main frame object will change during cross-origin navigation or re-navigation after renderer process termination (due to crashes, etc)."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefFrame> GetFocusedFrame() = 0
Return Value: "Returns the focused frame for the browser."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefFrame> GetFrameByIdentifier(const CefString& identifier) = 0
Return Value: "Returns the frame with the specified identifier, or NULL if not found."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefFrame> GetFrameByName(const CefString& name) = 0
Return Value: "Returns the frame with the specified name, or NULL if not found." (name is an optional parameter.)
Threading Constraint: Threading constraint not specified in source.
virtual size_t GetFrameCount() = 0
Return Value: "Returns the number of frames that currently exist."
Threading Constraint: Threading constraint not specified in source.
virtual void GetFrameIdentifiers(std::vector<CefString>& identifiers) = 0
Return Value: "Returns the identifiers of all existing frames."
Threading Constraint: Threading constraint not specified in source.
virtual void GetFrameNames(std::vector<CefString>& names) = 0
Return Value: "Returns the names of all existing frames."
Threading Constraint: Threading constraint not specified in source.
Usage Example
// Inside a handler that holds a CefRefPtr<CefBrowser> browser:
if (browser->IsValid()) {
if (browser->CanGoBack()) browser->GoBack();
CefRefPtr<CefFrame> main = browser->GetMainFrame();
if (main) main->LoadURL("https://example.com");
}
// Browser-process only:
CefRefPtr<CefBrowserHost> host = browser->GetHost();
host->SetZoomLevel(1.5);CefRunFileDialogCallback
Source File: include/cef_browser.h
Process / Thread Context: "The methods of this class will be called on the browser process UI thread."
Purpose: "Callback interface for CefBrowserHost::RunFileDialog." Implement to receive the user's file selection.
Methods
virtual void OnFileDialogDismissed(const std::vector<CefString>& file_paths) = 0
Parameters:
file_paths: "Will be a single value or a list of values depending on the dialog mode. If the selection was cancelled |file_paths| will be empty."
Return Value: void.
Usage Instruction: Handle the user's selection or cancellation.
Threading Constraint: Browser process UI thread.
Usage Example
class MyFileDialogCallback : public CefRunFileDialogCallback {
public:
explicit MyFileDialogCallback(CefRefPtr<CefBrowser> b) : browser_(b) {}
void OnFileDialogDismissed(const std::vector<CefString>& paths) override {
if (paths.empty()) return; // user cancelled
for (const auto& p : paths) {
// process selected file
}
}
private:
CefRefPtr<CefBrowser> browser_;
IMPLEMENT_REFCOUNTING(MyFileDialogCallback);
};
// Trigger from UI:
host->RunFileDialog(FILE_DIALOG_OPEN, "Open File", "", {".txt"},
new MyFileDialogCallback(browser));CefNavigationEntryVisitor
Source File: include/cef_browser.h
Process / Thread Context: "The methods of this class will be called on the browser process UI thread."
Purpose: "Callback interface for CefBrowserHost::GetNavigationEntries." Implement to iterate through the back/forward navigation history.
Methods
virtual bool Visit(CefRefPtr<CefNavigationEntry> entry, bool current, int index, int total) = 0
Parameters:
entry: A snapshot navigation entry. "Do not keep a reference to |entry| outside of this callback."current: "True if this entry is the currently loaded navigation entry."index: "0-based index of this entry."total: "Total number of entries."
Return Value: bool. "Return true to continue visiting entries or false to stop."
Usage Instruction: Iteration visitor pattern — copy any data you need before returning.
Threading Constraint: Browser process UI thread.
Usage Example
class MyHistoryVisitor : public CefNavigationEntryVisitor {
public:
bool Visit(CefRefPtr<CefNavigationEntry> entry,
bool current, int index, int total) override {
entries_.push_back({entry->GetURL().ToString(),
entry->GetTitle().ToString(),
current});
return true; // continue
}
const std::vector<HistoryItem>& items() const { return entries_; }
private:
struct HistoryItem { std::string url, title; bool current; };
std::vector<HistoryItem> entries_;
IMPLEMENT_REFCOUNTING(MyHistoryVisitor);
};
// Usage:
auto v = new MyHistoryVisitor();
host->GetNavigationEntries(v, /* current_only */ false);
// v->items() populated synchronously by the time the call returnsCefPdfPrintCallback
Source File: include/cef_browser.h
Process / Thread Context: "The methods of this class will be called on the browser process UI thread."
Purpose: "Callback interface for CefBrowserHost::PrintToPDF." Implement to learn when PDF generation completes.
Methods
virtual void OnPdfPrintFinished(const CefString& path, bool ok) = 0
Parameters:
path: The output path passed toPrintToPDF.ok: "True if the printing completed successfully or false otherwise."
Return Value: void.
Usage Instruction: React to success/failure; the caller owns path and is responsible for deleting the file when done.
Threading Constraint: Browser process UI thread. Note: on Linux you must implement CefPrintHandler::GetPdfPaperSize.
Usage Example
class MyPdfCallback : public CefPdfPrintCallback {
public:
void OnPdfPrintFinished(const CefString& path, bool ok) override {
if (ok) LOG(INFO) << "PDF saved to " << path.ToString();
else LOG(ERROR) << "PDF print failed for " << path.ToString();
}
private:
IMPLEMENT_REFCOUNTING(MyPdfCallback);
};
CefPdfPrintSettings settings{};
// configure settings...
host->PrintToPDF("/tmp/out.pdf", settings, new MyPdfCallback());CefDownloadImageCallback
Source File: include/cef_browser.h
Process / Thread Context: "The methods of this class will be called on the browser process UI thread."
Purpose: "Callback interface for CefBrowserHost::DownloadImage." Implement to receive downloaded favicon/image bitmaps.
Methods
virtual void OnDownloadImageFinished(const CefString& image_url, int http_status_code, CefRefPtr<CefImage> image) = 0
Parameters:
image_url: "The URL that was downloaded."http_status_code: "Resulting HTTP status code."image: "The resulting image, possibly at multiple scale factors, or empty if the download failed." (Optional parameter — may be empty.)
Return Value: void.
Usage Instruction: Inspect http_status_code; if image is non-empty, use CefImage methods to retrieve bitmaps at the desired scale.
Threading Constraint: Browser process UI thread.
Usage Example
class FaviconCallback : public CefDownloadImageCallback {
public:
void OnDownloadImageFinished(const CefString& url, int code,
CefRefPtr<CefImage> img) override {
if (code != 200 || !img) return;
// Use img->GetAsBitmap(...) to extract pixel data
}
private:
IMPLEMENT_REFCOUNTING(FaviconCallback);
};
host->DownloadImage(faviconUrl, /* is_favicon */ true,
/* max_image_size */ 64, /* bypass_cache */ false,
new FaviconCallback());CefBrowserHost
Source File: include/cef_browser.h
Process / Thread Context: "Class used to represent the browser process aspects of a browser. The methods of this class can only be called in the browser process. They may be called on any thread in that process unless otherwise indicated in the comments."
Purpose: The browser-process-only control surface for a CefBrowser. Owns browser creation (CreateBrowser/CreateBrowserSync), close lifecycle (CloseBrowser/TryCloseBrowser/IsReadyToBeClosed), window/UI integration (focus, window handles, zoom), file dialogs, downloads, printing, find-in-page, DevTools protocol, navigation entry snapshots, accessibility, drag-and-drop, IME, mouse/key/touch event injection, and a large set of windowless-rendering helpers.
Methods
static bool CreateBrowser(const CefWindowInfo& windowInfo, CefRefPtr<CefClient> client, const CefString& url, const CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue> extra_info, CefRefPtr<CefRequestContext> request_context)
Parameters:
windowInfo: Window parameters. "All values will be copied internally and the actual window (if any) will be created on the UI thread."client: Browser client. Optional (optional_param=client).url: Initial URL. Optional.settings: Browser-level settings.extra_info: Optional dictionary passed toCefRenderProcessHandler::OnBrowserCreated(). Optional.request_context: Optional — empty means the global request context.
Return Value: bool. True if the browser was created (the actual window creation happens asynchronously on the UI thread).
Usage Instruction: "This method can be called on any browser process thread and will not block." Preferred entry point for new browser windows.
Threading Constraint: Any browser process thread.
static CefRefPtr<CefBrowser> CreateBrowserSync(const CefWindowInfo& windowInfo, CefRefPtr<CefClient> client, const CefString& url, const CefBrowserSettings& settings, CefRefPtr<CefDictionaryValue> extra_info, CefRefPtr<CefRequestContext> request_context)
Return Value: The created CefBrowser. "This method can only be called on the browser process UI thread."
Usage Instruction: Use when you need a synchronous browser handle (e.g. inside OnContextInitialized).
Threading Constraint: Browser process UI thread.
static CefRefPtr<CefBrowser> GetBrowserByIdentifier(int browser_id)
Return Value: "Returns the browser (if any) with the specified identifier." Use the int returned by CefBrowser::GetIdentifier().
Threading Constraint: Browser process.
virtual CefRefPtr<CefBrowser> GetBrowser() = 0
Return Value: "Returns the hosted browser object."
Threading Constraint: Threading constraint not specified in source.
virtual void CloseBrowser(bool force_close) = 0
Return Value: Multi-stage close. "If |force_close| is false then JavaScript unload handlers, if any, may be fired and the close may be delayed or canceled by the user. If |force_close| is true then the user will not be prompted and the close will proceed immediately (possibly asynchronously)." Header recommends TryCloseBrowser() for most use cases.
Threading Constraint: Threading constraint not specified in source.
virtual bool TryCloseBrowser() = 0
Return Value: "Helper for closing a browser." Call from a top-level window close handler. "Returns false if the close will be delayed (JavaScript unload handlers triggered but still pending) or true if the close will proceed immediately (possibly asynchronously). This method must be called on the browser process UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsReadyToBeClosed() = 0
Return Value: "Returns true if the browser is ready to be closed, meaning that the close has already been initiated and that JavaScript unload handlers have already executed or should be ignored." "This method must be called on the browser process UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void SetFocus(bool focus) = 0
Return Value: "Set whether the browser is focused."
Threading Constraint: Threading constraint not specified in source.
virtual CefWindowHandle GetWindowHandle() = 0
Return Value: "Retrieve the window handle (if any) for this browser. If this browser is wrapped in a CefBrowserView this method should be called on the browser process UI thread and it will return the handle for the top-level native window."
Threading Constraint: Threading constraint not specified in source.
virtual CefWindowHandle GetOpenerWindowHandle() = 0
Return Value: "Retrieve the window handle (if any) of the browser that opened this browser. Will return NULL for non-popup browsers or if this browser is wrapped in a CefBrowserView."
Threading Constraint: Threading constraint not specified in source.
virtual int GetOpenerIdentifier() = 0
Return Value: "Retrieve the unique identifier of the browser that opened this browser. Will return 0 for non-popup browsers."
Threading Constraint: Threading constraint not specified in source.
virtual bool HasView() = 0
Return Value: "Returns true if this browser is wrapped in a CefBrowserView."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefClient> GetClient() = 0
Return Value: "Returns the client for this browser."
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefRequestContext> GetRequestContext() = 0
Return Value: "Returns the request context for this browser."
Threading Constraint: Threading constraint not specified in source.
virtual bool CanZoom(cef_zoom_command_t command) = 0
Return Value: "Returns true if this browser can execute the specified zoom command. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void Zoom(cef_zoom_command_t command) = 0
Return Value: "Execute a zoom command in this browser. If called on the UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual double GetDefaultZoomLevel() = 0
Return Value: "Get the default zoom level. This value will be 0.0 by default but can be configured. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual double GetZoomLevel() = 0
Return Value: "Get the current zoom level. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void SetZoomLevel(double zoomLevel) = 0
Return Value: "Change the zoom level to the specified value. Specify 0.0 to reset the zoom level to the default. If called on the UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void RunFileDialog(FileDialogMode mode, const CefString& title, const CefString& default_file_path, const std::vector<CefString>& accept_filters, CefRefPtr<CefRunFileDialogCallback> callback) = 0
Return Value: File chooser dialog. accept_filters may be MIME types ("text/*", "image/*"), individual extensions (.txt, .png), or combined description and extension ("Image Types|.png;.gif;.jpg"). "The dialog will be initiated asynchronously on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void StartDownload(const CefString& url) = 0
Return Value: "Download the file at |url| using CefDownloadHandler."
Threading Constraint: Threading constraint not specified in source.
virtual void DownloadImage(const CefString& image_url, bool is_favicon, uint32_t max_image_size, bool bypass_cache, CefRefPtr<CefDownloadImageCallback> callback) = 0
Return Value: Download image at image_url; if is_favicon, cookies are not sent or accepted; images larger than max_image_size DIP are filtered (0 = unlimited); bypass_cache ignores cached entries.
Threading Constraint: Threading constraint not specified in source.
virtual void Print() = 0
Return Value: "Print the current browser contents."
Threading Constraint: Threading constraint not specified in source.
virtual void PrintToPDF(const CefString& path, const CefPdfPrintSettings& settings, CefRefPtr<CefPdfPrintCallback> callback) = 0
Return Value: Print to PDF. "The caller is responsible for deleting |path| when done. For PDF printing to work on Linux you must implement the CefPrintHandler::GetPdfPaperSize method." callback is optional.
Threading Constraint: Threading constraint not specified in source.
virtual void Find(const CefString& searchText, bool forward, bool matchCase, bool findNext) = 0
Return Value: Search. "The search will be restarted if |searchText| or |matchCase| change. The search will be stopped if |searchText| is empty. The CefFindHandler instance, if any, returned via CefClient::GetFindHandler will be called to report find results."
Threading Constraint: Threading constraint not specified in source.
virtual void StopFinding(bool clearSelection) = 0
Return Value: "Cancel all searches that are currently going on."
Threading Constraint: Threading constraint not specified in source.
virtual void ShowDevTools(const CefWindowInfo& windowInfo, CefRefPtr<CefClient> client, const CefBrowserSettings& settings, const CefPoint& inspect_element_at) = 0
Return Value: Open DevTools in its own browser. If already open, focuses it and ignores the parameters. inspect_element_at non-empty inspects the element at (x,y). "The |windowInfo| parameter will be ignored if this browser is wrapped in a CefBrowserView." All four optional.
Threading Constraint: Threading constraint not specified in source.
virtual void CloseDevTools() = 0
Return Value: "Explicitly close the associated DevTools browser, if any."
Threading Constraint: Threading constraint not specified in source.
virtual bool HasDevTools() = 0
Return Value: "Returns true if this browser currently has an associated DevTools browser. Must be called on the browser process UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual bool SendDevToolsMessage(const void* message, size_t message_size) = 0
Return Value: "Send a method call message over the DevTools protocol. |message| must be a UTF8-encoded JSON dictionary that contains 'id' (int), 'method' (string) and 'params' (dictionary, optional) values." Returns true if called on the UI thread and the message was successfully submitted for validation; false otherwise.
Threading Constraint: Threading constraint not specified in source.
virtual int ExecuteDevToolsMethod(int message_id, const CefString& method, CefRefPtr<CefDictionaryValue> params) = 0
Return Value: Structured version of SendDevToolsMessage. "Returns the assigned message ID if called on the UI thread and the message was successfully submitted for validation, otherwise 0." Pass message_id=0 to auto-assign. params optional.
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefRegistration> AddDevToolsMessageObserver(CefRefPtr<CefDevToolsMessageObserver> observer) = 0
Return Value: "Add an observer for DevTools protocol messages (method results and events). The observer will remain registered until the returned Registration object is destroyed."
Threading Constraint: Threading constraint not specified in source.
virtual void GetNavigationEntries(CefRefPtr<CefNavigationEntryVisitor> visitor, bool current_only) = 0
Return Value: "Retrieve a snapshot of current navigation entries as values sent to the specified visitor. If |current_only| is true only the current navigation entry will be sent, otherwise all navigation entries will be sent."
Threading Constraint: Threading constraint not specified in source.
virtual void ReplaceMisspelling(const CefString& word) = 0
Return Value: "If a misspelled word is currently selected in an editable node calling this method will replace it with the specified |word|."
Threading Constraint: Threading constraint not specified in source.
virtual void AddWordToDictionary(const CefString& word) = 0
Return Value: "Add the specified |word| to the spelling dictionary."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsWindowRenderingDisabled() = 0
Return Value: "Returns true if window rendering is disabled."
Threading Constraint: Threading constraint not specified in source.
virtual void WasResized() = 0
Return Value: "Notify the browser that the widget has been resized. The browser will first call CefRenderHandler::GetViewRect to get the new size and then call CefRenderHandler::OnPaint asynchronously with the updated regions. This method is only used when window rendering is disabled."
Threading Constraint: Threading constraint not specified in source.
virtual void WasHidden(bool hidden) = 0
Return Value: "Notify the browser that it has been hidden or shown. Layouting and CefRenderHandler::OnPaint notification will stop when the browser is hidden. This method is only used when window rendering is disabled."
Threading Constraint: Threading constraint not specified in source.
virtual void NotifyScreenInfoChanged() = 0
Return Value: "Notify the browser that screen information has changed. Updated information will be sent to the renderer process to configure screen size and position values used by CSS and JavaScript (window.deviceScaleFactor, window.screenX/Y, window.outerWidth/Height, etc.)." Used with (a) windowless rendering and (b) windowed rendering with external (client-provided) root window.
Threading Constraint: Threading constraint not specified in source.
virtual void Invalidate(PaintElementType type) = 0
Return Value: "Invalidate the view. The browser will call CefRenderHandler::OnPaint asynchronously. This method is only used when window rendering is disabled."
Threading Constraint: Threading constraint not specified in source.
virtual void SendExternalBeginFrame() = 0
Return Value: "Issue a BeginFrame request to Chromium. Only valid when CefWindowInfo::external_begin_frame_enabled is set to true."
Threading Constraint: Threading constraint not specified in source.
virtual void SendKeyEvent(const CefKeyEvent& event) = 0
Return Value: "Send a key event to the browser."
Threading Constraint: Threading constraint not specified in source.
virtual void SendMouseClickEvent(const CefMouseEvent& event, MouseButtonType type, bool mouseUp, int clickCount) = 0
Return Value: "Send a mouse click event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view."
Threading Constraint: Threading constraint not specified in source.
virtual void SendMouseMoveEvent(const CefMouseEvent& event, bool mouseLeave) = 0
Return Value: "Send a mouse move event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view."
Threading Constraint: Threading constraint not specified in source.
virtual void SendMouseWheelEvent(const CefMouseEvent& event, int deltaX, int deltaY) = 0
Return Value: "Send a mouse wheel event to the browser. The |x| and |y| coordinates are relative to the upper-left corner of the view. The |deltaX| and |deltaY| values represent the movement delta in the X and Y directions respectively. In order to scroll inside select popups with window rendering disabled CefRenderHandler::GetScreenPoint should be implemented properly."
Threading Constraint: Threading constraint not specified in source.
virtual void SendTouchEvent(const CefTouchEvent& event) = 0
Return Value: "Send a touch event to the browser for a windowless browser."
Threading Constraint: Threading constraint not specified in source.
virtual void SendCaptureLostEvent() = 0
Return Value: "Send a capture lost event to the browser."
Threading Constraint: Threading constraint not specified in source.
virtual void NotifyMoveOrResizeStarted() = 0
Return Value: "Notify the browser that the window hosting it is about to be moved or resized. This method is only used on Windows and Linux."
Threading Constraint: Threading constraint not specified in source.
virtual int GetWindowlessFrameRate() = 0
Return Value: "Returns the maximum rate in frames per second (fps) that CefRenderHandler::OnPaint will be called for a windowless browser. The actual fps may be lower if the browser cannot generate frames at the requested rate. The minimum value is 1 and the default value is 30. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void SetWindowlessFrameRate(int frame_rate) = 0
Return Value: "Set the maximum rate in frames per second (fps) that CefRenderHandler::OnPaint will be called for a windowless browser. The actual fps may be lower if the browser cannot generate frames at the requested rate. The minimum value is 1 and the default value is 30. Can also be set at browser creation via CefBrowserSettings.windowless_frame_rate."
Threading Constraint: Threading constraint not specified in source.
virtual void ImeSetComposition(const CefString& text, const std::vector<CefCompositionUnderline>& underlines, const CefRange& replacement_range, const CefRange& selection_range) = 0
Return Value: "Begins a new composition or updates the existing composition." text optional; underlines optional; replacement_range and selection_range only used on OS X. "This method is only used when window rendering is disabled." Cancel via ImeCancelComposition; complete via ImeCommitText or ImeFinishComposingText.
Threading Constraint: Threading constraint not specified in source.
virtual void ImeCommitText(const CefString& text, const CefRange& replacement_range, int relative_cursor_pos) = 0
Return Value: "Completes the existing composition by optionally inserting the specified |text| into the composition node." text optional. replacement_range and relative_cursor_pos only used on OS X. Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void ImeFinishComposingText(bool keep_selection) = 0
Return Value: "Completes the existing composition by applying the current composition node contents. If |keep_selection| is false the current selection, if any, will be discarded." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void ImeCancelComposition() = 0
Return Value: "Cancels the existing composition and discards the composition node contents without applying them." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragTargetDragEnter(CefRefPtr<CefDragData> drag_data, const CefMouseEvent& event, DragOperationsMask allowed_ops) = 0
Return Value: "Call this method when the user drags the mouse into the web view (before calling DragTargetDragOver/DragTargetLeave/DragTargetDrop). |drag_data| should not contain file contents as this type of data is not allowed to be dragged into the web view." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragTargetDragOver(const CefMouseEvent& event, DragOperationsMask allowed_ops) = 0
Return Value: "Call this method each time the mouse is moved across the web view during a drag operation (after calling DragTargetDragEnter and before calling DragTargetDragLeave/DragTargetDrop)." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragTargetDragLeave() = 0
Return Value: "Call this method when the user drags the mouse out of the web view (after calling DragTargetDragEnter)." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragTargetDrop(const CefMouseEvent& event) = 0
Return Value: "Call this method when the user completes the drag operation by dropping the object onto the web view (after calling DragTargetDragEnter). The object being dropped is |drag_data|, given as an argument to the previous DragTargetDragEnter call." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragSourceEndedAt(int x, int y, DragOperationsMask op) = 0
Return Value: "Call this method when the drag operation started by a CefRenderHandler::StartDragging call has ended either in a drop or by being cancelled. |x| and |y| are mouse coordinates relative to the upper-left corner of the view. If the web view is both the drag source and the drag target then all DragTarget* methods should be called before DragSource* methods." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual void DragSourceSystemDragEnded() = 0
Return Value: "Call this method when the drag operation started by a CefRenderHandler::StartDragging call has completed. This method may be called immediately without first calling DragSourceEndedAt to cancel a drag operation." Windowless rendering only.
Threading Constraint: Threading constraint not specified in source.
virtual CefRefPtr<CefNavigationEntry> GetVisibleNavigationEntry() = 0
Return Value: "Returns the current visible navigation entry for this browser. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void SetAccessibilityState(cef_state_t accessibility_state) = 0
Return Value: "Set accessibility state for all frames. |accessibility_state| may be default, enabled or disabled." STATE_DEFAULT → disabled unless forced via flags; STATE_ENABLED → enabled; STATE_DISABLED → fully disabled. For windowed browsers uses Complete mode (Chromium manages platform a11y objects); for windowless uses TreeOnly mode (events delivered to CefAccessibilityHandler, no platform a11y objects).
Threading Constraint: Threading constraint not specified in source.
virtual void SetAutoResizeEnabled(bool enabled, const CefSize& min_size, const CefSize& max_size) = 0
Return Value: "Enable notifications of auto resize via CefDisplayHandler::OnAutoResize. Notifications are disabled by default. |min_size| and |max_size| define the range of allowed sizes."
Threading Constraint: Threading constraint not specified in source.
virtual void SetAudioMuted(bool mute) = 0
Return Value: "Set whether the browser's audio is muted."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsAudioMuted() = 0
Return Value: "Returns true if the browser's audio is muted. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsFullscreen() = 0
Return Value: "Returns true if the renderer is currently in browser fullscreen. This differs from window fullscreen in that browser fullscreen is entered using the JavaScript Fullscreen API and modifies CSS attributes such as the ::backdrop pseudo-element and :fullscreen pseudo-class. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual void ExitFullscreen(bool will_cause_resize) = 0
Return Value: "Requests the renderer to exit browser fullscreen. In most cases exiting window fullscreen should also exit browser fullscreen. With Alloy style this method should be called in response to a user action such as clicking the green traffic light button on MacOS (CefWindowDelegate::OnWindowFullscreenTransition callback) or pressing the 'ESC' key (CefKeyboardHandler::OnPreKeyEvent callback). With Chrome style these standard exit actions are handled internally but new/additional user actions can use this method. Set |will_cause_resize| to true if exiting browser fullscreen will cause a view resize."
Threading Constraint: Threading constraint not specified in source.
virtual bool CanExecuteChromeCommand(int command_id) = 0
Return Value: "Returns true if a Chrome command is supported and enabled. Use the cef_id_for_command_id_name() function for version-safe mapping of command IDC names from cef_command_ids.h to version-specific numerical |command_id| values. This method can only be called on the UI thread. Only used with Chrome style."
Threading Constraint: Threading constraint not specified in source.
virtual void ExecuteChromeCommand(int command_id, cef_window_open_disposition_t disposition) = 0
Return Value: "Execute a Chrome command. Use the cef_id_for_command_id_name() function for version-safe mapping of command IDC names from cef_command_ids.h to version-specific numerical |command_id| values. |disposition| provides information about the intended command target. Only used with Chrome style."
Threading Constraint: Threading constraint not specified in source.
virtual bool IsRenderProcessUnresponsive() = 0
Return Value: "Returns true if the render process associated with this browser is currently unresponsive as indicated by a lack of input event processing for at least 15 seconds. To receive associated state change notifications and optionally handle an unresponsive render process implement CefRequestHandler::OnRenderProcessUnresponsive. This method can only be called on the UI thread."
Threading Constraint: Threading constraint not specified in source.
virtual cef_runtime_style_t GetRuntimeStyle() = 0
Return Value: "Returns the runtime style for this browser (ALLOY or CHROME). See cef_runtime_style_t documentation for details." Default retval: CEF_RUNTIME_STYLE_DEFAULT.
Threading Constraint: Threading constraint not specified in source.
Usage Example
// 1) Create a browser asynchronously (most common):
void MyApp::OnContextInitialized() override {
CefWindowInfo wi;
wi.SetAsTopLevel(/* native_parent_hwnd */ nullptr);
CefBrowserSettings settings;
CefBrowserHost::CreateBrowser(wi, new MyClient(), "https://example.com",
settings, /* extra_info */ nullptr,
/* request_context */ nullptr);
}
// 2) Create synchronously on the UI thread:
CefRefPtr<CefBrowser> browser = CefBrowserHost::CreateBrowserSync(
wi, new MyClient(), "https://example.com", settings, nullptr, nullptr);
// 3) Send DevTools method (UI thread):
int id = browser->GetHost()->ExecuteDevToolsMethod(
0 /* auto-id */, "Page.reload",
CefDictionaryValue::Create());