5
5
using CefSharp . OutOfProcess . Internal ;
6
6
using CefSharp . Dom ;
7
7
using PInvoke ;
8
+ using System . Collections . Generic ;
8
9
9
10
namespace CefSharp . OutOfProcess . WinForms
10
11
{
@@ -17,6 +18,7 @@ public class ChromiumWebBrowser : Control, IChromiumWebBrowserInternal
17
18
private IDevToolsContext _devToolsContext ;
18
19
private OutOfProcessConnectionTransport _devToolsContextConnectionTransport ;
19
20
private bool _devToolsReady ;
21
+ private IDictionary < string , object > requestContextPreferences ;
20
22
21
23
/// <inheritdoc/>
22
24
public event EventHandler DOMContentLoaded ;
@@ -75,6 +77,18 @@ public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress)
75
77
_initialAddress = initialAddress ;
76
78
}
77
79
80
+ /// <summary>
81
+ /// Initializes a new instance of the <see cref="ChromiumWebBrowser"/> instance.
82
+ /// </summary>
83
+ /// <param name="host">Out of process host</param>
84
+ /// <param name="initialAddress">address to load initially</param>
85
+ /// <param name="requestContextPreferences">requestContextPreferences to set</param>
86
+ public ChromiumWebBrowser ( OutOfProcessHost host , string initialAddress = null , IDictionary < string , object > requestContextPreferences = null )
87
+ : this ( host , initialAddress )
88
+ {
89
+ this . requestContextPreferences = requestContextPreferences ;
90
+ }
91
+
78
92
/// <inheritdoc/>
79
93
int IChromiumWebBrowserInternal . Id
80
94
{
@@ -128,7 +142,7 @@ protected override void OnHandleCreated(EventArgs e)
128
142
129
143
var size = Size ;
130
144
131
- _host . CreateBrowser ( this , Handle , url : _initialAddress , out _id ) ;
145
+ _host . CreateBrowser ( this , Handle , url : _initialAddress , out _id , requestContextPreferences ) ;
132
146
133
147
_devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
134
148
@@ -305,6 +319,15 @@ public Task<Response> GoBackAsync(NavigationOptions options = null)
305
319
return _devToolsContext . GoBackAsync ( options ) ;
306
320
}
307
321
322
+ /// <summary>
323
+ /// Update Request Context Preferences for this browser.
324
+ /// </summary>
325
+ /// <param name="preferences">The preferences.</param>
326
+ public void UpdateRequestContextPreferences ( IDictionary < string , object > preferences )
327
+ {
328
+ _host . UpdateRequestContextPreferences ( this . _id , preferences ) ;
329
+ }
330
+
308
331
/// <inheritdoc/>
309
332
public Task < Response > GoForwardAsync ( NavigationOptions options = null )
310
333
{
0 commit comments