Skip to main content

class QCefContext

class QCefContext
: public QObject

Represents the CEF context.

Summary

MembersDescriptions
public QCefContext(QCoreApplication * app, int argc, char ** argv, const QCefConfig * config)Constructs the CEF context.
public ~QCefContext()Destructs the CEF context.
public void addLocalFolderResource(const QString & path, const QString & url, int priority)Adds a url mapping item with local web resource directory. This works for all instances created subsequently.
public void addArchiveResource(const QString & path, const QString & url, const QString & password, int priority)Adds a url mapping item with local archive (.zip) file which contains the web resource. This works for all instances created subsequently.
public bool addCookie(const QString & name, const QString & value, const QString & domain, const QString & url)Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context.
public bool deleteAllCookies()Deletes all cookies from the CEF context.
public bool addCrossOriginWhitelistEntry(const QString & sourceOrigin, const QString & targetSchema, const QString & targetDomain, bool allowTargetSubdomains)Adds an entry to the cross-origin access whitelist. For details please refer to: https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L81C23-L81C23.
public bool removeCrossOriginWhitelistEntry(const QString & sourceOrigin, const QString & targetSchema, const QString & targetDomain, bool allowTargetSubdomains)Removes an entry from the cross-origin access whitelist. For details please refer to: https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L91C12-L91C12.
public bool clearCrossOriginWhitelistEntry()Removes all entries from the cross-origin access whitelist.
public const QCefConfig*cefConfig() constGets the QCefConfig.
protected bool init(const QCefConfig * config)Initialize the CEF context.
protected void uninit()Uninitialize the CEF context.
private QScopedPointer< QCefContextPrivate > d_ptr
public static QCefContext*instance()Gets the unique default instance.

Members


public QCefContext(QCoreApplication * app, int argc, char ** argv, const QCefConfig * config)

Constructs the CEF context.

Parameters

  • app The application

  • argc The argument count

  • argv The argument list pointer

  • config The QCefConfig instance


public ~QCefContext()

Destructs the CEF context.


public void addLocalFolderResource(const QString & path, const QString & url, int priority)

Adds a url mapping item with local web resource directory. This works for all instances created subsequently.

Parameters

  • path The path to the local resource directory

  • url The url to be mapped to

  • priority The priority


public void addArchiveResource(const QString & path, const QString & url, const QString & password, int priority)

Adds a url mapping item with local archive (.zip) file which contains the web resource. This works for all instances created subsequently.

Parameters

  • path The path to the local archive file

  • url The url to be mapped to

  • password The password of the archive

  • priority The priority


public bool addCookie(const QString & name, const QString & value, const QString & domain, const QString & url)

Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context.

Parameters

  • name The cookie item name

  • value The cookie item value

  • domain The applicable domain name

  • url The applicable url

Returns

True on success; otherwise false


public bool deleteAllCookies()

Deletes all cookies from the CEF context.

Returns

True on success; otherwise false


public bool addCrossOriginWhitelistEntry(const QString & sourceOrigin, const QString & targetSchema, const QString & targetDomain, bool allowTargetSubdomains)

Adds an entry to the cross-origin access whitelist. For details please refer to: https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L81C23-L81C23.

Parameters

  • sourceOrigin The source origin

  • targetSchema The target schema

  • targetDomain The target domain

  • allowTargetSubdomains Whether to allow subdomain or not

Returns

True on success; otherwise false


public bool removeCrossOriginWhitelistEntry(const QString & sourceOrigin, const QString & targetSchema, const QString & targetDomain, bool allowTargetSubdomains)

Removes an entry from the cross-origin access whitelist. For details please refer to: https://github.com/chromiumembedded/cef/blob/605c2bac86415dcec1e2902cdc46dc11c1ad026a/include/cef_origin_whitelist.h#L91C12-L91C12.

Parameters

  • sourceOrigin The source origin

  • targetSchema The target schema

  • targetDomain The target domain

  • allowTargetSubdomains Whether to allow subdomain or not

Returns

True on success; otherwise false


public bool clearCrossOriginWhitelistEntry()

Removes all entries from the cross-origin access whitelist.


public const QCefConfig*cefConfig() const

Gets the QCefConfig.

Returns

The QCefConfig instance


protected bool init(const QCefConfig * config)

Initialize the CEF context.

Parameters

Returns

True on success; otherwise false


protected void uninit()

Uninitialize the CEF context.


private QScopedPointer< QCefContextPrivate > d_ptr


public static QCefContext*instance()

Gets the unique default instance.

Returns

The default instance