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=b299c22d4f97022efefefeb17a7848b0b44d4af3$
// $hash=6af3f901e4429197d0e47b15a68e980ea574b256$
//
#include "libcef_dll/cpptoc/client_cpptoc.h"
@ -27,6 +27,7 @@
#include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h"
#include "libcef_dll/cpptoc/life_span_handler_cpptoc.h"
#include "libcef_dll/cpptoc/load_handler_cpptoc.h"
#include "libcef_dll/cpptoc/permission_handler_cpptoc.h"
#include "libcef_dll/cpptoc/print_handler_cpptoc.h"
#include "libcef_dll/cpptoc/render_handler_cpptoc.h"
#include "libcef_dll/cpptoc/request_handler_cpptoc.h"
@ -198,6 +199,22 @@ client_get_frame_handler(struct _cef_client_t* self) {
return CefFrameHandlerCppToC::Wrap(_retval);
}
struct _cef_permission_handler_t* CEF_CALLBACK
client_get_permission_handler(struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefPermissionHandler> _retval =
CefClientCppToC::Get(self)->GetPermissionHandler();
// Return type: refptr_same
return CefPermissionHandlerCppToC::Wrap(_retval);
}
struct _cef_jsdialog_handler_t* CEF_CALLBACK
client_get_jsdialog_handler(struct _cef_client_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -358,6 +375,7 @@ CefClientCppToC::CefClientCppToC() {
GetStruct()->get_find_handler = client_get_find_handler;
GetStruct()->get_focus_handler = client_get_focus_handler;
GetStruct()->get_frame_handler = client_get_frame_handler;
GetStruct()->get_permission_handler = client_get_permission_handler;
GetStruct()->get_jsdialog_handler = client_get_jsdialog_handler;
GetStruct()->get_keyboard_handler = client_get_keyboard_handler;
GetStruct()->get_life_span_handler = client_get_life_span_handler;

View File

@ -0,0 +1,81 @@
// 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=dd3f62153541c74c294da2a33265a96491d17f2b$
//
#include "libcef_dll/cpptoc/media_access_callback_cpptoc.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK
media_access_callback_cont(struct _cef_media_access_callback_t* self,
uint32 allowed_permissions) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefMediaAccessCallbackCppToC::Get(self)->Continue(allowed_permissions);
}
void CEF_CALLBACK
media_access_callback_cancel(struct _cef_media_access_callback_t* self) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Execute
CefMediaAccessCallbackCppToC::Get(self)->Cancel();
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefMediaAccessCallbackCppToC::CefMediaAccessCallbackCppToC() {
GetStruct()->cont = media_access_callback_cont;
GetStruct()->cancel = media_access_callback_cancel;
}
// DESTRUCTOR - Do not edit by hand.
CefMediaAccessCallbackCppToC::~CefMediaAccessCallbackCppToC() {
shutdown_checker::AssertNotShutdown();
}
template <>
CefRefPtr<CefMediaAccessCallback> CefCppToCRefCounted<
CefMediaAccessCallbackCppToC,
CefMediaAccessCallback,
cef_media_access_callback_t>::UnwrapDerived(CefWrapperType type,
cef_media_access_callback_t*
s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCRefCounted<CefMediaAccessCallbackCppToC,
CefMediaAccessCallback,
cef_media_access_callback_t>::kWrapperType =
WT_MEDIA_ACCESS_CALLBACK;

View File

@ -0,0 +1,38 @@
// 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=0adf2c32c67b7480fa4c544c5c570674d6917f7f$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_MEDIA_ACCESS_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_MEDIA_ACCESS_CALLBACK_CPPTOC_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/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefMediaAccessCallbackCppToC
: public CefCppToCRefCounted<CefMediaAccessCallbackCppToC,
CefMediaAccessCallback,
cef_media_access_callback_t> {
public:
CefMediaAccessCallbackCppToC();
virtual ~CefMediaAccessCallbackCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_MEDIA_ACCESS_CALLBACK_CPPTOC_H_

View File

@ -0,0 +1,96 @@
// 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=9c8d3c2295998f7a976967aa7f4b6a6da7c5c53d$
//
#include "libcef_dll/cpptoc/permission_handler_cpptoc.h"
#include "libcef_dll/ctocpp/browser_ctocpp.h"
#include "libcef_dll/ctocpp/frame_ctocpp.h"
#include "libcef_dll/ctocpp/media_access_callback_ctocpp.h"
#include "libcef_dll/shutdown_checker.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK permission_handler_on_request_media_access_permission(
struct _cef_permission_handler_t* self,
cef_browser_t* browser,
cef_frame_t* frame,
const cef_string_t* requesting_url,
uint32 requested_permissions,
cef_media_access_callback_t* callback) {
shutdown_checker::AssertNotShutdown();
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: frame; type: refptr_diff
DCHECK(frame);
if (!frame)
return 0;
// Verify param: requesting_url; type: string_byref_const
DCHECK(requesting_url);
if (!requesting_url)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return 0;
// Execute
bool _retval =
CefPermissionHandlerCppToC::Get(self)->OnRequestMediaAccessPermission(
CefBrowserCToCpp::Wrap(browser), CefFrameCToCpp::Wrap(frame),
CefString(requesting_url), requested_permissions,
CefMediaAccessCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPermissionHandlerCppToC::CefPermissionHandlerCppToC() {
GetStruct()->on_request_media_access_permission =
permission_handler_on_request_media_access_permission;
}
// DESTRUCTOR - Do not edit by hand.
CefPermissionHandlerCppToC::~CefPermissionHandlerCppToC() {
shutdown_checker::AssertNotShutdown();
}
template <>
CefRefPtr<CefPermissionHandler> CefCppToCRefCounted<
CefPermissionHandlerCppToC,
CefPermissionHandler,
cef_permission_handler_t>::UnwrapDerived(CefWrapperType type,
cef_permission_handler_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCRefCounted<CefPermissionHandlerCppToC,
CefPermissionHandler,
cef_permission_handler_t>::kWrapperType =
WT_PERMISSION_HANDLER;

View File

@ -0,0 +1,38 @@
// 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=0f90cfade714209df150953eabed70bc7b264122$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_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/cpptoc/cpptoc_ref_counted.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed wrapper-side only.
class CefPermissionHandlerCppToC
: public CefCppToCRefCounted<CefPermissionHandlerCppToC,
CefPermissionHandler,
cef_permission_handler_t> {
public:
CefPermissionHandlerCppToC();
virtual ~CefPermissionHandlerCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_PERMISSION_HANDLER_CPPTOC_H_