-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blazor Open Links in Browser with Configurability (#4645)
* Blazor Android Open Links in Browser with Configurability * Blazor Windows Open Links in Browser with Configurability (#4680) * Blazor Windows Open Links in Browser with Configurability Windows portion of #4338 * TryCreate URI * PR Feedback (cherry picked from commit 35f637e) * OnExternalNavigationStarting * Pranav Points * Event based approach * Info -> EventArgs * iOS & Mac Catalyst * Fix WPF/Winforms Browser Start * Winforms ExternalNavigationStarting * PR Feedback * Remove ordering dependency during property mapping * @blowdart feedback * @Eilon feedback
- Loading branch information
1 parent
451b484
commit 78c1ffe
Showing
17 changed files
with
341 additions
and
56 deletions.
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
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
26 changes: 26 additions & 0 deletions
26
src/BlazorWebView/src/Maui/Android/BlazorWebChromeClient.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,26 @@ | ||
| ||
using Android.Content; | ||
using Android.Net; | ||
using Android.OS; | ||
using Android.Webkit; | ||
|
||
namespace Microsoft.AspNetCore.Components.WebView.Maui | ||
{ | ||
class BlazorWebChromeClient : WebChromeClient | ||
{ | ||
public override bool OnCreateWindow(Android.Webkit.WebView? view, bool isDialog, bool isUserGesture, Message? resultMsg) | ||
{ | ||
if (view?.Context is not null) | ||
{ | ||
// Intercept _blank target <a> tags to always open in device browser | ||
// regardless of ExternalLinkMode.OpenInWebview | ||
var requestUrl = view.GetHitTestResult().Extra; | ||
var intent = new Intent(Intent.ActionView, Uri.Parse(requestUrl)); | ||
view.Context.StartActivity(intent); | ||
} | ||
|
||
// We don't actually want to create a new WebView window so we just return false | ||
return false; | ||
} | ||
} | ||
} |
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
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
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
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.