1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-16 06:31:42 +02:00
Files
Configuration
Core
Bridge
Controls
Handling
BrowserProcessHandler.cs
ContextMenuBase.cs
ContextMenuBrowser.cs
ContextMenuNotification.cs
FileDialogHandler.cs
JavaScriptDialogHandler.cs
LifeSpanHandler.cs
Notification
Other
Utils
FormBrowser.Designer.cs
FormBrowser.cs
FormBrowser.resx
FormNotification.Designer.cs
FormNotification.cs
TrayIcon.Designer.cs
TrayIcon.cs
Libraries
Plugins
Properties
Resources
Updates
bld
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDck.csproj
TweetDck.sln
_postbuild.bat
TweetDuck/Core/Handling/JavaScriptDialogHandler.cs

50 lines
1.9 KiB
C#

using CefSharp;
using CefSharp.WinForms;
using System.Windows.Forms;
using TweetDck.Core.Controls;
using TweetDck.Core.Other;
namespace TweetDck.Core.Handling {
class JavaScriptDialogHandler : IJsDialogHandler{
bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage){
if (dialogType != CefJsDialogType.Alert && dialogType != CefJsDialogType.Confirm){
return false;
}
((ChromiumWebBrowser)browserControl).InvokeSafe(() => {
FormMessage form = new FormMessage(Program.BrandName, messageText, MessageBoxIcon.None);
Button btnConfirm;
if (dialogType == CefJsDialogType.Alert){
btnConfirm = form.AddButton("OK");
}
else if (dialogType == CefJsDialogType.Confirm){
form.AddButton("No");
btnConfirm = form.AddButton("Yes");
}
else{
return;
}
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnConfirm){
callback.Continue(true);
}
else{
callback.Continue(false);
}
form.Dispose();
});
return true;
}
bool IJsDialogHandler.OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload, IJsDialogCallback callback){
return false;
}
void IJsDialogHandler.OnResetDialogState(IWebBrowser browserControl, IBrowser browser){}
void IJsDialogHandler.OnDialogClosed(IWebBrowser browserControl, IBrowser browser){}
}
}