Esempio n. 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)
 {
     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);
 }
Esempio n. 2
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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 protected override Boolean OnBeforeUnloadDialog(CefBrowser browser, String messageText, Boolean isReload, CefJSDialogCallback callback)
 {
     Log.Trace("JSDialogHandler.OnBeforeUnloadDialog");
     Log.Trace("JSDialogHandler.OnBeforeUnloadDialog( browser: {0}, messageText: {1}, isReload: {2} )",
               browser.Identifier,
               messageText,
               isReload);
     callback.Continue(true, null);
     return(true);
 }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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)
            {
                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)
        {
            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);
        }
 public void Continue(bool success, string input)
 {
     _currentCallback?.Continue(success, input);
     _currentCallback = null;
 }