![]() |
UCefView
|
Represents the Chromium Embedded Framework (CEF) context within Unreal Engine. This class acts as a subsystem, providing centralized access to CEF features such as resource mapping, cookie management, and cross-origin resource sharing (CORS) configuration. All browser instances created after modifying this context will inherit its settings and mappings. More...
#include <CefContext.h>
Public Member Functions | |
bool | bIsCefInitialized () const |
Checks whether the CEF context has been successfully initialized and is ready for use. | |
void | AddLocalFolderResource (const FString &InPath, const FString &InUrl, int32 InPriority=0) |
Registers a local folder as a web resource directory, mapping it to a specified URL. All browser instances created after this call will be able to access the folder's contents via the mapped URL. | |
void | AddArchiveFileResource (const FString &pInPathath, const FString &InUrl, const FString &InPassword, int32 InPriority=0) |
Registers a local archive file (such as a .zip) as a web resource, mapping its contents to a specified URL. All browser instances created after this call will be able to access the archive's contents via the mapped URL. | |
bool | AddCookie (const FString &InName, const FString &InValue, const FString &InDomain, const FString &InUrl) |
Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context. | |
bool | DeleteAllCookies () |
Deletes all cookies from the CEF context. | |
bool | AddCrossOriginWhitelistEntry (const FString &InSourceOrigin, const FString &InTargetSchema, const FString &InTargetDomain, bool InAllowTargetSubdomains) |
Adds an entry to the cross-origin access whitelist for the CEF context, allowing specific cross-origin requests from a given source origin to a target schema and domain. This enables controlled CORS (Cross-Origin Resource Sharing) behavior for browser instances managed by this context. | |
bool | RemoveCrossOriginWhitelistEntry (const FString &InSourceOrigin, const FString &InTargetSchema, const FString &InTargetDomain, bool InAllowTargetSubdomains) |
Removes a specific entry from the cross-origin access whitelist for the CEF context. This revokes previously granted cross-origin permissions for the specified source and target combination, enforcing the default CORS policy for affected requests. | |
void | ClearCrossOriginWhitelistEntry () |
Removes all entries from the cross-origin access whitelist for the CEF context. This action revokes any previously granted cross-origin permissions, restoring the default CORS policy. | |
Public Attributes | |
UCefSettings * | Settings = GetMutableDefault<UCefSettings>() |
The settings object containing configuration parameters for the CEF context. This includes options such as cache path, user agent, and other browser-related settings. | |
Protected Member Functions | |
virtual void | Initialize (FSubsystemCollectionBase &Collection) override |
Called when the engine subsystem is initialized. This method sets up the CEF context and prepares it for use by browser instances. | |
virtual void | Deinitialize () override |
Called when the engine subsystem is deinitialized. This method releases all CEF resources and performs necessary cleanup. | |
Represents the Chromium Embedded Framework (CEF) context within Unreal Engine. This class acts as a subsystem, providing centralized access to CEF features such as resource mapping, cookie management, and cross-origin resource sharing (CORS) configuration. All browser instances created after modifying this context will inherit its settings and mappings.
UCefContext should be accessed via the engine subsystem interface. It is responsible for initializing and deinitializing CEF resources, and exposes Blueprint-callable methods for common browser integration tasks.
void UCefContext::AddArchiveFileResource | ( | const FString & | pInPathath, |
const FString & | InUrl, | ||
const FString & | InPassword, | ||
int32 | InPriority = 0 ) |
Registers a local archive file (such as a .zip) as a web resource, mapping its contents to a specified URL. All browser instances created after this call will be able to access the archive's contents via the mapped URL.
pInPathath | Absolute or relative path to the local archive file (e.g., .zip). |
InUrl | The virtual URL to which the archive will be mapped. |
InPassword | Password for the archive, if required. Pass an empty string if not needed. |
InPriority | The priority of the mapping. Higher values take precedence. |
This is useful for distributing web assets in a compressed format. The archive is mounted read-only.
bool UCefContext::AddCookie | ( | const FString & | InName, |
const FString & | InValue, | ||
const FString & | InDomain, | ||
const FString & | InUrl ) |
Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context.
InName | The cookie item name. |
InValue | The cookie item value. |
InDomain | The applicable domain name. |
InUrl | The applicable url. |
bool UCefContext::AddCrossOriginWhitelistEntry | ( | const FString & | InSourceOrigin, |
const FString & | InTargetSchema, | ||
const FString & | InTargetDomain, | ||
bool | InAllowTargetSubdomains ) |
Adds an entry to the cross-origin access whitelist for the CEF context, allowing specific cross-origin requests from a given source origin to a target schema and domain. This enables controlled CORS (Cross-Origin Resource Sharing) behavior for browser instances managed by this context.
InSourceOrigin | The source origin (e.g., "http://myapp.local") from which cross-origin requests will be allowed. |
InTargetSchema | The target schema (e.g., "https") to which cross-origin requests are permitted. |
InTargetDomain | The target domain (e.g., "example.com") that will accept cross-origin requests from the source origin. |
InAllowTargetSubdomains | If true , subdomains of the target domain are also allowed for cross-origin access. |
true
if the whitelist entry was successfully added; otherwise, false
. Use this method to enable communication between web content hosted in different origins, such as when embedding local or remote web applications that require access to resources across domains. This is particularly useful for scenarios involving authentication, APIs, or integration with third-party services.
Be cautious when granting cross-origin permissions, as this can have security implications. Only allow trusted origins and domains as needed by your application.
If the entry already exists, this method will not add a duplicate. The changes apply to all browser instances created after the entry is added.
For more information, see the CEF documentation: https://github.com/chromiumembedded/cef/blob/master/include/cef_origin_whitelist.h
void UCefContext::AddLocalFolderResource | ( | const FString & | InPath, |
const FString & | InUrl, | ||
int32 | InPriority = 0 ) |
Registers a local folder as a web resource directory, mapping it to a specified URL. All browser instances created after this call will be able to access the folder's contents via the mapped URL.
InPath | Absolute or relative path to the local resource directory. |
InUrl | The virtual URL to which the directory will be mapped (e.g., "http://myapp.local/"). |
InPriority | The priority of the mapping. Higher values take precedence when resolving resources. |
Use this method to serve static assets (HTML, JS, CSS, etc.) from the local filesystem to CEF browsers.
bool UCefContext::bIsCefInitialized | ( | ) | const |
Checks whether the CEF context has been successfully initialized and is ready for use.
true
if the CEF context is initialized and operational; otherwise, false
. This method can be used to verify that CEF is available before attempting browser operations.
void UCefContext::ClearCrossOriginWhitelistEntry | ( | ) |
Removes all entries from the cross-origin access whitelist for the CEF context. This action revokes any previously granted cross-origin permissions, restoring the default CORS policy.
Use this method to reset the CORS configuration for all browser instances managed by this context. After calling this, any custom cross-origin access rules added via AddCrossOriginWhitelistEntry will be removed, and only the default CEF cross-origin policy will apply.
This is useful when you need to ensure a clean security state or when dynamically changing the set of allowed origins.
For more information, see the CEF documentation: https://github.com/chromiumembedded/cef/blob/master/include/cef_origin_whitelist.h
|
overrideprotectedvirtual |
Called when the engine subsystem is deinitialized. This method releases all CEF resources and performs necessary cleanup.
bool UCefContext::DeleteAllCookies | ( | ) |
Deletes all cookies from the CEF context.
|
overrideprotectedvirtual |
Called when the engine subsystem is initialized. This method sets up the CEF context and prepares it for use by browser instances.
Collection | The subsystem collection used for initialization. |
bool UCefContext::RemoveCrossOriginWhitelistEntry | ( | const FString & | InSourceOrigin, |
const FString & | InTargetSchema, | ||
const FString & | InTargetDomain, | ||
bool | InAllowTargetSubdomains ) |
Removes a specific entry from the cross-origin access whitelist for the CEF context. This revokes previously granted cross-origin permissions for the specified source and target combination, enforcing the default CORS policy for affected requests.
InSourceOrigin | The source origin (e.g., "http://myapp.local") for which the whitelist entry was added. |
InTargetSchema | The target schema (e.g., "https") that was allowed for cross-origin access. |
InTargetDomain | The target domain (e.g., "example.com") that was allowed for cross-origin access. |
InAllowTargetSubdomains | Whether subdomains of the target domain were included in the whitelist entry. |
true
if the whitelist entry was successfully removed; otherwise, false
. Use this method to dynamically revoke cross-origin permissions previously granted via AddCrossOriginWhitelistEntry. This is useful for tightening security or responding to changes in application policy at runtime.
If the specified entry does not exist, the method returns false
and no changes are made.
For more information, see the CEF documentation: https://github.com/chromiumembedded/cef/blob/master/include/cef_origin_whitelist.h
UCefSettings* UCefContext::Settings = GetMutableDefault<UCefSettings>() |
The settings object containing configuration parameters for the CEF context. This includes options such as cache path, user agent, and other browser-related settings.
The Settings property is initialized with the project's mutable default UCefSettings instance. Modifying these settings affects all subsequently created browser instances.