Skip to content

Commit a9d6f53

Browse files
Updates after API Review mtg
1 parent 2751936 commit a9d6f53

1 file changed

Lines changed: 15 additions & 23 deletions

File tree

specs/IFramePermissionRequested.md

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ void RegisterIFramePermissionRequestedHandler()
9191
CHECK_FAILURE(args->get_IsUserInitiated(&userInitiated));
9292
CHECK_FAILURE(args->get_Uri(&uri));
9393

94-
auto cachedKey = std::tuple<
95-
std::wstring, COREWEBVIEW2_PERMISSION_KIND, BOOL>(
94+
auto cachedKey = std::make_tuple(
9695
std::wstring(uri.get()), kind, userInitiated);
9796

9897
auto cachedPermission =
@@ -137,12 +136,12 @@ void RegisterIFramePermissionRequestedHandler()
137136

138137
if (response == IDYES)
139138
{
140-
m_cachedPermissions[cachedKey] = true;
139+
m_cachedPermissions.insert_or_assign(cachedKey, true);
141140
state = COREWEBVIEW2_PERMISSION_STATE_ALLOW;
142141
}
143142
else if (response == IDNO)
144143
{
145-
m_cachedPermissions[cachedKey] = false;
144+
m_cachedPermissions.insert_or_assign(cachedKey, false);
146145
state = COREWEBVIEW2_PERMISSION_STATE_DENY;
147146
}
148147

@@ -245,12 +244,12 @@ void RegisterIFramePermissionRequestedHandler()
245244
var cachedKey = Tuple.Create(permissionArgs.Uri,
246245
permissionArgs.PermissionKind, permissionArgs.IsUserInitiated);
247246
248-
if (m_cachedPermissions.ContainsKey(cachedKey))
247+
if (m_cachedPermissions.TryGetValue(cachedKey, out value))
249248
{
250-
permissionArgs.State = m_cachedPermissions[cachedKey]
251-
? CoreWebView2PermissionState.Allow
249+
permissionArgs.State = value
250+
? CoreWebView2PermissionState.Allow
252251
: CoreWebView2PermissionState.Deny;
253-
252+
254253
PutHandled(permissionArgs);
255254
return;
256255
}
@@ -289,8 +288,8 @@ void RegisterIFramePermissionRequestedHandler()
289288
}
290289
catch (NotImplementedException exception)
291290
{
292-
MessageBox.Show(this, "Frame Permission Requested Failed: " + exception.Message,
293-
"Frame Permission Requested");
291+
// If the runtime support is not there we probably want this
292+
// to be a no-op.
294293
}
295294
};
296295
}
@@ -324,19 +323,12 @@ void PutHandled(CoreWebView2PermissionEventArgs args)
324323
// and invoke it's handlers. However, If we set Handled to true on the
325324
// CoreWebView2Frame event handler, then we will not raise the
326325
// PermissionRequested event off the CoreWebView2.
327-
try
328-
{
329-
// NotImplementedException could be thrown if underlying runtime did not
330-
// implement Handled. However, we only run this code after checking if
331-
// CoreWebView2Frame.PermissionRequested exists, and both exist together,
332-
// so it would not be a problem.
333-
permissionArgs.Handled = true;
334-
}
335-
catch(NotImplementedException exception)
336-
{
337-
MessageBox.Show(this, "Put Handled Failed: " + exception.Message,
338-
"Frame Permission Requested Handled");
339-
}
326+
//
327+
// NotImplementedException could be thrown if underlying runtime did not
328+
// implement Handled. However, we only run this code after checking if
329+
// CoreWebView2Frame.PermissionRequested exists, and both exist together,
330+
// so it would not be a problem.
331+
args.Handled = true;
340332
}
341333
```
342334

0 commit comments

Comments
 (0)