55using CefSharp . OutOfProcess . Internal ;
66using CefSharp . Dom ;
77using PInvoke ;
8+ using System . Collections . Generic ;
89
910namespace CefSharp . OutOfProcess . WinForms
1011{
@@ -17,6 +18,7 @@ public class ChromiumWebBrowser : Control, IChromiumWebBrowserInternal
1718 private IDevToolsContext _devToolsContext ;
1819 private OutOfProcessConnectionTransport _devToolsContextConnectionTransport ;
1920 private bool _devToolsReady ;
21+ private IDictionary < string , object > requestContextPreferences ;
2022
2123 /// <inheritdoc/>
2224 public event EventHandler DOMContentLoaded ;
@@ -75,6 +77,18 @@ public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress)
7577 _initialAddress = initialAddress ;
7678 }
7779
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+
7892 /// <inheritdoc/>
7993 int IChromiumWebBrowserInternal . Id
8094 {
@@ -128,7 +142,7 @@ protected override void OnHandleCreated(EventArgs e)
128142
129143 var size = Size ;
130144
131- _host . CreateBrowser ( this , Handle , url : _initialAddress , out _id ) ;
145+ _host . CreateBrowser ( this , Handle , url : _initialAddress , out _id , requestContextPreferences ) ;
132146
133147 _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
134148
@@ -305,6 +319,15 @@ public Task<Response> GoBackAsync(NavigationOptions options = null)
305319 return _devToolsContext . GoBackAsync ( options ) ;
306320 }
307321
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+
308331 /// <inheritdoc/>
309332 public Task < Response > GoForwardAsync ( NavigationOptions options = null )
310333 {
0 commit comments