forked from SapphireServer/SapphireLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CefRequestHandler.cs
103 lines (83 loc) · 4.1 KB
/
CefRequestHandler.cs
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using CefSharp;
using System;
using System.Security.Cryptography.X509Certificates;
namespace SapphireBootWPF
{
public class CefRequestHandler : IRequestHandler
{
public bool OnBeforeBrowse( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isRedirect )
{
var destUrl = new Uri( request.Url );
Uri frontierUrl = null;
try
{
frontierUrl = new Uri( Properties.Settings.Default.WebServerUrl );
}
// don't really care if it's invalid format/argumentnull exceptions
catch( Exception ex )
{
System.Diagnostics.Trace.TraceError( ex.Message );
return false;
}
// if hosts don't match, open url in users browser
if ( destUrl.Host != frontierUrl.Host )
{
System.Diagnostics.Process.Start( request.Url );
return true;
}
// host match, load url in embedded browser
return false;
}
public bool GetAuthCredentials( IWebBrowser browserControl, IBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback )
{
return GetAuthCredentials( browserControl, browser, frame, isProxy, host, port, realm, scheme, callback );
}
public IResponseFilter GetResourceResponseFilter( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response )
{
return null;
}
public CefReturnValue OnBeforeResourceLoad( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback )
{
return CefReturnValue.Continue;
}
public bool OnCertificateError( IWebBrowser browserControl, IBrowser browser, CefErrorCode errorCode, string requestUrl, ISslInfo sslInfo, IRequestCallback callback )
{
return OnCertificateError( browserControl, browser, errorCode, requestUrl, sslInfo, callback );
}
public bool OnOpenUrlFromTab( IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture )
{
return OnOpenUrlFromTab( browserControl, browser, frame, targetUrl, targetDisposition, userGesture );
}
public void OnPluginCrashed( IWebBrowser browserControl, IBrowser browser, string pluginPath )
{
}
public bool OnProtocolExecution( IWebBrowser browserControl, IBrowser browser, string url )
{
return false;
}
public bool OnQuotaRequest( IWebBrowser browserControl, IBrowser browser, string originUrl, long newSize, IRequestCallback callback )
{
return OnQuotaRequest( browserControl, browser, originUrl, newSize, callback );
}
public void OnRenderProcessTerminated( IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status )
{
}
public void OnRenderViewReady( IWebBrowser browserControl, IBrowser browser )
{
}
public void OnResourceLoadComplete( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength )
{
}
public void OnResourceRedirect( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response, ref string newUrl )
{
}
public bool OnResourceResponse( IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response )
{
return false;
}
public bool OnSelectClientCertificate( IWebBrowser browserControl, IBrowser browser, bool isProxy, string host, int port, X509Certificate2Collection certificates, ISelectClientCertificateCallback callback )
{
return OnSelectClientCertificate( browserControl, browser, isProxy, host, port, certificates, callback );
}
}
}