-
Notifications
You must be signed in to change notification settings - Fork 433
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (57 loc) · 2.84 KB
/
Program.cs
File metadata and controls
70 lines (57 loc) · 2.84 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright © 2010-2015 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
using CefSharp.WinForms;
using System;
using System.IO;
using System.Windows.Forms;
namespace CefSharp.MinimalExample.WinForms
{
public static class Program
{
[STAThread]
public static int Main(string[] args)
{
#if ANYCPU
CefRuntime.SubscribeAnyCpuAssemblyResolver();
#endif
var cachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache2");
var settings = new CefSettings()
{
// You must spcify a unique cache path per instance of your application
CachePath = cachePath
};
//Example of setting a command line argument
//Enables WebRTC
// - CEF Doesn't currently support permissions on a per browser basis see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access
// - CEF Doesn't currently support displaying a UI for media access permissions
//
//NOTE: WebRTC Device Id's aren't persisted as they are in Chrome see https://bitbucket.org/chromiumembedded/cef/issues/2064/persist-webrtc-deviceids-across-restart
settings.CefCommandLineArgs.Add("enable-media-stream");
//https://peter.sh/experiments/chromium-command-line-switches/#use-fake-ui-for-media-stream
settings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream");
//For screen sharing add (see https://bitbucket.org/chromiumembedded/cef/issues/2582/allow-run-time-handling-of-media-access#comment-58677180)
settings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing");
settings.CefCommandLineArgs.Add("disable-features", "OptimizationGuideOnDeviceModel");
//--
//Perform dependency check to make sure all relevant resources are in our output directory.
var initialized = Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
if (!initialized)
{
var exitCode = Cef.GetExitCode();
if (exitCode == Enums.ResultCode.NormalExitProcessNotified)
{
MessageBox.Show($"Cef.Initialize failed with {exitCode}, another process is already using cache path {cachePath}");
}
else
{
MessageBox.Show($"Cef.Initialize failed with {exitCode}, check the log file for more details.");
}
return 0;
}
Application.EnableVisualStyles();
Application.Run(new BrowserForm());
return 0;
}
}
}