public JBCefClient addJSDialogHandler(@NotNull CefJSDialogHandler handler, @NotNull CefBrowser browser) {
    return myJSDialogHandler.add(handler, browser, () -> {
      myCefClient.addJSDialogHandler(new CefJSDialogHandler() {
        @Override
        public boolean onJSDialog(CefBrowser browser,
                                  String origin_url,
                                  JSDialogType dialog_type,
                                  String message_text,
                                  String default_prompt_text,
                                  CefJSDialogCallback callback,
                                  BoolRef suppress_message) {
          return myJSDialogHandler.handleBooleanFirst(browser, handler -> {
            return handler.onJSDialog(browser, origin_url, dialog_type, message_text, default_prompt_text, callback, suppress_message);
          });
        }

        @Override
        public boolean onBeforeUnloadDialog(CefBrowser browser, String message_text, boolean is_reload, CefJSDialogCallback callback) {
          return myJSDialogHandler.handleBooleanFirst(browser, handler -> {
            return handler.onBeforeUnloadDialog(browser, message_text, is_reload, callback);
          });
        }

        @Override
        public void onResetDialogState(CefBrowser browser) {
          myJSDialogHandler.handleAll(browser, handler -> {
            handler.onResetDialogState(browser);
          });
        }

        @Override
        public void onDialogClosed(CefBrowser browser) {
          myJSDialogHandler.handleAll(browser, handler -> {
            handler.onDialogClosed(browser);
          });
        }
      });
    });
  }
public JBCefClient addJSDialogHandler(@NotNull CefJSDialogHandler handler, @NotNull CefBrowser browser)