New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Catalyst] Allow to use a custom WKUIDelegate on WebView #18483
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f5f5b1d
Fix the issue
jsuarezruiz 6b38958
Update src/Core/src/Handlers/WebView/WebViewHandler.cs
jsuarezruiz c459aaf
Merge branch 'main' into fix-18394
jsuarezruiz 5e42cfd
Merge branch 'fix-18394' of https://github.com/dotnet/maui into fix-1…
jsuarezruiz 27c7d11
Add pending snapshot
jsuarezruiz c11349e
Revert change
jsuarezruiz ff5b411
Merge branch 'main' into fix-18394
jsuarezruiz 4b8b2b5
Added sample
jsuarezruiz 1274484
Merge branch 'main' into fix-18394
jsuarezruiz 6379719
Merge branch 'main' into fix-18394
jsuarezruiz File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/Controls/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewGallery.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Microsoft.Maui.Controls; | ||
|
||
namespace Maui.Controls.Sample.Pages.WebViewGalleries | ||
{ | ||
public class WebViewGallery : ContentPage | ||
{ | ||
public WebViewGallery() | ||
{ | ||
Content = new ScrollView | ||
{ | ||
Content = new StackLayout | ||
{ | ||
Spacing = 5, | ||
Children = | ||
{ | ||
GalleryBuilder.NavButton("WebView Playground", () => new WebViewPlayground(), Navigation), | ||
#if MACCATALYST | ||
GalleryBuilder.NavButton("WebView using a custom UIDelegate", () => new WebViewUIDelegatePage(), Navigation), | ||
#endif | ||
} | ||
} | ||
}; | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...ls.Sample/Pages/Controls/WebViewPage.xaml → ...s/WebViewGalleries/WebViewPlayground.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...ntrols/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewUIDelegatePage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<views:BasePage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Pages.WebViewGalleries.WebViewUIDelegatePage" | ||
xmlns:views="clr-namespace:Maui.Controls.Sample.Pages.Base" | ||
Title="WebView"> | ||
<views:BasePage.Content> | ||
<AbsoluteLayout> | ||
<WebView | ||
x:Name="DelegateWebView" | ||
AbsoluteLayout.LayoutBounds="0,0,1,1" | ||
AbsoluteLayout.LayoutFlags="SizeProportional" /> | ||
</AbsoluteLayout> | ||
</views:BasePage.Content> | ||
</views:BasePage> |
14 changes: 14 additions & 0 deletions
14
...ols/samples/Controls.Sample/Pages/Controls/WebViewGalleries/WebViewUIDelegatePage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
|
||
namespace Maui.Controls.Sample.Pages.WebViewGalleries | ||
{ | ||
public partial class WebViewUIDelegatePage | ||
{ | ||
public WebViewUIDelegatePage() | ||
{ | ||
InitializeComponent(); | ||
|
||
DelegateWebView.Source = new Uri("https://webrtc.github.io/samples/src/content/getusermedia/gum/"); | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Controls/samples/Controls.Sample/Platforms/MacCatalyst/CustomWebViewUIDelegate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using Foundation; | ||
using WebKit; | ||
|
||
|
||
namespace Maui.Controls.Sample.Platforms.MacCatalyst | ||
{ | ||
public class CustomWebViewUIDelegate : WKUIDelegate | ||
{ | ||
public CustomWebViewUIDelegate() | ||
{ | ||
|
||
} | ||
|
||
[Export("webView:requestMediaCapturePermissionForOrigin:initiatedByFrame:type:decisionHandler:")] | ||
public override void RequestMediaCapturePermission(WKWebView webView, WKSecurityOrigin origin, WKFrameInfo frame, WKMediaCaptureType type, Action<WKPermissionDecision> decisionHandler) | ||
{ | ||
decisionHandler(WKPermissionDecision.Grant); | ||
} | ||
public override void RequestDeviceOrientationAndMotionPermission(WKWebView webView, WKSecurityOrigin origin, WKFrameInfo frame, Action<WKPermissionDecision> decisionHandler) | ||
{ | ||
base.RequestDeviceOrientationAndMotionPermission(webView, origin, frame, decisionHandler); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this does anything in our code
Semi-confusingly
We already build everything marked as IOS for MACCatalyst
https://github.com/dotnet/maui/blob/main/src/MultiTargeting.targets#L99-L102
I'm not really sure what the users problem is but I don't think this will fix anything for them.
I don't quite understand on the repro, why they are setting the delegate inside a "BeginInvoke" call.
Like, if I check the type of the UIDelegate it's definitely already being replaced
you can also see it here that it's already set