提交 4e38a24a 编写于 作者: M Martin Zikmund

chore: Notify about CanGoBack, CanGoForward changes

上级 3fbd8fb5
......@@ -180,7 +180,7 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
}
_coreWebView.DocumentTitle = Title;
_coreWebView.RaiseNavigationCompleted(destinationUrl, true, 200, CoreWebView2WebErrorStatus.Unknown);
RaiseNavigationCompleted(destinationUrl, true, 200, CoreWebView2WebErrorStatus.Unknown);
_lastNavigationData = destinationUrl;
}
......@@ -198,7 +198,7 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
}
var targetString = target?.ToString();
_coreWebView.RaiseNewWindowRequested(targetString, action.SourceFrame?.Request?.Url?.ToUri(), out var handled);
RaiseNewWindowRequested(targetString, action.SourceFrame?.Request?.Url?.ToUri(), out var handled);
if (handled)
{
......@@ -217,11 +217,11 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
#endif
{
OpenUrl(targetString);
_coreWebView.RaiseNavigationCompleted(target, true, 200, CoreWebView2WebErrorStatus.Unknown);
RaiseNavigationCompleted(target, true, 200, CoreWebView2WebErrorStatus.Unknown);
}
else
{
_coreWebView.RaiseNavigationCompleted(target, false, 400, CoreWebView2WebErrorStatus.Unknown);
RaiseNavigationCompleted(target, false, 400, CoreWebView2WebErrorStatus.Unknown);
}
}
}
......@@ -231,7 +231,6 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
private void OpenUrl(string url)
{
//TODO: CanGoBack and CanGoForward should be refreshed after navigation completed on both Android and iOS
var nsUrl = new NSUrl(url);
//Opens the specified URL, launching the app that's registered to handle the scheme.
#if __IOS__
......@@ -410,9 +409,15 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
return;
}
_coreWebView.SetHistoryProperties(CanGoBack, CanGoForward);
_coreWebView.RaiseNavigationStarting(uriString, out cancel);
}
private void RaiseNavigationCompleted(Uri? uri, bool isSuccess, int httpStatusCode, CoreWebView2WebErrorStatus errorStatus)
{
_coreWebView.SetHistoryProperties(CanGoBack, CanGoForward);
_coreWebView.RaiseNavigationCompleted(uri, isSuccess, httpStatusCode, errorStatus);
}
#if __IOS__
private void ParseUriAndLauchMailto(Uri mailtoUri)
......@@ -553,7 +558,7 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
uri = webView.Url?.ToUri() ?? new Uri(_coreWebView.Source); // TODO:MZ: What if Source is invalid URI?
}
_coreWebView.RaiseNavigationCompleted(uri, false, 0, status); // TODO:MZ: What HTTP Status code?
RaiseNavigationCompleted(uri, false, 0, status); // TODO:MZ: What HTTP Status code?
}
_isCancelling = false;
......@@ -667,7 +672,7 @@ public partial class UnoWKWebView : WKWebView, INativeWebView, IWKScriptMessageH
this.Log().Error($"The uri [{uri}] is invalid.");
}
_coreWebView.RaiseNavigationCompleted(uri, false, 404, CoreWebView2WebErrorStatus.UnexpectedError);
RaiseNavigationCompleted(uri, false, 404, CoreWebView2WebErrorStatus.UnexpectedError);
}
}
......
......@@ -40,9 +40,3 @@ At the end of the navigation, on `WebView` the either `NavigationCompleted` or `
In `WebView`, most the events include `Uri`, but `WebView2` uses a unique `NavigationId` instead.
For details on `WebView2` event behavior see: https://learn.microsoft.com/en-us/microsoft-edge/webview2/concepts/navigation-events
## Navigation ID
As `WebView2` tracks each navigation via a unique identifier, we need to have a way to generate these IDs properly.
On iOS and macOS we use the `WKNavigation` which is a unique identifier of the load request for a webpage.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册