Add methods for configuring website/content settings (fixes #3490)

This approach is now used to allow popups on a case-by-case basis in
tests instead of globally disabling the popup blocker with the Chrome
runtime.
This commit is contained in:
Marshall Greenblatt
2023-05-25 11:15:06 +00:00
parent ecdfd467f8
commit 5707889555
18 changed files with 1005 additions and 27 deletions

View File

@@ -46,6 +46,7 @@
#include "include/cef_extension_handler.h"
#include "include/cef_media_router.h"
#include "include/cef_preference.h"
#include "include/cef_values.h"
class CefRequestContextHandler;
class CefSchemeHandlerFactory;
@@ -314,6 +315,72 @@ class CefRequestContext : public CefPreferenceManager {
/*--cef(optional_param=callback)--*/
virtual CefRefPtr<CefMediaRouter> GetMediaRouter(
CefRefPtr<CefCompletionCallback> callback) = 0;
///
/// Returns the current value for |content_type| that applies for the
/// specified URLs. If both URLs are empty the default value will be returned.
/// Returns nullptr if no value is configured. Must be called on the browser
/// process UI thread.
///
/*--cef(optional_param=requesting_url,optional_param=top_level_url)--*/
virtual CefRefPtr<CefValue> GetWebsiteSetting(
const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) = 0;
///
/// Sets the current value for |content_type| for the specified URLs in the
/// default scope. If both URLs are empty, and the context is not incognito,
/// the default value will be set. Pass nullptr for |value| to remove the
/// default value for this content type.
///
/// WARNING: Incorrect usage of this method may cause instability or security
/// issues in Chromium. Make sure that you first understand the potential
/// impact of any changes to |content_type| by reviewing the related source
/// code in Chromium. For example, if you plan to modify
/// CEF_CONTENT_SETTING_TYPE_POPUPS, first review and understand the usage of
/// ContentSettingsType::POPUPS in Chromium:
/// https://source.chromium.org/search?q=ContentSettingsType::POPUPS
///
/*--cef(optional_param=requesting_url,optional_param=top_level_url,
optional_param=value)--*/
virtual void SetWebsiteSetting(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type,
CefRefPtr<CefValue> value) = 0;
///
/// Returns the current value for |content_type| that applies for the
/// specified URLs. If both URLs are empty the default value will be returned.
/// Returns CEF_CONTENT_SETTING_VALUE_DEFAULT if no value is configured. Must
/// be called on the browser process UI thread.
///
/*--cef(optional_param=requesting_url,optional_param=top_level_url,
default_retval=CEF_CONTENT_SETTING_VALUE_DEFAULT)--*/
virtual cef_content_setting_values_t GetContentSetting(
const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type) = 0;
///
/// Sets the current value for |content_type| for the specified URLs in the
/// default scope. If both URLs are empty, and the context is not incognito,
/// the default value will be set. Pass CEF_CONTENT_SETTING_VALUE_DEFAULT for
/// |value| to use the default value for this content type.
///
/// WARNING: Incorrect usage of this method may cause instability or security
/// issues in Chromium. Make sure that you first understand the potential
/// impact of any changes to |content_type| by reviewing the related source
/// code in Chromium. For example, if you plan to modify
/// CEF_CONTENT_SETTING_TYPE_POPUPS, first review and understand the usage of
/// ContentSettingsType::POPUPS in Chromium:
/// https://source.chromium.org/search?q=ContentSettingsType::POPUPS
///
/*--cef(optional_param=requesting_url,optional_param=top_level_url)--*/
virtual void SetContentSetting(const CefString& requesting_url,
const CefString& top_level_url,
cef_content_setting_types_t content_type,
cef_content_setting_values_t value) = 0;
};
#endif // CEF_INCLUDE_CEF_REQUEST_CONTEXT_H_