// Copyright © 2022 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
namespace CefSharp.Handler
{
///
public class PermissionHandler : IPermissionHandler
{
///
bool IPermissionHandler.OnRequestMediaAccessPermission(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string requestingOrigin, MediaAccessPermissionType requestedPermissions, IMediaAccessCallback callback)
{
return OnRequestMediaAccessPermission(chromiumWebBrowser, browser, frame, requestingOrigin, requestedPermissions, callback);
}
///
/// Called when a page requests permission to access media.
/// With the Chrome runtime, default handling will display the
/// permission request UI.With the Alloy runtime, default handling will deny
/// the request.This method will not be called if the "--enable-media-stream"
/// command-line switch is used to grant all permissions.
///
/// The ChromiumWebBrowser control
/// The browser object
/// The frame object
/// is the URL origin requesting permission.
/// is a combination of values that represent the requested permissions
/// Callback interface used for asynchronous continuation of media access.
/// Return true and call CefMediaAccessCallback methods either in this method or at a later time to continue or cancel the request.
/// Return false to proceed with default handling.
///
protected virtual bool OnRequestMediaAccessPermission(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, string requestingOrigin, MediaAccessPermissionType requestedPermissions, IMediaAccessCallback callback)
{
using (callback)
{
return false;
}
}
///
bool IPermissionHandler.OnShowPermissionPrompt(IWebBrowser chromiumWebBrowser, IBrowser browser, ulong promptId, string requestingOrigin, PermissionRequestType requestedPermissions, IPermissionPromptCallback callback)
{
return OnShowPermissionPrompt(chromiumWebBrowser, browser, promptId, requestingOrigin, requestedPermissions, callback);
}
///
/// Called when a page should show a permission prompt.
///
/// The ChromiumWebBrowser control
/// The browser object
/// Uniquely identifies the prompt.
/// Is the URL origin requesting permission.
/// Is a combination of values from that represent the requested permissions.
/// Callback interface used for asynchronous continuation of permission prompts.
/// Return true and call either in this method or at a later time to continue or cancel the request.
/// Return false to proceed with default handling.
/// With the Chrome runtime, default handling
/// will display the permission prompt UI. With the Alloy runtime, default
/// handling is .
protected virtual bool OnShowPermissionPrompt(IWebBrowser chromiumWebBrowser, IBrowser browser, ulong promptId, string requestingOrigin, PermissionRequestType requestedPermissions, IPermissionPromptCallback callback)
{
using (callback)
{
return false;
}
}
///
void IPermissionHandler.OnDismissPermissionPrompt(IWebBrowser chromiumWebBrowser, IBrowser browser, ulong promptId, PermissionRequestResult result)
{
OnDismissPermissionPrompt(chromiumWebBrowser, browser, promptId, result);
}
///
/// Called when a permission prompt handled via is dismissed.
/// will be the value passed to
/// or if
/// the dialog was dismissed for other reasons such as navigation, browser
/// closure, etc. This method will not be called if
/// returned false for .
///
/// The ChromiumWebBrowser control
/// The browser object
/// Will match the value that was passed to .
/// will be the value passed to or if the dialog was dismissed for other reasons such as navigation, browser closure, etc. This method will not be called if returned false for .
protected virtual void OnDismissPermissionPrompt(IWebBrowser chromiumWebBrowser, IBrowser browser, ulong promptId, PermissionRequestResult result)
{
}
}
}