Skip to content

Commit 2080fd6

Browse files
committed
Example - Update RequestContextHandler
1 parent e0bad63 commit 2080fd6

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

CefSharp.Example/Handlers/RequestContextHandler.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,26 @@ public class RequestContextHandler : CefSharp.Handler.RequestContextHandler
88
{
99
protected override IResourceRequestHandler GetResourceRequestHandler(IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
1010
{
11+
// Return null for the default behaviour
12+
//return null;
13+
14+
// To handle resource requests at the RequestContext level
15+
// Implement CefSharp.IResourceRequestHandler or inherit from CefSharp.Handler.ResourceRequestHandler
1116
return new ExampleResourceRequestHandler();
1217
}
1318

1419
protected override void OnRequestContextInitialized(IRequestContext requestContext)
1520
{
16-
//You can set preferences here on your newly initialized request context.
17-
//Note, there is called on the CEF UI Thread, so you can directly call SetPreference
21+
// You can set preferences here on your newly initialized request context.
22+
// Note, there is called on the CEF UI Thread, so you can directly call SetPreference
1823

19-
//Use this to check that settings preferences are working in your code
24+
// Use this to check that settings preferences are working in your code
25+
// You should see the minimum font size is now 24pt
2026
//string errorMessage;
2127
//var success = requestContext.SetPreference("webkit.webprefs.minimum_font_size", 24, out errorMessage);
2228

29+
// This is the preferred place to set the proxy as it's called before the first request is made,
30+
// ensuring all requests go through the specified proxy
2331
//string errorMessage;
2432
//bool success = requestContext.SetProxy("http://localhost:8080", out errorMessage);
2533
}

0 commit comments

Comments
 (0)