mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-06 04:00:07 +00:00
WinForms - Improve handling of Load method when called after CreateBrowser and before OnAfterBrowserCreated
Call MainFrame.Load after the browser has been created if the Address property has been set after CreateBrowser and before OnAfterBrowserCreated
This commit is contained in:
@@ -52,6 +52,12 @@ namespace CefSharp.WinForms
|
||||
/// </summary>
|
||||
private bool browserCreated;
|
||||
/// <summary>
|
||||
/// A flag indicating if the <see cref="Address"/> was used when calling CreateBrowser
|
||||
/// If false and <see cref="Address"/> contains a non empty string Load will be called
|
||||
/// on the main frame
|
||||
/// </summary>
|
||||
private bool initialAddressLoaded;
|
||||
/// <summary>
|
||||
/// Browser initialization settings
|
||||
/// </summary>
|
||||
private IBrowserSettings browserSettings;
|
||||
@@ -645,6 +651,8 @@ namespace CefSharp.WinForms
|
||||
{
|
||||
var windowInfo = CreateBrowserWindowInfo(Handle);
|
||||
|
||||
initialAddressLoaded = !string.IsNullOrEmpty(Address);
|
||||
|
||||
managedCefBrowserAdapter.CreateBrowser(windowInfo, browserSettings as BrowserSettings, requestContext as RequestContext, Address);
|
||||
|
||||
browserSettings = null;
|
||||
@@ -681,6 +689,13 @@ namespace CefSharp.WinForms
|
||||
|
||||
ResizeBrowser();
|
||||
|
||||
//If Load was called after the call to CreateBrowser we'll call Load
|
||||
//on the MainFrame
|
||||
if (!initialAddressLoaded && !string.IsNullOrEmpty(Address))
|
||||
{
|
||||
browser.MainFrame.LoadUrl(Address);
|
||||
}
|
||||
|
||||
IsBrowserInitializedChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user