// Copyright © 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. namespace CefSharp { /// /// Implement this interface to handle events related to JavaScript dialogs. /// The methods of this class will be called on the CEF UI thread. /// public interface IJsDialogHandler { /// /// Called to run a JavaScript dialog. /// /// the ChromiumWebBrowser control /// the browser object /// originating url /// Dialog Type /// Message Text /// value will be specified for prompt dialogs only /// Callback can be executed inline or in an async fashion /// Set suppressMessage to true and return false to suppress the message (suppressing messages is preferable to immediately executing the callback as this is used to detect presumably malicious behavior like spamming alert messages in onbeforeunload). Set suppressMessage to false and return false to use the default implementation (the default implementation will show one modal dialog at a time and suppress any additional dialog requests until the displayed dialog is dismissed). /// Return true if the application will use a custom dialog or if the callback has been executed immediately. Custom dialogs may be either modal or modeless. If a custom dialog is used the application must execute |callback| once the custom dialog is dismissed. bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage); /// /// Called to run a dialog asking the user if they want to leave a page. Return false to use the default dialog implementation. /// Return true if the application will use a custom dialog or if the callback has been executed immediately. /// Custom dialogs may be either modal or modeless. If a custom dialog is used the application must execute /// once the custom dialog is dismissed. /// /// the ChromiumWebBrowser control /// the browser object /// message text (optional) /// indicates a page reload /// Callback can be executed inline or in an async fashion /// Return false to use the default dialog implementation otherwise return true to handle with your own custom implementation. bool OnBeforeUnloadDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string messageText, bool isReload, IJsDialogCallback callback); /// /// Called to cancel any pending dialogs and reset any saved dialog state. Will /// be called due to events like page navigation irregardless of whether any /// dialogs are currently pending. /// /// the ChromiumWebBrowser control /// the browser object void OnResetDialogState(IWebBrowser chromiumWebBrowser, IBrowser browser); /// /// Called when the default implementation dialog is closed. /// /// the ChromiumWebBrowser control /// the browser object void OnDialogClosed(IWebBrowser chromiumWebBrowser, IBrowser browser); } }