Support registration of custom preferences.

Custom global and request context preferences can now be registered via
CefBrowserProcessHandler::OnRegisterCustomPreferences. CefRequestContext
now extends CefPreferenceManager and global preferences can be accessed
via CefPreferenceManager::GetGlobalPreferenceManager.
This commit is contained in:
Marshall Greenblatt
2022-10-25 18:50:29 -04:00
parent 767c4422ac
commit 09bb643ef6
45 changed files with 2022 additions and 531 deletions

View File

@ -9,17 +9,41 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=452f119327aff2ec0aaed162adf85bbd239b9033$
// $hash=984f4b764ebd914b5f5e585479866bd7a36c0429$
//
#include "libcef_dll/cpptoc/browser_process_handler_cpptoc.h"
#include "libcef_dll/cpptoc/client_cpptoc.h"
#include "libcef_dll/ctocpp/command_line_ctocpp.h"
#include "libcef_dll/ctocpp/preference_registrar_ctocpp.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK browser_process_handler_on_register_custom_preferences(
struct _cef_browser_process_handler_t* self,
cef_preferences_type_t type,
struct _cef_preference_registrar_t* registrar) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Verify param: registrar; type: rawptr_diff
DCHECK(registrar);
if (!registrar)
return;
// Translate param: registrar; type: rawptr_diff
CefOwnPtr<CefPreferenceRegistrar> registrarPtr(
CefPreferenceRegistrarCToCpp::Wrap(registrar));
// Execute
CefBrowserProcessHandlerCppToC::Get(self)->OnRegisterCustomPreferences(
type, registrarPtr.get());
}
void CEF_CALLBACK browser_process_handler_on_context_initialized(
struct _cef_browser_process_handler_t* self) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
@ -85,6 +109,8 @@ struct _cef_client_t* CEF_CALLBACK browser_process_handler_get_default_client(
// CONSTRUCTOR - Do not edit by hand.
CefBrowserProcessHandlerCppToC::CefBrowserProcessHandlerCppToC() {
GetStruct()->on_register_custom_preferences =
browser_process_handler_on_register_custom_preferences;
GetStruct()->on_context_initialized =
browser_process_handler_on_context_initialized;
GetStruct()->on_before_child_process_launch =

View File

@ -0,0 +1,183 @@
// 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=6958fb584fde290169bdcf0fa3f1c94a2c9d77ea$
//
#include "libcef_dll/cpptoc/preference_manager_cpptoc.h"
#include "libcef_dll/cpptoc/dictionary_value_cpptoc.h"
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
// GLOBAL FUNCTIONS - Body may be edited by hand.
CEF_EXPORT cef_preference_manager_t* cef_preference_manager_get_global() {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
// Execute
CefRefPtr<CefPreferenceManager> _retval =
CefPreferenceManager::GetGlobalPreferenceManager();
// Return type: refptr_same
return CefPreferenceManagerCppToC::Wrap(_retval);
}
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK
preference_manager_has_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefPreferenceManagerCppToC::Get(self)->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
preference_manager_get_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefPreferenceManagerCppToC::Get(self)->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
preference_manager_get_all_preferences(struct _cef_preference_manager_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefPreferenceManagerCppToC::Get(self)->GetAllPreferences(
include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
preference_manager_can_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefPreferenceManagerCppToC::Get(self)->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
preference_manager_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefPreferenceManagerCppToC::Get(self)->SetPreference(
CefString(name), CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceManagerCppToC::CefPreferenceManagerCppToC() {
GetStruct()->has_preference = preference_manager_has_preference;
GetStruct()->get_preference = preference_manager_get_preference;
GetStruct()->get_all_preferences = preference_manager_get_all_preferences;
GetStruct()->can_set_preference = preference_manager_can_set_preference;
GetStruct()->set_preference = preference_manager_set_preference;
}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceManagerCppToC::~CefPreferenceManagerCppToC() {}
template <>
CefRefPtr<CefPreferenceManager> CefCppToCRefCounted<
CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t>::UnwrapDerived(CefWrapperType type,
cef_preference_manager_t* s) {
if (type == WT_REQUEST_CONTEXT) {
return CefRequestContextCppToC::Unwrap(
reinterpret_cast<cef_request_context_t*>(s));
}
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCRefCounted<CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t>::kWrapperType =
WT_PREFERENCE_MANAGER;

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=d8fe527c202b0c4438c542174f61c553faf851f5$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.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 CefPreferenceManagerCppToC
: public CefCppToCRefCounted<CefPreferenceManagerCppToC,
CefPreferenceManager,
cef_preference_manager_t> {
public:
CefPreferenceManagerCppToC();
virtual ~CefPreferenceManagerCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_MANAGER_CPPTOC_H_

View File

@ -0,0 +1,82 @@
// 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=c20ff60ecd65930e687921444e6c46e90e7cc230$
//
#include "libcef_dll/cpptoc/preference_registrar_cpptoc.h"
#include "libcef_dll/cpptoc/value_cpptoc.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
int CEF_CALLBACK
preference_registrar_add_preference(struct _cef_preference_registrar_t* self,
const cef_string_t* name,
struct _cef_value_t* default_value) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: default_value; type: refptr_same
DCHECK(default_value);
if (!default_value)
return 0;
// Execute
bool _retval = CefPreferenceRegistrarCppToC::Get(self)->AddPreference(
CefString(name), CefValueCppToC::Unwrap(default_value));
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCppToC::CefPreferenceRegistrarCppToC() {
GetStruct()->add_preference = preference_registrar_add_preference;
}
// DESTRUCTOR - Do not edit by hand.
CefPreferenceRegistrarCppToC::~CefPreferenceRegistrarCppToC() {}
template <>
CefOwnPtr<CefPreferenceRegistrar> CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedOwn(CefWrapperType type, cef_preference_registrar_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return CefOwnPtr<CefPreferenceRegistrar>();
}
template <>
CefRawPtr<CefPreferenceRegistrar> CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::
UnwrapDerivedRaw(CefWrapperType type, cef_preference_registrar_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return nullptr;
}
template <>
CefWrapperType CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t>::kWrapperType =
WT_PREFERENCE_REGISTRAR;

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=79809d65530b8405f3fed4adf7c55f8d28f515e0$
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_
#pragma once
#if !defined(BUILDING_CEF_SHARED)
#error This file can be included DLL-side only
#endif
#include "include/capi/cef_preference_capi.h"
#include "include/cef_preference.h"
#include "libcef_dll/cpptoc/cpptoc_scoped.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefPreferenceRegistrarCppToC
: public CefCppToCScoped<CefPreferenceRegistrarCppToC,
CefPreferenceRegistrar,
cef_preference_registrar_t> {
public:
CefPreferenceRegistrarCppToC();
virtual ~CefPreferenceRegistrarCppToC();
};
#endif // CEF_LIBCEF_DLL_CPPTOC_PREFERENCE_REGISTRAR_CPPTOC_H_

View File

@ -9,7 +9,7 @@
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
// $hash=ab7b829bdc8e583b08496227e5e9bebc2b166025$
// $hash=e4711889504d06c942d937a1e61fa48cee26b912$
//
#include "libcef_dll/cpptoc/request_context_cpptoc.h"
@ -238,118 +238,6 @@ int CEF_CALLBACK request_context_clear_scheme_handler_factories(
return _retval;
}
int CEF_CALLBACK
request_context_has_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
request_context_get_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefRequestContextCppToC::Get(self)->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
request_context_get_all_preferences(struct _cef_request_context_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefRequestContextCppToC::Get(self)->GetAllPreferences(
include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_can_set_preference(struct _cef_request_context_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval =
CefRequestContextCppToC::Get(self)->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_set_preference(struct _cef_request_context_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefRequestContextCppToC::Get(self)->SetPreference(
CefString(name), CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
void CEF_CALLBACK request_context_clear_certificate_exceptions(
struct _cef_request_context_t* self,
cef_completion_callback_t* callback) {
@ -551,6 +439,125 @@ request_context_get_media_router(struct _cef_request_context_t* self,
return CefMediaRouterCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_has_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->HasPreference(CefString(name));
// Return type: bool
return _retval;
}
struct _cef_value_t* CEF_CALLBACK
request_context_get_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return NULL;
// Execute
CefRefPtr<CefValue> _retval =
CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->GetPreference(CefString(name));
// Return type: refptr_same
return CefValueCppToC::Wrap(_retval);
}
struct _cef_dictionary_value_t* CEF_CALLBACK
request_context_get_all_preferences(struct _cef_preference_manager_t* self,
int include_defaults) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return NULL;
// Execute
CefRefPtr<CefDictionaryValue> _retval =
CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->GetAllPreferences(include_defaults ? true : false);
// Return type: refptr_same
return CefDictionaryValueCppToC::Wrap(_retval);
}
int CEF_CALLBACK
request_context_can_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->CanSetPreference(CefString(name));
// Return type: bool
return _retval;
}
int CEF_CALLBACK
request_context_set_preference(struct _cef_preference_manager_t* self,
const cef_string_t* name,
struct _cef_value_t* value,
cef_string_t* error) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: name; type: string_byref_const
DCHECK(name);
if (!name)
return 0;
// Verify param: error; type: string_byref
DCHECK(error);
if (!error)
return 0;
// Unverified params: value
// Translate param: error; type: string_byref
CefString errorStr(error);
// Execute
bool _retval = CefRequestContextCppToC::Get(
reinterpret_cast<cef_request_context_t*>(self))
->SetPreference(CefString(name),
CefValueCppToC::Unwrap(value), errorStr);
// Return type: bool
return _retval;
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
@ -566,11 +573,6 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
request_context_register_scheme_handler_factory;
GetStruct()->clear_scheme_handler_factories =
request_context_clear_scheme_handler_factories;
GetStruct()->has_preference = request_context_has_preference;
GetStruct()->get_preference = request_context_get_preference;
GetStruct()->get_all_preferences = request_context_get_all_preferences;
GetStruct()->can_set_preference = request_context_can_set_preference;
GetStruct()->set_preference = request_context_set_preference;
GetStruct()->clear_certificate_exceptions =
request_context_clear_certificate_exceptions;
GetStruct()->clear_http_auth_credentials =
@ -583,6 +585,11 @@ CefRequestContextCppToC::CefRequestContextCppToC() {
GetStruct()->get_extensions = request_context_get_extensions;
GetStruct()->get_extension = request_context_get_extension;
GetStruct()->get_media_router = request_context_get_media_router;
GetStruct()->base.has_preference = request_context_has_preference;
GetStruct()->base.get_preference = request_context_get_preference;
GetStruct()->base.get_all_preferences = request_context_get_all_preferences;
GetStruct()->base.can_set_preference = request_context_can_set_preference;
GetStruct()->base.set_preference = request_context_set_preference;
}
// DESTRUCTOR - Do not edit by hand.