Skip to content

Commit f94e851

Browse files
author
Maura Winstanley
committed
remove handled property
1 parent 88685f3 commit f94e851

1 file changed

Lines changed: 15 additions & 30 deletions

File tree

specs/LaunchingRegisteredProtocols.md

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
11
# Background
22

3-
We are exposing an event that will be raised when an attempt to launch an external protocol is made. The host will be given the option to cancel the launch as well as hide the default dialog and display a custom dialog.
3+
We are exposing an event that will be raised when an attempt to launch an external protocol is made. The host will be given the option to cancel the launch. Cancelling the launch gives the host the opportunity to hide the default dialog, display a custom dialog, and then launch the external protocol themselves.
44

55
# Description
66

77
This event will be raised before the external protocol launch occurs. When an attempt to launch an external protocol is made, the default dialog is displayed in which the user can select `Open` or `Cancel`. The `NavigationStarting`, `NavigationCompleted`, `SourceChanged`, `ContentLoading`, and `HistoryChanged` events will not be raised when a request is made to launch an external protocol.
88

99
The `LaunchingExternalProtocol` event will be raised on the `CoreWebView2` interface.
1010

11-
The host may set the `Cancel` or `Handled` event args which would result in the following behavior:
12-
13-
| Cancel | Handled | Outcome |
14-
|-|-|-|
15-
| False | False | Default dialog shown, URI optionally launched based on end user input |
16-
| False | True | No dialog, URI is launched |
17-
| True | * | No dialog shown, URI is not launched |
18-
1911
# Examples
2012

2113
## Win32 C++
@@ -77,7 +69,14 @@ void RegisterLaunchingExternalProtocolHandler()
7769
MB_YESNOCANCEL | MB_ICONWARNING);
7870
if (response == IDYES)
7971
{
80-
args->put_Handled(true);
72+
args->put_Cancel(true);
73+
std::wstring protocol_url = L"calculator://";
74+
SHELLEXECUTEINFO info = {sizeof(info)};
75+
info.fMask = SEE_MASK_NOASYNC;
76+
info.lpVerb = L"open";
77+
info.lpFile = protocol_url.c_str();
78+
info.nShow = SW_SHOWNORMAL;
79+
::ShellExecuteEx(&info);
8180
}
8281
else
8382
{
@@ -147,7 +146,8 @@ void RegisterLaunchingExternalProtocolHandler()
147146
switch (resultbox)
148147
{
149148
case MessageBoxResult.Yes:
150-
args.Handled = true;
149+
Process.Start("calc");
150+
args.Cancel = true;
151151
break;
152152

153153
case MessageBoxResult.No:
@@ -184,8 +184,6 @@ interface ICoreWebView2_16 : ICoreWebView2_15 {
184184
/// Add an event handler for the `LaunchingExternalProtocol` event.
185185
/// The `LaunchingExternalProtocol` event is raised when a launch request is made to
186186
/// a protocol that is registered with the OS.
187-
/// The `LaunchingExternalProtocol` event may suppress the default dialog
188-
/// and replace the default dialog with a custom dialog.
189187
///
190188
/// If a deferral is not taken on the event args, the external protocol launch is
191189
/// blocked until the event handler returns. If a deferral is taken, the
@@ -194,14 +192,14 @@ interface ICoreWebView2_16 : ICoreWebView2_15 {
194192
///
195193
/// The `NavigationStarting`, `NavigationCompleted, `SourceChanged`,
196194
/// `ContentLoading`, and `HistoryChanged` events will not be raised, regardless
197-
/// of whether the `Cancel` or `Handled` property is set to `TRUE` or
195+
/// of whether the `Cancel` property is set to `TRUE` or
198196
/// `FALSE`.
199197
///
200198
/// If the request is made from a trustworthy origin
201199
/// (https://w3c.github.io/webappsec-secure-contexts#potentially-trustworthy-origin)
202200
/// a checkmark box will be displayed that gives the user the option to always allow
203-
/// the external protocol to launch from this origin. If the user checks this box, upon the next
204-
/// request from that origin to the protocol, the event will still be raised.
201+
/// the external protocol to launch from this origin. If the user checks this box, upon the
202+
/// next request from that origin to the protocol, the event will still be raised.
205203
///
206204
/// \snippet SettingsComponent.cpp LaunchingExternalProtocol
207205
HRESULT add_LaunchingExternalProtocol(
@@ -237,26 +235,14 @@ interface ICoreWebView2LaunchingExternalProtocolEventArgs: IUnknown {
237235
238236
/// The host may set this flag to cancel the external protocol launch. If set to
239237
/// `TRUE`, the external protocol will not be launched, and the default
240-
/// dialog is not displayed regardless of the `Handled` property.
238+
/// dialog is not displayed.
241239
242240
[propget] HRESULT Cancel([out, retval] BOOL* cancel);
243241
244242
/// Sets the `Cancel` property. The default value is `FALSE`.
245243
246244
[propput] HRESULT Cancel([in] BOOL cancel);
247245
248-
/// The host may set this flag to `TRUE` to hide the default
249-
/// dialog for this navigation.
250-
/// The external protocol request will continue as normal if it is not
251-
/// cancelled, although there will be no default UI shown. The default
252-
/// value is `FALSE` and the default dialog is shown.
253-
254-
[propget] HRESULT Handled([out, retval] BOOL* handled);
255-
256-
/// Sets the `Handled` property.
257-
258-
[propput] HRESULT Handled([in] BOOL handled);
259-
260246
/// Returns an `ICoreWebView2Deferral` object. Use this operation to
261247
/// complete the event at a later time.
262248
@@ -277,7 +263,6 @@ namespace Microsoft.Web.WebView2.Core
277263
String Uri { get; };
278264
String InitiatingUri { get; };
279265
Boolean Cancel { get; set; };
280-
Boolean Handled {get; set; };
281266
Windows.Foundation.Deferral GetDeferral();
282267
}
283268

0 commit comments

Comments
 (0)