C# Class CefSharp.Wpf.ChromiumWebBrowser

Inheritance: System.Windows.Controls.ContentControl, IRenderWebBrowser, IWpfWebBrowser
Show file Open project: cefsharp/CefSharp Class Usage Examples

Public Properties

Property Type Description
AddressProperty System.Windows.DependencyProperty
CanGoBackProperty System.Windows.DependencyProperty
CanGoForwardProperty System.Windows.DependencyProperty
CleanupElementProperty System.Windows.DependencyProperty
IsBrowserInitializedProperty System.Windows.DependencyProperty
IsLoadingProperty System.Windows.DependencyProperty
TitleProperty System.Windows.DependencyProperty
TooltipTextProperty System.Windows.DependencyProperty
WebBrowserProperty System.Windows.DependencyProperty
ZoomLevelIncrementProperty System.Windows.DependencyProperty
ZoomLevelProperty System.Windows.DependencyProperty

Private Properties

Property Type Description
ChromiumWebBrowser System
CreateImage Image
CreatePopup System.Windows.Controls.Primitives.Popup
GetDragEffects DragDropEffects
GetDragOperationsMask DragOperationsMask
GetMouseEvent MouseEvent
IRenderWebBrowser CefSharp.Internals.BitmapInfo
IRenderWebBrowser CefSharp.Internals.ScreenInfo
IRenderWebBrowser CefSharp.Internals.ViewRect
IRenderWebBrowser bool
IRenderWebBrowser void
IRenderWebBrowser void
IRenderWebBrowser void
IRenderWebBrowser void
IRenderWebBrowser void
IRenderWebBrowser void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
IWebBrowserInternal void
OnActualSizeChanged void
OnAddressChanged void
OnApplicationExit void
OnCleanupElementChanged void
OnCleanupElementUnloaded void
OnDragEnter void
OnDragLeave void
OnDragOver void
OnDrop void
OnGotKeyboardFocus void
OnIsBrowserInitializedChanged void
OnIsVisibleChanged void
OnLoaded void
OnLostKeyboardFocus void
OnMouseButton void
OnPreviewKey void
OnTitleChanged void
OnTooltipClosed void
OnTooltipTextChanged void
OnTooltipTimerTick void
OnZoomLevelChanged void
PopupMouseEnter void
PopupMouseLeave void
PresentationSourceChangedHandler void
RemoveSourceHook void
SetPopupSizeAndPositionImpl void
UiThreadRunAsync void
UiThreadRunSync void
UpdateTooltip void
ZoomIn void
ZoomOut void
ZoomReset void

Public Methods

Method Description
Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

GetBrowser ( ) : IBrowser

Returns the current IBrowser Instance

Load ( string url ) : void

Loads the specified URL.

OnApplyTemplate ( ) : void

When overridden in a derived class, is invoked whenever application code or internal processes call M:System.Windows.FrameworkElement.ApplyTemplate.

RegisterAsyncJsObject ( string name, object objectToBind, BindingOptions options = null ) : void

Asynchronously registers a Javascript object in this specific browser instance.

Only methods of the object will be availabe.

The registered methods can only be called in an async way, they will all return immeditaly and the resulting object will be a standard javascript Promise object which is usable to wait for completion or failure.

RegisterJsObject ( string name, object objectToBind, BindingOptions options = null ) : void

Registers a Javascript object in this specific browser instance.

Protected Methods

Method Description
CreateOffscreenBrowser ( Size size ) : bool

Create the underlying Browser instance, can be overriden to defer control creation The browser will only be created when size > Size(0,0). If you specify a positive size then the browser will be created, if the ActualWidth and ActualHeight properties are in reality still 0 then you'll likely end up with a browser that won't render.

Dispose ( bool isDisposing ) : void

Releases unmanaged and - optionally - managed resources.

OnAddressChanged ( string oldValue, string newValue ) : void

Called when [address changed].

OnCleanupElementChanged ( FrameworkElement oldValue, FrameworkElement newValue ) : void

Called when [cleanup element changed].

OnIsBrowserInitializedChanged ( bool oldValue, bool newValue ) : void

Called when [is browser initialized changed].

OnMouseDown ( System.Windows.Input.MouseButtonEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnMouseLeave ( System.Windows.Input.MouseEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseLeave attached event is raised on this element. Implement this method to add class handling for this event.

OnMouseMove ( System.Windows.Input.MouseEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseMove attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnMouseUp ( System.Windows.Input.MouseButtonEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnMouseWheel ( System.Windows.Input.MouseWheelEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseWheel attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnPreviewKeyDown ( System.Windows.Input.KeyEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Keyboard.PreviewKeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnPreviewKeyUp ( System.Windows.Input.KeyEventArgs e ) : void

Invoked when an unhandled E:System.Windows.Input.Keyboard.PreviewKeyUp attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.

OnRendering ( object sender, WpfBitmapInfo bitmapInfo ) : void

Raises Rendering event

OnZoomLevelChanged ( double oldValue, double newValue ) : void

Called when [zoom level changed].

SourceHook ( IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, bool &handled ) : IntPtr

WindowProc callback interceptor. Handles Windows messages intended for the source hWnd, and passes them to the contained browser as needed.

Private Methods

Method Description
ChromiumWebBrowser ( ) : System

Initializes static members of the ChromiumWebBrowser class.

CreateImage ( ) : Image

Creates the image.

CreatePopup ( ) : System.Windows.Controls.Primitives.Popup

Creates the popup.

GetDragEffects ( DragOperationsMask mask ) : DragDropEffects

Gets the drag effects.

GetDragOperationsMask ( DragDropEffects dragDropEffects ) : DragOperationsMask

Converts .NET drag drop effects to CEF Drag Operations

GetMouseEvent ( System.Windows.DragEventArgs e ) : MouseEvent

Converts a .NET Drag event to a CefSharp MouseEvent

IRenderWebBrowser ( bool isPopup ) : CefSharp.Internals.BitmapInfo

Creates the bitmap information.

IRenderWebBrowser ( ) : CefSharp.Internals.ScreenInfo

Gets the screen information.

IRenderWebBrowser ( ) : CefSharp.Internals.ViewRect

Gets the view rect.

IRenderWebBrowser ( IDragData dragData, DragOperationsMask mask, int x, int y ) : bool

Starts the dragging.

IRenderWebBrowser ( CefSharp.Internals.BitmapInfo bitmapInfo ) : void

Invokes the render asynchronous.

IRenderWebBrowser ( DragOperationsMask operation ) : void
IRenderWebBrowser ( IntPtr handle, CefCursorType type ) : void

Sets the cursor.

IRenderWebBrowser ( Range selectedRange, Rect characterBounds ) : void
IRenderWebBrowser ( bool isOpen ) : void

Sets the popup is open.

IRenderWebBrowser ( int width, int height, int x, int y ) : void

Sets the popup size and position.

IWebBrowserInternal ( AddressChangedEventArgs args ) : void

Sets the address.

IWebBrowserInternal ( ConsoleMessageEventArgs args ) : void

Handles the E:ConsoleMessage event.

IWebBrowserInternal ( FrameLoadEndEventArgs args ) : void

Handles the E:FrameLoadEnd event.

IWebBrowserInternal ( FrameLoadStartEventArgs args ) : void

Handles the E:FrameLoadStart event.

IWebBrowserInternal ( IBrowser browser ) : void

Called when [after browser created].

IWebBrowserInternal ( LoadErrorEventArgs args ) : void

Handles the E:LoadError event.

IWebBrowserInternal ( LoadingStateChangedEventArgs args ) : void

Sets the loading state change.

IWebBrowserInternal ( StatusMessageEventArgs args ) : void

Handles the E:StatusMessage event.

IWebBrowserInternal ( TitleChangedEventArgs args ) : void

Sets the title.

IWebBrowserInternal ( string tooltipText ) : void

Sets the tooltip text.

OnActualSizeChanged ( object sender, System.Windows.SizeChangedEventArgs e ) : void

Handles the E:ActualSizeChanged event.

OnAddressChanged ( DependencyObject sender, System.Windows.DependencyPropertyChangedEventArgs args ) : void

Handles the E:AddressChanged event.

OnApplicationExit ( object sender, System.Windows.ExitEventArgs e ) : void

Handles the E:ApplicationExit event.

OnCleanupElementChanged ( DependencyObject sender, System.Windows.DependencyPropertyChangedEventArgs args ) : void

Handles the E:CleanupElementChanged event.

OnCleanupElementUnloaded ( object sender, RoutedEventArgs e ) : void

Handles the E:CleanupElementUnloaded event.

OnDragEnter ( object sender, System.Windows.DragEventArgs e ) : void

Handles the E:DragEnter event.

OnDragLeave ( object sender, System.Windows.DragEventArgs e ) : void

Handles the E:DragLeave event.

OnDragOver ( object sender, System.Windows.DragEventArgs e ) : void

Handles the E:DragOver event.

OnDrop ( object sender, System.Windows.DragEventArgs e ) : void

Handles the E:Drop event.

OnGotKeyboardFocus ( object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e ) : void

Handles the E:GotKeyboardFocus event.

OnIsBrowserInitializedChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Handles the E:IsBrowserInitializedChanged event.

OnIsVisibleChanged ( object sender, System.Windows.DependencyPropertyChangedEventArgs args ) : void

Handles the E:IsVisibleChanged event.

OnLoaded ( object sender, RoutedEventArgs routedEventArgs ) : void

Handles the E:Loaded event.

OnLostKeyboardFocus ( object sender, System.Windows.Input.KeyboardFocusChangedEventArgs e ) : void

Handles the E:LostKeyboardFocus event.

OnMouseButton ( System.Windows.Input.MouseButtonEventArgs e ) : void

Handles the E:MouseButton event.

OnPreviewKey ( System.Windows.Input.KeyEventArgs e ) : void

Handles the E:PreviewKey event.

OnTitleChanged ( DependencyObject d, System.Windows.DependencyPropertyChangedEventArgs e ) : void

Handles the E:TitleChanged event.

OnTooltipClosed ( object sender, RoutedEventArgs e ) : void

Handles the E:TooltipClosed event.

OnTooltipTextChanged ( ) : void

Called when [tooltip text changed].

OnTooltipTimerTick ( object sender, EventArgs e ) : void

Handles the E:TooltipTimerTick event.

OnZoomLevelChanged ( DependencyObject sender, System.Windows.DependencyPropertyChangedEventArgs args ) : void

Handles the E:ZoomLevelChanged event.

PopupMouseEnter ( object sender, System.Windows.Input.MouseEventArgs e ) : void

Handle the mouse cursor entering the pop-up.

PopupMouseLeave ( object sender, System.Windows.Input.MouseEventArgs e ) : void

Handle the mouse cursor exiting the pop-up.

PresentationSourceChangedHandler ( object sender, System.Windows.SourceChangedEventArgs args ) : void

PresentationSource changed handler.

RemoveSourceHook ( ) : void

Removes the source hook.

SetPopupSizeAndPositionImpl ( int width, int height, int x, int y ) : void

Sets the popup size and position implementation.

UiThreadRunAsync ( System.Action action, DispatcherPriority priority = DispatcherPriority.DataBind ) : void

Runs the specific Action on the Dispatcher in an async fashion

UiThreadRunSync ( System.Action action, DispatcherPriority priority = DispatcherPriority.DataBind ) : void

Runs the specific Action on the Dispatcher in an sync fashion

UpdateTooltip ( string text ) : void

Updates the tooltip.

ZoomIn ( ) : void

Zooms the browser in.

ZoomOut ( ) : void

Zooms the browser out.

ZoomReset ( ) : void

Reset the browser's zoom level to default.

Method Details

CreateOffscreenBrowser() protected method

Create the underlying Browser instance, can be overriden to defer control creation The browser will only be created when size > Size(0,0). If you specify a positive size then the browser will be created, if the ActualWidth and ActualHeight properties are in reality still 0 then you'll likely end up with a browser that won't render.
protected CreateOffscreenBrowser ( Size size ) : bool
size System.Windows.Size size of the current control, must be greater than Size(0, 0)
return bool

Dispose() public method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public Dispose ( ) : void
return void

Dispose() protected method

Releases unmanaged and - optionally - managed resources.
protected Dispose ( bool isDisposing ) : void
isDisposing bool true to release both managed and unmanaged resources; false to release only unmanaged resources.
return void

GetBrowser() public method

Returns the current IBrowser Instance
public GetBrowser ( ) : IBrowser
return IBrowser

Load() public method

Loads the specified URL.
public Load ( string url ) : void
url string The URL to be loaded.
return void

OnAddressChanged() protected method

Called when [address changed].
protected OnAddressChanged ( string oldValue, string newValue ) : void
oldValue string The old value.
newValue string The new value.
return void

OnApplyTemplate() public method

When overridden in a derived class, is invoked whenever application code or internal processes call M:System.Windows.FrameworkElement.ApplyTemplate.
public OnApplyTemplate ( ) : void
return void

OnCleanupElementChanged() protected method

Called when [cleanup element changed].
protected OnCleanupElementChanged ( FrameworkElement oldValue, FrameworkElement newValue ) : void
oldValue System.Windows.FrameworkElement The old value.
newValue System.Windows.FrameworkElement The new value.
return void

OnIsBrowserInitializedChanged() protected method

Called when [is browser initialized changed].
protected OnIsBrowserInitializedChanged ( bool oldValue, bool newValue ) : void
oldValue bool if set to true [old value].
newValue bool if set to true [new value].
return void

OnMouseDown() protected method

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnMouseDown ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs The that contains the event data. /// This event data reports details about the mouse button that was pressed and the handled state.
return void

OnMouseLeave() protected method

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseLeave attached event is raised on this element. Implement this method to add class handling for this event.
protected OnMouseLeave ( System.Windows.Input.MouseEventArgs e ) : void
e System.Windows.Input.MouseEventArgs The that contains the event data.
return void

OnMouseMove() protected method

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseMove attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnMouseMove ( System.Windows.Input.MouseEventArgs e ) : void
e System.Windows.Input.MouseEventArgs The that contains the event data.
return void

OnMouseUp() protected method

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseUp routed event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnMouseUp ( System.Windows.Input.MouseButtonEventArgs e ) : void
e System.Windows.Input.MouseButtonEventArgs The that contains the event data. The event data reports that the mouse button was released.
return void

OnMouseWheel() protected method

Invoked when an unhandled E:System.Windows.Input.Mouse.MouseWheel attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnMouseWheel ( System.Windows.Input.MouseWheelEventArgs e ) : void
e System.Windows.Input.MouseWheelEventArgs The that contains the event data.
return void

OnPreviewKeyDown() protected method

Invoked when an unhandled E:System.Windows.Input.Keyboard.PreviewKeyDown attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnPreviewKeyDown ( System.Windows.Input.KeyEventArgs e ) : void
e System.Windows.Input.KeyEventArgs The that contains the event data.
return void

OnPreviewKeyUp() protected method

Invoked when an unhandled E:System.Windows.Input.Keyboard.PreviewKeyUp attached event reaches an element in its route that is derived from this class. Implement this method to add class handling for this event.
protected OnPreviewKeyUp ( System.Windows.Input.KeyEventArgs e ) : void
e System.Windows.Input.KeyEventArgs The that contains the event data.
return void

OnRendering() protected method

Raises Rendering event
protected OnRendering ( object sender, WpfBitmapInfo bitmapInfo ) : void
sender object The sender.
bitmapInfo WpfBitmapInfo The bitmap information.
return void

OnZoomLevelChanged() protected method

Called when [zoom level changed].
protected OnZoomLevelChanged ( double oldValue, double newValue ) : void
oldValue double The old value.
newValue double The new value.
return void

RegisterAsyncJsObject() public method

Asynchronously registers a Javascript object in this specific browser instance.

Only methods of the object will be availabe.

The registered methods can only be called in an async way, they will all return immeditaly and the resulting object will be a standard javascript Promise object which is usable to wait for completion or failure.
Browser is already initialized. RegisterJsObject must be + /// called before the underlying CEF browser is created.
public RegisterAsyncJsObject ( string name, object objectToBind, BindingOptions options = null ) : void
name string The name of the object. (e.g. "foo", if you want the object to be accessible as window.foo).
objectToBind object The object to be made accessible to Javascript.
options BindingOptions binding options - camelCaseJavascriptNames default to true
return void

RegisterJsObject() public method

Registers a Javascript object in this specific browser instance.
Browser is already initialized. RegisterJsObject must be + /// called before the underlying CEF browser is created.
public RegisterJsObject ( string name, object objectToBind, BindingOptions options = null ) : void
name string The name of the object. (e.g. "foo", if you want the object to be accessible as window.foo).
objectToBind object The object to be made accessible to Javascript.
options BindingOptions binding options - camelCaseJavascriptNames default to true
return void

SourceHook() protected method

WindowProc callback interceptor. Handles Windows messages intended for the source hWnd, and passes them to the contained browser as needed.
protected SourceHook ( IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, bool &handled ) : IntPtr
hWnd System.IntPtr The source handle.
message int The message.
wParam System.IntPtr Additional message info.
lParam System.IntPtr Even more message info.
handled bool if set to true, the event has already been handled by someone else.
return System.IntPtr

Property Details

AddressProperty public static property

The address property
public static DependencyProperty,System.Windows AddressProperty
return System.Windows.DependencyProperty

CanGoBackProperty public static property

The can go back property
public static DependencyProperty,System.Windows CanGoBackProperty
return System.Windows.DependencyProperty

CanGoForwardProperty public static property

The can go forward property
public static DependencyProperty,System.Windows CanGoForwardProperty
return System.Windows.DependencyProperty

CleanupElementProperty public static property

The cleanup element property
public static DependencyProperty,System.Windows CleanupElementProperty
return System.Windows.DependencyProperty

IsBrowserInitializedProperty public static property

The is browser initialized property
public static DependencyProperty,System.Windows IsBrowserInitializedProperty
return System.Windows.DependencyProperty

IsLoadingProperty public static property

The is loading property
public static DependencyProperty,System.Windows IsLoadingProperty
return System.Windows.DependencyProperty

TitleProperty public static property

The title property
public static DependencyProperty,System.Windows TitleProperty
return System.Windows.DependencyProperty

TooltipTextProperty public static property

The tooltip text property
public static DependencyProperty,System.Windows TooltipTextProperty
return System.Windows.DependencyProperty

WebBrowserProperty public static property

The WebBrowser property
public static DependencyProperty,System.Windows WebBrowserProperty
return System.Windows.DependencyProperty

ZoomLevelIncrementProperty public static property

The zoom level increment property
public static DependencyProperty,System.Windows ZoomLevelIncrementProperty
return System.Windows.DependencyProperty

ZoomLevelProperty public static property

The zoom level property
public static DependencyProperty,System.Windows ZoomLevelProperty
return System.Windows.DependencyProperty