// Copyright © 2011 The CefSharp Authors. All rights reserved. // // Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. using System; namespace CefSharp { /// /// ChromiumWebBrowser implementations implement this interface. Can be cast to /// the concrete implementation to access UI specific features. /// /// public interface IWebBrowser : IDisposable { /// /// Event handler for receiving Javascript console messages being sent from web pages. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang.. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// (The exception to this is when your running with settings.MultiThreadedMessageLoop = false, then they'll be the same thread). /// event EventHandler ConsoleMessage; /// /// Event handler for changes to the status message. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// (The exception to this is when your running with settings.MultiThreadedMessageLoop = false, then they'll be the same thread). /// event EventHandler StatusMessage; /// /// Event handler that will get called when the browser begins loading a frame. Multiple frames may be loading at the same /// time. Sub-frames may start or continue loading after the main frame load has ended. This method may not be called for a /// particular frame if the load request for that frame fails. For notification of overall browser load status use /// OnLoadingStateChange instead. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang.. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// /// Whilst this may seem like a logical place to execute js, it's called before the DOM has been loaded, implement /// as it's called when the underlying V8Context is created /// event EventHandler FrameLoadStart; /// /// Event handler that will get called when the browser is done loading a frame. Multiple frames may be loading at the same /// time. Sub-frames may start or continue loading after the main frame load has ended. This method will always be called /// for all frames irrespective of whether the request completes successfully. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang.. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// event EventHandler FrameLoadEnd; /// /// Event handler that will get called when the resource load for a navigation fails or is canceled. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang.. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// event EventHandler LoadError; /// /// Event handler that will get called when the Loading state has changed. /// This event will be fired twice. Once when loading is initiated either programmatically or /// by user action, and once when loading is terminated due to completion, cancellation of failure. /// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI /// thread. It is unwise to block on this thread for any length of time as your browser will become unresponsive and/or hang.. /// To access UI elements you'll need to Invoke/Dispatch onto the UI Thread. /// event EventHandler LoadingStateChanged; /// /// Event handler that will get called when the message that originates from CefSharp.PostMessage /// event EventHandler JavascriptMessageReceived; /// /// Loads the specified URL. /// /// The URL to be loaded. void Load(string url); /// /// The javascript object repository, one repository per ChromiumWebBrowser instance. /// IJavascriptObjectRepository JavascriptObjectRepository { get; } /// /// Implement and assign to handle dialog events. /// /// The dialog handler. IDialogHandler DialogHandler { get; set; } /// /// Implement and assign to handle events related to browser requests. /// /// The request handler. IRequestHandler RequestHandler { get; set; } /// /// Implement and assign to handle events related to browser display state. /// /// The display handler. IDisplayHandler DisplayHandler { get; set; } /// /// Implement and assign to handle events related to browser load status. /// /// The load handler. ILoadHandler LoadHandler { get; set; } /// /// Implement and assign to handle events related to popups. /// /// The life span handler. ILifeSpanHandler LifeSpanHandler { get; set; } /// /// Implement and assign to handle events related to key press. /// /// The keyboard handler. IKeyboardHandler KeyboardHandler { get; set; } /// /// Implement and assign to handle events related to JavaScript Dialogs. /// /// The js dialog handler. IJsDialogHandler JsDialogHandler { get; set; } /// /// Implement and assign to handle events related to dragging. /// /// The drag handler. IDragHandler DragHandler { get; set; } /// /// Implement and assign to handle events related to downloading files. /// /// The download handler. IDownloadHandler DownloadHandler { get; set; } /// /// Implement and assign to handle events related to the browser context menu /// /// The menu handler. IContextMenuHandler MenuHandler { get; set; } /// /// Implement and assign to handle events related to the browser component's focus /// /// The focus handler. IFocusHandler FocusHandler { get; set; } /// /// Implement and control the loading of resources /// /// The resource handler factory. IResourceRequestHandlerFactory ResourceRequestHandlerFactory { get; set; } /// /// Implement and assign to handle messages from the render process. /// /// The render process message handler. IRenderProcessMessageHandler RenderProcessMessageHandler { get; set; } /// /// Implement to handle events related to find results. /// /// The find handler. IFindHandler FindHandler { get; set; } /// /// A flag that indicates whether the WebBrowser is initialized (true) or not (false). /// /// true if this instance is browser initialized; otherwise, false. /// In the WPF control there are two IsBrowserInitialized properties, the ChromiumWebBrowser.IsBrowserInitialized /// property is implemented as a Dependency Property and fully supports data binding. This property /// can only be called from the UI Thread. The explicit IWebBrowser.IsBrowserInitialized interface implementation that /// can be called from any Thread. bool IsBrowserInitialized { get; } /// /// A flag that indicates whether the WebBrowser has been disposed () or not () /// /// if this instance is disposed; otherwise, bool IsDisposed { get; } /// /// A flag that indicates whether the control is currently loading one or more web pages (true) or not (false). /// /// true if this instance is loading; otherwise, false. /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool IsLoading { get; } /// /// A flag that indicates whether the state of the control current supports the GoBack action (true) or not (false). /// /// true if this instance can go back; otherwise, false. /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool CanGoBack { get; } /// /// A flag that indicates whether the state of the control currently supports the GoForward action (true) or not (false). /// /// true if this instance can go forward; otherwise, false. /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool CanGoForward { get; } /// /// The address (URL) which the browser control is currently displaying. /// Will automatically be updated as the user navigates to another page (e.g. by clicking on a link). /// /// The address. /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. string Address { get; } /// /// The text that will be displayed as a ToolTip /// /// The tooltip text. string TooltipText { get; } /// /// A flag that indicates if you can execute javascript in the main frame. /// Flag is set to true in IRenderProcessMessageHandler.OnContextCreated. /// and false in IRenderProcessMessageHandler.OnContextReleased /// bool CanExecuteJavascriptInMainFrame { get; } /// /// Gets the custom request context assigned to this browser instance /// If no instance was assigned this will be null and the global /// request context will have been used for this browser. /// You can access the global request context through Cef.GetGlobalRequestContext() /// IRequestContext RequestContext { get; } /// /// Attempts to give focus to the IWebBrowser control. /// /// true if keyboard focus and logical focus were set to this element; false if only logical focus /// was set to this element, or if the call to this method did not force the focus to change. bool Focus(); /// /// Returns the current CEF Browser Instance /// /// browser instance or null IBrowser GetBrowser(); } }