// Copyright © 2010-2015 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
{
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.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
///
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.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
///
event EventHandler FrameLoadEnd;
///
/// Event handler that will get called when the resource load for a navigation fails or is canceled.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
///
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.
/// This event will be called on the CEF UI thread.
/// Blocking this thread will likely cause your UI to become unresponsive and/or hang.
///
event EventHandler LoadingStateChanged;
///
/// Loads the specified URL.
///
/// The URL to be loaded.
void Load(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.
/// camel case the javascript names of properties/methods, defaults to true
void RegisterJsObject(string name, object objectToBind, bool camelCaseJavascriptNames = true);
///
/// Asynchronously registers a Javascript object in this specific browser instance.
/// Only methods of the object will be availabe.
///
/// 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.
/// camel case the javascript names of methods, defaults to true
///
/// 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.
///
void RegisterAsyncJsObject(string name, object objectToBind, bool camelCaseJavascriptNames = true);
///
/// 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 browser display state.
///
IDisplayHandler DisplayHandler { get; set; }
///
/// Implement and assign to handle events related to browser load status.
///
ILoadHandler LoadHandler { 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 dragging.
///
IDragHandler DragHandler { get; set; }
///
/// Implement and assign to handle events related to downloading files.
///
IDownloadHandler DownloadHandler { get; set; }
///
/// Implement and assign to handle events related to the browser context menu
///
IContextMenuHandler MenuHandler { get; set; }
///
/// Implement and assign to handle events related to the browser component's focus
///
IFocusHandler FocusHandler { get; set; }
///
/// Implement and control the loading of resources
///
IResourceHandlerFactory ResourceHandlerFactory { get; set; }
///
/// Implement and assign to handle requests for permission to use geolocation.
///
IGeolocationHandler GeolocationHandler { 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; }
///
/// 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 text that will be displayed as a ToolTip
///
string TooltipText { get; }
///
/// 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();
///
/// Returns the current CEF Browser Instance
///
/// browser instance or null
IBrowser GetBrowser();
}
}