|
17 | 17 | using System.Windows.Interop;
|
18 | 18 | using System.Windows.Threading;
|
19 | 19 | using Window = System.Windows.Window;
|
| 20 | +using System.Collections.Generic; |
20 | 21 |
|
21 | 22 | namespace CefSharp.OutOfProcess.Wpf.HwndHost
|
22 | 23 | {
|
@@ -131,6 +132,11 @@ private static extern IntPtr CreateWindowEx(int dwExStyle,
|
131 | 132 | /// </summary>
|
132 | 133 | private bool _initialFocus;
|
133 | 134 |
|
| 135 | + /// <summary> |
| 136 | + /// Contains the initial requests context preferences if any given in constructor. |
| 137 | + /// </summary> |
| 138 | + private readonly IDictionary<string, object> _requestContextPreferences; |
| 139 | + |
134 | 140 | /// <summary>
|
135 | 141 | /// Activates browser upon creation, the default value is false. Prior to version 73
|
136 | 142 | /// the default behaviour was to activate browser on creation (Equivilent of setting this property to true).
|
@@ -279,13 +285,15 @@ public bool IsDisposed
|
279 | 285 | /// </summary>
|
280 | 286 | /// <param name="host">Out of process host</param>
|
281 | 287 | /// <param name="initialAddress">address to load initially</param>
|
282 |
| - public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress = null) |
| 288 | + /// <param name="requestContextPreferences">requestContextPreferences to set</param> |
| 289 | + public ChromiumWebBrowser(OutOfProcessHost host, string initialAddress = null, IDictionary<string, object> requestContextPreferences = null) |
283 | 290 | {
|
284 | 291 | if(host == null)
|
285 | 292 | {
|
286 | 293 | throw new ArgumentNullException(nameof(host));
|
287 | 294 | }
|
288 | 295 |
|
| 296 | + _requestContextPreferences = requestContextPreferences; |
289 | 297 | _host = host;
|
290 | 298 | _initialAddress = initialAddress;
|
291 | 299 |
|
@@ -418,6 +426,15 @@ public Task<Response> GoForwardAsync(NavigationOptions options = null)
|
418 | 426 | return _devToolsContext.GoForwardAsync(options);
|
419 | 427 | }
|
420 | 428 |
|
| 429 | + /// <summary> |
| 430 | + /// Set Request Context Preferences for this browser. |
| 431 | + /// </summary> |
| 432 | + /// <param name="preferences">The preferences.</param> |
| 433 | + public void SetRequestContextPreferences(IDictionary<string, object> preferences) |
| 434 | + { |
| 435 | + _host.SetRequestContextPreferences(this._id, preferences); |
| 436 | + } |
| 437 | + |
421 | 438 | private void PresentationSourceChangedHandler(object sender, SourceChangedEventArgs args)
|
422 | 439 | {
|
423 | 440 | if (args.NewSource != null)
|
@@ -492,7 +509,7 @@ protected override HandleRef BuildWindowCore(HandleRef hwndParent)
|
492 | 509 | 0);
|
493 | 510 | }
|
494 | 511 |
|
495 |
| - _host.CreateBrowser(this, _hwndHost, url: _initialAddress, out _id); |
| 512 | + _host.CreateBrowser(this, _hwndHost, url: _initialAddress, out _id, _requestContextPreferences); |
496 | 513 |
|
497 | 514 | _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport(_id, _host);
|
498 | 515 |
|
|
0 commit comments