// Copyright © 2010-2014 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; using System.Threading.Tasks; namespace CefSharp { public interface IWebBrowser : IDisposable { /// /// Event handler for receiving Javascript console messages being sent from web pages. /// event EventHandler ConsoleMessage; /// /// Event handler for changes to the status message. /// 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. /// 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. /// event EventHandler FrameLoadEnd; /// /// Event handler that will get called when the resource load for a navigation fails or is canceled. /// event EventHandler LoadError; /// /// Loads the specified URL. /// /// The URL to be loaded. void Load(string url); /// /// Loads custom HTML content into the web browser. /// /// The HTML content. /// The URL that will be treated as the address of the content. void LoadHtml(string html, string url); /// /// Registers a Javascript object in this specific browser instance. /// /// The name of the object. (e.g. "foo", if you want the object to be accessible as window.foo). /// The object to be made accessible to Javascript. void RegisterJsObject(string name, object objectToBind); /// /// Execute some Javascript code in the context of this WebBrowser. As the method name implies, the script will be /// executed asynchronously, and the method therefore returns before the script has actually been executed. /// /// The Javascript code that should be executed. void ExecuteScriptAsync(string script); /// /// Execute some Javascript code in the context of this WebBrowser, and return the result of the evaluation. /// /// The Javascript code that should be executed. /// The timeout after which the Javascript code execution should be aborted. object EvaluateScript(string script, TimeSpan? timeout = null); /// /// Implement and assign to handle dialog events. /// IDialogHandler DialogHandler { get; set; } /// /// Implement and assign to handle events related to browser requests. /// IRequestHandler RequestHandler { get; set; } /// /// Implement and assign to handle events related to popups. /// ILifeSpanHandler LifeSpanHandler { get; set; } /// /// Implement and assign to handle events related to key press. /// IKeyboardHandler KeyboardHandler { get; set; } /// /// Implement and assign to handle events related to JavaScript Dialogs. /// IJsDialogHandler JsDialogHandler { get; set; } /// /// Implement and assign to handle events related to downloading files. /// IDownloadHandler DownloadHandler { get; set; } /// /// A flag that indicates whether the WebBrowser is initialized (true) or not (false). /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool IsBrowserInitialized { get; } /// /// A flag that indicates whether the control is currently loading one or more web pages (true) or not (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). /// /// 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). /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool CanGoForward { get; } /// /// A flag that indicates whether the state of the control currently supports the Reload action (true) or not (false). /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. bool CanReload { 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). /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. string Address { get; } /// /// The title of the web page being currently displayed. /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. string Title { get; } /// /// The text that will be displayed as a ToolTip /// string TooltipText { get; } /// /// The zoom level at which the browser control is currently displaying. Can be set to 0 to clear the zoom level (resets to /// default zoom level). /// /// In the WPF control, this property is implemented as a Dependency Property and fully supports data /// binding. double ZoomLevel { get; set; } /// /// Search for text within the current page. /// /// Can be used in can conjunction with searchText to have multiple /// searches running simultaneously. /// search text /// indicates whether to search forward or backward within the page. /// indicates whether the search should be case-sensitive. /// indicates whether this is the first request or a follow-up. void Find(int identifier, string searchText, bool forward, bool matchCase, bool findNext); /// /// Cancel all searches that are currently going on. /// /// clear the current search selection void StopFinding(bool clearSelection); /// /// Navigates back, must check before calling this method. /// void Back(); /// /// Navigates forward, must check before calling this method. /// void Forward(); /// /// Stops loading the current page. /// void Stop(); /// /// Retrieve the main frame's HTML source using a . /// /// that when executed returns the frame source as a string Task GetSourceAsync(); /// /// Retrieve the main frame's display text using a . /// /// that when executed returns the frame display text as a string. Task GetTextAsync(); /// /// Opens up a new program window (using the default text editor) where the source code of the currently displayed web /// page is shown. /// void ViewSource(); /// /// Attempts to give focus to the IWpfWebBrowser 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(); /// /// Reloads the page being displayed. This method will use data from the browser's cache, if available. /// void Reload(); /// /// Reloads the page being displayed, optionally ignoring the cache (which means the whole page including all .css, .js /// etc. resources will be re-fetched). /// /// true A reload is performed ignoring browser cache; false A reload is /// performed using files from the browser cache, if available. void Reload(bool ignoreCache); /// /// Opens a Print Dialog which if used (can be user cancelled) will print the browser contents. /// void Print(); /// /// Open developer tools in its own window. /// void ShowDevTools(); /// /// Explicitly close the developer tools window if one exists for this browser instance. /// void CloseDevTools(); } }