WPF - Add ChromiumWebBrowser constructor overload with initialAddress param

Allows for address to be passed directly to CefBrowserHost::CreateBrowser which is required for CefExtension support

Resolves #2645
This commit is contained in:
amaitland
2019-04-05 11:56:45 +10:00
parent 8ced344ccd
commit dfb2cd55f1
+14 -3
View File
@@ -63,6 +63,10 @@ namespace CefSharp.Wpf
/// </summary>
private bool ignoreUriChange;
/// <summary>
/// Initial address
/// </summary>
private readonly string initialAddress;
/// <summary>
/// Has the underlying Cef Browser been created (slightly different to initliazed in that
/// the browser is initialized in an async fashion)
/// </summary>
@@ -463,6 +467,13 @@ namespace CefSharp.Wpf
}
}
public ChromiumWebBrowser(string initialAddress)
{
this.initialAddress = initialAddress;
NoInliningConstructor();
}
/// <summary>
/// Constructor logic has been moved into this method
/// Required for designer support - this method cannot be inlined as the designer
@@ -1097,8 +1108,8 @@ namespace CefSharp.Wpf
{
SetCurrentValue(IsBrowserInitializedProperty, true);
// If Address was previously set, only now can we actually do the load
if (!string.IsNullOrEmpty(Address))
// Only call Load if initialAddress is null and Address is not empty
if (string.IsNullOrEmpty(initialAddress) && !string.IsNullOrEmpty(Address))
{
Load(Address);
}
@@ -1789,7 +1800,7 @@ namespace CefSharp.Wpf
var windowInfo = CreateOffscreenBrowserWindowInfo(source == null ? IntPtr.Zero : source.Handle);
//Pass null in for Address and rely on Load being called in OnAfterBrowserCreated
//Workaround for issue https://github.com/cefsharp/CefSharp/issues/2300
managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings as BrowserSettings, requestContext as RequestContext, address: null);
managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings as BrowserSettings, requestContext as RequestContext, address: initialAddress);
browserSettings = null;
}