Click or drag to resize

IBrowserHost Interface

Version 118.6.80
Interface used to represent the browser process aspects of a browser window. They may be called on any thread in that process unless otherwise indicated in the comments.

Namespace:  CefSharp
Assembly:  CefSharp (in CefSharp.dll) Version: 118.6.80.0 (118.6.80.0)
Syntax
public interface IBrowserHost : IDisposable

The IBrowserHost type exposes the following members.

Properties
  NameDescription
Public propertyExtension
Returns the extension hosted in this browser or null if no extension is hosted. See LoadExtension(String, String, IExtensionHandler) for details.
Public propertyHasDevTools
Returns true if this browser currently has an associated DevTools browser. Must be called on the CEF UI thread.
Public propertyIsAudioMuted
Returns true if the browser's audio is muted. This method can only be called on the CEF UI thread.
Public propertyIsBackgroundHost
Returns true if this browser is hosting an extension background script. Background hosts do not have a window and are not displayable. See LoadExtension(String, String, IExtensionHandler) for details.
Public propertyIsDisposed
Gets a value indicating whether the browserHost has been disposed of.
Public propertyRequestContext
Returns the request context for this browser.
Public propertyWindowlessFrameRate
Gets/sets 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 maximum value is 60 (default 30). This method can only be called on the UI thread. Can also be set at browser creation via BrowserSettings.WindowlessFrameRate.
Public propertyWindowRenderingDisabled
Returns true if window rendering is disabled.
Top
Methods
  NameDescription
Public methodAddDevToolsMessageObserver
Add an observer for DevTools protocol messages (method results and events). The observer will remain registered until the returned Registration object is destroyed. See the SendDevToolsMessage documentation for additional usage information.
Public methodAddWordToDictionary
Add the specified word to the spelling dictionary.
Public methodCloseBrowser
Request that the browser close. The JavaScript 'onbeforeunload' event will be fired.
Public methodCloseDevTools
Explicitly close the developer tools window if one exists for this browser instance.
Public methodDispose
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
(Inherited from IDisposable.)
Public methodDragSourceEndedAt
Call this method when the drag operation started by a StartDragging(IDragData, DragOperationsMask, Int32, Int32) call has ended either in a drop or by being cancelled. If the web view is both the drag source and the drag target then all DragTarget* methods should be called before DragSource* methods. This method is only used when window rendering is disabled.
Public methodDragSourceSystemDragEnded
Call this method when the drag operation started by a StartDragging(IDragData, DragOperationsMask, Int32, Int32) call has completed. This method may be called immediately without first calling DragSourceEndedAt to cancel a drag operation. If the web view is both the drag source and the drag target then all DragTarget* methods should be called before DragSource* mthods. This method is only used when window rendering is disabled.
Public methodDragTargetDragDrop
Call this method when the user completes the drag operation by dropping the object onto the web view (after calling DragTargetDragEnter(IDragData, MouseEvent, DragOperationsMask)). The object being dropped is IDragData, given as an argument to the previous DragTargetDragEnter(IDragData, MouseEvent, DragOperationsMask) call. This method is only used when window rendering is disabled.
Public methodDragTargetDragEnter
Public methodDragTargetDragLeave
Call this method when the user drags the mouse out of the web view (after calling DragTargetDragEnter(IDragData, MouseEvent, DragOperationsMask)). This method is only used when window rendering is disabled.
Public methodDragTargetDragOver
Call this method each time the mouse is moved across the web view during a drag operation (after calling DragTargetDragEnter(IDragData, MouseEvent, DragOperationsMask) and before calling DragTargetDragLeave/DragTargetDragDrop(MouseEvent)). This method is only used when window rendering is disabled.
Public methodExecuteDevToolsMethod(Int32, String, IDictionaryString, Object)
Execute a method call over the DevTools protocol. This is a more structured version of SendDevToolsMessage. See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details of supported methods and the expected parameters dictionary contents. See the SendDevToolsMessage documentation for additional usage information.
Public methodExecuteDevToolsMethod(Int32, String, String)
Execute a method call over the DevTools protocol. This is a more structured version of SendDevToolsMessage. See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details of supported methods and the expected paramsAsJson dictionary contents. See the SendDevToolsMessage documentation for additional usage information.
Public methodFind
Search for searchText.
Public methodGetNavigationEntries
Retrieve a snapshot of current navigation entries as values sent to the specified visitor.
Public methodGetNextDevToolsMessageId
Public methodGetOpenerWindowHandle
Retrieve the window handle of the browser that opened this browser.
Public methodGetVisibleNavigationEntry
Returns the current visible navigation entry for this browser. This method can only be called on the CEF UI thread which by default is not the same as your application UI thread.
Public methodGetWindowHandle
Retrieve the window handle for this browser.
Public methodGetZoomLevel
Gets the current zoom level. The default zoom level is 0.0. This method can only be called on the CEF UI thread.
Public methodGetZoomLevelAsync
Get the current zoom level. The default zoom level is 0.0. This method executes GetZoomLevel on the CEF UI thread in an async fashion.
Public methodImeCancelComposition
Cancels the existing composition and discards the composition node contents without applying them. See comments on ImeSetComposition for usage. This method is only used when window rendering is disabled. (WPF and OffScreen)
Public methodImeCommitText
Completes the existing composition by optionally inserting the specified text into the composition node. This method is only used when window rendering is disabled. (WPF and OffScreen)
Public methodImeFinishComposingText
Completes the existing composition by applying the current composition node contents. See comments on ImeSetComposition for usage. This method is only used when window rendering is disabled. (WPF and OffScreen)
Public methodImeSetComposition
Begins a new composition or updates the existing composition. Blink has a special node (a composition node) that allows the input method to change text without affecting other DOM nodes. This method may be called multiple times as the composition changes. When the client is done making changes the composition should either be canceled or completed. To cancel the composition call ImeCancelComposition. To complete the composition call either ImeCommitText or ImeFinishComposingText. Completion is usually signaled when: The client receives a WM_IME_COMPOSITION message with a GCS_RESULTSTR flag (on Windows). This method is only used when window rendering is disabled. (WPF and OffScreen)
Public methodInvalidate
Invalidate the view. The browser will call CefRenderHandler::OnPaint asynchronously. This method is only used when window rendering is disabled (OSR).
Public methodNotifyMoveOrResizeStarted
Notify the browser that the window hosting it is about to be moved or resized. This will dismiss any existing popups (dropdowns).
Public methodNotifyScreenInfoChanged
Send a notification to the browser that the screen info has changed. The browser will then call CefRenderHandler::GetScreenInfo to update the screen information with the new values. This simulates moving the webview window from one display to another, or changing the properties of the current display. This method is only used when window rendering is disabled.
Public methodPrint
Print the current browser contents.
Public methodPrintToPdf
Asynchronously prints the current browser contents to the Pdf file specified. The caller is responsible for deleting the file when done.
Public methodReplaceMisspelling
If a misspelled word is currently selected in an editable node calling this method will replace it with the specified word.
Public methodRunFileDialog
Call to run a file chooser dialog. Only a single file chooser dialog may be pending at any given time. The dialog will be initiated asynchronously on the CEF UI thread.
Public methodSendCaptureLostEvent
Send a capture lost event to the browser.
Public methodSendDevToolsMessage
Send a method call message over the DevTools protocol. messageAsJson must be a UTF8-encoded JSON dictionary that contains "id" (int), "method" (string) and "params" (dictionary, optional) values. See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details of supported methods and the expected "params" dictionary contents. messageAsJson will be copied if necessary. This method will return true if called on the CEF UI thread and the message was successfully submitted for validation, otherwise false. Validation will be applied asynchronously and any messages that fail due to formatting errors or missing parameters may be discarded without notification. Prefer ExecuteDevToolsMethod if a more structured approach to message formatting is desired. Every valid method call will result in an asynchronous method result or error message that references the sent message "id". Event messages are received while notifications are enabled (for example, between method calls for "Page.enable" and "Page.disable"). All received messages will be delivered to the observer(s) registered with AddDevToolsMessageObserver. See OnDevToolsMessage(IBrowser, Stream) documentation for details of received message contents. Usage of the SendDevToolsMessage, ExecuteDevToolsMethod and AddDevToolsMessageObserver methods does not require an active DevTools front-end or remote-debugging session. Other active DevTools sessions will continue to function independently. However, any modification of global browser state by one session may not be reflected in the UI of other sessions. Communication with the DevTools front-end (when displayed) can be logged for development purposes by passing the `--devtools-protocol-log-file=<path>` command-line flag.
Public methodSendExternalBeginFrame
Issue a BeginFrame request to Chromium. Only valid when ExternalBeginFrameEnabled is set to true.
Public methodSendFocusEvent
Send a focus event to the browser. . (Used for OSR Rendering e.g. WPF or OffScreen)
Public methodSendKeyEvent(KeyEvent)
Send a key event to the browser.
Public methodSendKeyEvent(Int32, Int32, Int32)
Send key event to browser based on operating system message
Public methodSendMouseClickEvent
Send a mouse click event to the browser.
Public methodSendMouseMoveEvent
Send a mouse move event to the browser, coordinates,
Public methodSendMouseWheelEvent
Send a mouse wheel event to the browser.
Public methodSendTouchEvent
Send a touch event to the browser. WPF and OffScreen browsers only
Public methodSetAccessibilityState
Set accessibility state for all frames. If accessibilityState is Default then accessibility will be disabled by default and the state may be further controlled with the "force-renderer-accessibility" and "disable-renderer-accessibility" command-line switches. If accessibilityState is STATE_ENABLED then accessibility will be enabled. If accessibilityState is STATE_DISABLED then accessibility will be completely disabled. For windowed browsers accessibility will be enabled in Complete mode (which corresponds to kAccessibilityModeComplete in Chromium). In this mode all platform accessibility objects will be created and managed by Chromium's internal implementation. The client needs only to detect the screen reader and call this method appropriately. For example, on Windows the client can handle WM_GETOBJECT with OBJID_CLIENT to detect accessibility readers. For windowless browsers accessibility will be enabled in TreeOnly mode (which corresponds to kAccessibilityModeWebContentsOnly in Chromium). In this mode renderer accessibility is enabled, the full tree is computed, and events are passed to IAccessibiltyHandler, but platform accessibility objects are not created. The client may implement platform accessibility objects using IAccessibiltyHandler callbacks if desired.
Public methodSetAudioMuted
Set whether the browser's audio is muted.
Public methodSetAutoResizeEnabled
Enable notifications of auto resize via IDisplayHandler.OnAutoResize. Notifications are disabled by default.
Public methodSetFocus
Set whether the browser is focused. (Used for Normal Rendering e.g. WinForms)
Public methodSetZoomLevel
Change the zoom level to the specified value. Specify 0.0 to reset the zoom level. If called on the CEF UI thread the change will be applied immediately. Otherwise, the change will be applied asynchronously on the UI thread.
Public methodShowDevTools
Open developer tools in its own window. If inspectElementAtX and/or inspectElementAtY are specified then the element at the specified (x,y) location will be inspected.
Public methodStartDownload
Download the file at url using IDownloadHandler.
Public methodStopFinding
Cancel all searches that are currently going on.
Public methodTryCloseBrowser
Helper for closing a browser. Call this method from the top-level window close handler. Internally this calls CloseBrowser(false) if the close has not yet been initiated. This method returns false while the close is pending and true after the close has completed. See CloseBrowser(Boolean) and DoClose(IWebBrowser, IBrowser) documentation for additional usage information. This method must be called on the CEF UI thread.
Public methodWasHidden
Notify the browser that it has been hidden or shown. Layouting and rendering notification will stop when the browser is hidden. This method is only used when window rendering is disabled (WPF/OffScreen).
Public methodWasResized
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.
Top
Extension Methods
  NameDescription
Public Extension MethodExecuteDevToolsMethod
Execute a method call over the DevTools protocol. This is a more structured version of SendDevToolsMessage. See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details of supported methods and the expected parameters JSON message format. See the SendDevToolsMessage documentation for additional usage information.
(Defined by DevToolsExtensions.)
Public Extension MethodGetNavigationEntriesAsync
Retrieve a snapshot of current navigation entries
(Defined by AsyncExtensions.)
Public Extension MethodSendMouseClickEvent
Send a mouse click event to the browser.
(Defined by WebBrowserExtensions.)
Public Extension MethodSendMouseMoveEvent
Send a mouse move event to the browser.
(Defined by WebBrowserExtensions.)
Public Extension MethodSendMouseWheelEvent
Send a mouse wheel event to the browser.
(Defined by WebBrowserExtensions.)
Top
See Also