protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { if (dialogType == CefJSDialogType.Alert) { MessageBox.Show(message_text, "CEF"); suppress_message = true; return(false); } if (dialogType == CefJSDialogType.Confirm) { DialogResult dialogResult = MessageBox.Show(message_text, "CEF", MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { callback.Continue(true, string.Empty); suppress_message = false; return(true); } if (dialogResult == DialogResult.Cancel) { callback.Continue(false, string.Empty); suppress_message = false; return(true); } } suppress_message = true; return(false); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { bool success; string input = null; switch (dialogType) { case CefJSDialogType.Alert: success = ShowJSAlert(message_text); break; case CefJSDialogType.Confirm: success = ShowJSConfirm(message_text); break; case CefJSDialogType.Prompt: success = ShowJSPromt(message_text, default_prompt_text, out input); break; default: throw new ArgumentOutOfRangeException(nameof(dialogType), dialogType, null); } callback.Continue(success, input); suppress_message = false; return(true); }
private static JsDialogType ConvertDialogType(CefJSDialogType type) { return(type switch { CefJSDialogType.Alert => JsDialogType.Alert, CefJSDialogType.Confirm => JsDialogType.Confirm, CefJSDialogType.Prompt => JsDialogType.Prompt, _ => JsDialogType.Unknown });
internal JsDialogEventArgs(CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback) { DialogType = dialogType; MessageText = messageText; DefaultPromptText = defaultPromptText; Callback = callback; SuppressMessage = false; Handled = false; }
/// <inheritdoc /> protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback, ref int suppressMessage) { ScriptDialogDeferral dialogDeferral = CreateScriptDialogDeferral(callback); var ea = new ScriptDialogOpeningRoutedEventArgs(originUrl, (ScriptDialogKind)dialogType, messageText, defaultPromptText, dialogDeferral); WebView.RaiseScriptDialogOpening(ea); suppressMessage = ea.Suppress ? 1 : 0; if (!ea.Handled) { ((IDisposable)dialogDeferral).Dispose(); } return(ea.Handled); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { bool result = false; suppress_message = true; switch (dialogType) { case CefJSDialogType.Alert: MessageBox.Show(message_text, "POS1"); break; case CefJSDialogType.Confirm: MessageBox.Show(message_text, "POS1", MessageBoxButtons.OKCancel); break; } return(result); }
private int on_jsdialog(cef_jsdialog_handler_t* self, cef_browser_t* browser, cef_string_t* origin_url, cef_string_t* accept_lang, CefJSDialogType dialog_type, cef_string_t* message_text, cef_string_t* default_prompt_text, cef_jsdialog_callback_t* callback, int* suppress_message) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_origin_url = cef_string_t.ToString(origin_url); var m_accept_lang = cef_string_t.ToString(accept_lang); var m_message_text = cef_string_t.ToString(message_text); var m_default_prompt_text = cef_string_t.ToString(default_prompt_text); var m_callback = CefJSDialogCallback.FromNative(callback); bool m_suppress_message; var result = OnJSDialog(m_browser, m_origin_url, m_accept_lang, dialog_type, m_message_text, m_default_prompt_text, m_callback, out m_suppress_message); *suppress_message = m_suppress_message ? 1 : 0; return result ? 1 : 0; }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { suppress_message = false; var javacriptDialogShown = OwnerWebView.JavacriptDialogShown; if (javacriptDialogShown == null) { return(false); } void Close() { callback.Continue(true, ""); callback.Dispose(); } javacriptDialogShown.Invoke(message_text, Close); return(true); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { _currentCallback = callback; switch (dialogType) { case CefJSDialogType.Alert: _mainWorker.InvokeCefDialog(message_text, default_prompt_text, DialogEventType.Alert); break; case CefJSDialogType.Confirm: _mainWorker.InvokeCefDialog(message_text, default_prompt_text, DialogEventType.Confirm); break; case CefJSDialogType.Prompt: _mainWorker.InvokeCefDialog(message_text, default_prompt_text, DialogEventType.Prompt); break; } suppress_message = false; return(true); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { switch (dialogType) { case CefJSDialogType.Alert: if (message_text.StartsWith("$Print$")) { var str = message_text.Substring(7); var ieb = new IEBrowser(); ieb.Print(str); ieb.Show(); suppress_message = true; return(false); } MessageBox.Show(message_text, "系统提示"); suppress_message = true; return(false); case CefJSDialogType.Confirm: var dr = MessageBox.Show(message_text, "系统提示", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { callback.Continue(true, string.Empty); suppress_message = false; return(true); } callback.Continue(false, string.Empty); suppress_message = false; return(true); case CefJSDialogType.Prompt: MessageBox.Show("系统不支持prompt形式的提示框", "UTMP系统提示"); break; } suppress_message = true; return(false); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { switch (dialogType) { case CefJSDialogType.Alert: _owner.InvokeIfRequired(() => { MessageBox.Show(_owner.HostWindow, message_text, Resources.Messages.JSDialog_AlertDialog_Title, MessageBoxButtons.OK, MessageBoxIcon.Information); callback.Continue(true, null); }); suppress_message = false; return(true); case CefJSDialogType.Confirm: _owner.InvokeIfRequired(() => { var retval = MessageBox.Show(_owner.HostWindow, message_text, Resources.Messages.JSDialog_AlertDialog_Title, MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (retval == DialogResult.Yes) { callback.Continue(true, null); } else { callback.Continue(false, null); } }); suppress_message = false; return(true); } suppress_message = false; return(false); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { bool success = false; string input = null; switch (dialogType) { case CefJSDialogType.Alert: success = this.ShowJSAlert(message_text); break; case CefJSDialogType.Confirm: success = this.ShowJSConfirm(message_text); break; case CefJSDialogType.Prompt: success = this.ShowJSPromt(message_text, default_prompt_text, out input); break; } callback.Continue(success, input); suppress_message = false; return(true); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback, out bool suppressMessage) { var ea = new JsDialogEventArgs(dialogType, messageText, defaultPromptText, callback); _core.OnJSDialog(ea); suppressMessage = ea.Handled && ea.SuppressMessage; return(ea.Handled); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback, out bool suppressMessage) { return(logic.OnJSDialog(ConvertDialogType(dialogType), messageText, callback, out suppressMessage)); }
protected internal unsafe override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback, ref int suppressMessage) { return(_implementation.OnJSDialog(browser, originUrl, dialogType, messageText, defaultPromptText, callback, ref suppressMessage)); }
/// <summary> /// Called to run a JavaScript dialog. If |origin_url| is non-NULL it can be /// passed to the CefFormatUrlForSecurityDisplay function to retrieve a secure /// and user-friendly display string. The |default_prompt_text| value will be /// specified for prompt dialogs only. Set |suppress_message| to true (1) and /// return false (0) 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 |suppress_message| to false (0) and return false (0) /// 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 (1) 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. /// </summary> protected internal unsafe virtual bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string messageText, string defaultPromptText, CefJSDialogCallback callback, ref int suppressMessage) { return(default);
public unsafe extern int OnJSDialog(cef_browser_t *browser, [Immutable] cef_string_t *origin_url, CefJSDialogType dialog_type, [Immutable] cef_string_t *message_text, [Immutable] cef_string_t *default_prompt_text, cef_jsdialog_callback_t *callback, int *suppress_message);
private int on_jsdialog(cef_jsdialog_handler_t *self, cef_browser_t *browser, cef_string_t *origin_url, cef_string_t *accept_lang, CefJSDialogType dialog_type, cef_string_t *message_text, cef_string_t *default_prompt_text, cef_jsdialog_callback_t *callback, int *suppress_message) { CheckSelf(self); throw new NotImplementedException(); // TODO: CefJSDialogHandler.OnJSDialog }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { switch (dialogType) { case CefJSDialogType.Alert: //LoadingUtil.ShowInformationMessage(message_text, "系统提示"); suppress_message = true; return(false); break; case CefJSDialogType.Confirm: var dr = MessageBox.Show(message_text, "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { callback.Continue(true, string.Empty); suppress_message = false; return(true); } else { callback.Continue(false, string.Empty); suppress_message = false; return(true); } break; case CefJSDialogType.Prompt: //var prompt = new FrmPrompt(message_text, "系统提示", default_prompt_text); //if (prompt.ShowDialog() == DialogResult.OK) //{ // callback.Continue(true, prompt.Content); // suppress_message = false; // return true; //} //else //{ // callback.Continue(false, string.Empty); // suppress_message = false; // return true; //} break; } suppress_message = true; return(false); }
protected override bool OnJSDialog(CefBrowser browser, string originUrl, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message) { suppress_message = false; return(false); }
private int on_jsdialog(cef_jsdialog_handler_t *self, cef_browser_t *browser, cef_string_t *origin_url, cef_string_t *accept_lang, CefJSDialogType dialog_type, cef_string_t *message_text, cef_string_t *default_prompt_text, cef_jsdialog_callback_t *callback, int *suppress_message) { CheckSelf(self); var m_browser = CefBrowser.FromNative(browser); var m_origin_url = cef_string_t.ToString(origin_url); var m_accept_lang = cef_string_t.ToString(accept_lang); var m_message_text = cef_string_t.ToString(message_text); var m_default_prompt_text = cef_string_t.ToString(default_prompt_text); var m_callback = CefJSDialogCallback.FromNative(callback); bool m_suppress_message; var result = OnJSDialog(m_browser, m_origin_url, m_accept_lang, dialog_type, m_message_text, m_default_prompt_text, m_callback, out m_suppress_message); *suppress_message = m_suppress_message ? 1 : 0; return(result ? 1 : 0); }
protected override Boolean OnJSDialog(CefBrowser browser, String originUrl, String acceptLang, CefJSDialogType dialogType, String messageText, String defaultPromptText, CefJSDialogCallback callback, out Boolean suppressMessage) { Log.Trace("JSDialogHandler.OnJSDialog( browser: {0}, originUrl: {1}, acceptLang: {2}, dialogType: {3}, messageText: {4}, defaultPromptText: {5} )", browser.Identifier, originUrl, acceptLang, Enum.GetName(typeof(CefJSDialogType), dialogType), messageText, defaultPromptText); suppressMessage = true; switch (dialogType) { case CefJSDialogType.Alert: if (this.Client.HandleJavascriptAlertDialog != null) { this.Client.HandleJavascriptAlertDialog(originUrl, messageText); return(true); } break; case CefJSDialogType.Confirm: if (this.Client.HandleJavascriptConfirmDialog != null) { Boolean confirmed; this.Client.HandleJavascriptConfirmDialog(originUrl, messageText, out confirmed); callback.Continue(confirmed, null); return(true); } break; case CefJSDialogType.Prompt: if (this.Client.HandleJavascriptPromptDialog != null) { String responseText; this.Client.HandleJavascriptPromptDialog(originUrl, messageText, out responseText); callback.Continue(responseText != null, responseText); return(true); } break; } return(false); }
public unsafe int OnJSDialog(cef_browser_t *browser, [Immutable] cef_string_t *origin_url, CefJSDialogType dialog_type, [Immutable] cef_string_t *message_text, [Immutable] cef_string_t *default_prompt_text, cef_jsdialog_callback_t *callback, int *suppress_message) { fixed(cef_jsdialog_handler_t *self = &this) { return(((delegate * unmanaged[Stdcall] < cef_jsdialog_handler_t *, cef_browser_t *, cef_string_t *, CefJSDialogType, cef_string_t *, cef_string_t *, cef_jsdialog_callback_t *, int *, int >)on_jsdialog)(self, browser, origin_url, dialog_type, message_text, default_prompt_text, callback, suppress_message)); } }
/// <summary> /// Called to run a JavaScript dialog. The |default_prompt_text| value will be /// specified for prompt dialogs only. Set |suppress_message| 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 /// |suppress_message| 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. /// </summary> protected abstract bool OnJSDialog(CefBrowser browser, string originUrl, string acceptLang, CefJSDialogType dialogType, string message_text, string default_prompt_text, CefJSDialogCallback callback, out bool suppress_message);