forked from cefsharp/CefSharp.OutOfProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsDialogHandlerProxy.cs
More file actions
56 lines (47 loc) · 2.22 KB
/
JsDialogHandlerProxy.cs
File metadata and controls
56 lines (47 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using CefSharp.OutOfProcess.Interface;
using CefSharp.OutOfProcess.Interface.Callbacks;
using System;
namespace CefSharp.OutOfProcess.BrowserProcess.CallbackProxies
{
internal sealed class JsDialogHandlerProxy : CallbackProxyBase<object>, IJsDialogHandler
{
public JsDialogHandlerProxy(IOutOfProcessHostRpc host)
: base(host)
{
}
public void Callback(JsDialogCallbackDetails details)
{
var cb = (CefSharp.OutOfProcess.Interface.Callbacks.IJsDialogCallback)GetCallback(details.CallbackId);
if (details.UserInput != string.Empty)
{
cb.Continue(details.Success, details.UserInput);
}
else
{
cb.Continue(details.Success);
}
}
public bool OnBeforeUnloadDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string messageText, bool isReload, IJsDialogCallback callback)
{
var result = host.OnBeforeUnloadDialog(((OutOfProcessChromiumWebBrowser)chromiumWebBrowser).Id, messageText, isReload, CreateCallback(callback));
return result;
}
public void OnDialogClosed(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
host.OnDialogClosed(((OutOfProcessChromiumWebBrowser)chromiumWebBrowser).Id);
}
public bool OnJSDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
var result = host.OnJSDialog(((OutOfProcessChromiumWebBrowser)chromiumWebBrowser).Id, originUrl, ParseEnum<Interface.Callbacks.CefJsDialogType>(Enum.GetName(typeof(CefJsDialogType), dialogType)), messageText, defaultPromptText, CreateCallback(callback), ref suppressMessage);
return result;
}
public void OnResetDialogState(IWebBrowser chromiumWebBrowser, IBrowser browser)
{
host.OnResetDialogState(((OutOfProcessChromiumWebBrowser)chromiumWebBrowser).Id);
}
public static T ParseEnum<T>(string value)
{
return (T)Enum.Parse(typeof(T), value, true);
}
}
}