1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-17 00: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
TrayIcon.Designer.cs
TrayIcon.cs
Libraries
Plugins
Properties
Resources
Updates
bld
tests
.gitignore
LICENSE.md
Program.cs
README.md
Reporter.cs
TweetDck.csproj
TweetDck.sln
TweetDck.sln.DotSettings
_postbuild.bat
packages.config
TweetDuck/Core/Handling/JavaScriptDialogHandler.cs

43 lines
1.6 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);
if (dialogType == CefJsDialogType.Alert){
form.AddButton("OK");
}
else if (dialogType == CefJsDialogType.Confirm){
form.AddButton("No", DialogResult.No);
form.AddButton("Yes");
}
else{
return;
}
callback.Continue(form.ShowDialog() == DialogResult.OK);
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){}
}
}