/* * File: QCefContext.h * Project: QCefView * Created: 29th March 2016 * Author: Sheen * Source: https://github.com/cefview/qcefview * Docs: https://cefview.github.io/QCefView/ */ #ifndef QCEFCONTEXT_H #define QCEFCONTEXT_H #pragma once #include #pragma region qt_headers #include #include #pragma endregion #include class QCefContextPrivate; /// /// Represents the CEF context /// class QCEFVIEW_EXPORT QCefContext : public QObject { Q_OBJECT Q_DECLARE_PRIVATE(QCefContext) QScopedPointer d_ptr; friend class QCefView; public: /// /// Constructs the CEF context /// /// The application /// The argument count /// The argument list pointer /// The instance QCefContext(QCoreApplication* app, int argc, char** argv, const QCefConfig* config); /// /// Gets the unique default instance /// /// The default instance static QCefContext* instance(); /// /// Destructs the CEF context /// ~QCefContext(); /// /// Adds a url mapping item with local web resource directory. This works for all instances /// created subsequently /// /// The path to the local resource directory /// The url to be mapped to /// The priority void addLocalFolderResource(const QString& path, const QString& url, int priority = 0); /// /// Adds a url mapping item with local archive (.zip) file which contains the web resource. This works for all instances created subsequently /// /// The path to the local archive file /// The url to be mapped to /// The password of the archive /// The priority void addArchiveResource(const QString& path, const QString& url, const QString& password = "", int priority = 0); /// /// Adds a cookie to the CEF context, this cookie is accessible from all browsers created with this context /// /// The cookie item name /// The cookie item value /// The applicable domain name /// The applicable url /// True on success; otherwise false bool addCookie(const QString& name, const QString& value, const QString& domain, const QString& url); /// /// Deletes all cookies from the CEF context /// /// True on success; otherwise false bool deleteAllCookies(); /// /// 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 /// /// The source origin /// The target schema /// The target domain /// Whether to allow subdomain or not /// True on success; otherwise false bool addCrossOriginWhitelistEntry(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 /// /// The source origin /// The target schema /// The target domain /// Whether to allow subdomain or not /// True on success; otherwise false bool removeCrossOriginWhitelistEntry(const QString& sourceOrigin, const QString& targetSchema, const QString& targetDomain, bool allowTargetSubdomains); /// /// Removes all entries from the cross-origin access whitelist. /// bool clearCrossOriginWhitelistEntry(); /// /// Gets the QCefConfig /// /// The QCefConfig instance const QCefConfig* cefConfig() const; protected: /// /// Initialize the CEF context /// /// The instance /// True on success; otherwise false bool init(const QCefConfig* config); /// /// Uninitialize the CEF context /// void uninit(); private: /// /// The default instance /// static QCefContext* s_self; }; #endif // QCEFCONTEXT_H