forked from cefsharp/CefSharp.OutOfProcess
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDialogHandlerProxy.cs
More file actions
49 lines (41 loc) · 1.49 KB
/
DialogHandlerProxy.cs
File metadata and controls
49 lines (41 loc) · 1.49 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
using System.Collections.Generic;
using CefSharp.OutOfProcess.Interface;
using CefSharp.Handler;
using System.Linq;
using CefSharp.OutOfProcess.Interface.Callbacks;
using System;
namespace CefSharp.OutOfProcess.BrowserProcess.CallbackProxies
{
internal sealed class DialogHandlerProxy : CallbackProxyBase<IFileDialogCallback>, IDialogHandler
{
public DialogHandlerProxy(IOutOfProcessHostRpc host)
: base(host)
{
}
public void Callback(FileDialogCallbackDetails details)
{
if (details == null)
{
throw new ArgumentNullException(nameof(details));
}
if (details.Files == null)
{
throw new ArgumentNullException(nameof(details.Files));
}
var cb = GetCallback(details.CallbackId);
if (details.Continue)
{
cb.Continue(details.Files.ToList());
}
else
{
cb.Cancel();
}
}
bool IDialogHandler.OnFileDialog(IWebBrowser chromiumWebBrowser, IBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, List<string> acceptFilters, IFileDialogCallback callback)
{
var result = host.OnFileDialog(((OutOfProcessChromiumWebBrowser)chromiumWebBrowser).Id, mode.ToString(), title, defaultFilePath, acceptFilters.ToArray(), CreateCallback(callback));
return result.Result;
}
}
}