未验证 提交 31a2f86d 编写于 作者: M Martin Zikmund 提交者: GitHub

Merge pull request #10794 from unoplatform/dev/mazi/webview2

feat: `WebView2`
......@@ -9395,6 +9395,10 @@
<IgnoreSet baseVersion="4.8">
<Types>
<!-- BEGIN WebView -->
<Member fullName="Windows.UI.Xaml.Controls.INativeWebView" reason="Should not be public" />
<Member fullName="Uno.UI.Web.WebErrorStatus" reason="Incorrect namespace" />
<!-- END WebView -->
</Types>
<Events>
......@@ -9404,6 +9408,10 @@
</Fields>
<Properties>
<!-- BEGIN WebView -->
<Member fullName="Uno.UI.Web.WebErrorStatus Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs::WebErrorStatus()" reason="Incorrect type" />
<Member fullName="Uno.UI.Web.WebErrorStatus Windows.UI.Xaml.Controls.WebViewNavigationFailedEventArgs::WebErrorStatus()" reason="Incorrect type" />
<!-- END WebView -->
</Properties>
<Methods>
......@@ -9413,6 +9421,29 @@
<Member fullName="System.Void Windows.Media.Playback.PlaybackMediaMarkerReachedEventArgs..ctor()" reason="Not present in Windows" />
<Member fullName="System.Void Windows.Media.Playback.MediaPlaybackSession..ctor()" reason="Not present in Windows" />
<!-- END MediaPlayer updates -->
<!-- BEGIN WebView -->
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2..ctor()" reason="Should not be public" />
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs..ctor()" reason="Should not be public" />
<Member fullName=" System.Void Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs..ctor()" reason="Should not be public" />
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2NewWindowRequestedEventArgs..ctor()" reason="Should not be public" />
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs..ctor()" reason="Should not be public" />
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2Settings..ctor()" reason="Should not be public" />
<Member fullName="System.Threading.Tasks.Task Microsoft.UI.Xaml.Controls.WebView.LaunchMailto(System.Threading.CancellationToken ct, System.String subject, System.String body, System.String[] to, System.String[] cc, System.String[] bcc)" reason="Should not be public" />
<Member fullName="System.Boolean Windows.UI.Xaml.Controls.WebView.MustUseWebKitWebView()" reason="Should not be public" />
<Member fullName="Uno.UI.Web.WebErrorStatus Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs.get_WebErrorStatus()" reason="Incorrect return type" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs..ctor()" reason="Should not be public" />
<Member fullName="Uno.UI.Web.WebErrorStatus Windows.UI.Xaml.Controls.WebViewNavigationFailedEventArgs.get_WebErrorStatus()" reason="Incorrect return type" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.WebViewNavigationFailedEventArgs..ctor()" reason="Should not be public" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs..ctor()" reason="Should not be public" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.WebViewUnsupportedUriSchemeIdentifiedEventArgs..ctor(System.Uri uri)" reason="Should not be public" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.UnoWKWebView.RegisterNavigationEvents(Windows.UI.Xaml.Controls.WebView xamlWebView)" reason="Should not be public" />
<Member fullName="System.Threading.Tasks.Task`1&lt;System.String&gt; Windows.UI.Xaml.Controls.UnoWKWebView.EvaluateJavascriptAsync(System.Threading.CancellationToken ct, System.String javascript)" reason="Should not be public" />
<Member fullName="System.Void Windows.UI.Xaml.Controls.WebView.Navigate(System.Uri uri)" reason="Was using incorrect parameter name" />
<Member fullName="System.Threading.Tasks.Task Windows.UI.Xaml.Controls.WebView.LaunchMailto(System.Threading.CancellationToken ct, System.String subject, System.String body, System.String[] to, System.String[] cc, System.String[] bcc)" reason="Should not be public" />
<Member fullName="System.Void Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs..ctor()" reason="Should not be public" />
<!-- END WebView -->
</Methods>
</IgnoreSet>
......
# `WebView` (`WebView2`)
> Uno Platform supports two `WebView` controls - a legacy `WebView` and a modernized `WebView2` control. For new development we strongly recommend `WebView2` as it will get further improvements in the future.
`WebView2` is currently supported on Windows, Android, iOS and macOS.
## Basic usage
You can include the `WebView2` control anywhere in XAML:
```xaml
<WebView2 x:Name="MyWebView" Source="https://platform.uno/" />
```
To manipulate the control from C#, first ensure that you call its EnsureCoreWebView2Async() method:
```csharp
await MyWebView.EnsureCoreWebView2Async();
```
Afterward, you can perform actions such as navigating to an HTML string:
```csharp
MyWebView.NavigateToString("<html><body><p>Hello world!</p></body></html>");
```
## Executing JavaScript
When a page is loaded inside the `WebView2` control, you can execute custom JavaScript code. To do this, call the `ExecuteScriptAsync` method:
```csharp
webView.NavigateToString("<div id='test' style='width: 10px; height: 10px; background-color: blue;'></div>");
// Renders a blue <div>
await webView.ExecuteScriptAsync("document.getElementById('test').style.backgroundColor = 'red';");
// The <div> is now red.
```
The method can also return a string result, with returned values being JSON-encoded:
```csharp
await webView.ExecuteScriptAsync("1 + 1"); // Returns a string containing 2
await webView.ExecuteScriptAsync($"(1 + 1).toString()"); // Returns a string containing "2"
await webView.ExecuteScriptAsync("eval({'test': 1})"); // Returns a string containing {"test":1}
```
## JavaScript to C# communication
`WebView2` enables sending web messages from JavaScript to C# on all supported targets. In your web page, include code that sends a message to the `WebView2` control if available. Since Uno Platform runs on multiple targets, you need to use the correct approach for each. We recommend creating a reusable function like the following:
```javascript
function postWebViewMessage(message){
try{
if (window.hasOwnProperty("chrome") && typeof chrome.webview !== undefined) {
// Windows
chrome.webview.postMessage(message);
} else if (window.hasOwnProperty("unoWebView")) {
// Android
unoWebView.postMessage(JSON.stringify(message));
} else if (window.hasOwnProperty("webkit") && typeof webkit.messageHandlers !== undefined) {
// iOS and macOS
webkit.messageHandlers.unoWebView.postMessage(JSON.stringify(message));
}
}
catch (ex){
alert("Error occurred: " + ex);
}
}
// Usage:
postWebViewMessage("hello world");
postWebViewMessage({"some": ['values',"in","json",1]});
```
> **Note:** Make sure not to omit the `JSON.stringify` calls for Android, iOS and macOS as seen in the snippet above, as they are crucial to transfer data correctly.
To receive the message in C#, subscribe to the `WebMessageReceived` event:
```csharp
webView.WebMessageReceived += (s, e) =>
{
Debug.WriteLine(e.WebMessageAsJson);
};
```
The `WebMessageAsJson` property contains a JSON-encoded string of the data passed to `postWebViewMessage` above.
\ No newline at end of file
......@@ -232,6 +232,8 @@
href: controls/TimePicker.md
- name: ToggleSwitch
href: controls/ToggleSwitch.md
- name: WebView (WebView2)
href: controls/WebView.md
- name: Non-UI APIs
items:
- name: Accelerometer
......
......@@ -103,7 +103,7 @@
<Version>7.0.2</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.8.0-prerelease.210927001</Version>
<Version>2.8.2-prerelease.220830001</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework" Version="2.1.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.11.4-develop" />
......
......@@ -7,7 +7,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
xmlns:lottie="using:Microsoft.Toolkit.Uwp.UI.Lottie"
mc:Ignorable="d"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d not_win"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
<lottie:LottieVisualSource UriSource="ms-appx:///Assets/Animations/squirrel.json" x:Key="SquirrelAnimation"/>
......@@ -16,19 +17,19 @@
<StackPanel Margin="50">
<TextBlock Text="Indeterminate"/>
<muxc:ProgressRing IsActive="True"
IndeterminateSource="{StaticResource SquirrelAnimation}"/>
not_win:IndeterminateSource="{StaticResource SquirrelAnimation}"/>
<muxc:ProgressRing IsActive="True"
IndeterminateSource="{StaticResource AcrobatAnimation}"/>
not_win:IndeterminateSource="{StaticResource AcrobatAnimation}"/>
<TextBlock Text="Determinate"/>
<muxc:ProgressRing IsIndeterminate="False"
IsActive="True"
DeterminateSource="{StaticResource SquirrelAnimation}"
not_win:DeterminateSource="{StaticResource SquirrelAnimation}"
Value="{Binding Value, ElementName=progressSlider}"
Minimum="0"
Maximum="100"/>
<muxc:ProgressRing IsIndeterminate="False"
IsActive="True"
DeterminateSource="{StaticResource AcrobatAnimation}"
not_win:DeterminateSource="{StaticResource AcrobatAnimation}"
Value="{Binding Value, ElementName=progressSlider}"
Minimum="0"
Maximum="100"/>
......
......@@ -6,7 +6,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lottie="using:Microsoft.Toolkit.Uwp.UI.Lottie"
mc:Ignorable="d"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d not_win"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Page.Resources>
......@@ -31,7 +32,7 @@
<winui:ProgressRing Foreground="Yellow" x:Name="indeterminate60" IsIndeterminate="True" />
<winui:ProgressRing Foreground="Orange" x:Name="indeterminate99" IsIndeterminate="True" />
<winui:ProgressRing Foreground="Red" x:Name="indeterminate100" IsIndeterminate="True" />
<winui:ProgressRing x:Name="indeterminateCustom" IsIndeterminate="True" IndeterminateSource="{StaticResource CustomIndeterminateSource}" />
<winui:ProgressRing x:Name="indeterminateCustom" IsIndeterminate="True" not_win:IndeterminateSource="{StaticResource CustomIndeterminateSource}" />
</StackPanel>
<TextBlock>Static Determinate mode:</TextBlock>
<StackPanel Spacing="4" Orientation="Horizontal">
......@@ -42,7 +43,7 @@
<winui:ProgressRing Foreground="Yellow" x:Name="determinate60" IsIndeterminate="False" Value="60" />
<winui:ProgressRing Foreground="Orange" x:Name="determinate99" IsIndeterminate="False" Value="99" />
<winui:ProgressRing Foreground="Red" x:Name="determinate100" IsIndeterminate="False" Value="100" />
<winui:ProgressRing x:Name="determinateCustom" Width="80" IsIndeterminate="False" Value="75" DeterminateSource="{StaticResource CustomDeterminateSource}" />
<winui:ProgressRing x:Name="determinateCustom" Width="80" IsIndeterminate="False" Value="75" not_win:DeterminateSource="{StaticResource CustomDeterminateSource}" />
</StackPanel>
<TextBlock>Dynamic Determinate mode:</TextBlock>
<Slider Minimum="0" Maximum="100" Value="50" x:Name="dynamicValue" />
......@@ -55,7 +56,7 @@
<winui:ProgressRing Foreground="Yellow" x:Name="dyn5" IsIndeterminate="False" Value="{Binding Value, ElementName=dynamicValue}" />
<winui:ProgressRing Foreground="Orange" x:Name="dyn6" IsIndeterminate="False" Value="{Binding Value, ElementName=dynamicValue}" />
<winui:ProgressRing Foreground="Red" x:Name="dyn7" IsIndeterminate="False" Value="{Binding Value, ElementName=dynamicValue}" />
<winui:ProgressRing x:Name="dyn8" Width="80" IsIndeterminate="False" Value="{Binding Value, ElementName=dynamicValue}" DeterminateSource="{StaticResource CustomDeterminateSource}" />
<winui:ProgressRing x:Name="dyn8" Width="80" IsIndeterminate="False" Value="{Binding Value, ElementName=dynamicValue}" not_win:DeterminateSource="{StaticResource CustomDeterminateSource}" />
</StackPanel>
......
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2ControlJavaScriptAlertConfirmPrompt"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d xamarin"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<mux:WebView2 x:Name="MyWebView2" />
</Grid>
</UserControl>
using System;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Sample("WebView", Name = "WebView2_Javascript_AlertConfirmPrompt")]
public sealed partial class WebView2ControlJavaScriptAlertConfirmPrompt : UserControl
{
public WebView2ControlJavaScriptAlertConfirmPrompt()
{
InitializeComponent();
Loaded += WebView2ControlWithJavaError_Loaded;
}
private async void WebView2ControlWithJavaError_Loaded(object sender, RoutedEventArgs e)
{
await MyWebView2.EnsureCoreWebView2Async();
var sampleHTML = @"
<html>
<head>
<title></title>
</head>
<body>
<p><br />This is a WebView2</p>
<p><br />Basic alert:</p>
<button onclick='basicAlert()'>Tap Me</button>
<p><br />Confirmation alert:</p>
<button onclick='confirmationAlert()'>Tap Me</button>
<p id='confirmResult'></p>
<p><br />Prompt alert:</p>
<button onclick='promptAlert()'>Tap Me</button>
<p id='promptResult'></p>
<script>
function basicAlert() {
alert('Hello, World!');
}
function confirmationAlert() {
var resultString;
var result = confirm('Are you sure?');
if (result == true) {
resultString = 'You tapped OK!';
} else {
resultString = 'You tapped Cancel!';
}
document.getElementById('confirmResult').innerHTML = resultString;
}
function promptAlert() {
var result = prompt('Enter some text','Placeholder Text');
if (result != null) {
document.getElementById('promptResult').innerHTML = 'You wrote: ' + result;
}
}
</script>
</body>
</html>";
MyWebView2.NavigateToString(sampleHTML);
}
}
}
#if HAS_UNO
using Uno.Foundation.Logging;
using Windows.UI.Xaml;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
public static class WebView2ObserverBehavior
{
#region IsAttached ATTACHED PROPERTY
public static bool GetIsAttached(Microsoft.UI.Xaml.Controls.WebView2 obj)
{
return (bool)obj.GetValue(IsAttachedProperty);
}
public static void SetIsAttached(Microsoft.UI.Xaml.Controls.WebView2 obj, bool value)
{
obj.SetValue(IsAttachedProperty, value);
}
public static DependencyProperty IsAttachedProperty { get; } =
DependencyProperty.RegisterAttached("IsAttached", typeof(bool), typeof(WebView2ObserverBehavior), new PropertyMetadata(false, OnIsAttachedChanged));
private static void OnIsAttachedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var webView2 = d as Microsoft.UI.Xaml.Controls.WebView2;
if (webView2 != null)
{
UnregisterEvents(webView2);
if ((bool)e.NewValue)
{
RegisterEvents(webView2);
}
}
}
#endregion
#region Message ATTACHED PROPERTY
public static string GetMessage(DependencyObject obj)
{
return (string)obj.GetValue(MessageProperty);
}
public static void SetMessage(DependencyObject obj, string value)
{
obj.SetValue(MessageProperty, value);
}
public static DependencyProperty MessageProperty { get; } =
DependencyProperty.RegisterAttached("Message", typeof(string), typeof(WebView2ObserverBehavior), new PropertyMetadata(null));
#endregion
private static void RegisterEvents(Microsoft.UI.Xaml.Controls.WebView2 webView)
{
webView.NavigationStarting += WebView2_NavigationStarting;
webView.NavigationCompleted += WebView2_NavigationCompleted;
//webView.NavigationFailed += WebView2_NavigationFailed;//TODO:MZ:
}
private static void UnregisterEvents(Microsoft.UI.Xaml.Controls.WebView2 webView)
{
webView.NavigationStarting -= WebView2_NavigationStarting;
webView.NavigationCompleted -= WebView2_NavigationCompleted;
//webView.NavigationFailed -= WebView2_NavigationFailed; //TODO:MZ:
}
private static void WebView2_NavigationStarting(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs args)
{
var message = $"NavigationStarting @ {args.Uri} [{sender.Source}]";
SetMessage(sender, message);
sender.Log().Debug(message);
}
//private static void WebView2_NavigationFailed(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationFailedEventArgs e)
//{
// //var webView2 = sender as Microsoft.UI.Xaml.Controls.WebView2;
// //var message = $"NavigationFailed {e.WebErrorStatus} @ {e.Uri} [{webView.Source}]";
// //SetMessage(webView, message);
// //sender.Log().Debug(message); //TODO:MZ:
//}
private static void WebView2_NavigationCompleted(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs args)
{
//var message = $"NavigationCompleted @ {args.Uri} [{sender.Source}]";
//SetMessage(sender, message);
//sender.Log().Debug(message); //TODO:MZ:
}
}
}
#endif
#if HAS_UNO
using System;
using Windows.UI.Xaml;
using WebView2Uno = Microsoft.UI.Xaml.Controls.WebView2;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
public static class WebView2SampleBehavior
{
public static string GetSourceUri(DependencyObject obj)
{
return (string)obj.GetValue(SourceUriProperty);
}
public static void SetSourceUri(DependencyObject obj, string value)
{
obj.SetValue(SourceUriProperty, value);
}
public static DependencyProperty SourceUriProperty { get; } =
DependencyProperty.RegisterAttached("SourceUri", typeof(string), typeof(WebView2SampleBehavior), new PropertyMetadata("", OnSourceUriChanged));
private static void OnSourceUriChanged(object d, DependencyPropertyChangedEventArgs e)
{
var uriString = e.NewValue?.ToString();
if (!string.IsNullOrEmpty(uriString))
{
((WebView2Uno)d).Source = new Uri(uriString, UriKind.Absolute);
}
}
}
}
#endif
using System.Windows.Input;
using Windows.UI.Core;
using Uno.UI.Samples.UITests.Helpers;
using ICommand = System.Windows.Input.ICommand;
using EventHandler = System.EventHandler;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
internal class WebView2StaticViewModel : ViewModelBase
{
private static readonly string[] WebSites =
{
"http://microsoft.com",
"http://nventive.com",
"http://xamarin.com",
"http://burymewithmymoney.com/"
};
private string _webSource;
private int _nextLink = 0;
public WebView2StaticViewModel(CoreDispatcher dispatcher) : base(dispatcher)
{
}
private void GoNextLink()
{
_nextLink++;
var link = WebSites[_nextLink % WebSites.Length];
WebSource = link;
}
public string ChromeTestUri => "https://presgit.github.io/camera.html";
public string WebSource
{
get => _webSource;
private set
{
_webSource = value;
RaisePropertyChanged();
}
}
public ICommand GoToNextWebSource => GetOrCreateCommand(GoNextLink);
}
}
using Windows.UI.Core;
using Uno.UI.Samples.UITests.Helpers;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
internal class WebView2ViewModel : ViewModelBase
{
private const string SampleHtml = @"
<!DOCTYPE html>
<html>
<head>
<title>Uno Samples</title>
</head>
<body>
<p>Welcome to <a href=""https://platform.uno/"">Uno Platform</a>'s samples!</p>
</body>
</html>";
public WebView2ViewModel(CoreDispatcher dispatcher) : base(dispatcher)
{
}
public string InitialSourceString => SampleHtml;
public string InitialUri => "http://www.google.com";
public string AlertHtml => @"
<html>
<head>
<title>Spamming alert</title>
</head>
<body>
<h1>This page spam alert each 5 seconds.</h1>
<script>
let count = 0;
function timer() {
count++;
alert('Spamming alert #' + count);
console.log(""Spamming alert #"" + count);
setTimeout(timer, 5000)
}
timer()
</script>
</body>
</html>";
}
}
<Page
x:Class="UITests.Shared.Windows_UI_Xaml.WebView2_Alert"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:unoControls="using:Uno.UI.Samples.Controls"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<unoControls:StarStackPanel Sizes="*,Auto">
<mux:WebView2 x:Name="web" />
<Button Click="Load">LOAD WEBVIEW WITH ALERT SCRIPT</Button>
</unoControls:StarStackPanel>
</Page>
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
namespace UITests.Shared.Windows_UI_Xaml
{
[Sample("WebView", Name = "WebView2_Alert", ViewModelType = typeof(WebView2ViewModel))]
public sealed partial class WebView2_Alert : Page
{
public WebView2_Alert()
{
this.InitializeComponent();
}
private async void Load(object sender, RoutedEventArgs e)
{
var html = ((WebView2ViewModel)DataContext).AlertHtml;
await web.EnsureCoreWebView2Async();
web.CoreWebView2.NavigateToString(html);
}
}
}
<UserControl x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_AnchorNavigation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel>
<TextBlock Text="Navigation Starting Uri:" />
<TextBlock x:Name="NavigationStartingTextBlock"
Margin="0,0,0,12"/>
<TextBlock Text="Navigation Completed Uri:" />
<TextBlock x:Name="NavigationCompletedTextBlock"
Margin="0,0,0,12"/>
<Button x:Name="NavigateToAnchorButton"
Content="Navigate To Anchor"
Click="{x:Bind ButtonClicked}"
Height="50" />
<Button x:Name="ClickAnchorButton"
Content="Click Anchor"
Click="{x:Bind OnClickAnchor}"
Height="50" />
</StackPanel>
<mux:WebView2 x:Name="webView"
Grid.Row="1"
Margin="32" />
</Grid>
</UserControl>
using System;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Sample("WebView", Description = "This sample tests that anchor navigation raises the proper events. The 2 uris received from the NavigationStarting and NavigationCompleted must update whether you tap the NavigateToAnchor button or tap on anchors from the web content.")]
public sealed partial class WebView2_AnchorNavigation : UserControl
{
public WebView2_AnchorNavigation()
{
InitializeComponent();
#if HAS_UNO
//TODO:MZ:
//webView.Navigate(new Uri("https://nv-assets.azurewebsites.net/tests/docs/WebView2_NavigateToAnchor.html"));
//webView.NavigationStarting += WebView2_NavigationStarting;
//webView.NavigationCompleted += WebView2_NavigationCompleted;
#endif
}
private void WebView2_NavigationStarting(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs args)
{
NavigationStartingTextBlock.Text = args.Uri.ToString();
}
private void WebView2_NavigationCompleted(Microsoft.UI.Xaml.Controls.WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs args)
{
//TODO: MZ: How to get the URI here?
//NavigationCompletedTextBlock.Text = sender.CoreWebView2.Ur;
}
private async void ButtonClicked()
{
await webView.EnsureCoreWebView2Async();
webView.CoreWebView2.Navigate("https://nv-assets.azurewebsites.net/tests/docs/WebView2_NavigateToAnchor.html#section-1");
}
private void OnClickAnchor()
{
_ = webView.ExecuteScriptAsync("document.querySelector(\"a[href =\\\"#page-4\\\"]\").click()");
}
}
}
<UserControl x:Class="UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Animated_Opacity"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:local="using:UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d xamarin"
d:DesignHeight="300"
d:DesignWidth="400">
<Grid Background="Red">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Button Content="Some Text !" />
<ContentControl x:Name="test"
Grid.Row="1"
Width="100"
Height="100">
<ContentControl.Template>
<ControlTemplate TargetType="ContentControl">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="LoadingStates">
<VisualState x:Name="Loading">
<Storyboard>
<DoubleAnimation Storyboard.TargetName="PART_WebView"
Storyboard.TargetProperty="Opacity"
Duration="0:0:0.1"
To="1" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<!-- Value -->
<mux:WebView2 x:Name="PART_WebView"
Source="https://web.archive.org/web/20181010203846/https://www.bloomberg.com/view/articles/2018-10-09/google-is-big-and-google-was-small" />
</Grid>
</ControlTemplate>
</ContentControl.Template>
</ContentControl>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Uno.UI.Samples.Controls;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236
namespace UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Sample("WebView", Description = "Opacity is animated on WebView2. It shouldn't exceed bounds while page is loading (Android bug #2006)")]
public sealed partial class WebView2_Animated_Opacity : UserControl
{
public WebView2_Animated_Opacity()
{
this.InitializeComponent();
#if HAS_UNO
VisualStateManager.GoToState(test, "Loading", true);
#endif
}
}
}
<Page
x:Class="UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Basic"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<controls:WebView2 Source="https://platform.uno"/>
</Grid>
</Page>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=234238
namespace UITests.Microsoft_UI_Xaml_Controls.WebView2Tests
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
[Uno.UI.Samples.Controls.Sample("WebView")]
public sealed partial class WebView2_Basic : Page
{
public WebView2_Basic()
{
this.InitializeComponent();
}
}
}
<UserControl x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_ChromeClient"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:local="using:SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d xamarin"
d:DesignHeight="300"
d:DesignWidth="400">
<controls:SampleControl SampleDescription="WebChromeClient">
<controls:SampleControl.SampleContent>
<DataTemplate>
<mux:WebView2 Source="{Binding [ChromeTestUri]}" />
</DataTemplate>
</controls:SampleControl.SampleContent>
</controls:SampleControl>
</UserControl>
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_ChromeClient", typeof(WebView2StaticViewModel))]
public sealed partial class WebView2_ChromeClient : UserControl
{
public WebView2_ChromeClient()
{
this.InitializeComponent();
}
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Events"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:local="using:SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d xamarin not_win"
d:DesignHeight="300"
d:DesignWidth="400">
<controls:SampleControl SampleDescription="Monitoring WebView2 events">
<controls:SampleControl.SampleContent>
<DataTemplate>
<not_win:Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<mux:WebView2 x:Name="WebView2Control"
Source="http://microsoft.com"
local:WebView2ObserverBehavior.IsAttached="True" />
<TextBlock x:Name="Feedback"
Text="{Binding (local:WebView2ObserverBehavior.Message), ElementName=WebView2Control}"
Grid.Row="1"
Height="100"
HorizontalAlignment="Stretch"
VerticalAlignment="Bottom"
TextWrapping="Wrap" />
</not_win:Grid>
</DataTemplate>
</controls:SampleControl.SampleContent>
</controls:SampleControl>
</UserControl>
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Sample("WebView", ViewModelType = typeof(WebView2ViewModel), IgnoreInSnapshotTests = true /*WebView2 may or may not have fully loaded*/)]
public sealed partial class WebView2_Events : UserControl
{
public WebView2_Events()
{
this.InitializeComponent();
}
}
}
<Page
x:Class="UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_ExecuteScriptAsync"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<Button Click="{x:Bind ChangeColor}">Change color</Button>
<Button Click="{x:Bind GetColor}">Get color</Button>
<TextBlock x:Name="CurrentColorTextBlock" />
<controls:WebView2 x:Name="TestWebView" Width="200" Height="200" />
</StackPanel>
</Page>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace UITests.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Uno.UI.Samples.Controls.Sample("WebView")]
public sealed partial class WebView2_ExecuteScriptAsync : Page
{
public WebView2_ExecuteScriptAsync()
{
this.InitializeComponent();
TestWebView.Loaded += TestWebView_Loaded;
}
private async void TestWebView_Loaded(object sender, RoutedEventArgs e)
{
await TestWebView.EnsureCoreWebView2Async();
var testHtml = "<html><body><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>";
TestWebView.NavigateToString(testHtml);
}
private async void ChangeColor()
{
await TestWebView.ExecuteScriptAsync("document.getElementById('test').style.backgroundColor = 'red';");
}
private async void GetColor()
{
var color = await TestWebView.ExecuteScriptAsync("eval({ 'color' : document.getElementById('test').style.backgroundColor })");
CurrentColorTextBlock.Text = color;
}
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_JavascriptInvoke"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:android="http://uno.ui/android"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<StackPanel Orientation="Vertical">
<TextBlock Text="WebView2_NavigateWithHttpRequestMessage" />
<mux:WebView2 Source="http://www.google.com/"
x:Name="MyWebView2"
Height="100"
Width="100" />
<TextBlock x:Name="MyTextBlock" TextWrapping="Wrap" />
<Button Content="Invoke Javascript in Web Browser" x:Name="MyButton" />
</StackPanel>
</Grid>
</UserControl>
using System;
using System.Threading;
using System.Threading.Tasks;
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Core;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_JavascriptInvoke", typeof(WebView2ViewModel))]
public sealed partial class WebView2_JavascriptInvoke : UserControl
{
#if HAS_UNO
public WebView2_JavascriptInvoke()
{
this.InitializeComponent();
//TODO:MZ:
// MyButton.Click += MyButton_OnClick;
//}
//private void MyButton_OnClick(object sender, RoutedEventArgs e)
//{
// var t = Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
// async () => await InvokeScriptAsync(MyWebView2, CancellationToken.None, GetReloadJavascript(), new string[] { "" })
// );
//}
//public static async Task<string> InvokeScriptAsync(Microsoft.UI.Xaml.Controls.WebView2 webView, CancellationToken ct, string script, string[] arguments)
//{
//
// //return await webView.CoreWebView2.ExecuteScriptAsync(script, arguments).AsTask(ct);
}
// private static string GetReloadJavascript()
// {
//#if XAMARIN_IOS
// return "location.reload(true);";
//#else
// return "window.location.reload()";
//#endif
// }
#endif
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Mailto"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<mux:WebView2
x:Name="webView"
Height="100"
Width="100" />
</UserControl>
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_Mailto", description: "This sample will open a mailto: link")]
public sealed partial class WebView2_Mailto : UserControl
{
public WebView2_Mailto()
{
InitializeComponent();
var html = "<a href=\"mailto:uno-platform-test@platform.uno?subject=Tests\">open mailto link</a>";
webView.NavigateToString(html);
}
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigateToString"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:uBehaviors="using:Uno.UI.Samples.Behaviors"
xmlns:ios="http://nventive.com/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://nventive.com/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d ios android xamarin not_win"
d:DesignHeight="2000"
d:DesignWidth="400">
<not_win:Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Background="Honeydew">
<TextBlock Text="HTML content to load:" />
<TextBox x:Name="WebView2_NavigateToStringTextBox"
Width="400"
Height="100"
Foreground="Black"
TextWrapping="Wrap"
Text="{Binding [InitialSourceString]}" />
</StackPanel>
<mux:WebView2 Grid.Row="1"
uBehaviors:WebView2Behavior.SourceString="{Binding ElementName=WebView2_NavigateToStringTextBox, Path=Text}" />
</not_win:Grid>
</UserControl>
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_NavigateToString", typeof(WebView2ViewModel), description: "WebView2 demonstrating NavigateToString method")]
public sealed partial class WebView2_NavigateToString : UserControl
{
public WebView2_NavigateToString()
{
this.InitializeComponent();
}
}
}
<UserControl
x:Class="UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigateToString2"
xmlns:controls="using:Uno.UI.Samples.Controls"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:uBehaviors="using:Uno.UI.Samples.Behaviors"
xmlns:ios="http://nventive.com/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://nventive.com/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Background="Honeydew">
<TextBox Header="Size of (big) string, in thousands of lines" Text="1000" x:Name="WebView2_NavigateToStringSize" InputScope="Number" />
<Button Content="generate long string" Click="generateLong_Click" x:Name="startButton" />
<TextBlock Text="waiting for NavigationCompleted" x:Name="WebView2_NavigateToStringResult" />
</StackPanel>
<mux:WebView2 Grid.Row="1" Name="webViewControl" />
</Grid>
</UserControl>

using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace UITests.Shared.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Uno.UI.Samples.Controls.SampleControlInfo("WebView", "WebView2_NavigateToString2", description: "Testing a NavigateToString with a very long string")]
public sealed partial class WebView2_NavigateToString2 : UserControl
{
public WebView2_NavigateToString2()
{
this.InitializeComponent();
}
string longString = "";
private void generateLong_Click(object sender, object e)
{
if (longString.Length < 10)
{
// generate string
WebView2_NavigateToStringResult.Text = "generating string";
int linesCount = 0;
if (!int.TryParse(WebView2_NavigateToStringSize.Text, out linesCount))
{
return;
}
longString = "<html><body>";
for (int i = 0; i < linesCount; i++)
{
string line = "Linia " + i.ToString() + " ";
line = line.PadRight(1000, 'x');
longString = longString + "<p>" + line;
WebView2_NavigateToStringResult.Text = ((int)(i * 100 / linesCount)).ToString(); // percentage, as generating string takes loooong
}
longString += "</body></html>";
WebView2_NavigateToStringResult.Text = "string ready";
startButton.Content = "NavigateTo";
}
else
{
// NavigateTo
WebView2_NavigateToStringResult.Text = "waiting for NavigationCompleted";
webViewControl.NavigationCompleted += webViewControl_NavigationCompleted;
webViewControl.NavigateToString(longString);
}
}
private void webViewControl_NavigationCompleted(object sender, object args)
{
WebView2_NavigateToStringResult.Text = "success";
}
}
}
<Page
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_NavigateToUri"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:uBehaviors="using:Uno.UI.Samples.Behaviors"
xmlns:ios="http://nventive.com/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://nventive.com/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d ios android xamarin not_win"
d:DesignHeight="2000"
d:DesignWidth="400">
<not_win:Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Background="Honeydew">
<TextBlock Text="Uri to load (navigates instantly upon modification):" />
<TextBox x:Name="WebView2_NavigateToStringTextBox"
Width="400"
Height="100"
Foreground="Black"
TextWrapping="Wrap"
Text="http://www.google.com" />
</StackPanel>
<mux:WebView2 Grid.Row="1"
local:WebView2SampleBehavior.SourceUri="{Binding ElementName=WebView2_NavigateToStringTextBox, Path=Text}" />
</not_win:Grid>
</Page>
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_NavigateToUri", description: "WebView2 demonstrating simple navigation to a URI")]
public sealed partial class WebView2_NavigateToUri : Page
{
public WebView2_NavigateToUri()
{
this.InitializeComponent();
}
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Static"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
xmlns:not_win="http://uno.ui/not_win"
mc:Ignorable="d xamarin not_win"
d:DesignHeight="300"
d:DesignWidth="400">
<not_win:Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<mux:WebView2 Source="{Binding [WebSource]}"
local:WebView2ObserverBehavior.IsAttached="True" />
<Button Grid.Row="1"
Content="Next URL"
Command="{Binding [GoToNextWebSource]}" />
</not_win:Grid>
</UserControl>
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml.Controls;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_Static", typeof(WebView2StaticViewModel), description: "Simple WebView2 navigation using Source property")]
public sealed partial class WebView2_Static : UserControl
{
public WebView2_Static()
{
this.InitializeComponent();
}
}
}
<Page
x:Class="UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Title"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:UITests.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
mc:Ignorable="d xamarin">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal">
<TextBox
x:Name="UriInput"
Width="150"
Text="https://microsoft.com/" />
<Button>Go</Button>
</StackPanel>
<TextBlock Grid.Row="1" Text="{Binding ElementName=Web, Path=DocumentTitle}" />
<mux:WebView2
x:Name="Web"
Grid.Row="2"
Source="{Binding ElementName=UriInput, Path=Text}" />
</Grid>
</Page>
using Uno.UI.Samples.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace UITests.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", IgnoreInSnapshotTests = true)]
public sealed partial class WebView2_Title : Page
{
public WebView2_Title()
{
this.InitializeComponent();
}
}
}
<Page
x:Class="UITests.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_Video_Bug546"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel>
<TextBlock>This is an illuatration of GH bug #546 where the video were not playing (only sound) in a webview on Android.</TextBlock>
<StackPanel Orientation="Horizontal">
<Button Click="ButtonBase_OnClick">PLAY</Button>
<TextBox x:Name="addr" Text="https://www.youtube.com/watch?v=K8Cp-1n_MQY" />
</StackPanel>
</StackPanel>
<mux:WebView2 x:Name="webview" Grid.Row="1" />
</Grid>
</Page>
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Uno.UI.Samples.Controls;
namespace UITests.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[Sample("WebView", IgnoreInSnapshotTests = true)]
public sealed partial class WebView2_Video_Bug546 : Page
{
public WebView2_Video_Bug546()
{
this.InitializeComponent();
}
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
await webview.EnsureCoreWebView2Async();
webview.CoreWebView2.Navigate(addr.Text);
}
}
}
<UserControl
x:Class="SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests.WebView2_WithHeaders"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:u="using:Uno.UI.Samples.Controls"
xmlns:ios="http://uno.ui/ios"
xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:android="http://uno.ui/android"
xmlns:xamarin="http://uno.ui/xamarin"
xmlns:mux="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d ios android xamarin"
d:DesignHeight="2000"
d:DesignWidth="400">
<Grid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
<StackPanel Orientation="Vertical">
<TextBlock Text="WebView2_NavigateWithHttpRequestMessage" />
<mux:WebView2 Source="http://www.hslkdjghsldkjhlskjdhlsfjbvxcmnbxcmvnbjkhfksjdhf.com/"
x:Name="MyWebView2"
Height="100"
Width="100" />
<TextBlock x:Name="MyTextBlock" TextWrapping="Wrap" />
<Button Content="Navigate to Requestb.in" x:Name="MyButton" />
</StackPanel>
</Grid>
</UserControl>
using Uno.UI.Samples.Controls;
using System;
using Windows.UI.Xaml;
using SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests;
using Windows.UI.Xaml.Controls;
using System.Net.Http;
namespace SamplesApp.Microsoft_UI_Xaml_Controls.WebView2Tests
{
[SampleControlInfo("WebView", "WebView2_WithHeaders", typeof(WebView2ViewModel))]
public sealed partial class WebView2_WithHeaders : UserControl
{
#if HAS_UNO
public WebView2_WithHeaders()
{
InitializeComponent();
MyButton.Click += MyButton_OnClick;
}
private void MyButton_OnClick(object sender, RoutedEventArgs e)
{
var url = "http://requestb.in/rw35narw";
MyTextBlock.Text = $"Inspect data at {url}?inspect";
var request = new HttpRequestMessage
{
RequestUri = new Uri(url),
Method = HttpMethod.Get
};
request.Headers.Add("HELLO", "TESTTEST, TEST2");
request.Headers.Add("HELLO2", "TEST111");
MyWebView2.CoreWebView2.NavigateWithHttpRequestMessage(request);
}
#endif
}
}
......@@ -2498,14 +2498,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewControl_JavaScript_Alert_Confirm_Prompt.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Alert.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\xBindTests\xBind.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -3738,6 +3730,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewControl_JavaScript_Alert_Confirm_Prompt.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Alert.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_AnchorNavigation.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -3754,6 +3754,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_InvokeScriptAsync.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_JavascriptInvoke.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -3790,6 +3794,74 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2Control_JavaScript_Alert_Confirm_Prompt.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Alert.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_AnchorNavigation.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Animated_Opacity.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Basic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_ChromeClient.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Events.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_ExecuteScriptAsync.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_JavascriptInvoke.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Mailto.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToString.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToString2.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToUri.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Static.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Title.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Video_Bug546.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_WithHeaders.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Input\Keyboard\Keyboard_Clickthrough_Modal.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
......@@ -6703,9 +6775,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ViewBoxTests\Viewbox_Behavior.xaml.cs">
<DependentUpon>Viewbox_Behavior.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewObserverBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewSampleBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewStaticViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\xBindTests\xBind.xaml.cs">
<DependentUpon>xBind.xaml</DependentUpon>
</Compile>
......@@ -7381,20 +7450,6 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\ListView\UndefinedHeightListView.xaml.cs">
<DependentUpon>UndefinedHeightListView.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_AnchorNavigation.xaml.cs">
<DependentUpon>WebView_AnchorNavigation.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Animated_Opacity.xaml.cs">
<DependentUpon>WebView_Animated_Opacity.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_NavigateToString2.xaml.cs">
<DependentUpon>WebView_NavigateToString2.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Title.xaml.cs">
<DependentUpon>WebView_Title.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Video_Bug546.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Input\Keyboard\Keyboard_Clickthrough_Modal.xaml.cs">
<DependentUpon>Keyboard_Clickthrough_Modal.xaml</DependentUpon>
</Compile>
......@@ -8475,6 +8530,23 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\Resources\XamlGlobalResources.xaml.cs">
<DependentUpon>XamlGlobalResources.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewObserverBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewSampleBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewStaticViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_AnchorNavigation.xaml.cs">
<DependentUpon>WebView_AnchorNavigation.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Animated_Opacity.xaml.cs">
<DependentUpon>WebView_Animated_Opacity.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_NavigateToString2.xaml.cs">
<DependentUpon>WebView_NavigateToString2.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Title.xaml.cs">
<DependentUpon>WebView_Title.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Video_Bug546.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebViewControl_JavaScript_Alert_Confirm_Prompt.xaml.cs">
<DependentUpon>WebViewControl_JavaScript_Alert_Confirm_Prompt.xaml</DependentUpon>
</Compile>
......@@ -8487,6 +8559,9 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_Events.xaml.cs">
<DependentUpon>WebView_Events.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_InvokeScriptAsync.xaml.cs">
<DependentUpon>WebView_InvokeScriptAsync.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_JavascriptInvoke.xaml.cs">
<DependentUpon>WebView_JavascriptInvoke.xaml</DependentUpon>
</Compile>
......@@ -8505,6 +8580,61 @@
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml_Controls\WebView\WebView_WithHeaders.xaml.cs">
<DependentUpon>WebView_WithHeaders.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2ObserverBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2SampleBehavior.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2StaticViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2ViewModel.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_AnchorNavigation.xaml.cs">
<DependentUpon>WebView2_AnchorNavigation.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Animated_Opacity.xaml.cs">
<DependentUpon>WebView2_Animated_Opacity.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToString2.xaml.cs">
<DependentUpon>WebView2_NavigateToString2.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Title.xaml.cs">
<DependentUpon>WebView2_Title.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Video_Bug546.xaml.cs">
<DependentUpon>WebView2_Video_Bug546.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2Control_JavaScript_Alert_Confirm_Prompt.xaml.cs">
<DependentUpon>WebView2Control_JavaScript_Alert_Confirm_Prompt.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Alert.xaml.cs">
<DependentUpon>WebView2_Alert.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Basic.xaml.cs">
<DependentUpon>WebView2_Basic.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_ChromeClient.xaml.cs">
<DependentUpon>WebView2_ChromeClient.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Events.xaml.cs">
<DependentUpon>WebView2_Events.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_ExecuteScriptAsync.xaml.cs">
<DependentUpon>WebView2_ExecuteScriptAsync.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_JavascriptInvoke.xaml.cs">
<DependentUpon>WebView2_JavascriptInvoke.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Mailto.xaml.cs">
<DependentUpon>WebView2_Mailto.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToString.xaml.cs">
<DependentUpon>WebView2_NavigateToString.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_NavigateToUri.xaml.cs">
<DependentUpon>WebView2_NavigateToUri.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_Static.xaml.cs">
<DependentUpon>WebView2_Static.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Microsoft_UI_Xaml_Controls\WebView2Tests\WebView2_WithHeaders.xaml.cs">
<DependentUpon>WebView2_WithHeaders.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)Windows_UI_Xaml\ThemeResources\BasicThemeResources.xaml.cs">
<DependentUpon>BasicThemeResources.xaml</DependentUpon>
</Compile>
......
......@@ -11,11 +11,9 @@ namespace Uno.UI.Samples.Content.UITests.WebView
{
InitializeComponent();
#if HAS_UNO
webView.Navigate(new Uri("https://nv-assets.azurewebsites.net/tests/docs/WebView_NavigateToAnchor.html"));
webView.NavigationStarting += WebView_NavigationStarting;
webView.NavigationCompleted += WebView_NavigationCompleted;
#endif
}
private void WebView_NavigationStarting(Windows.UI.Xaml.Controls.WebView sender, WebViewNavigationStartingEventArgs args)
......
<Page
x:Class="UITests.Microsoft_UI_Xaml_Controls.WebViewTests.WebView_InvokeScriptAsync"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UITests.Microsoft_UI_Xaml_Controls.WebView2Tests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:Microsoft.UI.Xaml.Controls"
mc:Ignorable="d"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<StackPanel>
<Button Click="{x:Bind ChangeColor}">Change color</Button>
<Button Click="{x:Bind GetColor}">Get color</Button>
<TextBlock x:Name="CurrentColorTextBlock" />
<WebView x:Name="TestWebView" Width="200" Height="200" />
</StackPanel>
</Page>
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
namespace UITests.Microsoft_UI_Xaml_Controls.WebViewTests
{
[Uno.UI.Samples.Controls.Sample("WebView")]
public sealed partial class WebView_InvokeScriptAsync : Page
{
public WebView_InvokeScriptAsync()
{
this.InitializeComponent();
TestWebView.Loaded += TestWebView_Loaded;
}
private void TestWebView_Loaded(object sender, RoutedEventArgs e)
{
var testHtml = "<html><body><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>";
TestWebView.NavigateToString(testHtml);
}
private async void ChangeColor()
{
await TestWebView.InvokeScriptAsync("eval", new[] { "document.getElementById('test').style.backgroundColor = 'red'" });
}
private async void GetColor()
{
var color = await TestWebView.InvokeScriptAsync("eval", new[] { "document.getElementById('test').style.backgroundColor.toString()" });
CurrentColorTextBlock.Text = color;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Private.Infrastructure;
using Windows.UI.Xaml.Controls;
namespace Uno.UI.RuntimeTests.Tests.Microsoft_UI_Xaml_Controls;
#if !HAS_UNO || __ANDROID__ || __IOS__
[TestClass]
[RunsOnUIThread]
public class Given_WebView2
{
[TestMethod]
public async Task When_Navigate()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
await TestServices.WindowHelper.WaitForLoaded(border);
var uri = new Uri("https://example.com/");
await webView.EnsureCoreWebView2Async();
bool navigationDone = false;
webView.NavigationCompleted += (s, e) => navigationDone = true;
webView.CoreWebView2.Navigate(uri.ToString());
Assert.IsNull(webView.Source);
await TestServices.WindowHelper.WaitFor(() => navigationDone, 3000);
Assert.IsNotNull(webView.Source);
Assert.IsTrue(webView.Source.OriginalString.StartsWith("https://example.com/", StringComparison.OrdinalIgnoreCase));
}
[TestMethod]
public async Task When_NavigateToString()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
await TestServices.WindowHelper.WaitForLoaded(border);
var uri = new Uri("https://example.com/");
await webView.EnsureCoreWebView2Async();
bool navigationDone = false;
webView.NavigationCompleted += (s, e) => navigationDone = true;
webView.Source = uri;
Assert.IsNotNull(webView.Source);
await TestServices.WindowHelper.WaitFor(() => navigationDone, 3000);
Assert.IsNotNull(webView.Source);
navigationDone = false;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigationDone, 3000);
Assert.AreEqual(CoreWebView2.BlankUri, webView.Source);
}
[TestMethod]
public async Task When_ExecuteScriptAsync()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
await webView.EnsureCoreWebView2Async();
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html><body><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var color = await webView.ExecuteScriptAsync("eval({ 'color' : document.getElementById('test').style.backgroundColor })");
Assert.AreEqual("{\"color\":\"blue\"}", color);
// Change color to red
await webView.ExecuteScriptAsync("document.getElementById('test').style.backgroundColor = 'red';");
color = await webView.ExecuteScriptAsync("eval({ 'color' : document.getElementById('test').style.backgroundColor })");
Assert.AreEqual("{\"color\":\"red\"}", color);
}
[TestMethod]
public async Task When_ExecuteScriptAsync_String_Double_Quote()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
await webView.EnsureCoreWebView2Async();
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var script = $"'hello \"world\"'.toString()";
var result = await webView.ExecuteScriptAsync(script);
Assert.AreEqual("\"hello \\\"world\\\"\"", result);
}
[TestMethod]
public async Task When_ExecuteScriptAsync_String()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
await webView.EnsureCoreWebView2Async();
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var script = "(1 + 1).toString()";
var result = await webView.ExecuteScriptAsync($"eval(\"{script}\")");
Assert.AreEqual("\"2\"", result);
}
[TestMethod]
public async Task When_ExecuteScriptAsync_Non_String()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
await webView.EnsureCoreWebView2Async();
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var script = "(1 + 1)";
var result = await webView.ExecuteScriptAsync($"eval(\"{script}\")");
Assert.AreEqual("2", result);
}
[TestMethod]
public async Task When_WebMessageReceived()
{
var border = new Border();
var webView = new WebView2();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
await TestServices.WindowHelper.WaitForLoaded(border);
await webView.EnsureCoreWebView2Async();
string message = null;
webView.WebMessageReceived += (s, e) =>
{
message = e.WebMessageAsJson;
};
webView.NavigateToString(
"""
<html>
<head>
<title>Test message</title>
</head>
<body>
<div id='test' style='width: 100px; height: 100px; background-color: blue;'></div>
<script type="text/javascript">
function sendWebMessage(){
try{
let message = {"some": ['values',"in","json",1]};
if (window.hasOwnProperty("chrome") && typeof chrome.webview !== undefined) {
// Windows
chrome.webview.postMessage(message);
} else if (window.hasOwnProperty("unoWebView")) {
// Android
unoWebView.postMessage(JSON.stringify(message));
} else if (window.hasOwnProperty("webkit") && typeof webkit.messageHandlers !== undefined) {
// iOS and macOS
webkit.messageHandlers.unoWebView.postMessage(JSON.stringify(message));
}
}
catch (ex){
alert("Error occurred: " + ex);
}
}
sendWebMessage()
</script>
</body>
</html>
"""
);
await TestServices.WindowHelper.WaitFor(() => message is not null, 2000);
Assert.AreEqual(@"{""some"":[""values"",""in"",""json"",1]}", message);
}
}
#endif
using System;
using System.Threading.Tasks;
using Private.Infrastructure;
using Windows.UI.Xaml.Controls;
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls;
#if !HAS_UNO || __ANDROID__ || __IOS__ || __MACOS__
[TestClass]
[RunsOnUIThread]
public class Given_WebView
{
[TestClass]
[RunsOnUIThread]
public class Given_WebView
[TestMethod]
public void When_Navigate()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.Navigate(uri);
Assert.IsNotNull(webView.Source);
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
}
#if __ANDROID__ || __IOS__ || __MACOS__
[TestMethod]
public void When_Navigate()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.Navigate(uri);
Assert.IsNotNull(webView.Source);
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
}
[TestMethod]
public void When_NavigateWithHttpRequestMessage()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.NavigateWithHttpRequestMessage(new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, uri));
Assert.IsNotNull(webView.Source);
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
}
[TestMethod]
public void When_NavigateToString()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.Source = uri;
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
webView.NavigateToString("<html></html>");
Assert.IsNull(webView.Source);
}
[TestMethod]
public void When_NavigateWithHttpRequestMessage()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.NavigateWithHttpRequestMessage(new System.Net.Http.HttpRequestMessage(System.Net.Http.HttpMethod.Get, uri));
Assert.IsNotNull(webView.Source);
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
}
#endif
[TestMethod]
public void When_NavigateToString()
{
var webView = new WebView();
var uri = new Uri("https://bing.com");
webView.Source = uri;
Assert.AreEqual("https://bing.com/", webView.Source.OriginalString);
Assert.AreEqual("https://bing.com", uri.OriginalString);
webView.NavigateToString("<html></html>");
Assert.IsNull(webView.Source);
}
#if !HAS_UNO
[TestMethod]
public async Task When_InvokeScriptAsync()
{
var border = new Border();
var webView = new WebView();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html><body><div id='test' style='width: 100px; height: 100px; background-color: blue;' /></body></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var color = await webView.InvokeScriptAsync("eval", new[] { "document.getElementById('test').style.backgroundColor.toString()" });
Assert.AreEqual("blue", color);
// Change color to red
await webView.InvokeScriptAsync("eval", new[] { "document.getElementById('test').style.backgroundColor = 'red'" });
color = await webView.InvokeScriptAsync("eval", new[] { "document.getElementById('test').style.backgroundColor.toString()" });
Assert.AreEqual("red", color);
}
[TestMethod]
public async Task When_InvokeScriptAsync_String()
{
var border = new Border();
var webView = new WebView();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var script = "(1 + 1).toString()";
var result = await webView.InvokeScriptAsync("eval", new[] { script });
Assert.AreEqual("2", result);
}
[TestMethod]
public async Task When_InvokeScriptAsync_Non_String()
{
var border = new Border();
var webView = new WebView();
webView.Width = 200;
webView.Height = 200;
border.Child = webView;
TestServices.WindowHelper.WindowContent = border;
bool navigated = false;
await TestServices.WindowHelper.WaitForLoaded(border);
webView.NavigationCompleted += (sender, e) => navigated = true;
webView.NavigateToString("<html></html>");
await TestServices.WindowHelper.WaitFor(() => navigated);
var script = "(1 + 1)";
var result = await webView.InvokeScriptAsync("eval", new[] { script });
Assert.AreEqual("", result);
}
#endif
}
#endif
......@@ -74,6 +74,8 @@
<!-- We remove Unit tests imported from MUX on UAP as they are usualy heavily relying on internal classes.-->
<Compile Remove="$(MSBuildThisFileDirectory)MUX\Microsoft_UI_XAML_Controls\**\*.cs" />
<!-- We remove WebView2 tests, as the installed version of Microsoft.UI.Xaml does not include this control -->
<Compile Remove="$(MSBuildThisFileDirectory)Tests\Microsoft_UI_Xaml_Controls\Given_WebView2.cs" />
</ItemGroup>
<PropertyGroup Condition="'$(TargetFramework)'=='uap10.0.18362'">
<!--SkipMicrosoftUIXamlCheckTargetPlatformVersion is required for Microsoft.UI.Xaml as we only validate compilation on UAP-->
......@@ -108,4 +110,4 @@
<Import Project="..\SourceGenerators\Uno.UI.SourceGenerators\Content\Uno.UI.SourceGenerators.props" />
<Import Project="..\SourceGenerators\Uno.UI.Tasks\Content\Uno.UI.Tasks.targets" Condition="'$(SkipUnoResourceGeneration)' == '' " />
</Project>
</Project>
\ No newline at end of file
......@@ -6566,4 +6566,4 @@ Global
GlobalSection(TestCaseManagementSettings) = postSolution
CategoryFile = Umbrella.vsmdi
EndGlobalSection
EndGlobal
EndGlobal
\ No newline at end of file
......@@ -2,21 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2InitializedEventArgs
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Exception Exception
{
get
{
throw new global::System.NotImplementedException("The member Exception CoreWebView2InitializedEventArgs.Exception is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=Exception%20CoreWebView2InitializedEventArgs.Exception");
}
}
#endif
// Skipping already declared property Exception
// Forced skipping of method Microsoft.UI.Xaml.Controls.CoreWebView2InitializedEventArgs.Exception.get
}
}
......@@ -2,134 +2,32 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.UI.Xaml.Controls
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class WebView2 : global::Windows.UI.Xaml.Controls.Control
public partial class WebView2
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Uri Source
{
get
{
return (global::System.Uri)this.GetValue(SourceProperty);
}
set
{
this.SetValue(SourceProperty, value);
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool CanGoForward
{
get
{
return (bool)this.GetValue(CanGoForwardProperty);
}
set
{
this.SetValue(CanGoForwardProperty, value);
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool CanGoBack
{
get
{
return (bool)this.GetValue(CanGoBackProperty);
}
set
{
this.SetValue(CanGoBackProperty, value);
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty CanGoBackProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(CanGoBack), typeof(bool),
typeof(global::Microsoft.UI.Xaml.Controls.WebView2),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(bool)));
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty CanGoForwardProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(CanGoForward), typeof(bool),
typeof(global::Microsoft.UI.Xaml.Controls.WebView2),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(bool)));
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty SourceProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(Source), typeof(global::System.Uri),
typeof(global::Microsoft.UI.Xaml.Controls.WebView2),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(global::System.Uri)));
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public WebView2() : base()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "WebView2.WebView2()");
}
#endif
// Skipping already declared property Source
// Skipping already declared property CanGoForward
// Skipping already declared property CanGoBack
// Skipping already declared property CanGoBackProperty
// Skipping already declared property CanGoForwardProperty
// Skipping already declared property SourceProperty
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.WebView2()
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.WebView2()
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CoreWebView2.get
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Foundation.IAsyncAction EnsureCoreWebView2Async()
{
throw new global::System.NotImplementedException("The member IAsyncAction WebView2.EnsureCoreWebView2Async() is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=IAsyncAction%20WebView2.EnsureCoreWebView2Async%28%29");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Foundation.IAsyncOperation<string> ExecuteScriptAsync( string javascriptCode)
{
throw new global::System.NotImplementedException("The member IAsyncOperation<string> WebView2.ExecuteScriptAsync(string javascriptCode) is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=IAsyncOperation%3Cstring%3E%20WebView2.ExecuteScriptAsync%28string%20javascriptCode%29");
}
#endif
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.EnsureCoreWebView2Async()
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.ExecuteScriptAsync(string)
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.Source.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.Source.set
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoForward.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoForward.set
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoBack.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoBack.set
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Reload()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "void WebView2.Reload()");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void GoForward()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "void WebView2.GoForward()");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void GoBack()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "void WebView2.GoBack()");
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void NavigateToString( string htmlContent)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "void WebView2.NavigateToString(string htmlContent)");
}
#endif
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.Reload()
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.GoForward()
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.GoBack()
// Skipping already declared method Microsoft.UI.Xaml.Controls.WebView2.NavigateToString(string)
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public void Close()
......@@ -150,85 +48,10 @@ namespace Microsoft.UI.Xaml.Controls
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.SourceProperty.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoForwardProperty.get
// Forced skipping of method Microsoft.UI.Xaml.Controls.WebView2.CanGoBackProperty.get
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.WebView2, global::Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs> CoreProcessFailed
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2ProcessFailedEventArgs> WebView2.CoreProcessFailed");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2ProcessFailedEventArgs> WebView2.CoreProcessFailed");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.WebView2, global::Microsoft.UI.Xaml.Controls.CoreWebView2InitializedEventArgs> CoreWebView2Initialized
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2InitializedEventArgs> WebView2.CoreWebView2Initialized");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2InitializedEventArgs> WebView2.CoreWebView2Initialized");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.WebView2, global::Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs> NavigationCompleted
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2NavigationCompletedEventArgs> WebView2.NavigationCompleted");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2NavigationCompletedEventArgs> WebView2.NavigationCompleted");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.WebView2, global::Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs> NavigationStarting
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2NavigationStartingEventArgs> WebView2.NavigationStarting");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2NavigationStartingEventArgs> WebView2.NavigationStarting");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Microsoft.UI.Xaml.Controls.WebView2, global::Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs> WebMessageReceived
{
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2WebMessageReceivedEventArgs> WebView2.WebMessageReceived");
}
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.UI.Xaml.Controls.WebView2", "event TypedEventHandler<WebView2, CoreWebView2WebMessageReceivedEventArgs> WebView2.WebMessageReceived");
}
}
#endif
// Skipping already declared event Microsoft.UI.Xaml.Controls.WebView2.CoreProcessFailed
// Skipping already declared event Microsoft.UI.Xaml.Controls.WebView2.CoreWebView2Initialized
// Skipping already declared event Microsoft.UI.Xaml.Controls.WebView2.NavigationCompleted
// Skipping already declared event Microsoft.UI.Xaml.Controls.WebView2.NavigationStarting
// Skipping already declared event Microsoft.UI.Xaml.Controls.WebView2.WebMessageReceived
}
}
......@@ -2,31 +2,13 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2ContentLoadingEventArgs
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsErrorPage
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2ContentLoadingEventArgs.IsErrorPage is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2ContentLoadingEventArgs.IsErrorPage");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ulong NavigationId
{
get
{
throw new global::System.NotImplementedException("The member ulong CoreWebView2ContentLoadingEventArgs.NavigationId is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=ulong%20CoreWebView2ContentLoadingEventArgs.NavigationId");
}
}
#endif
// Skipping already declared property IsErrorPage
// Skipping already declared property NavigationId
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2ContentLoadingEventArgs.IsErrorPage.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2ContentLoadingEventArgs.NavigationId.get
}
......
......@@ -2,21 +2,12 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2DOMContentLoadedEventArgs
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ulong NavigationId
{
get
{
throw new global::System.NotImplementedException("The member ulong CoreWebView2DOMContentLoadedEventArgs.NavigationId is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=ulong%20CoreWebView2DOMContentLoadedEventArgs.NavigationId");
}
}
#endif
// Skipping already declared property NavigationId
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2DOMContentLoadedEventArgs.NavigationId.get
}
}
......@@ -2,41 +2,14 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2NavigationCompletedEventArgs
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsSuccess
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2NavigationCompletedEventArgs.IsSuccess is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2NavigationCompletedEventArgs.IsSuccess");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ulong NavigationId
{
get
{
throw new global::System.NotImplementedException("The member ulong CoreWebView2NavigationCompletedEventArgs.NavigationId is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=ulong%20CoreWebView2NavigationCompletedEventArgs.NavigationId");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus WebErrorStatus
{
get
{
throw new global::System.NotImplementedException("The member CoreWebView2WebErrorStatus CoreWebView2NavigationCompletedEventArgs.WebErrorStatus is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=CoreWebView2WebErrorStatus%20CoreWebView2NavigationCompletedEventArgs.WebErrorStatus");
}
}
#endif
// Skipping already declared property IsSuccess
// Skipping already declared property NavigationId
// Skipping already declared property WebErrorStatus
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs.IsSuccess.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs.WebErrorStatus.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs.NavigationId.get
......
......@@ -2,55 +2,15 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2NavigationStartingEventArgs
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool Cancel
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2NavigationStartingEventArgs.Cancel is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2NavigationStartingEventArgs.Cancel");
}
set
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs", "bool CoreWebView2NavigationStartingEventArgs.Cancel");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsRedirected
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2NavigationStartingEventArgs.IsRedirected is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2NavigationStartingEventArgs.IsRedirected");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsUserInitiated
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2NavigationStartingEventArgs.IsUserInitiated is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2NavigationStartingEventArgs.IsUserInitiated");
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public ulong NavigationId
{
get
{
throw new global::System.NotImplementedException("The member ulong CoreWebView2NavigationStartingEventArgs.NavigationId is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=ulong%20CoreWebView2NavigationStartingEventArgs.NavigationId");
}
}
#endif
// Skipping already declared property Cancel
// Skipping already declared property IsRedirected
// Skipping already declared property IsUserInitiated
// Skipping already declared property NavigationId
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.Web.WebView2.Core.CoreWebView2HttpRequestHeaders RequestHeaders
......@@ -61,16 +21,7 @@ namespace Microsoft.Web.WebView2.Core
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string Uri
{
get
{
throw new global::System.NotImplementedException("The member string CoreWebView2NavigationStartingEventArgs.Uri is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20CoreWebView2NavigationStartingEventArgs.Uri");
}
}
#endif
// Skipping already declared property Uri
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs.Uri.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs.IsUserInitiated.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs.IsRedirected.get
......
......@@ -2,7 +2,7 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2NewWindowRequestedEventArgs
......@@ -21,20 +21,7 @@ namespace Microsoft.Web.WebView2.Core
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool Handled
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2NewWindowRequestedEventArgs.Handled is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2NewWindowRequestedEventArgs.Handled");
}
set
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.Web.WebView2.Core.CoreWebView2NewWindowRequestedEventArgs", "bool CoreWebView2NewWindowRequestedEventArgs.Handled");
}
}
#endif
// Skipping already declared property Handled
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsUserInitiated
......@@ -45,16 +32,7 @@ namespace Microsoft.Web.WebView2.Core
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string Uri
{
get
{
throw new global::System.NotImplementedException("The member string CoreWebView2NewWindowRequestedEventArgs.Uri is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20CoreWebView2NewWindowRequestedEventArgs.Uri");
}
}
#endif
// Skipping already declared property Uri
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Microsoft.Web.WebView2.Core.CoreWebView2WindowFeatures WindowFeatures
......
......@@ -2,7 +2,7 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2Settings
......@@ -21,20 +21,7 @@ namespace Microsoft.Web.WebView2.Core
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsWebMessageEnabled
{
get
{
throw new global::System.NotImplementedException("The member bool CoreWebView2Settings.IsWebMessageEnabled is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=bool%20CoreWebView2Settings.IsWebMessageEnabled");
}
set
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Microsoft.Web.WebView2.Core.CoreWebView2Settings", "bool CoreWebView2Settings.IsWebMessageEnabled");
}
}
#endif
// Skipping already declared property IsWebMessageEnabled
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool IsStatusBarEnabled
......
......@@ -2,60 +2,26 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
public enum CoreWebView2WebErrorStatus
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
Unknown = 0,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
CertificateCommonNameIsIncorrect = 1,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
CertificateExpired = 2,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
ClientCertificateContainsErrors = 3,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
CertificateRevoked = 4,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
CertificateIsInvalid = 5,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
ServerUnreachable = 6,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
Timeout = 7,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
ErrorHttpInvalidServerResponse = 8,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
ConnectionAborted = 9,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
ConnectionReset = 10,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
Disconnected = 11,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
CannotConnect = 12,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
HostNameNotResolved = 13,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
OperationCanceled = 14,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
RedirectFailed = 15,
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
UnexpectedError = 16,
#endif
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.Unknown
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.CertificateCommonNameIsIncorrect
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.CertificateExpired
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.ClientCertificateContainsErrors
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.CertificateRevoked
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.CertificateIsInvalid
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.ServerUnreachable
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.Timeout
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.ErrorHttpInvalidServerResponse
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.ConnectionAborted
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.ConnectionReset
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.Disconnected
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.CannotConnect
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.HostNameNotResolved
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.OperationCanceled
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.RedirectFailed
// Skipping already declared field Microsoft.Web.WebView2.Core.CoreWebView2WebErrorStatus.UnexpectedError
}
#endif
}
......@@ -2,7 +2,7 @@
#pragma warning disable 114 // new keyword hiding
namespace Microsoft.Web.WebView2.Core
{
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
#if false || false || false || false || false || false || false
[global::Uno.NotImplemented]
#endif
public partial class CoreWebView2WebMessageReceivedEventArgs
......@@ -17,24 +17,9 @@ namespace Microsoft.Web.WebView2.Core
}
}
#endif
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string WebMessageAsJson
{
get
{
throw new global::System.NotImplementedException("The member string CoreWebView2WebMessageReceivedEventArgs.WebMessageAsJson is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20CoreWebView2WebMessageReceivedEventArgs.WebMessageAsJson");
}
}
#endif
// Skipping already declared property WebMessageAsJson
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs.Source.get
// Forced skipping of method Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs.WebMessageAsJson.get
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public string TryGetWebMessageAsString()
{
throw new global::System.NotImplementedException("The member string CoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString() is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20CoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString%28%29");
}
#endif
// Skipping already declared method Microsoft.Web.WebView2.Core.CoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString()
}
}
......@@ -7,20 +7,7 @@ namespace Windows.UI.Xaml.Controls
#endif
public partial class WebView
{
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public global::System.Uri Source
{
get
{
return (global::System.Uri)this.GetValue(SourceProperty);
}
set
{
this.SetValue(SourceProperty, value);
}
}
#endif
// Skipping already declared property Source
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::System.Collections.Generic.IList<global::System.Uri> AllowedScriptNotifyUris
......@@ -59,36 +46,9 @@ namespace Windows.UI.Xaml.Controls
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public bool CanGoBack
{
get
{
return (bool)this.GetValue(CanGoBackProperty);
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public bool CanGoForward
{
get
{
return (bool)this.GetValue(CanGoForwardProperty);
}
}
#endif
#if false || false || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")]
public string DocumentTitle
{
get
{
return (string)this.GetValue(DocumentTitleProperty);
}
}
#endif
// Skipping already declared property CanGoBack
// Skipping already declared property CanGoForward
// Skipping already declared property DocumentTitle
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public bool ContainsFullScreenElement
......@@ -159,30 +119,9 @@ namespace Windows.UI.Xaml.Controls
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(global::Windows.ApplicationModel.DataTransfer.DataPackage)));
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public static global::Windows.UI.Xaml.DependencyProperty SourceProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(Source), typeof(global::System.Uri),
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(global::System.Uri)));
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public static global::Windows.UI.Xaml.DependencyProperty CanGoBackProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(CanGoBack), typeof(bool),
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(bool)));
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public static global::Windows.UI.Xaml.DependencyProperty CanGoForwardProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(CanGoForward), typeof(bool),
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(bool)));
#endif
// Skipping already declared property SourceProperty
// Skipping already declared property CanGoBackProperty
// Skipping already declared property CanGoForwardProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty DefaultBackgroundColorProperty { get; } =
......@@ -191,14 +130,7 @@ namespace Windows.UI.Xaml.Controls
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(global::Windows.UI.Color)));
#endif
#if false || false || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")]
public static global::Windows.UI.Xaml.DependencyProperty DocumentTitleProperty { get; } =
Windows.UI.Xaml.DependencyProperty.Register(
nameof(DocumentTitle), typeof(string),
typeof(global::Windows.UI.Xaml.Controls.WebView),
new Windows.UI.Xaml.FrameworkPropertyMetadata(default(string)));
#endif
// Skipping already declared property DocumentTitleProperty
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public static global::Windows.UI.Xaml.DependencyProperty ContainsFullScreenElementProperty { get; } =
......@@ -249,20 +181,8 @@ namespace Windows.UI.Xaml.Controls
throw new global::System.NotImplementedException("The member string WebView.InvokeScript(string scriptName, string[] arguments) is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20WebView.InvokeScript%28string%20scriptName%2C%20string%5B%5D%20arguments%29");
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public void Navigate( global::System.Uri source)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.Navigate(Uri source)");
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public void NavigateToString( string text)
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.NavigateToString(string text)");
}
#endif
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.Navigate(System.Uri)
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.NavigateToString(string)
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.CanGoBack.get
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.CanGoForward.get
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.DocumentTitle.get
......@@ -272,34 +192,10 @@ namespace Windows.UI.Xaml.Controls
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.ContentLoading.remove
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.DOMContentLoaded.add
// Forced skipping of method Windows.UI.Xaml.Controls.WebView.DOMContentLoaded.remove
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public void GoForward()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.GoForward()");
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public void GoBack()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.GoBack()");
}
#endif
#if false || false || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")]
public void Refresh()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.Refresh()");
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public void Stop()
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "void WebView.Stop()");
}
#endif
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.GoForward()
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.GoBack()
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.Refresh()
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.Stop()
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Foundation.IAsyncAction CapturePreviewToStreamAsync( global::Windows.Storage.Streams.IRandomAccessStream stream)
......@@ -307,13 +203,7 @@ namespace Windows.UI.Xaml.Controls
throw new global::System.NotImplementedException("The member IAsyncAction WebView.CapturePreviewToStreamAsync(IRandomAccessStream stream) is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=IAsyncAction%20WebView.CapturePreviewToStreamAsync%28IRandomAccessStream%20stream%29");
}
#endif
#if false || false || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__")]
public global::Windows.Foundation.IAsyncOperation<string> InvokeScriptAsync( string scriptName, global::System.Collections.Generic.IEnumerable<string> arguments)
{
throw new global::System.NotImplementedException("The member IAsyncOperation<string> WebView.InvokeScriptAsync(string scriptName, IEnumerable<string> arguments) is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=IAsyncOperation%3Cstring%3E%20WebView.InvokeScriptAsync%28string%20scriptName%2C%20IEnumerable%3Cstring%3E%20arguments%29");
}
#endif
// Skipping already declared method Windows.UI.Xaml.Controls.WebView.InvokeScriptAsync(string, System.Collections.Generic.IEnumerable<string>)
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public global::Windows.Foundation.IAsyncOperation<global::Windows.ApplicationModel.DataTransfer.DataPackage> CaptureSelectedContentToDataPackageAsync()
......@@ -436,22 +326,7 @@ namespace Windows.UI.Xaml.Controls
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public event global::Windows.UI.Xaml.Controls.WebViewNavigationFailedEventHandler NavigationFailed
{
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event WebViewNavigationFailedEventHandler WebView.NavigationFailed");
}
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event WebViewNavigationFailedEventHandler WebView.NavigationFailed");
}
}
#endif
// Skipping already declared event Windows.UI.Xaml.Controls.WebView.NavigationFailed
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.UI.Xaml.Controls.NotifyEventHandler ScriptNotify
......@@ -580,38 +455,8 @@ namespace Windows.UI.Xaml.Controls
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewNavigationCompletedEventArgs> NavigationCompleted
{
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNavigationCompletedEventArgs> WebView.NavigationCompleted");
}
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNavigationCompletedEventArgs> WebView.NavigationCompleted");
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewNavigationStartingEventArgs> NavigationStarting
{
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNavigationStartingEventArgs> WebView.NavigationStarting");
}
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNavigationStartingEventArgs> WebView.NavigationStarting");
}
}
#endif
// Skipping already declared event Windows.UI.Xaml.Controls.WebView.NavigationCompleted
// Skipping already declared event Windows.UI.Xaml.Controls.WebView.NavigationStarting
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, object> UnsafeContentWarningDisplaying
......@@ -660,22 +505,7 @@ namespace Windows.UI.Xaml.Controls
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewNewWindowRequestedEventArgs> NewWindowRequested
{
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> WebView.NewWindowRequested");
}
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewNewWindowRequestedEventArgs> WebView.NewWindowRequested");
}
}
#endif
// Skipping already declared event Windows.UI.Xaml.Controls.WebView.NewWindowRequested
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewPermissionRequestedEventArgs> PermissionRequested
......@@ -692,22 +522,7 @@ namespace Windows.UI.Xaml.Controls
}
}
#endif
#if false || false || NET461 || false || false || __NETSTD_REFERENCE__ || false
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewUnsupportedUriSchemeIdentifiedEventArgs> UnsupportedUriSchemeIdentified
{
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
add
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewUnsupportedUriSchemeIdentifiedEventArgs> WebView.UnsupportedUriSchemeIdentified");
}
[global::Uno.NotImplemented("NET461", "__NETSTD_REFERENCE__")]
remove
{
global::Windows.Foundation.Metadata.ApiInformation.TryRaiseNotImplemented("Windows.UI.Xaml.Controls.WebView", "event TypedEventHandler<WebView, WebViewUnsupportedUriSchemeIdentifiedEventArgs> WebView.UnsupportedUriSchemeIdentified");
}
}
#endif
// Skipping already declared event Windows.UI.Xaml.Controls.WebView.UnsupportedUriSchemeIdentified
#if __ANDROID__ || __IOS__ || NET461 || __WASM__ || __SKIA__ || __NETSTD_REFERENCE__ || __MACOS__
[global::Uno.NotImplemented("__ANDROID__", "__IOS__", "NET461", "__WASM__", "__SKIA__", "__NETSTD_REFERENCE__", "__MACOS__")]
public event global::Windows.Foundation.TypedEventHandler<global::Windows.UI.Xaml.Controls.WebView, global::Windows.UI.Xaml.Controls.WebViewSeparateProcessLostEventArgs> SeparateProcessLost
......
using System;
using System.Linq;
#nullable enable
using System;
using System.Collections.Generic;
using System.Text;
using Uno.UI;
using Uno.Extensions;
using Uno.UI.Extensions;
using Windows.UI.Xaml;
using Uno.UI.Web;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using Windows.UI.Core;
using System.Threading.Tasks;
using Android.Graphics;
using Android.Runtime;
using Android.Views;
using Android.Webkit;
using Uno.Disposables;
using Uno.Extensions;
using Uno.Foundation.Logging;
using Uno.UI;
using Uno.UI.Extensions;
using Windows.Foundation;
using Windows.Web;
using Windows.UI.Xaml.Controls;
using Uno.UI.Xaml.Controls;
using Windows.UI.Xaml;
namespace Microsoft.Web.WebView2.Core;
namespace Windows.UI.Xaml.Controls
public partial class CoreWebView2
{
public partial class WebView
internal INativeWebView? GetNativeWebViewFromTemplate()
{
//This should be IAsyncOperation<string> instead of Task<string> but we use an extension method to enable the same signature in Win.
//IAsyncOperation is not available in Xamarin.
public Task<string> InvokeScriptAsync(CancellationToken ct, string script, string[] arguments)
{
throw new NotSupportedException();
}
var webView = (_owner as ViewGroup)?
.GetChildren(v => v is Android.Webkit.WebView)
.FirstOrDefault() as Android.Webkit.WebView;
public Task<string> InvokeScriptAsync(string script, string[] arguments)
if (webView is null)
{
throw new NotSupportedException();
return null;
}
return new NativeWebViewWrapper(webView, this);
}
}
using Windows.Foundation;
using Windows.UI.Xaml.Controls;
namespace Microsoft.Web.WebView2.Core;
#pragma warning disable CS0067 // TODO:MZ: Undo this
public partial class CoreWebView2
{
private string _documentTitle = "";
private string _source = "";
/// <summary>
/// True if the WebView is able to navigate to a previous page in the navigation history.
/// </summary>
public bool CanGoBack { get; private set; }
/// <summary>
/// True if the WebView is able to navigate to a next page in the navigation history.
/// </summary>
public bool CanGoForward { get; private set; }
/// <summary>
/// Gets the title for the current top-level document.
/// </summary>
public string DocumentTitle
{
get => _documentTitle;
set
{
if (_documentTitle != value)
{
_documentTitle = value;
DocumentTitleChanged?.Invoke(this, null);
}
}
}
/// <summary>
/// Gets the URI of the current top level document.
/// </summary>
public string Source
{
get => _source;
private set
{
if (_source != value)
{
_source = value;
SourceChanged?.Invoke(this, new());
}
}
}
/// <summary>
/// NavigationStarting is raised when the WebView main frame is requesting permission to navigate to a different URI.
/// </summary>
public event TypedEventHandler<CoreWebView2, CoreWebView2NavigationStartingEventArgs> NavigationStarting;
/// <summary>
/// NavigationCompleted is raised when the WebView has completely loaded (body.onload has been raised) or loading stopped with error.
/// </summary>
public event TypedEventHandler<CoreWebView2, CoreWebView2NavigationCompletedEventArgs> NavigationCompleted;
/// <summary>
/// NewWindowRequested is raised when content inside the WebView requests to open a new window, such as through window.open().
/// </summary>
public event TypedEventHandler<CoreWebView2, CoreWebView2NewWindowRequestedEventArgs> NewWindowRequested;
/// <summary>
/// DocumentTitleChanged is raised when the CoreWebView2.DocumentTitle property changes and may be raised
/// before or after the CoreWebView2.NavigationCompleted event.
/// </summary>
public event TypedEventHandler<CoreWebView2, object> DocumentTitleChanged;
/// <summary>
/// HistoryChanged is raised for changes to joint session history, which consists of top-level and manual frame navigations.
/// </summary>
public event TypedEventHandler<CoreWebView2, object> HistoryChanged;
/// <summary>
/// SourceChanged is raised when the CoreWebView2.Source property changes. SourceChanged is raised when
/// navigating to a different site or fragment navigations.
/// </summary>
public event TypedEventHandler<CoreWebView2, CoreWebView2SourceChangedEventArgs> SourceChanged;
/// <summary>
/// Dispatches after web content sends a message to the app host.
/// </summary>
public event TypedEventHandler<CoreWebView2, CoreWebView2WebMessageReceivedEventArgs> WebMessageReceived;
internal event TypedEventHandler<CoreWebView2, WebViewUnsupportedUriSchemeIdentifiedEventArgs> UnsupportedUriSchemeIdentified;
}
#nullable enable
using System;
using Uno.Extensions;
using Uno.Foundation.Logging;
using System.Net.Http;
using Uno.UI.Xaml.Controls;
using System.Threading;
using System.Globalization;
using Windows.Foundation;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
namespace Microsoft.Web.WebView2.Core;
public partial class CoreWebView2
{
internal const string BlankUrl = "about:blank";
internal const string DataUriFormatString = "data:text/html;charset=utf-8;base64,{0}";
internal static readonly Uri BlankUri = new Uri(BlankUrl);
private readonly IWebView _owner;
private bool _scrollEnabled;
private INativeWebView? _nativeWebView;
internal long _navigationId;
private object? _processedSource;
internal CoreWebView2(IWebView owner)
{
_owner = owner;
}
/// <summary>
/// Gets the CoreWebView2Settings object contains various modifiable
/// settings for the running WebView.
/// </summary>
public CoreWebView2Settings Settings { get; } = new();
public void Navigate(string uri)
{
if (!Uri.TryCreate(uri, UriKind.Absolute, out var actualUri))
{
throw new ArgumentException("The passed in value is not an absolute URI", nameof(uri));
}
_processedSource = actualUri;
if (_owner.SwitchSourceBeforeNavigating)
{
Source = actualUri.ToString();
}
UpdateFromInternalSource();
}
public void NavigateToString(string htmlContent)
{
_processedSource = htmlContent;
if (_owner.SwitchSourceBeforeNavigating)
{
Source = BlankUrl;
}
UpdateFromInternalSource();
}
internal void NavigateWithHttpRequestMessage(global::System.Net.Http.HttpRequestMessage requestMessage)
{
if (requestMessage?.RequestUri is null)
{
throw new ArgumentException("Invalid request message. It does not have a RequestUri.", nameof(requestMessage));
}
_processedSource = requestMessage;
if (_owner.SwitchSourceBeforeNavigating)
{
Source = requestMessage.RequestUri.ToString();
}
UpdateFromInternalSource();
}
public void GoBack() => _nativeWebView?.GoBack();
public void GoForward() => _nativeWebView?.GoForward();
public void Stop() => _nativeWebView?.Stop();
public void Reload() => _nativeWebView?.Reload();
public IAsyncOperation<string?> ExecuteScriptAsync(string javaScript) =>
AsyncOperation.FromTask(ct =>
{
if (_nativeWebView is null)
{
return Task.FromResult<string?>(null);
}
return _nativeWebView.ExecuteScriptAsync(javaScript, ct);
});
internal async Task<string?> InvokeScriptAsync(string script, string[]? arguments, CancellationToken ct)
{
if (_nativeWebView is null)
{
return null;
}
return await _nativeWebView.InvokeScriptAsync(script, arguments, ct);
}
internal void OnOwnerApplyTemplate()
{
_nativeWebView = GetNativeWebViewFromTemplate();
//The nativate WebView already navigate to a blank page if no source is set.
//Avoid a bug where invoke GoBack() on WebView do nothing in Android 4.4
UpdateFromInternalSource();
OnScrollEnabledChanged(_scrollEnabled);
}
internal void OnScrollEnabledChanged(bool newValue)
{
_scrollEnabled = newValue;
_nativeWebView?.SetScrollingEnabled(newValue);
}
internal void RaiseNavigationStarting(object navigationData, out bool cancel)
{
string? uriString = null;
if (navigationData is Uri uri)
{
uriString = uri.ToString();
}
else if (navigationData is string htmlContent)
{
// Convert to data URI string
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(htmlContent);
var base64String = System.Convert.ToBase64String(plainTextBytes);
uriString = string.Format(CultureInfo.InvariantCulture, DataUriFormatString, base64String);
}
var newNavigationId = Interlocked.Increment(ref _navigationId);
var args = new CoreWebView2NavigationStartingEventArgs((ulong)newNavigationId, uriString);
NavigationStarting?.Invoke(this, args);
cancel = args.Cancel;
}
internal void RaiseNewWindowRequested(string target, Uri referer, out bool handled)
{
var args = new CoreWebView2NewWindowRequestedEventArgs(target, referer);
NewWindowRequested?.Invoke(this, args);
handled = args.Handled;
}
internal void RaiseNavigationCompleted(Uri? uri, bool isSuccess, int httpStatusCode, CoreWebView2WebErrorStatus errorStatus)
{
Source = (uri ?? BlankUri).ToString();
NavigationCompleted?.Invoke(this, new CoreWebView2NavigationCompletedEventArgs((ulong)_navigationId, uri, isSuccess, httpStatusCode, errorStatus));
}
internal void RaiseHistoryChanged() => HistoryChanged?.Invoke(this, null);
internal void RaiseWebMessageReceived(string message) => WebMessageReceived?.Invoke(this, new(message));
internal void RaiseUnsupportedUriSchemeIdentified(Uri targetUri, out bool handled)
{
var args = new Windows.UI.Xaml.Controls.WebViewUnsupportedUriSchemeIdentifiedEventArgs(targetUri);
UnsupportedUriSchemeIdentified?.Invoke(this, args);
handled = args.Handled;
}
internal void SetHistoryProperties(bool canGoBack, bool canGoForward)
{
CanGoBack = canGoBack;
CanGoForward = canGoForward;
RaiseHistoryChanged();
}
internal static bool GetIsHistoryEntryValid(string url) =>
!url.IsNullOrWhiteSpace() &&
!url.Equals(BlankUrl, StringComparison.OrdinalIgnoreCase);
[MemberNotNullWhen(true, nameof(_nativeWebView))]
private bool VerifyWebViewAvailability()
{
if (_nativeWebView == null)
{
if (_owner.IsLoaded)
{
_owner.Log().Warn(
"This WebView control instance does not have a native WebView child, " +
"the control template may be missing.");
}
return false;
}
return true;
}
private void UpdateFromInternalSource()
{
if (!VerifyWebViewAvailability())
{
return;
}
if (_processedSource is Uri uri)
{
_nativeWebView.ProcessNavigation(uri);
}
else if (_processedSource is string html)
{
_nativeWebView.ProcessNavigation(html);
}
else if (_processedSource is HttpRequestMessage httpRequestMessage)
{
_nativeWebView.ProcessNavigation(httpRequestMessage);
}
_processedSource = null;
}
}
#nullable enable
using System;
using System.Linq;
using Uno.UI.Xaml.Controls;
using Uno.Foundation.Logging;
using Windows.UI.Xaml.Controls;
#if __IOS__
using UIKit;
using _View = UIKit.UIView;
#else
using AppKit;
using _View = AppKit.NSView;
#endif
namespace Microsoft.Web.WebView2.Core;
public partial class CoreWebView2
{
internal INativeWebView? GetNativeWebViewFromTemplate()
{
var nativeWebView = ((_View)_owner)
.FindSubviewsOfType<INativeWebView>()
.FirstOrDefault();
if (nativeWebView is null)
{
_owner.Log().Error(
$"No view of type {nameof(NativeWebView)} found in children, " +
$"are you missing one of these types in a template? ");
}
else
{
nativeWebView.SetOwner(this);
}
return nativeWebView;
}
}
#if !__ANDROID__ && !__IOS__ && !__MACOS__ && !__MACCATALYST__
#nullable enable
using Uno.UI.Xaml.Controls;
namespace Microsoft.Web.WebView2.Core;
public partial class CoreWebView2
{
internal INativeWebView? GetNativeWebViewFromTemplate() => null;
}
#endif
#nullable enable
using System;
namespace Microsoft.Web.WebView2.Core;
/// <summary>
/// Event args for the NavigationCompleted event.
/// </summary>
public partial class CoreWebView2NavigationCompletedEventArgs : EventArgs
{
internal CoreWebView2NavigationCompletedEventArgs(
ulong navigationId,
Uri? uri,
bool isSuccess,
int httpStatusCode,
CoreWebView2WebErrorStatus webErrorStatus)
{
NavigationId = navigationId;
Uri = uri;
IsSuccess = isSuccess;
HttpStatusCode = httpStatusCode;
WebErrorStatus = webErrorStatus;
}
/// <summary>
/// Gets the ID of the navigation.
/// </summary>
public ulong NavigationId { get; }
/// <summary>
/// true when the navigation is successful; false for a navigation that ended up in an error page
/// (failures due to no network, DNS lookup failure, HTTP server responds with 4xx). Note that
/// WebView2 will report the navigation as 'unsuccessful' if the load for the navigation did not
/// reach the expected completion for any reason. Such reasons include potentially catastrophic
/// issues such network and certificate issues, but can also be the result of intended actions such
/// as the app canceling a navigation or navigating away before the original navigation completed.
/// Applications should not just rely on this flag, but also consider the reported WebErrorStatus
/// to determine whether the failure is indeed catastrophic in their context.
/// </summary>
public bool IsSuccess { get; }
/// <summary>
/// The HTTP status code of the navigation if it involved an HTTP request. For instance,
/// this will usually be 200 if the request was successful, 404 if a page was not found, etc.
/// See https://developer.mozilla.org/docs/Web/HTTP/Status for a list of common status codes.
/// </summary>
public int HttpStatusCode { get; }
/// <summary>
/// Gets the error code if the navigation failed.
/// </summary>
public CoreWebView2WebErrorStatus WebErrorStatus { get; }
internal Uri? Uri { get; }
}
#nullable enable
using System;
namespace Microsoft.Web.WebView2.Core;
/// <summary>
/// Event args for the NavigationStarting event.
/// </summary>
public partial class CoreWebView2NavigationStartingEventArgs : EventArgs
{
public CoreWebView2NavigationStartingEventArgs(ulong navigationId, string? uri) =>
(NavigationId, Uri) = (navigationId, uri);
/// <summary>
/// Gets the ID of the navigation.
/// </summary>
public ulong NavigationId { get; }
/// <summary>
/// Gets the URI of the requested navigation.
/// </summary>
public string? Uri { get; }
/// <summary>
/// Determines whether to cancel the navigation.
/// </summary>
public bool Cancel { get; set; }
/// <summary>
/// true when the navigation is redirected.
/// </summary>
public bool IsRedirected { get; }
/// <summary>
/// true when the new window request was initiated through a user gesture.
/// </summary>
public bool IsUserInitiated { get; }
}
using System;
namespace Microsoft.Web.WebView2.Core;
public partial class CoreWebView2NewWindowRequestedEventArgs
{
internal CoreWebView2NewWindowRequestedEventArgs(string uri, Uri referrer) =>
(Uri, Referrer) = (uri, referrer);
public string Uri { get; }
internal Uri Referrer { get; }
public bool Handled { get; set; }
}
namespace Microsoft.Web.WebView2.Core;
/// <summary>
/// Defines properties that enable, disable, or modify WebView features.
/// </summary>
public partial class CoreWebView2Settings
{
internal CoreWebView2Settings()
{
}
/// <summary>
/// Determines whether communication from the host
/// to the top-level HTML document of the WebView is allowed.
/// </summary>
public bool IsWebMessageEnabled { get; set; } = true;
}
namespace Microsoft.Web.WebView2.Core;
/// <summary>
/// Indicates the error status values for web navigations.
/// </summary>
public enum CoreWebView2WebErrorStatus
{
/// <summary>
/// Indicates that an unknown error occurred.
/// </summary>
Unknown = 0,
/// <summary>
/// Indicates that the SSL certificate common name does not match the web address.
/// </summary>
CertificateCommonNameIsIncorrect = 1,
/// <summary>
/// Indicates that the SSL certificate has expired.
/// </summary>
CertificateExpired = 2,
/// <summary>
/// Indicates that the SSL client certificate contains errors.
/// </summary>
ClientCertificateContainsErrors = 3,
/// <summary>
/// Indicates that the SSL certificate has been revoked.
/// </summary>
CertificateRevoked = 4,
/// <summary>
/// Indicates that the SSL certificate is not valid. The certificate may not match the public key pins for the host name, the certificate is signed by an untrusted authority or using a weak sign algorithm, the certificate claimed DNS names violate name constraints, the certificate contains a weak key, the validity period of the certificate is too long, lack of revocation information or revocation mechanism, non-unique host name, lack of certificate transparency information, or the certificate is chained to a legacy Symantec root.
/// </summary>
CertificateIsInvalid = 5,
/// <summary>
/// Indicates that the host is unreachable.
/// </summary>
ServerUnreachable = 6,
/// <summary>
/// Indicates that the connection has timed out.
/// </summary>
Timeout = 7,
/// <summary>
/// Indicates that the server returned an invalid or unrecognized response.
/// </summary>
ErrorHttpInvalidServerResponse = 8,
/// <summary>
/// Indicates that the connection was stopped.
/// </summary>
ConnectionAborted = 9,
/// <summary>
/// Indicates that the connection was reset.
/// </summary>
ConnectionReset = 10,
/// <summary>
/// Indicates that the Internet connection has been lost.
/// </summary>
Disconnected = 11,
/// <summary>
/// Indicates that a connection to the destination was not established.
/// </summary>
CannotConnect = 12,
/// <summary>
/// Indicates that the provided host name was not able to be resolved.
/// </summary>
HostNameNotResolved = 13,
/// <summary>
/// Indicates that the operation was canceled.
/// </summary>
OperationCanceled = 14,
/// <summary>
/// Indicates that the request redirect failed.
/// </summary>
RedirectFailed = 15,
/// <summary>
/// An unexpected error occurred.
/// </summary>
UnexpectedError = 16,
/// <summary>
/// Indicates that user is prompted with a login, waiting on user action.
/// Initial navigation to a login site will always return this even if app provides
/// credential using BasicAuthenticationRequested. HTTP response status code
/// in this case is 401. See status code reference here: https://developer.mozilla.org/docs/Web/HTTP/Status.
/// </summary>
ValidAuthenticationCredentialsRequired = 17,
/// <summary>
/// Indicates that user lacks proper authentication credentials for a proxy server.
/// HTTP response status code in this case is 407. See status code reference
/// here: https://developer.mozilla.org/docs/Web/HTTP/Status.
/// </summary>
ValidProxyAuthenticationRequired = 18,
}
namespace Microsoft.Web.WebView2.Core;
/// <summary>
/// Event args for the WebMessageReceived event.
/// </summary>
public partial class CoreWebView2WebMessageReceivedEventArgs
{
internal CoreWebView2WebMessageReceivedEventArgs(string webMessageAsJson)
{
WebMessageAsJson = webMessageAsJson;
}
/// <summary>
/// Gets the message posted from the WebView content to the host converted to a JSON string.
/// </summary>
public string WebMessageAsJson { get; }
/// <summary>
/// Gets the message posted from the WebView content to the host as a string.
/// </summary>
/// <returns></returns>
public string TryGetWebMessageAsString()
{
throw new global::System.NotImplementedException("The member string CoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString() is not implemented. For more information, visit https://aka.platform.uno/notimplemented?m=string%20CoreWebView2WebMessageReceivedEventArgs.TryGetWebMessageAsString%28%29");
}
}
using Foundation;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace Windows.UI.Xaml.Controls
{
/// <summary>
/// Wrapper for a version-dependent native iOS WebView
/// </summary>
public interface INativeWebView
{
// Native properties
bool CanGoBack { get; }
bool CanGoForward { get; }
// Native methods
void GoBack();
void GoForward();
void LoadRequest(NSUrlRequest request);
void StopLoading();
void Reload();
void LoadHtmlString(string s, NSUrl baseUrl);
void SetScrollingEnabled(bool isScrollingEnabled);
void RegisterNavigationEvents(WebView xamlWebView);
Task<string> EvaluateJavascriptAsync(CancellationToken ct, string javascript);
}
}
namespace Uno.UI.Xaml.Controls;
internal interface IWebView
{
bool SwitchSourceBeforeNavigating { get; }
bool IsLoaded { get; }
}
using System;
using System.Threading;
using System.Threading.Tasks;
using Android.Webkit;
using Uno.Disposables;
using Uno.Foundation.Logging;
namespace Uno.UI.Xaml.Controls;
internal class InternalWebChromeClient : WebChromeClient
{
private IValueCallback _filePathCallback;
readonly SerialDisposable _fileChooserTaskDisposable = new SerialDisposable();
public override bool OnShowFileChooser(
Android.Webkit.WebView webView,
IValueCallback filePathCallback,
FileChooserParams fileChooserParams)
{
_filePathCallback = filePathCallback;
var cancellationDisposable = new CancellationDisposable();
_fileChooserTaskDisposable.Disposable = cancellationDisposable;
Task.Run(async () =>
{
try
{
await StartFileChooser(cancellationDisposable.Token, fileChooserParams);
}
catch (Exception e)
{
this.Log().Error(e.Message, e);
}
});
return true;
}
public override void OnPermissionRequest(PermissionRequest request) => request.Grant(request.GetResources());
/// <summary>
/// Uses the Activity Tracker to start, then return an Activity
/// </summary>
/// <typeparam name="T">A BaseActivity to start</typeparam>
/// <param name="ct">CancellationToken</param>
/// <returns>The BaseActivity that just started (OnResume called)</returns>
private async Task<T> StartActivity<T>(CancellationToken ct) where T : BaseActivity
{
//Get topmost Activity
var currentActivity = BaseActivity.Current;
if (currentActivity != null)
{
//Set up event handler for when activity changes
var finished = new TaskCompletionSource<BaseActivity>();
EventHandler<CurrentActivityChangedEventArgs> handler = null;
handler = new EventHandler<CurrentActivityChangedEventArgs>((snd, args) =>
{
if (args?.Current != null)
{
finished.TrySetResult(args.Current);
BaseActivity.CurrentChanged -= handler;
}
});
BaseActivity.CurrentChanged += handler;
//Start a new DelegateActivity
currentActivity.StartActivity(typeof(T));
//Wait for it to be the current....
var newCurrent = await finished.Task;
//return the activity.
return newCurrent as T;
}
return null;
}
private async Task StartFileChooser(CancellationToken ct, FileChooserParams fileChooserParams)
{
var intent = fileChooserParams.CreateIntent();
//Get an invisible (Transparent) Activity to handle the Intent
var delegateActivity = await StartActivity<DelegateActivity>(ct);
var result = await delegateActivity.GetActivityResult(ct, intent);
_filePathCallback.OnReceiveValue(FileChooserParams.ParseResult((int)result.ResultCode, result.Intent));
}
}
using System;
using System.Globalization;
using Android.Graphics;
using Android.Runtime;
using Android.Views;
using Android.Webkit;
using Microsoft.Web.WebView2.Core;
using Windows.UI.Xaml.Controls;
using Windows.Web;
namespace Uno.UI.Xaml.Controls;
internal class InternalClient : Android.Webkit.WebViewClient
{
private readonly CoreWebView2 _coreWebView;
private readonly NativeWebViewWrapper _nativeWebViewWrapper;
#pragma warning disable CS0414 //TODO:MZ:
//_owner is because we go through onReceivedError() and OnPageFinished() when the call fail.
private bool _coreWebViewSuccess = true;
//_owner is to not have duplicate event call
private WebErrorStatus _webErrorStatus = WebErrorStatus.Unknown;
internal InternalClient(CoreWebView2 coreWebView, NativeWebViewWrapper webViewWrapper)
{
_coreWebView = coreWebView;
_nativeWebViewWrapper = webViewWrapper;
}
#pragma warning disable CS0672 // Member overrides obsolete member
public override bool ShouldOverrideUrlLoading(Android.Webkit.WebView view, string url)
#pragma warning restore CS0672 // Member overrides obsolete member
{
if (url.StartsWith(Uri.UriSchemeMailto, true, CultureInfo.InvariantCulture))
{
_nativeWebViewWrapper.CreateAndLaunchMailtoIntent(view.Context, url);
return true;
}
_coreWebView.RaiseNavigationStarting(url, out var cancel);
return cancel;
}
public override void OnPageStarted(Android.Webkit.WebView view, string url, Bitmap favicon)
{
base.OnPageStarted(view, url, favicon);
//Reset Webview Success on page started so that if we have successful navigation we don't send an webView error if a previous error happened.
_coreWebViewSuccess = true;
}
#pragma warning disable 0672, 618
public override void OnReceivedError(Android.Webkit.WebView view, [GeneratedEnum] ClientError errorCode, string description, string failingUrl)
{
_coreWebViewSuccess = false;
_webErrorStatus = ConvertClientError(errorCode);
base.OnReceivedError(view, errorCode, description, failingUrl);
}
#pragma warning restore 0672, 618
public override void OnPageFinished(Android.Webkit.WebView view, string url)
{
_coreWebView.DocumentTitle = view.Title;
_coreWebView.RaiseHistoryChanged();
var uri = !_nativeWebViewWrapper._wasLoadedFromString && !string.IsNullOrEmpty(url) ? new Uri(url) : null;
_coreWebView.RaiseNavigationCompleted(uri, true, 200, CoreWebView2WebErrorStatus.Unknown);
base.OnPageFinished(view, url);
}
//Matched using these two sources
//http://developer.xamarin.com/api/type/Android.Webkit.ClientError/
//https://msdn.microsoft.com/en-ca/library/windows/apps/windows.web.weberrorstatus
private WebErrorStatus ConvertClientError(ClientError clientError) => clientError switch
{
ClientError.Authentication => WebErrorStatus.Unauthorized,
ClientError.BadUrl => WebErrorStatus.BadRequest,
ClientError.Connect => WebErrorStatus.CannotConnect,
ClientError.FailedSslHandshake => WebErrorStatus.UnexpectedClientError,
ClientError.File => WebErrorStatus.UnexpectedClientError,
ClientError.FileNotFound => WebErrorStatus.NotFound,
ClientError.HostLookup => WebErrorStatus.HostNameNotResolved,
ClientError.Io => WebErrorStatus.InternalServerError,
ClientError.ProxyAuthentication => WebErrorStatus.ProxyAuthenticationRequired,
ClientError.RedirectLoop => WebErrorStatus.RedirectFailed,
ClientError.Timeout => WebErrorStatus.Timeout,
ClientError.TooManyRequests => WebErrorStatus.UnexpectedClientError,
ClientError.Unknown => WebErrorStatus.Unknown,
ClientError.UnsupportedAuthScheme => WebErrorStatus.Unauthorized,
ClientError.UnsupportedScheme => WebErrorStatus.UnexpectedClientError,
_ => WebErrorStatus.UnexpectedClientError,
};
}
using Uno.UI;
using Uno.UI.Xaml.Controls;
namespace Windows.UI.Xaml.Controls;
public partial class NativeWebView : Android.Webkit.WebView
{
public NativeWebView() : base(ContextHelper.Current)
{
}
}
using System;
using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using System.Linq;
using System.Net.Http;
using Android.Webkit;
using Android.Views;
using Android.Content;
using Uno.Extensions;
using Windows.Foundation;
using System.Collections.Generic;
using Microsoft.Web.WebView2.Core;
namespace Uno.UI.Xaml.Controls;
internal class NativeWebViewWrapper : INativeWebView
{
private readonly WebView _webView;
private readonly CoreWebView2 _coreWebView;
internal bool _wasLoadedFromString;
public NativeWebViewWrapper(WebView webView, CoreWebView2 coreWebView)
{
_webView = webView;
_coreWebView = coreWebView;
// For some reason, the native WebView requires this internal registration
// to avoid launching an external task, out of context of the current activity.
//
// this will still be used to handle extra activity with the native control.
_webView.Settings.JavaScriptEnabled = true;
_webView.Settings.DomStorageEnabled = true;
_webView.Settings.BuiltInZoomControls = true;
_webView.Settings.DisplayZoomControls = false;
_webView.Settings.SetSupportZoom(true);
_webView.Settings.LoadWithOverviewMode = true;
_webView.Settings.UseWideViewPort = true;
_webView.SetWebViewClient(new InternalClient(_coreWebView, this));
_webView.SetWebChromeClient(new InternalWebChromeClient());
_webView.AddJavascriptInterface(new UnoWebViewHandler(this), "unoWebView");
//Allow ThirdPartyCookies by default only on Android 5.0 and UP
if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
{
Android.Webkit.CookieManager.Instance.SetAcceptThirdPartyCookies(_webView, true);
}
// The native webview control requires to have LayoutParameters to function properly.
_webView.LayoutParameters = new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MatchParent,
ViewGroup.LayoutParams.MatchParent);
if (FeatureConfiguration.WebView.ForceSoftwareRendering)
{
//SetLayerType disables hardware acceleration for a single view.
//_owner is required to remove glitching issues particularly when having a keyboard pop-up with a webview present.
//http://developer.android.com/guide/topics/graphics/hardware-accel.html
//http://stackoverflow.com/questions/27172217/android-systemui-glitches-in-lollipop
_webView.SetLayerType(LayerType.Software, null);
}
}
internal WebView WebView => _webView;
public void GoBack() => GoToNearestValidHistoryEntry(direction: -1 /* backward */);
public void GoForward() => GoToNearestValidHistoryEntry(direction: 1 /* forward */);
public void Stop() => _webView.StopLoading();
public void Reload() => _webView.Reload();
public void SetScrollingEnabled(bool isScrollingEnabled)
{
_webView.HorizontalScrollBarEnabled = isScrollingEnabled;
_webView.VerticalScrollBarEnabled = isScrollingEnabled;
}
private void GoToNearestValidHistoryEntry(int direction) =>
Enumerable
.Repeat(
element: direction > 0
? (Action)_webView.GoForward
: (Action)_webView.GoBack,
count: GetStepsToNearestValidHistoryEntry(direction))
.ForEach(action => action.Invoke());
private int GetStepsToNearestValidHistoryEntry(int direction)
{
var history = _webView.CopyBackForwardList();
// Iterate through every next/previous (depending on direction) history entry until a valid one is found
for (int i = history.CurrentIndex + direction; 0 <= i && i < history.Size; i += direction)
if (CoreWebView2.GetIsHistoryEntryValid(history.GetItemAtIndex(i).Url))
// return the absolute number of steps from the current entry to the nearest valid entry
return Math.Abs(i - history.CurrentIndex);
return 0; // no valid entry found
}
internal void CreateAndLaunchMailtoIntent(Android.Content.Context context, string url)
{
var mailto = Android.Net.MailTo.Parse(url);
var email = new global::Android.Content.Intent(global::Android.Content.Intent.ActionSendto);
//Set the data with the mailto: uri to ensure only mail apps will show up as options for the user
email.SetData(global::Android.Net.Uri.Parse("mailto:"));
email.PutExtra(global::Android.Content.Intent.ExtraEmail, mailto.To);
email.PutExtra(global::Android.Content.Intent.ExtraCc, mailto.Cc);
email.PutExtra(global::Android.Content.Intent.ExtraSubject, mailto.Subject);
email.PutExtra(global::Android.Content.Intent.ExtraText, mailto.Body);
context.StartActivity(email);
}
public void ProcessNavigation(Uri uri)
{
_wasLoadedFromString = false;
if (uri.Scheme.Equals("local", StringComparison.OrdinalIgnoreCase))
{
var path = $"file:///android_asset/{uri.PathAndQuery}";
_webView.LoadUrl(path);
return;
}
if (uri.Scheme.Equals(Uri.UriSchemeMailto, StringComparison.OrdinalIgnoreCase))
{
CreateAndLaunchMailtoIntent(_webView.Context, uri.AbsoluteUri);
return;
}
//The replace is present because the uri cuts off any slashes that are more than two when it creates the uri.
//Therefore we add the final forward slash manually in Android because the file:/// requires 3 slashles.
_webView.LoadUrl(uri.AbsoluteUri.Replace("file://", "file:///"));
}
public void ProcessNavigation(HttpRequestMessage requestMessage)
{
var uri = requestMessage.RequestUri;
var headers = requestMessage.Headers
.Safe()
.ToDictionary(
header => header.Key,
element => element.Value.JoinBy(", ")
);
_wasLoadedFromString = false;
_webView.LoadUrl(uri.AbsoluteUri, headers);
}
public void ProcessNavigation(string html)
{
_wasLoadedFromString = true;
//Note : _webView.LoadData does not work properly on Android 10 even when we encode to base64.
_webView.LoadDataWithBaseURL(null, html, "text/html; charset=utf-8", "utf-8", null);
}
async Task<string> INativeWebView.ExecuteScriptAsync(string script, CancellationToken token)
{
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
using var _ = token.Register(() => tcs.TrySetCanceled());
_webView.EvaluateJavascript(
string.Format(CultureInfo.InvariantCulture, "javascript:{0}", script),
new ScriptResponse(value => tcs.SetResult(value)));
return await tcs.Task;
}
async Task<string> INativeWebView.InvokeScriptAsync(string script, string[] arguments, CancellationToken ct)
{
var argumentString = Windows.UI.Xaml.Controls.WebView.ConcatenateJavascriptArguments(arguments);
TaskCompletionSource<string> tcs = new TaskCompletionSource<string>();
ct.Register(() => tcs.TrySetCanceled());
_webView.EvaluateJavascript(
string.Format(CultureInfo.InvariantCulture, "javascript:{0}(\"{1}\");", script, argumentString),
new ScriptResponse(value => tcs.SetResult(value)));
return await tcs.Task;
}
// On Windows, the WebView ignores "about:blank" entries from its navigation history.
// Because Android doesn't let you modify the navigation history,
// we need CanGoBack, CanGoForward, GoBack and GoForward to take the above condition into consideration.
internal void OnNavigationHistoryChanged()
{
// A non-zero number of steps to the nearest valid history entry means that navigation in the given direction is allowed
var canGoBack = GetStepsToNearestValidHistoryEntry(direction: -1 /* backward */) != 0;
var canGoForward = GetStepsToNearestValidHistoryEntry(direction: 1 /* forward */) != 0;
_coreWebView.SetHistoryProperties(canGoBack, canGoForward);
}
private class ScriptResponse : Java.Lang.Object, IValueCallback
{
private Action<string> _setCallBackValue;
internal ScriptResponse(Action<string> setCallBackValue)
{
_setCallBackValue = setCallBackValue;
}
public void OnReceiveValue(Java.Lang.Object value)
{
_setCallBackValue(value?.ToString() ?? string.Empty);
}
}
internal void OnScrollEnabledChangedPartial(bool scrollingEnabled)
{
_webView.HorizontalScrollBarEnabled = scrollingEnabled;
_webView.VerticalScrollBarEnabled = scrollingEnabled;
}
internal void OnWebMessageReceived(string message)
{
if (_coreWebView.Settings.IsWebMessageEnabled)
{
_coreWebView.RaiseWebMessageReceived(message);
}
}
}
using Android.Webkit;
using Java.Interop;
namespace Uno.UI.Xaml.Controls;
internal class UnoWebViewHandler : Java.Lang.Object
{
private readonly NativeWebViewWrapper _nativeWebView;
public UnoWebViewHandler(NativeWebViewWrapper wrapper)
{
_nativeWebView = wrapper;
}
[Export]
[JavascriptInterface]
public void postMessage(string message) => _nativeWebView?.OnWebMessageReceived(message);
}
#nullable enable
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace Uno.UI.Xaml.Controls;
internal partial interface INativeWebView
{
void GoBack();
void GoForward();
void Stop();
void Reload();
void ProcessNavigation(Uri uri);
void ProcessNavigation(string html);
void ProcessNavigation(HttpRequestMessage httpRequestMessage);
Task<string?> ExecuteScriptAsync(string script, CancellationToken token);
Task<string?> InvokeScriptAsync(string script, string[]? arguments, CancellationToken token);
void SetScrollingEnabled(bool isScrollingEnabled);
}
......@@ -2,9 +2,8 @@
using System.Collections.Generic;
using System.Text;
namespace Windows.UI.Xaml.Controls
namespace Windows.UI.Xaml.Controls;
public partial class NativeWebView : FrameworkElement
{
public partial class NativeWebView : UnoWKWebView
{
}
}

using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using Foundation;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Uno.Extensions;
using Microsoft.Web.WebView2.Core;
namespace Windows.UI.Xaml.Controls
namespace Uno.UI.Xaml.Controls;
/// <summary>
/// Wrapper for a version-dependent native iOS WebView
/// </summary>
internal partial interface INativeWebView
{
public partial class WebView : Control
{
}
void SetOwner(CoreWebView2 xamlWebView);
}
using System;
using WebKit;
using Uno.Foundation.Logging;
using Uno.UI.Extensions;
namespace Windows.UI.Xaml.Controls;
internal class LocalWKUIDelegate : WKUIDelegate
{
private readonly Func<WKWebView, WKWebViewConfiguration, WKNavigationAction, WKWindowFeatures, WKWebView> _createWebView;
private readonly Action<WKWebView, string, WKFrameInfo, Action> _runJavaScriptAlertPanel;
private readonly Action<WKWebView, string, string, WKFrameInfo, Action<string>> _runJavaScriptTextInputPanel;
private readonly Action<WKWebView, string, WKFrameInfo, Action<bool>> _runJavaScriptConfirmPanel;
private readonly Action<WKWebView> _didClose;
public LocalWKUIDelegate(
Func<WKWebView, WKWebViewConfiguration, WKNavigationAction, WKWindowFeatures, WKWebView> onCreateWebView,
Action<WKWebView, string, WKFrameInfo, Action> onRunJavaScriptAlertPanel,
Action<WKWebView, string, string, WKFrameInfo, Action<string>> onRunJavaScriptTextInputPanel,
Action<WKWebView, string, WKFrameInfo, Action<bool>> onRunJavaScriptConfirmPanel,
Action<WKWebView> didClose
)
{
_createWebView = onCreateWebView;
_runJavaScriptAlertPanel = onRunJavaScriptAlertPanel;
_runJavaScriptTextInputPanel = onRunJavaScriptTextInputPanel;
_runJavaScriptConfirmPanel = onRunJavaScriptConfirmPanel;
_didClose = didClose;
}
public override WKWebView CreateWebView(WKWebView webView, WKWebViewConfiguration configuration, WKNavigationAction navigationAction, WKWindowFeatures windowFeatures)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"CreateWebView: TargetRequest[{navigationAction?.TargetFrame?.Request?.Url?.ToUri()}] Request:[{navigationAction.Request?.Url?.ToUri()}]");
}
return _createWebView?.Invoke(webView, configuration, navigationAction, windowFeatures);
}
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"WKUIDelegate.RunJavaScriptAlertPanel: {message}");
}
_runJavaScriptAlertPanel?.Invoke(webView, message, frame, completionHandler);
}
public override void RunJavaScriptTextInputPanel(WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action<string> completionHandler)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"WKUIDelegate.RunJavaScriptTextInputPanel: {prompt} / {defaultText}");
}
_runJavaScriptTextInputPanel?.Invoke(webView, prompt, defaultText, frame, completionHandler);
}
public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action<bool> completionHandler)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"WKUIDelegate.RunJavaScriptConfirmPanel: {message}");
}
_runJavaScriptConfirmPanel?.Invoke(webView, message, frame, completionHandler);
}
public override void DidClose(WKWebView webView)
{
if (this.Log().IsEnabled(Uno.Foundation.Logging.LogLevel.Debug))
{
this.Log().Debug($"WKUIDelegate.DidClose");
}
_didClose?.Invoke(webView);
}
}
namespace Windows.UI.Xaml.Controls;
public partial class NativeWebView : UnoWKWebView
{
}
using Foundation;
using System.Collections.Generic;
using Windows.Web;
using Microsoft.Web.WebView2.Core;
namespace Windows.UI.Xaml.Controls;
partial class UnoWKWebView
{
private Dictionary<NSUrlError, CoreWebView2WebErrorStatus> _errorMap = new()
{
[NSUrlError.DownloadDecodingFailedToComplete] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.DownloadDecodingFailedMidStream] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotMoveFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotRemoveFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotWriteToFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotCloseFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotOpenFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotCreateFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotLoadFromNetwork] = CoreWebView2WebErrorStatus.ServerUnreachable,
[NSUrlError.ClientCertificateRequired] = CoreWebView2WebErrorStatus.ValidAuthenticationCredentialsRequired,
[NSUrlError.ClientCertificateRejected] = CoreWebView2WebErrorStatus.CertificateIsInvalid,
[NSUrlError.ServerCertificateNotYetValid] = CoreWebView2WebErrorStatus.CertificateIsInvalid,
[NSUrlError.ServerCertificateHasUnknownRoot] = CoreWebView2WebErrorStatus.CertificateIsInvalid,
[NSUrlError.ServerCertificateUntrusted] = CoreWebView2WebErrorStatus.CertificateCommonNameIsIncorrect,
[NSUrlError.ServerCertificateHasBadDate] = CoreWebView2WebErrorStatus.CertificateExpired,
[NSUrlError.SecureConnectionFailed] = CoreWebView2WebErrorStatus.ServerUnreachable,
[NSUrlError.DataLengthExceedsMaximum] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.NoPermissionsToReadFile] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.FileIsDirectory] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.FileDoesNotExist] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.AppTransportSecurityRequiresSecureConnection] = CoreWebView2WebErrorStatus.CannotConnect,
[NSUrlError.RequestBodyStreamExhausted] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.DataNotAllowed] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CallIsActive] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.InternationalRoamingOff] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotParseResponse] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotDecodeContentData] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.CannotDecodeRawData] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.ZeroByteResource] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.UserAuthenticationRequired] = CoreWebView2WebErrorStatus.ValidAuthenticationCredentialsRequired,
[NSUrlError.UserCancelledAuthentication] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.BadServerResponse] = CoreWebView2WebErrorStatus.ErrorHttpInvalidServerResponse,
[NSUrlError.RedirectToNonExistentLocation] = CoreWebView2WebErrorStatus.RedirectFailed,
[NSUrlError.NotConnectedToInternet] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.ResourceUnavailable] = CoreWebView2WebErrorStatus.ServerUnreachable,
[NSUrlError.HTTPTooManyRedirects] = CoreWebView2WebErrorStatus.RedirectFailed,
[NSUrlError.DNSLookupFailed] = CoreWebView2WebErrorStatus.HostNameNotResolved,
[NSUrlError.NetworkConnectionLost] = CoreWebView2WebErrorStatus.ServerUnreachable,
[NSUrlError.CannotConnectToHost] = CoreWebView2WebErrorStatus.ServerUnreachable,
[NSUrlError.CannotFindHost] = CoreWebView2WebErrorStatus.HostNameNotResolved,
[NSUrlError.UnsupportedURL] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.TimedOut] = CoreWebView2WebErrorStatus.Timeout,
[NSUrlError.BadURL] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.Cancelled] = CoreWebView2WebErrorStatus.OperationCanceled,
[NSUrlError.BackgroundSessionWasDisconnected] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.BackgroundSessionInUseByAnotherProcess] = CoreWebView2WebErrorStatus.UnexpectedError,
[NSUrlError.BackgroundSessionRequiresSharedContainer] = CoreWebView2WebErrorStatus.UnexpectedError,
};
}
using System;
using System.Collections.Generic;
using System.Text;
using Uno.UI;
namespace Windows.UI.Xaml.Controls
{
public partial class NativeWebView : Android.Webkit.WebView
{
public NativeWebView() : base(ContextHelper.Current)
{
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace Windows.UI.Xaml.Controls
{
public partial class NativeWebView : FrameworkElement
{
}
}
# `WebView` Developer Notes
On UWP, there are two variants of `WebView`:
- `WebView` - the default `WebView` implementation, which uses the EdgeHTML rendering engine.
- `WebView2` - the new `WebView` implementation, which uses the Chromium-based Edge rendering engine.
On WinAppSDK, there is only one variant of `WebView`:
- `WebView2` - the new `WebView` implementation, which uses the Chromium-based Edge rendering engine.
In case of Uno Platform, both `WebView` and `WebView2` are currently provided in both `Uno.UI` and `Uno.WinUI`.
`WebView` may be removed in a future release as a breaking change.
## Structure of `WebView2`
`WebView2` consists of two components - `WebView2` class, which is a Windows App SDK `Control` and a `CoreWebView2`,
which is a "native" controller, shared among different `WebView2` implementations (WPF, WinForms, etc.). The inner
`CoreWebView2` is accessible from `WebView2` via `CoreWebView2` property.
## Anatomy of `WebView` and `WebView2` in Uno
To make the shared implementation between `WebView` and `WebView2` as large as possible, both controls will have
use the `CoreWebView2` for most of the logic. The public members of both controls will then act as a proxy to the
`CoreWebView2`. However, the actual platform-specific logic is then in yet another layer - classes that implement
the `INativeWebView` interface. This is the actual place where the platform-bound `WebViews` reside.
Most of the native logic is provided by the native web view controls - e.g. `WKWebView` on iOS, `WebView` on Android.
## Navigation event order
Both `WebView` and `WebView2` have the same navigation event order:
- `NavigationStarting`
- `ContentLoading`
- `DOMContentLoaded`
At the end of the navigation, on `WebView` the either `NavigationCompleted` or `NavigationFailed` are raised.
`WebView2` has only `NavigationCompleted`.
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
using CoreGraphics;
using Foundation;
using System;
using System.Collections.Generic;
using System.Text;
using WebKit;
using System.Threading;
using System.Threading.Tasks;
using ObjCRuntime;
using Uno.UI.Web;
namespace Windows.UI.Xaml.Controls
{
partial class UnoWKWebView
{
private Dictionary<NSUrlError, WebErrorStatus> _errorMap = new Dictionary<NSUrlError, WebErrorStatus>
{
[NSUrlError.DownloadDecodingFailedToComplete] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.DownloadDecodingFailedMidStream] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotMoveFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotRemoveFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotWriteToFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotCloseFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotOpenFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotCreateFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotLoadFromNetwork] = WebErrorStatus.ServerUnreachable,
[NSUrlError.ClientCertificateRequired] = WebErrorStatus.Unauthorized,
[NSUrlError.ClientCertificateRejected] = WebErrorStatus.CertificateIsInvalid,
[NSUrlError.ServerCertificateNotYetValid] = WebErrorStatus.CertificateIsInvalid,
[NSUrlError.ServerCertificateHasUnknownRoot] = WebErrorStatus.CertificateContainsErrors,
[NSUrlError.ServerCertificateUntrusted] = WebErrorStatus.CertificateCommonNameIsIncorrect,
[NSUrlError.ServerCertificateHasBadDate] = WebErrorStatus.CertificateContainsErrors,
[NSUrlError.SecureConnectionFailed] = WebErrorStatus.ServerUnreachable,
[NSUrlError.DataLengthExceedsMaximum] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.NoPermissionsToReadFile] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.FileIsDirectory] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.FileDoesNotExist] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.AppTransportSecurityRequiresSecureConnection] = WebErrorStatus.CannotConnect,
[NSUrlError.RequestBodyStreamExhausted] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.DataNotAllowed] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CallIsActive] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.InternationalRoamingOff] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotParseResponse] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotDecodeContentData] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.CannotDecodeRawData] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.ZeroByteResource] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.UserAuthenticationRequired] = WebErrorStatus.Unauthorized,
[NSUrlError.UserCancelledAuthentication] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.BadServerResponse] = WebErrorStatus.ErrorHttpInvalidServerResponse,
[NSUrlError.RedirectToNonExistentLocation] = WebErrorStatus.UnexpectedRedirection,
[NSUrlError.NotConnectedToInternet] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.ResourceUnavailable] = WebErrorStatus.ServerUnreachable,
[NSUrlError.HTTPTooManyRedirects] = WebErrorStatus.UnexpectedRedirection,
[NSUrlError.DNSLookupFailed] = WebErrorStatus.HostNameNotResolved,
[NSUrlError.NetworkConnectionLost] = WebErrorStatus.ServerUnreachable,
[NSUrlError.CannotConnectToHost] = WebErrorStatus.ServerUnreachable,
[NSUrlError.CannotFindHost] = WebErrorStatus.HostNameNotResolved,
[NSUrlError.UnsupportedURL] = WebErrorStatus.UnexpectedClientError,
[NSUrlError.TimedOut] = WebErrorStatus.Timeout,
[NSUrlError.BadURL] = WebErrorStatus.UnexpectedServerError,
[NSUrlError.Cancelled] = WebErrorStatus.OperationCanceled,
[NSUrlError.BackgroundSessionWasDisconnected] = WebErrorStatus.UnexpectedServerError,
[NSUrlError.BackgroundSessionInUseByAnotherProcess] = WebErrorStatus.UnexpectedServerError,
[NSUrlError.BackgroundSessionRequiresSharedContainer] = WebErrorStatus.UnexpectedServerError,
};
}
}

using Windows.Foundation;
using Windows.UI.Xaml.Controls;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Uno.Extensions;
namespace Windows.UI.Xaml.Controls
{
public partial class WebView : Control
{
public WebView()
{
}
}
}
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using Uno.UI;
using Uno.Extensions;
using Uno.UI.Extensions;
using Windows.UI.Xaml;
using Uno.UI.Web;
using System.Globalization;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using Windows.UI.Core;
using Uno.Foundation.Logging;
namespace Windows.UI.Xaml.Controls
{
public partial class WebView
{
//This should be IAsyncOperation<string> instead of Task<string> but we use an extension method to enable the same signature in Win.
//IAsyncOperation is not available in Xamarin.
public Task<string> InvokeScriptAsync(CancellationToken ct, string script, string[] arguments)
{
throw new NotSupportedException();
}
public Task<string> InvokeScriptAsync(string script, string[] arguments)
{
throw new NotSupportedException();
}
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册