Add CefPermissionHandler callback for media access (fixes issue #2582)

This commit is contained in:
Marshall Greenblatt
2022-06-30 07:31:18 +00:00
parent d3a2237a5a
commit 26e30b3859
29 changed files with 1852 additions and 83 deletions

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=8e158f3ea54211b95f0b716b1eeec2ff475f1245$
// $hash=71c2e9dd248276daa80be557773fe86bdc2bcb99$
//
#include "libcef_dll/ctocpp/client_ctocpp.h"
@@ -30,6 +30,7 @@
#include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h"
#include "libcef_dll/ctocpp/life_span_handler_ctocpp.h"
#include "libcef_dll/ctocpp/load_handler_ctocpp.h"
#include "libcef_dll/ctocpp/permission_handler_ctocpp.h"
#include "libcef_dll/ctocpp/print_handler_ctocpp.h"
#include "libcef_dll/ctocpp/render_handler_ctocpp.h"
#include "libcef_dll/ctocpp/request_handler_ctocpp.h"
@@ -187,6 +188,21 @@ CefRefPtr<CefFrameHandler> CefClientCToCpp::GetFrameHandler() {
return CefFrameHandlerCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefPermissionHandler> CefClientCToCpp::GetPermissionHandler() {
cef_client_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, get_permission_handler))
return nullptr;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
cef_permission_handler_t* _retval = _struct->get_permission_handler(_struct);
// Return type: refptr_same
return CefPermissionHandlerCToCpp::Wrap(_retval);
}
NO_SANITIZE("cfi-icall")
CefRefPtr<CefJSDialogHandler> CefClientCToCpp::GetJSDialogHandler() {
cef_client_t* _struct = GetStruct();

View File

@@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=69f82ee575779deaf1d3581dbedcf8aa75f35710$
// $hash=821429d4e38b03407a1e6cf73a67e479810f0c21$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_
@@ -43,6 +43,7 @@ class CefClientCToCpp
CefRefPtr<CefFindHandler> GetFindHandler() override;
CefRefPtr<CefFocusHandler> GetFocusHandler() override;
CefRefPtr<CefFrameHandler> GetFrameHandler() override;
CefRefPtr<CefPermissionHandler> GetPermissionHandler() override;
CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() override;
CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() override;
CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override;

View File

@@ -0,0 +1,71 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=bfd836add2381882b8c0408181621ebf24cddce1$
//
#include "libcef_dll/ctocpp/media_access_callback_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
void CefMediaAccessCallbackCToCpp::Continue(uint32 allowed_permissions) {
shutdown_checker::AssertNotShutdown();
cef_media_access_callback_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, cont))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->cont(_struct, allowed_permissions);
}
NO_SANITIZE("cfi-icall") void CefMediaAccessCallbackCToCpp::Cancel() {
shutdown_checker::AssertNotShutdown();
cef_media_access_callback_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, cancel))
return;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
_struct->cancel(_struct);
}
// CONSTRUCTOR - Do not edit by hand.
CefMediaAccessCallbackCToCpp::CefMediaAccessCallbackCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefMediaAccessCallbackCToCpp::~CefMediaAccessCallbackCToCpp() {
shutdown_checker::AssertNotShutdown();
}
template <>
cef_media_access_callback_t* CefCToCppRefCounted<
CefMediaAccessCallbackCToCpp,
CefMediaAccessCallback,
cef_media_access_callback_t>::UnwrapDerived(CefWrapperType type,
CefMediaAccessCallback* c) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppRefCounted<CefMediaAccessCallbackCToCpp,
CefMediaAccessCallback,
cef_media_access_callback_t>::kWrapperType =
WT_MEDIA_ACCESS_CALLBACK;

View File

@@ -0,0 +1,42 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1b4c8da03ff2853b057860369bdb5dd1b48cf046$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_MEDIA_ACCESS_CALLBACK_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_MEDIA_ACCESS_CALLBACK_CTOCPP_H_
#pragma once
#if !defined(WRAPPING_CEF_SHARED)
#error This file can be included wrapper-side only
#endif
#include "include/capi/cef_permission_handler_capi.h"
#include "include/cef_permission_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed wrapper-side only.
class CefMediaAccessCallbackCToCpp
: public CefCToCppRefCounted<CefMediaAccessCallbackCToCpp,
CefMediaAccessCallback,
cef_media_access_callback_t> {
public:
CefMediaAccessCallbackCToCpp();
virtual ~CefMediaAccessCallbackCToCpp();
// CefMediaAccessCallback methods.
void Continue(uint32 allowed_permissions) override;
void Cancel() override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_MEDIA_ACCESS_CALLBACK_CTOCPP_H_

View File

@@ -0,0 +1,89 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=f9073ac6e5a3634a3bf3c919ac1b0a9c607b4398$
//
#include "libcef_dll/ctocpp/permission_handler_ctocpp.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/frame_cpptoc.h"
#include "libcef_dll/cpptoc/media_access_callback_cpptoc.h"
#include "libcef_dll/shutdown_checker.h"
// VIRTUAL METHODS - Body may be edited by hand.
NO_SANITIZE("cfi-icall")
bool CefPermissionHandlerCToCpp::OnRequestMediaAccessPermission(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& requesting_url,
uint32 requested_permissions,
CefRefPtr<CefMediaAccessCallback> callback) {
shutdown_checker::AssertNotShutdown();
cef_permission_handler_t* _struct = GetStruct();
if (CEF_MEMBER_MISSING(_struct, on_request_media_access_permission))
return false;
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Verify param: browser; type: refptr_diff
DCHECK(browser.get());
if (!browser.get())
return false;
// Verify param: frame; type: refptr_diff
DCHECK(frame.get());
if (!frame.get())
return false;
// Verify param: requesting_url; type: string_byref_const
DCHECK(!requesting_url.empty());
if (requesting_url.empty())
return false;
// Verify param: callback; type: refptr_diff
DCHECK(callback.get());
if (!callback.get())
return false;
// Execute
int _retval = _struct->on_request_media_access_permission(
_struct, CefBrowserCppToC::Wrap(browser), CefFrameCppToC::Wrap(frame),
requesting_url.GetStruct(), requested_permissions,
CefMediaAccessCallbackCppToC::Wrap(callback));
// Return type: bool
return _retval ? true : false;
}
// CONSTRUCTOR - Do not edit by hand.
CefPermissionHandlerCToCpp::CefPermissionHandlerCToCpp() {}
// DESTRUCTOR - Do not edit by hand.
CefPermissionHandlerCToCpp::~CefPermissionHandlerCToCpp() {
shutdown_checker::AssertNotShutdown();
}
template <>
cef_permission_handler_t* CefCToCppRefCounted<
CefPermissionHandlerCToCpp,
CefPermissionHandler,
cef_permission_handler_t>::UnwrapDerived(CefWrapperType type,
CefPermissionHandler* c) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCToCppRefCounted<CefPermissionHandlerCToCpp,
CefPermissionHandler,
cef_permission_handler_t>::kWrapperType =
WT_PERMISSION_HANDLER;

View File

@@ -0,0 +1,46 @@
// Copyright (c) 2022 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=1c8392555b99119b866989c5461ad48a0ac662b5$
//
#ifndef CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_permission_handler_capi.h"
#include "include/cef_permission_handler.h"
#include "libcef_dll/ctocpp/ctocpp_ref_counted.h"
// Wrap a C structure with a C++ class.
// This class may be instantiated and accessed DLL-side only.
class CefPermissionHandlerCToCpp
: public CefCToCppRefCounted<CefPermissionHandlerCToCpp,
CefPermissionHandler,
cef_permission_handler_t> {
public:
CefPermissionHandlerCToCpp();
virtual ~CefPermissionHandlerCToCpp();
// CefPermissionHandler methods.
bool OnRequestMediaAccessPermission(
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefFrame> frame,
const CefString& requesting_url,
uint32 requested_permissions,
CefRefPtr<CefMediaAccessCallback> callback) override;
};
#endif // CEF_LIBCEF_DLL_CTOCPP_PERMISSION_HANDLER_CTOCPP_H_