mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-03-16 12:00:13 +01:00
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:
parent
767c4422ac
commit
09bb643ef6
6
BUILD.gn
6
BUILD.gn
@ -611,6 +611,8 @@ source_set("libcef_static") {
|
||||
"libcef/browser/frame_host_impl.cc",
|
||||
"libcef/browser/frame_host_impl.h",
|
||||
"libcef/browser/frame_service_base.h",
|
||||
"libcef/browser/global_preference_manager_impl.cc",
|
||||
"libcef/browser/global_preference_manager_impl.h",
|
||||
"libcef/browser/image_impl.cc",
|
||||
"libcef/browser/image_impl.h",
|
||||
"libcef/browser/iothread_state.cc",
|
||||
@ -709,6 +711,10 @@ source_set("libcef_static") {
|
||||
"libcef/browser/permission_prompt.h",
|
||||
"libcef/browser/prefs/browser_prefs.cc",
|
||||
"libcef/browser/prefs/browser_prefs.h",
|
||||
"libcef/browser/prefs/pref_helper.cc",
|
||||
"libcef/browser/prefs/pref_helper.h",
|
||||
"libcef/browser/prefs/pref_registrar.cc",
|
||||
"libcef/browser/prefs/pref_registrar.h",
|
||||
"libcef/browser/prefs/pref_store.cc",
|
||||
"libcef/browser/prefs/pref_store.h",
|
||||
"libcef/browser/prefs/renderer_prefs.cc",
|
||||
|
@ -8,7 +8,7 @@
|
||||
# by hand. See the translator.README.txt file in the tools directory for
|
||||
# more information.
|
||||
#
|
||||
# $hash=ffc0502a0275b74228f1fd642566d3f020e538a0$
|
||||
# $hash=0373d7e3fc02d16a128a5891aac70af56fb9ddc1$
|
||||
#
|
||||
|
||||
{
|
||||
@ -56,6 +56,7 @@
|
||||
'include/cef_parser.h',
|
||||
'include/cef_path_util.h',
|
||||
'include/cef_permission_handler.h',
|
||||
'include/cef_preference.h',
|
||||
'include/cef_print_handler.h',
|
||||
'include/cef_print_settings.h',
|
||||
'include/cef_process_message.h',
|
||||
@ -159,6 +160,7 @@
|
||||
'include/capi/cef_parser_capi.h',
|
||||
'include/capi/cef_path_util_capi.h',
|
||||
'include/capi/cef_permission_handler_capi.h',
|
||||
'include/capi/cef_preference_capi.h',
|
||||
'include/capi/cef_print_handler_capi.h',
|
||||
'include/capi/cef_print_settings_capi.h',
|
||||
'include/capi/cef_process_message_capi.h',
|
||||
@ -382,6 +384,10 @@
|
||||
'libcef_dll/cpptoc/post_data_cpptoc.h',
|
||||
'libcef_dll/cpptoc/post_data_element_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/post_data_element_cpptoc.h',
|
||||
'libcef_dll/cpptoc/preference_manager_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/preference_manager_cpptoc.h',
|
||||
'libcef_dll/cpptoc/preference_registrar_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/preference_registrar_cpptoc.h',
|
||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.cc',
|
||||
'libcef_dll/cpptoc/print_dialog_callback_cpptoc.h',
|
||||
'libcef_dll/ctocpp/print_handler_ctocpp.cc',
|
||||
@ -706,6 +712,10 @@
|
||||
'libcef_dll/ctocpp/post_data_ctocpp.h',
|
||||
'libcef_dll/ctocpp/post_data_element_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/post_data_element_ctocpp.h',
|
||||
'libcef_dll/ctocpp/preference_manager_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/preference_manager_ctocpp.h',
|
||||
'libcef_dll/ctocpp/preference_registrar_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/preference_registrar_ctocpp.h',
|
||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.cc',
|
||||
'libcef_dll/ctocpp/print_dialog_callback_ctocpp.h',
|
||||
'libcef_dll/cpptoc/print_handler_cpptoc.cc',
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=c4ed4278e513daa2a1ccf42e50e242d61dfbb86f$
|
||||
// $hash=a4d3026623111f1ba226d1579c6b03de3b924457$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_BROWSER_PROCESS_HANDLER_CAPI_H_
|
||||
@ -43,6 +43,7 @@
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_client_capi.h"
|
||||
#include "include/capi/cef_command_line_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -60,6 +61,33 @@ typedef struct _cef_browser_process_handler_t {
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Provides an opportunity to register custom preferences prior to global and
|
||||
/// request context initialization.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||
/// accessed via cef_preference_manager_t::GetGlobalPreferences after
|
||||
/// OnContextInitialized is called. Global preferences are registered a single
|
||||
/// time at application startup. See related cef_settings_t.cache_path and
|
||||
/// cef_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||
/// accessed via the cef_request_context_t after
|
||||
/// cef_request_context_handler_t::OnRequestContextInitialized is called.
|
||||
/// Request context preferences are registered each time a new
|
||||
/// cef_request_context_t is created. It is intended but not required that all
|
||||
/// request contexts have the same registered preferences. See related
|
||||
/// cef_request_context_settings_t.cache_path and
|
||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// Do not keep a reference to the |registrar| object. This function is called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
void(CEF_CALLBACK* on_register_custom_preferences)(
|
||||
struct _cef_browser_process_handler_t* self,
|
||||
cef_preferences_type_t type,
|
||||
struct _cef_preference_registrar_t* registrar);
|
||||
|
||||
///
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
|
148
include/capi/cef_preference_capi.h
Normal file
148
include/capi/cef_preference_capi.h
Normal file
@ -0,0 +1,148 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=eac0782793e7b9c64668f2a22a859357257140ea$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Structure that manages custom preference registrations.
|
||||
///
|
||||
typedef struct _cef_preference_registrar_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_scoped_t base;
|
||||
|
||||
///
|
||||
/// Register a preference with the specified |name| and |default_value|. To
|
||||
/// avoid conflicts with built-in preferences the |name| value should contain
|
||||
/// an application-specific prefix followed by a period (e.g. "myapp.value").
|
||||
/// The contents of |default_value| will be copied. The data type for the
|
||||
/// preference will be inferred from |default_value|'s type and cannot be
|
||||
/// changed after registration. Returns true (1) on success. Returns false (0)
|
||||
/// if |name| is already registered or if |default_value| has an invalid type.
|
||||
/// This function must be called from within the scope of the
|
||||
/// cef_browser_process_handler_t::OnRegisterCustomPreferences callback.
|
||||
///
|
||||
int(CEF_CALLBACK* add_preference)(struct _cef_preference_registrar_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* default_value);
|
||||
} cef_preference_registrar_t;
|
||||
|
||||
///
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
/// cef_browser_process_handler_t::OnRegisterCustomPreferences.
|
||||
///
|
||||
typedef struct _cef_preference_manager_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
} cef_preference_manager_t;
|
||||
|
||||
///
|
||||
/// Returns the global preference manager object.
|
||||
///
|
||||
CEF_EXPORT cef_preference_manager_t* cef_preference_manager_get_global(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_CAPI_H_
|
116
include/capi/cef_preference_manager_capi.h
Normal file
116
include/capi/cef_preference_manager_capi.h
Normal file
@ -0,0 +1,116 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// This file was generated by the CEF translator tool and should not edited
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=1f5dd49cfc5aeb4b673c10750de01768f5cd2694$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
||||
#define CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Manage access to preferences.
|
||||
///
|
||||
typedef struct _cef_preference_manager_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_preference_manager_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_preference_manager_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
} cef_preference_manager_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // CEF_INCLUDE_CAPI_CEF_PREFERENCE_MANAGER_CAPI_H_
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=0c12192146d0ecf006c1f3f294a4c2fd4bec484b$
|
||||
// $hash=62f9dd603840149334ecd1f25222dbda0682b0e6$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_CAPI_H_
|
||||
@ -45,7 +45,7 @@
|
||||
#include "include/capi/cef_extension_capi.h"
|
||||
#include "include/capi/cef_extension_handler_capi.h"
|
||||
#include "include/capi/cef_media_router_capi.h"
|
||||
#include "include/capi/cef_values_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -93,7 +93,7 @@ typedef struct _cef_request_context_t {
|
||||
///
|
||||
/// Base structure.
|
||||
///
|
||||
cef_base_ref_counted_t base;
|
||||
cef_preference_manager_t base;
|
||||
|
||||
///
|
||||
/// Returns true (1) if this object is pointing to the same context as |that|
|
||||
@ -165,58 +165,6 @@ typedef struct _cef_request_context_t {
|
||||
int(CEF_CALLBACK* clear_scheme_handler_factories)(
|
||||
struct _cef_request_context_t* self);
|
||||
|
||||
///
|
||||
/// Returns true (1) if a preference with the specified |name| exists. This
|
||||
/// function must be called on the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* has_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This function must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
struct _cef_value_t*(CEF_CALLBACK* get_preference)(
|
||||
struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true (1)
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This function must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
struct _cef_dictionary_value_t*(CEF_CALLBACK* get_all_preferences)(
|
||||
struct _cef_request_context_t* self,
|
||||
int include_defaults);
|
||||
|
||||
///
|
||||
/// Returns true (1) if the preference with the specified |name| can be
|
||||
/// modified using SetPreference. As one example preferences set via the
|
||||
/// command-line usually cannot be modified. This function must be called on
|
||||
/// the browser process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* can_set_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name);
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true (1) if the
|
||||
/// value is set successfully and false (0) otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This function must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
int(CEF_CALLBACK* set_preference)(struct _cef_request_context_t* self,
|
||||
const cef_string_t* name,
|
||||
struct _cef_value_t* value,
|
||||
cef_string_t* error);
|
||||
|
||||
///
|
||||
/// Clears all certificate exceptions that were added as part of handling
|
||||
/// cef_request_handler_t::on_certificate_error(). If you call this it is
|
||||
|
@ -33,7 +33,7 @@
|
||||
// by hand. See the translator.README.txt file in the tools directory for
|
||||
// more information.
|
||||
//
|
||||
// $hash=e2a1abf4d73bb90fb077cc5642d7b95ac5c11c14$
|
||||
// $hash=c25acf0c0dde9bbd8b9b3526e161aaa9e00445c8$
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CAPI_CEF_REQUEST_CONTEXT_HANDLER_CAPI_H_
|
||||
@ -43,6 +43,7 @@
|
||||
#include "include/capi/cef_base_capi.h"
|
||||
#include "include/capi/cef_browser_capi.h"
|
||||
#include "include/capi/cef_frame_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_request_capi.h"
|
||||
#include "include/capi/cef_resource_request_handler_capi.h"
|
||||
|
||||
|
@ -42,13 +42,13 @@
|
||||
// way that may cause binary incompatibility with other builds. The universal
|
||||
// hash value will change if any platform is affected whereas the platform hash
|
||||
// values will change only if that particular platform is affected.
|
||||
#define CEF_API_HASH_UNIVERSAL "6d1cae87bcec7d95d2a6415ced3101dcfd59381b"
|
||||
#define CEF_API_HASH_UNIVERSAL "043531d536c019ddd0c7c3096e7642bda2748755"
|
||||
#if defined(OS_WIN)
|
||||
#define CEF_API_HASH_PLATFORM "00cf5307a1868e22a8672a4904455ff908b14f9c"
|
||||
#define CEF_API_HASH_PLATFORM "4f82dbb840cb3ce49078c43de0c9d96b4aec37b8"
|
||||
#elif defined(OS_MAC)
|
||||
#define CEF_API_HASH_PLATFORM "f55dd87087c511892883aacd0e55a433f6a04588"
|
||||
#define CEF_API_HASH_PLATFORM "a6da25ff35d7fb833a3f91bc4586a21354c90457"
|
||||
#elif defined(OS_LINUX)
|
||||
#define CEF_API_HASH_PLATFORM "b7e663de88e1af8e8b775f8699463bae6c0d9a0a"
|
||||
#define CEF_API_HASH_PLATFORM "72eeaa876bc8c0a6f2fba5c54c855375683f2b9e"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_client.h"
|
||||
#include "include/cef_command_line.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
@ -51,6 +52,33 @@
|
||||
/*--cef(source=client,no_debugct_check)--*/
|
||||
class CefBrowserProcessHandler : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
/// Provides an opportunity to register custom preferences prior to
|
||||
/// global and request context initialization.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_GLOBAL the registered preferences can be
|
||||
/// accessed via CefPreferenceManager::GetGlobalPreferences after
|
||||
/// OnContextInitialized is called. Global preferences are registered a single
|
||||
/// time at application startup. See related cef_settings_t.cache_path and
|
||||
/// cef_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// If |type| is CEF_PREFERENCES_TYPE_REQUEST_CONTEXT the preferences can be
|
||||
/// accessed via the CefRequestContext after
|
||||
/// CefRequestContextHandler::OnRequestContextInitialized is called. Request
|
||||
/// context preferences are registered each time a new CefRequestContext is
|
||||
/// created. It is intended but not required that all request contexts have
|
||||
/// the same registered preferences. See related
|
||||
/// cef_request_context_settings_t.cache_path and
|
||||
/// cef_request_context_settings_t.persist_user_preferences configuration.
|
||||
///
|
||||
/// Do not keep a reference to the |registrar| object. This method is called
|
||||
/// on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual void OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) {}
|
||||
|
||||
///
|
||||
/// Called on the browser process UI thread immediately after the CEF context
|
||||
/// has been initialized.
|
||||
|
134
include/cef_preference.h
Normal file
134
include/cef_preference.h
Normal file
@ -0,0 +1,134 @@
|
||||
// Copyright (c) 2022 Marshall A. Greenblatt. All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are
|
||||
// met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright
|
||||
// notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above
|
||||
// copyright notice, this list of conditions and the following disclaimer
|
||||
// in the documentation and/or other materials provided with the
|
||||
// distribution.
|
||||
// * Neither the name of Google Inc. nor the name Chromium Embedded
|
||||
// Framework nor the names of its contributors may be used to endorse
|
||||
// or promote products derived from this software without specific prior
|
||||
// written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
// ---------------------------------------------------------------------------
|
||||
//
|
||||
// The contents of this file must follow a specific format in order to
|
||||
// support the CEF translator tool. See the translator.README.txt file in the
|
||||
// tools directory for more information.
|
||||
//
|
||||
|
||||
#ifndef CEF_INCLUDE_CEF_PREFERENCE_H_
|
||||
#define CEF_INCLUDE_CEF_PREFERENCE_H_
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_values.h"
|
||||
|
||||
///
|
||||
/// Class that manages custom preference registrations.
|
||||
///
|
||||
/*--cef(source=library)--*/
|
||||
class CefPreferenceRegistrar : public CefBaseScoped {
|
||||
public:
|
||||
///
|
||||
/// Register a preference with the specified |name| and |default_value|. To
|
||||
/// avoid conflicts with built-in preferences the |name| value should contain
|
||||
/// an application-specific prefix followed by a period (e.g. "myapp.value").
|
||||
/// The contents of |default_value| will be copied. The data type for the
|
||||
/// preference will be inferred from |default_value|'s type and cannot be
|
||||
/// changed after registration. Returns true on success. Returns false if
|
||||
/// |name| is already registered or if |default_value| has an invalid type.
|
||||
/// This method must be called from within the scope of the
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences callback.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool AddPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) = 0;
|
||||
};
|
||||
|
||||
///
|
||||
/// Manage access to preferences. Many built-in preferences are registered by
|
||||
/// Chromium. Custom preferences can be registered in
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
|
||||
///
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefPreferenceManager : public virtual CefBaseRefCounted {
|
||||
public:
|
||||
///
|
||||
/// Returns the global preference manager object.
|
||||
///
|
||||
/*--cef()--*/
|
||||
static CefRefPtr<CefPreferenceManager> GetGlobalPreferenceManager();
|
||||
|
||||
///
|
||||
/// Returns true if a preference with the specified |name| exists. This method
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This method must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This method must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) = 0;
|
||||
|
||||
///
|
||||
/// Returns true if the preference with the specified |name| can be modified
|
||||
/// using SetPreference. As one example preferences set via the command-line
|
||||
/// usually cannot be modified. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanSetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true if the
|
||||
/// value is set successfully and false otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef(optional_param=value)--*/
|
||||
virtual bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) = 0;
|
||||
};
|
||||
|
||||
#endif // CEF_INCLUDE_CEF_PREFERENCE_H_
|
@ -45,7 +45,7 @@
|
||||
#include "include/cef_extension.h"
|
||||
#include "include/cef_extension_handler.h"
|
||||
#include "include/cef_media_router.h"
|
||||
#include "include/cef_values.h"
|
||||
#include "include/cef_preference.h"
|
||||
|
||||
class CefRequestContextHandler;
|
||||
class CefSchemeHandlerFactory;
|
||||
@ -84,7 +84,7 @@ class CefResolveCallback : public virtual CefBaseRefCounted {
|
||||
/// all other request context objects will be ignored.
|
||||
///
|
||||
/*--cef(source=library,no_debugct_check)--*/
|
||||
class CefRequestContext : public virtual CefBaseRefCounted {
|
||||
class CefRequestContext : public CefPreferenceManager {
|
||||
public:
|
||||
///
|
||||
/// Returns the global context object.
|
||||
@ -179,57 +179,6 @@ class CefRequestContext : public virtual CefBaseRefCounted {
|
||||
/*--cef()--*/
|
||||
virtual bool ClearSchemeHandlerFactories() = 0;
|
||||
|
||||
///
|
||||
/// Returns true if a preference with the specified |name| exists. This method
|
||||
/// must be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool HasPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns the value for the preference with the specified |name|. Returns
|
||||
/// NULL if the preference does not exist. The returned object contains a copy
|
||||
/// of the underlying preference value and modifications to the returned
|
||||
/// object will not modify the underlying preference value. This method must
|
||||
/// be called on the browser process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefValue> GetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Returns all preferences as a dictionary. If |include_defaults| is true
|
||||
/// then preferences currently at their default value will be included. The
|
||||
/// returned object contains a copy of the underlying preference values and
|
||||
/// modifications to the returned object will not modify the underlying
|
||||
/// preference values. This method must be called on the browser process UI
|
||||
/// thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) = 0;
|
||||
|
||||
///
|
||||
/// Returns true if the preference with the specified |name| can be modified
|
||||
/// using SetPreference. As one example preferences set via the command-line
|
||||
/// usually cannot be modified. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef()--*/
|
||||
virtual bool CanSetPreference(const CefString& name) = 0;
|
||||
|
||||
///
|
||||
/// Set the |value| associated with preference |name|. Returns true if the
|
||||
/// value is set successfully and false otherwise. If |value| is NULL the
|
||||
/// preference will be restored to its default value. If setting the
|
||||
/// preference fails then |error| will be populated with a detailed
|
||||
/// description of the problem. This method must be called on the browser
|
||||
/// process UI thread.
|
||||
///
|
||||
/*--cef(optional_param=value)--*/
|
||||
virtual bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) = 0;
|
||||
|
||||
///
|
||||
/// Clears all certificate exceptions that were added as part of handling
|
||||
/// CefRequestHandler::OnCertificateError(). If you call this it is
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "include/cef_base.h"
|
||||
#include "include/cef_browser.h"
|
||||
#include "include/cef_frame.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "include/cef_request.h"
|
||||
#include "include/cef_resource_request_handler.h"
|
||||
|
||||
|
@ -3431,6 +3431,19 @@ typedef enum {
|
||||
CEF_TEST_CERT_EXPIRED,
|
||||
} cef_test_cert_type_t;
|
||||
|
||||
///
|
||||
/// Preferences type passed to
|
||||
/// CefBrowserProcessHandler::OnRegisterCustomPreferences.
|
||||
///
|
||||
typedef enum {
|
||||
/// Global preferences registered a single time at application startup.
|
||||
CEF_PREFERENCES_TYPE_GLOBAL,
|
||||
|
||||
/// Request context preferences registered each time a new CefRequestContext
|
||||
/// is created.
|
||||
CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
|
||||
} cef_preferences_type_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
54
libcef/browser/global_preference_manager_impl.cc
Normal file
54
libcef/browser/global_preference_manager_impl.cc
Normal file
@ -0,0 +1,54 @@
|
||||
// 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.
|
||||
|
||||
#include "libcef/browser/global_preference_manager_impl.h"
|
||||
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
|
||||
#include "chrome/browser/browser_process.h"
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::HasPreference(const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::HasPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CefGlobalPreferenceManagerImpl::GetPreference(
|
||||
const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||
return pref_helper::GetPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> CefGlobalPreferenceManagerImpl::GetAllPreferences(
|
||||
bool include_defaults) {
|
||||
CEF_REQUIRE_UIT_RETURN(nullptr);
|
||||
return pref_helper::GetAllPreferences(g_browser_process->local_state(),
|
||||
include_defaults);
|
||||
}
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::CanSetPreference(const CefString& name) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::CanSetPreference(g_browser_process->local_state(), name);
|
||||
}
|
||||
|
||||
bool CefGlobalPreferenceManagerImpl::SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
CEF_REQUIRE_UIT_RETURN(false);
|
||||
return pref_helper::SetPreference(g_browser_process->local_state(), name,
|
||||
value, error);
|
||||
}
|
||||
|
||||
// static
|
||||
CefRefPtr<CefPreferenceManager>
|
||||
CefPreferenceManager::GetGlobalPreferenceManager() {
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return new CefGlobalPreferenceManagerImpl();
|
||||
}
|
35
libcef/browser/global_preference_manager_impl.h
Normal file
35
libcef/browser/global_preference_manager_impl.h
Normal file
@ -0,0 +1,35 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_preference.h"
|
||||
|
||||
// Implementation of the CefPreferenceManager interface for global preferences.
|
||||
class CefGlobalPreferenceManagerImpl : public CefPreferenceManager {
|
||||
public:
|
||||
CefGlobalPreferenceManagerImpl() = default;
|
||||
|
||||
CefGlobalPreferenceManagerImpl(const CefGlobalPreferenceManagerImpl&) =
|
||||
delete;
|
||||
CefGlobalPreferenceManagerImpl& operator=(
|
||||
const CefGlobalPreferenceManagerImpl&) = delete;
|
||||
|
||||
// CefPreferenceManager methods.
|
||||
bool HasPreference(const CefString& name) override;
|
||||
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) override;
|
||||
bool CanSetPreference(const CefString& name) override;
|
||||
bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) override;
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(CefGlobalPreferenceManagerImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_GLOBAL_PREFERENCE_MANAGER_IMPL_H_
|
@ -8,6 +8,7 @@
|
||||
#include "libcef/browser/browser_host_base.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/media_capture_devices_dispatcher.h"
|
||||
#include "libcef/browser/prefs/pref_registrar.h"
|
||||
#include "libcef/browser/prefs/pref_store.h"
|
||||
#include "libcef/browser/prefs/renderer_prefs.h"
|
||||
#include "libcef/common/cef_switches.h"
|
||||
@ -118,18 +119,13 @@ std::string GetAcceptLanguageListSetting(CefBrowserContext* browser_context,
|
||||
const char kUserPrefsFileName[] = "UserPrefs.json";
|
||||
const char kLocalPrefsFileName[] = "LocalPrefs.json";
|
||||
|
||||
void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
|
||||
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_GLOBAL, registry);
|
||||
}
|
||||
|
||||
void RegisterProfilePrefs(PrefRegistrySimple* registry) {
|
||||
const base::CommandLine* command_line =
|
||||
base::CommandLine::ForCurrentProcess();
|
||||
if (command_line->HasSwitch(switches::kEnablePreferenceTesting)) {
|
||||
// Preferences used with unit tests.
|
||||
registry->RegisterBooleanPref("test.bool", true);
|
||||
registry->RegisterIntegerPref("test.int", 2);
|
||||
registry->RegisterDoublePref("test.double", 5.0);
|
||||
registry->RegisterStringPref("test.string", "default");
|
||||
registry->RegisterListPref("test.list");
|
||||
registry->RegisterDictionaryPref("test.dict");
|
||||
}
|
||||
pref_registrar::RegisterCustomPrefs(CEF_PREFERENCES_TYPE_REQUEST_CONTEXT,
|
||||
registry);
|
||||
}
|
||||
|
||||
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
@ -276,7 +272,6 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
privacy_sandbox::RegisterProfilePrefs(registry.get());
|
||||
ProfileNetworkContextService::RegisterProfilePrefs(registry.get());
|
||||
safe_browsing::RegisterProfilePrefs(registry.get());
|
||||
RegisterProfilePrefs(registry.get());
|
||||
|
||||
const std::string& locale =
|
||||
command_line->GetSwitchValueASCII(switches::kLang);
|
||||
@ -339,6 +334,12 @@ std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
base::Value(accept_language_list));
|
||||
}
|
||||
registry->RegisterListPref(prefs::kWebRtcLocalIpsAllowedUrls);
|
||||
|
||||
// Always do this after all other profile prefs.
|
||||
RegisterProfilePrefs(registry.get());
|
||||
} else {
|
||||
// Always do this after all other local state prefs.
|
||||
RegisterLocalStatePrefs(registry.get());
|
||||
}
|
||||
|
||||
// Build the PrefService that manages the PrefRegistry and PrefStores.
|
||||
|
@ -23,10 +23,12 @@ namespace browser_prefs {
|
||||
extern const char kUserPrefsFileName[];
|
||||
|
||||
// Register preferences specific to CEF.
|
||||
void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
|
||||
void RegisterProfilePrefs(PrefRegistrySimple* registry);
|
||||
|
||||
// Create the PrefService used to manage pref registration and storage.
|
||||
// |profile| will be nullptr for the system-level PrefService.
|
||||
// |profile| will be nullptr for the system-level PrefService. Used with the
|
||||
// Alloy runtime only.
|
||||
std::unique_ptr<PrefService> CreatePrefService(Profile* profile,
|
||||
const base::FilePath& cache_path,
|
||||
bool persist_user_preferences);
|
||||
|
120
libcef/browser/prefs/pref_helper.cc
Normal file
120
libcef/browser/prefs/pref_helper.cc
Normal file
@ -0,0 +1,120 @@
|
||||
// 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.
|
||||
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/notreached.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "components/prefs/pref_service.h"
|
||||
|
||||
namespace pref_helper {
|
||||
|
||||
namespace {
|
||||
|
||||
const char* GetTypeString(base::Value::Type type) {
|
||||
switch (type) {
|
||||
case base::Value::Type::NONE:
|
||||
return "NULL";
|
||||
case base::Value::Type::BOOLEAN:
|
||||
return "BOOLEAN";
|
||||
case base::Value::Type::INTEGER:
|
||||
return "INTEGER";
|
||||
case base::Value::Type::DOUBLE:
|
||||
return "DOUBLE";
|
||||
case base::Value::Type::STRING:
|
||||
return "STRING";
|
||||
case base::Value::Type::BINARY:
|
||||
return "BINARY";
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return "DICTIONARY";
|
||||
case base::Value::Type::LIST:
|
||||
return "LIST";
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
bool HasPreference(PrefService* pref_service, const CefString& name) {
|
||||
return (pref_service->FindPreference(name) != nullptr);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
|
||||
const CefString& name) {
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref)
|
||||
return nullptr;
|
||||
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
|
||||
bool include_defaults) {
|
||||
base::Value values = pref_service->GetPreferenceValues(
|
||||
include_defaults ? PrefService::INCLUDE_DEFAULTS
|
||||
: PrefService::EXCLUDE_DEFAULTS);
|
||||
|
||||
// CefDictionaryValueImpl takes ownership of |values|.
|
||||
return new CefDictionaryValueImpl(
|
||||
base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(std::move(values)))
|
||||
.release(),
|
||||
true, false);
|
||||
}
|
||||
|
||||
bool CanSetPreference(PrefService* pref_service, const CefString& name) {
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
return (pref && pref->IsUserModifiable());
|
||||
}
|
||||
|
||||
bool SetPreference(PrefService* pref_service,
|
||||
const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
// The below validation logic should match PrefService::SetUserPrefValue.
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref) {
|
||||
error = "Trying to modify an unregistered preference";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pref->IsUserModifiable()) {
|
||||
error = "Trying to modify a preference that is not user modifiable";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value.get()) {
|
||||
// Reset the preference to its default value.
|
||||
pref_service->ClearPref(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!value->IsValid()) {
|
||||
error = "A valid value is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
if (pref->GetType() != impl_value->type()) {
|
||||
error = base::StringPrintf(
|
||||
"Trying to set a preference of type %s to value of type %s",
|
||||
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// PrefService will make a DeepCopy of |impl_value|.
|
||||
pref_service->Set(name, *impl_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace pref_helper
|
33
libcef/browser/prefs/pref_helper.h
Normal file
33
libcef/browser/prefs/pref_helper.h
Normal file
@ -0,0 +1,33 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
||||
#define CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
||||
|
||||
#include "include/cef_values.h"
|
||||
|
||||
class PrefService;
|
||||
|
||||
namespace pref_helper {
|
||||
|
||||
// Function names and arguments match the CefPreferenceManager interface.
|
||||
|
||||
bool HasPreference(PrefService* pref_service, const CefString& name);
|
||||
|
||||
CefRefPtr<CefValue> GetPreference(PrefService* pref_service,
|
||||
const CefString& name);
|
||||
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(PrefService* pref_service,
|
||||
bool include_defaults);
|
||||
|
||||
bool CanSetPreference(PrefService* pref_service, const CefString& name);
|
||||
|
||||
bool SetPreference(PrefService* pref_service,
|
||||
const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error);
|
||||
|
||||
} // namespace pref_helper
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_HELPER_H_
|
99
libcef/browser/prefs/pref_registrar.cc
Normal file
99
libcef/browser/prefs/pref_registrar.cc
Normal file
@ -0,0 +1,99 @@
|
||||
// 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.
|
||||
|
||||
#include "libcef/browser/prefs/pref_registrar.h"
|
||||
|
||||
#include "include/cef_app.h"
|
||||
#include "include/cef_browser_process_handler.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "components/prefs/pref_registry_simple.h"
|
||||
#include "components/prefs/pref_store.h"
|
||||
|
||||
namespace pref_registrar {
|
||||
|
||||
namespace {
|
||||
|
||||
class CefPreferenceRegistrarImpl : public CefPreferenceRegistrar {
|
||||
public:
|
||||
explicit CefPreferenceRegistrarImpl(PrefRegistrySimple* registry)
|
||||
: registry_(registry) {}
|
||||
|
||||
CefPreferenceRegistrarImpl(const CefPreferenceRegistrarImpl&) = delete;
|
||||
CefPreferenceRegistrarImpl& operator=(const CefPreferenceRegistrarImpl&) =
|
||||
delete;
|
||||
|
||||
// CefPreferenceRegistrar methods.
|
||||
bool AddPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) override {
|
||||
const std::string nameStr = name;
|
||||
if (registry_->defaults()->GetValue(nameStr, nullptr)) {
|
||||
LOG(ERROR) << "Trying to register a previously registered preference: "
|
||||
<< nameStr;
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (default_value->GetType()) {
|
||||
case VTYPE_INVALID:
|
||||
case VTYPE_NULL:
|
||||
case VTYPE_BINARY:
|
||||
break;
|
||||
case VTYPE_BOOL:
|
||||
registry_->RegisterBooleanPref(nameStr, default_value->GetBool());
|
||||
return true;
|
||||
case VTYPE_INT:
|
||||
registry_->RegisterIntegerPref(nameStr, default_value->GetInt());
|
||||
return true;
|
||||
case VTYPE_DOUBLE:
|
||||
registry_->RegisterDoublePref(nameStr, default_value->GetDouble());
|
||||
return true;
|
||||
case VTYPE_STRING:
|
||||
registry_->RegisterStringPref(nameStr, default_value->GetString());
|
||||
return true;
|
||||
case VTYPE_DICTIONARY:
|
||||
case VTYPE_LIST:
|
||||
RegisterComplexPref(nameStr, default_value);
|
||||
return true;
|
||||
};
|
||||
|
||||
LOG(ERROR) << "Invalid value type for preference: " << nameStr;
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
void RegisterComplexPref(const std::string& name,
|
||||
CefRefPtr<CefValue> default_value) {
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(default_value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
// Will make a deep copy of |impl_value|.
|
||||
if (impl_value->type() == base::Value::Type::DICT) {
|
||||
registry_->RegisterDictionaryPref(name, impl_value->Clone());
|
||||
} else if (impl_value->type() == base::Value::Type::LIST) {
|
||||
registry_->RegisterListPref(name, impl_value->Clone());
|
||||
} else {
|
||||
NOTREACHED();
|
||||
}
|
||||
}
|
||||
|
||||
PrefRegistrySimple* const registry_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void RegisterCustomPrefs(cef_preferences_type_t type,
|
||||
PrefRegistrySimple* registry) {
|
||||
if (auto app = CefAppManager::Get()->GetApplication()) {
|
||||
if (auto handler = app->GetBrowserProcessHandler()) {
|
||||
CefPreferenceRegistrarImpl registrar(registry);
|
||||
handler->OnRegisterCustomPreferences(type, ®istrar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace pref_registrar
|
19
libcef/browser/prefs/pref_registrar.h
Normal file
19
libcef/browser/prefs/pref_registrar.h
Normal file
@ -0,0 +1,19 @@
|
||||
// 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.
|
||||
|
||||
#ifndef CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
||||
#define CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
||||
|
||||
#include "include/internal/cef_types.h"
|
||||
|
||||
class PrefRegistrySimple;
|
||||
|
||||
namespace pref_registrar {
|
||||
|
||||
void RegisterCustomPrefs(cef_preferences_type_t type,
|
||||
PrefRegistrySimple* registry);
|
||||
|
||||
} // namespace pref_registrar
|
||||
|
||||
#endif // CEF_LIBCEF_BROWSER_PREFS_PREF_REGISTRAR_H_
|
@ -5,10 +5,10 @@
|
||||
#include "libcef/browser/request_context_impl.h"
|
||||
#include "libcef/browser/browser_context.h"
|
||||
#include "libcef/browser/context.h"
|
||||
#include "libcef/browser/prefs/pref_helper.h"
|
||||
#include "libcef/browser/thread_util.h"
|
||||
#include "libcef/common/app_manager.h"
|
||||
#include "libcef/common/task_runner_impl.h"
|
||||
#include "libcef/common/values_impl.h"
|
||||
|
||||
#include "base/atomic_sequence_num.h"
|
||||
#include "base/logging.h"
|
||||
@ -30,30 +30,6 @@ namespace {
|
||||
|
||||
base::AtomicSequenceNumber g_next_id;
|
||||
|
||||
const char* GetTypeString(base::Value::Type type) {
|
||||
switch (type) {
|
||||
case base::Value::Type::NONE:
|
||||
return "NULL";
|
||||
case base::Value::Type::BOOLEAN:
|
||||
return "BOOLEAN";
|
||||
case base::Value::Type::INTEGER:
|
||||
return "INTEGER";
|
||||
case base::Value::Type::DOUBLE:
|
||||
return "DOUBLE";
|
||||
case base::Value::Type::STRING:
|
||||
return "STRING";
|
||||
case base::Value::Type::BINARY:
|
||||
return "BINARY";
|
||||
case base::Value::Type::DICTIONARY:
|
||||
return "DICTIONARY";
|
||||
case base::Value::Type::LIST:
|
||||
return "LIST";
|
||||
}
|
||||
|
||||
NOTREACHED();
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
class ResolveHostHelper : public network::ResolveHostClientBase {
|
||||
public:
|
||||
explicit ResolveHostHelper(CefRefPtr<CefResolveCallback> callback)
|
||||
@ -380,7 +356,7 @@ bool CefRequestContextImpl::HasPreference(const CefString& name) {
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
return (pref_service->FindPreference(name) != nullptr);
|
||||
return pref_helper::HasPreference(pref_service, name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
|
||||
@ -389,10 +365,7 @@ CefRefPtr<CefValue> CefRequestContextImpl::GetPreference(
|
||||
return nullptr;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref)
|
||||
return nullptr;
|
||||
return new CefValueImpl(pref->GetValue()->CreateDeepCopy().release());
|
||||
return pref_helper::GetPreference(pref_service, name);
|
||||
}
|
||||
|
||||
CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
|
||||
@ -401,17 +374,7 @@ CefRefPtr<CefDictionaryValue> CefRequestContextImpl::GetAllPreferences(
|
||||
return nullptr;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
|
||||
base::Value values = pref_service->GetPreferenceValues(
|
||||
include_defaults ? PrefService::INCLUDE_DEFAULTS
|
||||
: PrefService::EXCLUDE_DEFAULTS);
|
||||
|
||||
// CefDictionaryValueImpl takes ownership of |values|.
|
||||
return new CefDictionaryValueImpl(
|
||||
base::DictionaryValue::From(
|
||||
base::Value::ToUniquePtrValue(std::move(values)))
|
||||
.release(),
|
||||
true, false);
|
||||
return pref_helper::GetAllPreferences(pref_service, include_defaults);
|
||||
}
|
||||
|
||||
bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
|
||||
@ -419,8 +382,7 @@ bool CefRequestContextImpl::CanSetPreference(const CefString& name) {
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
return (pref && pref->IsUserModifiable());
|
||||
return pref_helper::CanSetPreference(pref_service, name);
|
||||
}
|
||||
|
||||
bool CefRequestContextImpl::SetPreference(const CefString& name,
|
||||
@ -430,46 +392,7 @@ bool CefRequestContextImpl::SetPreference(const CefString& name,
|
||||
return false;
|
||||
|
||||
PrefService* pref_service = browser_context()->AsProfile()->GetPrefs();
|
||||
|
||||
// The below validation logic should match PrefService::SetUserPrefValue.
|
||||
|
||||
const PrefService::Preference* pref = pref_service->FindPreference(name);
|
||||
if (!pref) {
|
||||
error = "Trying to modify an unregistered preference";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!pref->IsUserModifiable()) {
|
||||
error = "Trying to modify a preference that is not user modifiable";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!value.get()) {
|
||||
// Reset the preference to its default value.
|
||||
pref_service->ClearPref(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!value->IsValid()) {
|
||||
error = "A valid value is required";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefValueImpl* impl = static_cast<CefValueImpl*>(value.get());
|
||||
|
||||
CefValueImpl::ScopedLockedValue scoped_locked_value(impl);
|
||||
base::Value* impl_value = impl->GetValueUnsafe();
|
||||
|
||||
if (pref->GetType() != impl_value->type()) {
|
||||
error = base::StringPrintf(
|
||||
"Trying to set a preference of type %s to value of type %s",
|
||||
GetTypeString(pref->GetType()), GetTypeString(impl_value->type()));
|
||||
return false;
|
||||
}
|
||||
|
||||
// PrefService will make a DeepCopy of |impl_value|.
|
||||
pref_service->Set(name, *impl_value);
|
||||
return true;
|
||||
return pref_helper::SetPreference(pref_service, name, value, error);
|
||||
}
|
||||
|
||||
void CefRequestContextImpl::ClearCertificateExceptions(
|
||||
|
@ -2,8 +2,8 @@
|
||||
// reserved. Use of this source code is governed by a BSD-style license that
|
||||
// can be found in the LICENSE file.
|
||||
|
||||
#ifndef CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
#define CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
#ifndef CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
|
||||
#define CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include "include/cef_request_context.h"
|
||||
@ -176,4 +176,4 @@ class CefRequestContextImpl : public CefRequestContext {
|
||||
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefRequestContextImpl);
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_REQUEST_CONTEXT_IMPL_H_
|
||||
#endif // CEF_LIBCEF_BROWSER_REQUEST_CONTEXT_IMPL_H_
|
||||
|
@ -91,9 +91,6 @@ const char kDisableScrollBounce[] = "disable-scroll-bounce";
|
||||
// Disable the PDF extension.
|
||||
const char kDisablePdfExtension[] = "disable-pdf-extension";
|
||||
|
||||
// Expose preferences used only by unit tests.
|
||||
const char kEnablePreferenceTesting[] = "enable-preference-testing";
|
||||
|
||||
// Enable print preview.
|
||||
const char kEnablePrintPreview[] = "enable-print-preview";
|
||||
|
||||
|
@ -43,7 +43,6 @@ extern const char kEnableSpellingService[];
|
||||
extern const char kOverrideSpellCheckLang[];
|
||||
extern const char kDisableScrollBounce[];
|
||||
extern const char kDisablePdfExtension[];
|
||||
extern const char kEnablePreferenceTesting[];
|
||||
extern const char kEnablePrintPreview[];
|
||||
extern const char kDisableNewBrowserInfoTimeout[];
|
||||
extern const char kDevToolsProtocolLogFile[];
|
||||
|
@ -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 =
|
||||
|
183
libcef_dll/cpptoc/preference_manager_cpptoc.cc
Normal file
183
libcef_dll/cpptoc/preference_manager_cpptoc.cc
Normal 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;
|
38
libcef_dll/cpptoc/preference_manager_cpptoc.h
Normal file
38
libcef_dll/cpptoc/preference_manager_cpptoc.h
Normal 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_
|
82
libcef_dll/cpptoc/preference_registrar_cpptoc.cc
Normal file
82
libcef_dll/cpptoc/preference_registrar_cpptoc.cc
Normal 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;
|
38
libcef_dll/cpptoc/preference_registrar_cpptoc.h
Normal file
38
libcef_dll/cpptoc/preference_registrar_cpptoc.h
Normal 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_
|
@ -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.
|
||||
|
@ -9,15 +9,40 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=3302f28c60da03b9f5ba5fa110523b353765d1a3$
|
||||
// $hash=c6ad132e54265eb08e748bb22d2c90784ed098b0$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/browser_process_handler_ctocpp.h"
|
||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
|
||||
#include "libcef_dll/cpptoc/preference_registrar_cpptoc.h"
|
||||
#include "libcef_dll/ctocpp/client_ctocpp.h"
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefBrowserProcessHandlerCToCpp::OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) {
|
||||
cef_browser_process_handler_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, on_register_custom_preferences))
|
||||
return;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: registrar; type: rawptr_diff
|
||||
DCHECK(registrar);
|
||||
if (!registrar)
|
||||
return;
|
||||
|
||||
// Translate param: registrar; type: rawptr_diff
|
||||
CefOwnPtr<CefPreferenceRegistrarCppToC> registrarPtr(
|
||||
CefPreferenceRegistrarCppToC::WrapRaw(registrar));
|
||||
|
||||
// Execute
|
||||
_struct->on_register_custom_preferences(_struct, type,
|
||||
registrarPtr->GetStruct());
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefBrowserProcessHandlerCToCpp::OnContextInitialized() {
|
||||
cef_browser_process_handler_t* _struct = GetStruct();
|
||||
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=7a13d15a99d1c92a757b776bb00d932296012054$
|
||||
// $hash=dc8b4fabed723f33f4a5a7e668233a48913da2b4$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_BROWSER_PROCESS_HANDLER_CTOCPP_H_
|
||||
@ -35,6 +35,9 @@ class CefBrowserProcessHandlerCToCpp
|
||||
virtual ~CefBrowserProcessHandlerCToCpp();
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
void OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) override;
|
||||
void OnContextInitialized() override;
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) override;
|
||||
|
166
libcef_dll/ctocpp/preference_manager_ctocpp.cc
Normal file
166
libcef_dll/ctocpp/preference_manager_ctocpp.cc
Normal file
@ -0,0 +1,166 @@
|
||||
// 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=52f3ca6608adcc88d2fb8faf80f53255946880fc$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/preference_manager_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/dictionary_value_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/value_ctocpp.h"
|
||||
|
||||
// STATIC METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefPreferenceManager>
|
||||
CefPreferenceManager::GetGlobalPreferenceManager() {
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_preference_manager_t* _retval = cef_preference_manager_get_global();
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefPreferenceManagerCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefPreferenceManagerCToCpp::HasPreference(const CefString& name) {
|
||||
cef_preference_manager_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, has_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->has_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefValue> CefPreferenceManagerCToCpp::GetPreference(
|
||||
const CefString& name) {
|
||||
cef_preference_manager_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_preference))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return nullptr;
|
||||
|
||||
// Execute
|
||||
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefDictionaryValue> CefPreferenceManagerCToCpp::GetAllPreferences(
|
||||
bool include_defaults) {
|
||||
cef_preference_manager_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dictionary_value_t* _retval =
|
||||
_struct->get_all_preferences(_struct, include_defaults);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDictionaryValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefPreferenceManagerCToCpp::CanSetPreference(const CefString& name) {
|
||||
cef_preference_manager_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefPreferenceManagerCToCpp::SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
cef_preference_manager_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
// Unverified params: value
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->set_preference(_struct, name.GetStruct(),
|
||||
CefValueCToCpp::Unwrap(value),
|
||||
error.GetWritableStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefPreferenceManagerCToCpp::CefPreferenceManagerCToCpp() {}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefPreferenceManagerCToCpp::~CefPreferenceManagerCToCpp() {}
|
||||
|
||||
template <>
|
||||
cef_preference_manager_t* CefCToCppRefCounted<
|
||||
CefPreferenceManagerCToCpp,
|
||||
CefPreferenceManager,
|
||||
cef_preference_manager_t>::UnwrapDerived(CefWrapperType type,
|
||||
CefPreferenceManager* c) {
|
||||
if (type == WT_REQUEST_CONTEXT) {
|
||||
return reinterpret_cast<cef_preference_manager_t*>(
|
||||
CefRequestContextCToCpp::Unwrap(
|
||||
reinterpret_cast<CefRequestContext*>(c)));
|
||||
}
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType CefCToCppRefCounted<CefPreferenceManagerCToCpp,
|
||||
CefPreferenceManager,
|
||||
cef_preference_manager_t>::kWrapperType =
|
||||
WT_PREFERENCE_MANAGER;
|
48
libcef_dll/ctocpp/preference_manager_ctocpp.h
Normal file
48
libcef_dll/ctocpp/preference_manager_ctocpp.h
Normal file
@ -0,0 +1,48 @@
|
||||
// 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=ec2addea82a8ad9018bd3f8e8dee80c998c7229b$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(WRAPPING_CEF_SHARED)
|
||||
#error This file can be included wrapper-side only
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/cef_preference.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 CefPreferenceManagerCToCpp
|
||||
: public CefCToCppRefCounted<CefPreferenceManagerCToCpp,
|
||||
CefPreferenceManager,
|
||||
cef_preference_manager_t> {
|
||||
public:
|
||||
CefPreferenceManagerCToCpp();
|
||||
virtual ~CefPreferenceManagerCToCpp();
|
||||
|
||||
// CefPreferenceManager methods.
|
||||
bool HasPreference(const CefString& name) override;
|
||||
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) override;
|
||||
bool CanSetPreference(const CefString& name) override;
|
||||
bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_MANAGER_CTOCPP_H_
|
77
libcef_dll/ctocpp/preference_registrar_ctocpp.cc
Normal file
77
libcef_dll/ctocpp/preference_registrar_ctocpp.cc
Normal file
@ -0,0 +1,77 @@
|
||||
// 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=c2a2edb07cc7aa06a63a71b626898213712a840a$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/preference_registrar_ctocpp.h"
|
||||
#include "libcef_dll/ctocpp/value_ctocpp.h"
|
||||
|
||||
// VIRTUAL METHODS - Body may be edited by hand.
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefPreferenceRegistrarCToCpp::AddPreference(
|
||||
const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) {
|
||||
cef_preference_registrar_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, add_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
// Verify param: default_value; type: refptr_same
|
||||
DCHECK(default_value.get());
|
||||
if (!default_value.get())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->add_preference(_struct, name.GetStruct(),
|
||||
CefValueCToCpp::Unwrap(default_value));
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefPreferenceRegistrarCToCpp::CefPreferenceRegistrarCToCpp() {}
|
||||
|
||||
// DESTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefPreferenceRegistrarCToCpp::~CefPreferenceRegistrarCToCpp() {}
|
||||
|
||||
template <>
|
||||
cef_preference_registrar_t* CefCToCppScoped<CefPreferenceRegistrarCToCpp,
|
||||
CefPreferenceRegistrar,
|
||||
cef_preference_registrar_t>::
|
||||
UnwrapDerivedOwn(CefWrapperType type, CefOwnPtr<CefPreferenceRegistrar> c) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
cef_preference_registrar_t* CefCToCppScoped<CefPreferenceRegistrarCToCpp,
|
||||
CefPreferenceRegistrar,
|
||||
cef_preference_registrar_t>::
|
||||
UnwrapDerivedRaw(CefWrapperType type, CefRawPtr<CefPreferenceRegistrar> c) {
|
||||
NOTREACHED() << "Unexpected class type: " << type;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <>
|
||||
CefWrapperType CefCToCppScoped<CefPreferenceRegistrarCToCpp,
|
||||
CefPreferenceRegistrar,
|
||||
cef_preference_registrar_t>::kWrapperType =
|
||||
WT_PREFERENCE_REGISTRAR;
|
42
libcef_dll/ctocpp/preference_registrar_ctocpp.h
Normal file
42
libcef_dll/ctocpp/preference_registrar_ctocpp.h
Normal 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=ca84e9c8992668fc127f6aed0136687f0d5ce0a3$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_
|
||||
#define CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_
|
||||
#pragma once
|
||||
|
||||
#if !defined(WRAPPING_CEF_SHARED)
|
||||
#error This file can be included wrapper-side only
|
||||
#endif
|
||||
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/cef_preference.h"
|
||||
#include "libcef_dll/ctocpp/ctocpp_scoped.h"
|
||||
|
||||
// Wrap a C structure with a C++ class.
|
||||
// This class may be instantiated and accessed wrapper-side only.
|
||||
class CefPreferenceRegistrarCToCpp
|
||||
: public CefCToCppScoped<CefPreferenceRegistrarCToCpp,
|
||||
CefPreferenceRegistrar,
|
||||
cef_preference_registrar_t> {
|
||||
public:
|
||||
CefPreferenceRegistrarCToCpp();
|
||||
virtual ~CefPreferenceRegistrarCToCpp();
|
||||
|
||||
// CefPreferenceRegistrar methods.
|
||||
bool AddPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> default_value) override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_PREFERENCE_REGISTRAR_CTOCPP_H_
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=34a53ca8c93eb3dd0999d9e34d3f86307995e82d$
|
||||
// $hash=8abfb084742cdd3ed31754a33281f0eacfc5fceb$
|
||||
//
|
||||
|
||||
#include "libcef_dll/ctocpp/request_context_ctocpp.h"
|
||||
@ -225,109 +225,6 @@ bool CefRequestContextCToCpp::ClearSchemeHandlerFactories() {
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::HasPreference(const CefString& name) {
|
||||
cef_request_context_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, has_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->has_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefValue> CefRequestContextCToCpp::GetPreference(
|
||||
const CefString& name) {
|
||||
cef_request_context_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_preference))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return nullptr;
|
||||
|
||||
// Execute
|
||||
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefDictionaryValue> CefRequestContextCToCpp::GetAllPreferences(
|
||||
bool include_defaults) {
|
||||
cef_request_context_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dictionary_value_t* _retval =
|
||||
_struct->get_all_preferences(_struct, include_defaults);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDictionaryValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::CanSetPreference(const CefString& name) {
|
||||
cef_request_context_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
cef_request_context_t* _struct = GetStruct();
|
||||
if (CEF_MEMBER_MISSING(_struct, set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
// Unverified params: value
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->set_preference(_struct, name.GetStruct(),
|
||||
CefValueCToCpp::Unwrap(value),
|
||||
error.GetWritableStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
void CefRequestContextCToCpp::ClearCertificateExceptions(
|
||||
CefRefPtr<CefCompletionCallback> callback) {
|
||||
@ -533,6 +430,114 @@ CefRefPtr<CefMediaRouter> CefRequestContextCToCpp::GetMediaRouter(
|
||||
return CefMediaRouterCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::HasPreference(const CefString& name) {
|
||||
cef_preference_manager_t* _struct =
|
||||
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
|
||||
if (CEF_MEMBER_MISSING(_struct, has_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->has_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefValue> CefRequestContextCToCpp::GetPreference(
|
||||
const CefString& name) {
|
||||
cef_preference_manager_t* _struct =
|
||||
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
|
||||
if (CEF_MEMBER_MISSING(_struct, get_preference))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return nullptr;
|
||||
|
||||
// Execute
|
||||
cef_value_t* _retval = _struct->get_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
CefRefPtr<CefDictionaryValue> CefRequestContextCToCpp::GetAllPreferences(
|
||||
bool include_defaults) {
|
||||
cef_preference_manager_t* _struct =
|
||||
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
|
||||
if (CEF_MEMBER_MISSING(_struct, get_all_preferences))
|
||||
return nullptr;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Execute
|
||||
cef_dictionary_value_t* _retval =
|
||||
_struct->get_all_preferences(_struct, include_defaults);
|
||||
|
||||
// Return type: refptr_same
|
||||
return CefDictionaryValueCToCpp::Wrap(_retval);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::CanSetPreference(const CefString& name) {
|
||||
cef_preference_manager_t* _struct =
|
||||
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
|
||||
if (CEF_MEMBER_MISSING(_struct, can_set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->can_set_preference(_struct, name.GetStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
bool CefRequestContextCToCpp::SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) {
|
||||
cef_preference_manager_t* _struct =
|
||||
reinterpret_cast<cef_preference_manager_t*>(GetStruct());
|
||||
if (CEF_MEMBER_MISSING(_struct, set_preference))
|
||||
return false;
|
||||
|
||||
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
|
||||
|
||||
// Verify param: name; type: string_byref_const
|
||||
DCHECK(!name.empty());
|
||||
if (name.empty())
|
||||
return false;
|
||||
// Unverified params: value
|
||||
|
||||
// Execute
|
||||
int _retval = _struct->set_preference(_struct, name.GetStruct(),
|
||||
CefValueCToCpp::Unwrap(value),
|
||||
error.GetWritableStruct());
|
||||
|
||||
// Return type: bool
|
||||
return _retval ? true : false;
|
||||
}
|
||||
|
||||
// CONSTRUCTOR - Do not edit by hand.
|
||||
|
||||
CefRequestContextCToCpp::CefRequestContextCToCpp() {}
|
||||
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=693f5845874072abc324f643981531ed08d17b37$
|
||||
// $hash=92f03524a854cd701e24fadc9680585ef875a8c8$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
|
||||
@ -52,14 +52,6 @@ class CefRequestContextCToCpp
|
||||
const CefString& domain_name,
|
||||
CefRefPtr<CefSchemeHandlerFactory> factory) override;
|
||||
bool ClearSchemeHandlerFactories() override;
|
||||
bool HasPreference(const CefString& name) override;
|
||||
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) override;
|
||||
bool CanSetPreference(const CefString& name) override;
|
||||
bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) override;
|
||||
void ClearCertificateExceptions(
|
||||
CefRefPtr<CefCompletionCallback> callback) override;
|
||||
void ClearHttpAuthCredentials(
|
||||
@ -76,6 +68,16 @@ class CefRequestContextCToCpp
|
||||
CefRefPtr<CefExtension> GetExtension(const CefString& extension_id) override;
|
||||
CefRefPtr<CefMediaRouter> GetMediaRouter(
|
||||
CefRefPtr<CefCompletionCallback> callback) override;
|
||||
|
||||
// CefPreferenceManager methods.
|
||||
bool HasPreference(const CefString& name) override;
|
||||
CefRefPtr<CefValue> GetPreference(const CefString& name) override;
|
||||
CefRefPtr<CefDictionaryValue> GetAllPreferences(
|
||||
bool include_defaults) override;
|
||||
bool CanSetPreference(const CefString& name) override;
|
||||
bool SetPreference(const CefString& name,
|
||||
CefRefPtr<CefValue> value,
|
||||
CefString& error) override;
|
||||
};
|
||||
|
||||
#endif // CEF_LIBCEF_DLL_CTOCPP_REQUEST_CONTEXT_CTOCPP_H_
|
||||
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=b5dc1bb07ea5cbf057bf40491fdcdddeb58dfa57$
|
||||
// $hash=aa73ff15eb79f0e7f89338db9001e2876d2a3a6e$
|
||||
//
|
||||
|
||||
#include <dlfcn.h>
|
||||
@ -30,6 +30,7 @@
|
||||
#include "include/capi/cef_origin_whitelist_capi.h"
|
||||
#include "include/capi/cef_parser_capi.h"
|
||||
#include "include/capi/cef_path_util_capi.h"
|
||||
#include "include/capi/cef_preference_capi.h"
|
||||
#include "include/capi/cef_print_settings_capi.h"
|
||||
#include "include/capi/cef_process_message_capi.h"
|
||||
#include "include/capi/cef_process_util_capi.h"
|
||||
@ -155,6 +156,8 @@ struct libcef_pointers {
|
||||
decltype(&cef_image_create) cef_image_create;
|
||||
decltype(&cef_media_router_get_global) cef_media_router_get_global;
|
||||
decltype(&cef_menu_model_create) cef_menu_model_create;
|
||||
decltype(&cef_preference_manager_get_global)
|
||||
cef_preference_manager_get_global;
|
||||
decltype(&cef_print_settings_create) cef_print_settings_create;
|
||||
decltype(&cef_process_message_create) cef_process_message_create;
|
||||
decltype(&cef_request_create) cef_request_create;
|
||||
@ -385,6 +388,7 @@ int libcef_init_pointers(const char* path) {
|
||||
INIT_ENTRY(cef_image_create);
|
||||
INIT_ENTRY(cef_media_router_get_global);
|
||||
INIT_ENTRY(cef_menu_model_create);
|
||||
INIT_ENTRY(cef_preference_manager_get_global);
|
||||
INIT_ENTRY(cef_print_settings_create);
|
||||
INIT_ENTRY(cef_process_message_create);
|
||||
INIT_ENTRY(cef_request_create);
|
||||
@ -900,6 +904,11 @@ struct _cef_menu_model_t* cef_menu_model_create(
|
||||
return g_libcef_pointers.cef_menu_model_create(delegate);
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
struct _cef_preference_manager_t* cef_preference_manager_get_global() {
|
||||
return g_libcef_pointers.cef_preference_manager_get_global();
|
||||
}
|
||||
|
||||
NO_SANITIZE("cfi-icall")
|
||||
struct _cef_print_settings_t* cef_print_settings_create() {
|
||||
return g_libcef_pointers.cef_print_settings_create();
|
||||
|
@ -9,7 +9,7 @@
|
||||
// implementations. See the translator.README.txt file in the tools directory
|
||||
// for more information.
|
||||
//
|
||||
// $hash=15d99837c9ebf79df1d1ec2bab84900260410046$
|
||||
// $hash=e8bf5997bf7a4e77f39247068da48b539ef838b0$
|
||||
//
|
||||
|
||||
#ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_
|
||||
@ -100,6 +100,8 @@ enum CefWrapperType {
|
||||
WT_PERMISSION_PROMPT_CALLBACK,
|
||||
WT_POST_DATA,
|
||||
WT_POST_DATA_ELEMENT,
|
||||
WT_PREFERENCE_MANAGER,
|
||||
WT_PREFERENCE_REGISTRAR,
|
||||
WT_PRINT_DIALOG_CALLBACK,
|
||||
WT_PRINT_HANDLER,
|
||||
WT_PRINT_JOB_CALLBACK,
|
||||
|
@ -324,7 +324,7 @@ index 10b5cf030a944..49b773042ad24 100644
|
||||
#endif
|
||||
|
||||
diff --git chrome/browser/prefs/browser_prefs.cc chrome/browser/prefs/browser_prefs.cc
|
||||
index 621b03d86a86a..9123aa34187d1 100644
|
||||
index 621b03d86a86a..c5a24d944f984 100644
|
||||
--- chrome/browser/prefs/browser_prefs.cc
|
||||
+++ chrome/browser/prefs/browser_prefs.cc
|
||||
@@ -11,6 +11,7 @@
|
||||
@ -346,14 +346,26 @@ index 621b03d86a86a..9123aa34187d1 100644
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
#include "chrome/browser/accessibility/animation_policy_prefs.h"
|
||||
#include "chrome/browser/apps/platform_apps/shortcut_manager.h"
|
||||
@@ -1321,6 +1326,10 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
|
||||
SessionDataService::RegisterProfilePrefs(registry);
|
||||
#endif
|
||||
@@ -1228,6 +1233,11 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
|
||||
|
||||
// This is intentionally last.
|
||||
RegisterLocalStatePrefsForMigration(registry);
|
||||
+
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ // Always call this last.
|
||||
+ browser_prefs::RegisterLocalStatePrefs(registry);
|
||||
+#endif
|
||||
}
|
||||
|
||||
// Register prefs applicable to all profiles.
|
||||
@@ -1602,6 +1612,10 @@ void RegisterUserProfilePrefs(user_prefs::PrefRegistrySyncable* registry,
|
||||
const std::string& locale) {
|
||||
RegisterProfilePrefs(registry, locale);
|
||||
|
||||
+#if BUILDFLAG(ENABLE_CEF)
|
||||
+ browser_prefs::RegisterProfilePrefs(registry);
|
||||
+#endif
|
||||
+
|
||||
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
||||
ExtensionWebUI::RegisterProfilePrefs(registry);
|
||||
RegisterAnimationPolicyPrefs(registry);
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
::android::RegisterUserProfilePrefs(registry);
|
||||
#endif
|
||||
|
@ -36,24 +36,67 @@ std::string* PendingAction() {
|
||||
return &str;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateBoolValue(bool value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetBool(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateIntValue(int value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetInt(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateDoubleValue(double value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetDouble(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateStringValue(const std::string& value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetString(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateListValue(CefRefPtr<CefListValue> value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetList(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
CefRefPtr<CefValue> CreateDictionaryValue(CefRefPtr<CefDictionaryValue> value) {
|
||||
auto val = CefValue::Create();
|
||||
val->SetDictionary(value);
|
||||
return val;
|
||||
}
|
||||
|
||||
// Browser-side app delegate.
|
||||
class PreferenceBrowserTest : public client::ClientAppBrowser::Delegate {
|
||||
public:
|
||||
PreferenceBrowserTest() {}
|
||||
|
||||
void OnBeforeCommandLineProcessing(
|
||||
void OnRegisterCustomPreferences(
|
||||
CefRefPtr<client::ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) override {
|
||||
// Enables testing of preferences.
|
||||
// See CefBrowserPrefStore::CreateService.
|
||||
command_line->AppendSwitch("enable-preference-testing");
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) override {
|
||||
// Register test preferences.
|
||||
registrar->AddPreference(kPrefTestBool, CreateBoolValue(true));
|
||||
registrar->AddPreference(kPrefTestInt, CreateIntValue(2));
|
||||
registrar->AddPreference(kPrefTestDouble, CreateDoubleValue(5.0));
|
||||
registrar->AddPreference(kPrefTestString, CreateStringValue("default"));
|
||||
registrar->AddPreference(kPrefTestList,
|
||||
CreateListValue(CefListValue::Create()));
|
||||
registrar->AddPreference(
|
||||
kPrefTestDict, CreateDictionaryValue(CefDictionaryValue::Create()));
|
||||
}
|
||||
|
||||
private:
|
||||
IMPLEMENT_REFCOUNTING(PreferenceBrowserTest);
|
||||
};
|
||||
|
||||
void ValidateReset(CefRefPtr<CefRequestContext> context, const char* name) {
|
||||
void ValidateReset(CefRefPtr<CefPreferenceManager> context, const char* name) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
@ -62,117 +105,99 @@ void ValidateReset(CefRefPtr<CefRequestContext> context, const char* name) {
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
void ValidateBool(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateBool(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
bool expected,
|
||||
const char* name = kPrefTestBool) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetBool(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(context->SetPreference(name, CreateBoolValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_BOOL, value->GetType());
|
||||
EXPECT_EQ(expected, value->GetBool()) << *PendingAction();
|
||||
}
|
||||
|
||||
void ValidateInt(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateInt(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
int expected,
|
||||
const char* name = kPrefTestInt) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetInt(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(context->SetPreference(name, CreateIntValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_INT, value->GetType());
|
||||
EXPECT_EQ(expected, value->GetInt()) << *PendingAction();
|
||||
}
|
||||
|
||||
void ValidateDouble(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateDouble(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
double expected,
|
||||
const char* name = kPrefTestDouble) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetDouble(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(
|
||||
context->SetPreference(name, CreateDoubleValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_DOUBLE, value->GetType());
|
||||
EXPECT_EQ(expected, value->GetDouble()) << *PendingAction();
|
||||
}
|
||||
|
||||
void ValidateString(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateString(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
const std::string& expected,
|
||||
const char* name = kPrefTestString) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetString(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(
|
||||
context->SetPreference(name, CreateStringValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_STRING, value->GetType());
|
||||
EXPECT_STREQ(expected.c_str(), value->GetString().ToString().c_str())
|
||||
<< *PendingAction();
|
||||
}
|
||||
|
||||
void ValidateList(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateList(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
CefRefPtr<CefListValue> expected,
|
||||
const char* name = kPrefTestList) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetList(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(context->SetPreference(name, CreateListValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_LIST, value->GetType());
|
||||
CefRefPtr<CefListValue> list_val = value->GetList();
|
||||
@ -180,24 +205,21 @@ void ValidateList(CefRefPtr<CefRequestContext> context,
|
||||
TestListEqual(expected, list_val);
|
||||
}
|
||||
|
||||
void ValidateDict(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateDict(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
CefRefPtr<CefDictionaryValue> expected,
|
||||
const char* name = kPrefTestDict) {
|
||||
EXPECT_TRUE(context->HasPreference(name));
|
||||
EXPECT_TRUE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetDictionary(expected);
|
||||
CefString error;
|
||||
EXPECT_TRUE(context->SetPreference(name, value, error));
|
||||
EXPECT_TRUE(
|
||||
context->SetPreference(name, CreateDictionaryValue(expected), error));
|
||||
EXPECT_TRUE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_TRUE(value.get());
|
||||
EXPECT_EQ(VTYPE_DICTIONARY, value->GetType());
|
||||
CefRefPtr<CefDictionaryValue> dict_val = value->GetDictionary();
|
||||
@ -205,28 +227,24 @@ void ValidateDict(CefRefPtr<CefRequestContext> context,
|
||||
TestDictionaryEqual(expected, dict_val);
|
||||
}
|
||||
|
||||
void ValidateNoExist(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateNoExist(CefRefPtr<CefPreferenceManager> context,
|
||||
bool set,
|
||||
const char* name = kPrefTestNoExist) {
|
||||
EXPECT_FALSE(context->HasPreference(name));
|
||||
EXPECT_FALSE(context->CanSetPreference(name));
|
||||
|
||||
CefRefPtr<CefValue> value;
|
||||
|
||||
if (set) {
|
||||
value = CefValue::Create();
|
||||
value->SetBool(false);
|
||||
CefString error;
|
||||
EXPECT_FALSE(context->SetPreference(name, value, error));
|
||||
EXPECT_FALSE(context->SetPreference(name, CreateBoolValue(false), error));
|
||||
EXPECT_FALSE(error.empty());
|
||||
}
|
||||
|
||||
value = context->GetPreference(name);
|
||||
auto value = context->GetPreference(name);
|
||||
EXPECT_FALSE(value.get()) << *PendingAction();
|
||||
}
|
||||
|
||||
void PopulateRootDefaults(CefRefPtr<CefDictionaryValue> val) {
|
||||
// Should match the values in CefBrowserPrefStore::CreateService.
|
||||
// Should match the values in OnRegisterCustomPreferences.
|
||||
val->SetBool(kPrefBool, true);
|
||||
val->SetInt(kPrefInt, 2);
|
||||
val->SetDouble(kPrefDouble, 5.0);
|
||||
@ -246,7 +264,7 @@ void ValidateRoot(CefRefPtr<CefDictionaryValue> root,
|
||||
}
|
||||
|
||||
// Validate getting default values.
|
||||
void ValidateDefaults(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateDefaults(CefRefPtr<CefPreferenceManager> context,
|
||||
bool reset,
|
||||
CefRefPtr<CefWaitableEvent> event) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
@ -322,7 +340,7 @@ void PopulateRootSet(CefRefPtr<CefDictionaryValue> val) {
|
||||
}
|
||||
|
||||
// Validate getting and setting values.
|
||||
void ValidateSetGet(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateSetGet(CefRefPtr<CefPreferenceManager> context,
|
||||
CefRefPtr<CefWaitableEvent> event) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
CefPostTask(TID_UI, base::BindOnce(ValidateSetGet, context, event));
|
||||
@ -359,7 +377,7 @@ void ValidateSetGet(CefRefPtr<CefRequestContext> context,
|
||||
}
|
||||
|
||||
// Validate getting values.
|
||||
void ValidateGet(CefRefPtr<CefRequestContext> context,
|
||||
void ValidateGet(CefRefPtr<CefPreferenceManager> context,
|
||||
CefRefPtr<CefWaitableEvent> event) {
|
||||
if (!CefCurrentlyOn(TID_UI)) {
|
||||
CefPostTask(TID_UI, base::BindOnce(ValidateGet, context, event));
|
||||
@ -418,11 +436,39 @@ class TestRequestContextHandler : public CefRequestContextHandler {
|
||||
|
||||
} // namespace
|
||||
|
||||
// Verify default preference values on the global context.
|
||||
// Verify default preference values on the global state.
|
||||
TEST(PreferenceTest, GlobalDefaults) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
auto context = CefPreferenceManager::GetGlobalPreferenceManager();
|
||||
EXPECT_TRUE(context.get());
|
||||
|
||||
ValidateDefaults(context, false, event);
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify setting/getting preference values on the global state.
|
||||
TEST(PreferenceTest, GlobalSetGet) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
auto context = CefPreferenceManager::GetGlobalPreferenceManager();
|
||||
EXPECT_TRUE(context.get());
|
||||
|
||||
ValidateSetGet(context, event);
|
||||
event->Wait();
|
||||
|
||||
// Reset to the default values.
|
||||
ValidateDefaults(context, true, event);
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify default preference values on the global request context.
|
||||
TEST(PreferenceTest, RequestContextGlobalDefaults) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
CefRefPtr<CefRequestContext> context = CefRequestContext::GetGlobalContext();
|
||||
EXPECT_TRUE(context.get());
|
||||
|
||||
@ -430,8 +476,8 @@ TEST(PreferenceTest, GlobalDefaults) {
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify setting/getting preference values on the global context.
|
||||
TEST(PreferenceTest, GlobalSetGet) {
|
||||
// Verify setting/getting preference values on the global request context.
|
||||
TEST(PreferenceTest, RequestContextGlobalSetGet) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
@ -446,8 +492,8 @@ TEST(PreferenceTest, GlobalSetGet) {
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify setting/getting preference values on shared global contexts.
|
||||
TEST(PreferenceTest, GlobalSetGetShared) {
|
||||
// Verify setting/getting preference values on shared global request contexts.
|
||||
TEST(PreferenceTest, RequestContextGlobalSetGetShared) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
@ -505,8 +551,8 @@ TEST(PreferenceTest, GlobalSetGetShared) {
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify default preference values on a custom context.
|
||||
TEST(PreferenceTest, CustomDefaults) {
|
||||
// Verify default preference values on a custom request context.
|
||||
TEST(PreferenceTest, RequestContextCustomDefaults) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
@ -521,8 +567,8 @@ TEST(PreferenceTest, CustomDefaults) {
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify setting/getting preference values on a custom context.
|
||||
TEST(PreferenceTest, CustomSetGet) {
|
||||
// Verify setting/getting preference values on a custom request context.
|
||||
TEST(PreferenceTest, RequestContextCustomSetGet) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
@ -541,8 +587,8 @@ TEST(PreferenceTest, CustomSetGet) {
|
||||
event->Wait();
|
||||
}
|
||||
|
||||
// Verify setting/getting preference values on shared custom contexts.
|
||||
TEST(PreferenceTest, CustomSetGetShared) {
|
||||
// Verify setting/getting preference values on shared custom request contexts.
|
||||
TEST(PreferenceTest, RequestContextCustomSetGetShared) {
|
||||
CefRefPtr<CefWaitableEvent> event =
|
||||
CefWaitableEvent::CreateWaitableEvent(true, false);
|
||||
|
||||
|
@ -87,6 +87,14 @@ void ClientAppBrowser::OnBeforeCommandLineProcessing(
|
||||
}
|
||||
}
|
||||
|
||||
void ClientAppBrowser::OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
(*it)->OnRegisterCustomPreferences(this, type, registrar);
|
||||
}
|
||||
|
||||
void ClientAppBrowser::OnContextInitialized() {
|
||||
DelegateSet::iterator it = delegates_.begin();
|
||||
for (; it != delegates_.end(); ++it)
|
||||
|
@ -24,6 +24,11 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
CefRefPtr<CefCommandLine> command_line) {}
|
||||
|
||||
virtual void OnRegisterCustomPreferences(
|
||||
CefRefPtr<ClientAppBrowser> app,
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) {}
|
||||
|
||||
virtual void OnContextInitialized(CefRefPtr<ClientAppBrowser> app) {}
|
||||
|
||||
virtual void OnBeforeChildProcessLaunch(
|
||||
@ -59,6 +64,9 @@ class ClientAppBrowser : public ClientApp, public CefBrowserProcessHandler {
|
||||
}
|
||||
|
||||
// CefBrowserProcessHandler methods.
|
||||
void OnRegisterCustomPreferences(
|
||||
cef_preferences_type_t type,
|
||||
CefRawPtr<CefPreferenceRegistrar> registrar) override;
|
||||
void OnContextInitialized() override;
|
||||
void OnBeforeChildProcessLaunch(
|
||||
CefRefPtr<CefCommandLine> command_line) override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user