/* * File: QCefConfig.h * Project: QCefView * Created: 21nd January 2021 * Author: Sheen * Source: https://github.com/cefview/qcefview * Docs: https://cefview.github.io/QCefView/ */ #ifndef QCEFCONFIG_H #define QCEFCONFIG_H #pragma once #include #pragma region qt_headers #include #include #include #include #pragma endregion class QCefConfigPrivate; /// /// Represents the CEF setting. For more details please refer to: /// https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-cefsettings /// class QCEFVIEW_EXPORT QCefConfig { Q_DECLARE_PRIVATE(QCefConfig) QScopedPointer d_ptr; public: /// /// Represents the log severity /// enum LogLevel { /// Default logging (currently INFO logging) LOGSEVERITY_DEFAULT, /// Verbose logging LOGSEVERITY_VERBOSE, /// DEBUG logging LOGSEVERITY_DEBUG, /// INFO logging LOGSEVERITY_INFO, /// WARNING logging LOGSEVERITY_WARNING, /// ERROR logging LOGSEVERITY_ERROR, /// FATAL logging LOGSEVERITY_FATAL, /// Disable logging to file for all messages, and to stderr for messages with severity less than FATAL LOGSEVERITY_DISABLE = 99 }; public: /// /// Constructs a CEF config instance /// QCefConfig(); /// /// Constructs a CEF setting from existing one /// QCefConfig(const QCefConfig& other); /// /// Assigns an existing config to current /// QCefConfig& operator=(const QCefConfig& other); /// /// Destructs the config /// ~QCefConfig(); /// /// Adds a switch to the commandline args used to initialize the CEF /// /// The switch name void addCommandLineSwitch(const QString& smitch); /// /// Adds a switch with value to the commandline args used to initialize the CEF /// /// The swtich name /// The switch value void addCommandLineSwitchWithValue(const QString& smitch, const QString& v); /// /// Sets the flag to enable/disable OSR mode /// /// True to enable OSR mode, false to disable void setWindowlessRenderingEnabled(const bool enabled); /// /// Gets the OSR mode flag /// /// The flag indicates the enable/disable of OSR mode const QVariant WindowlessRenderingEnabled() const; #if !defined(Q_OS_MACOS) /// /// Sets the browser subprocess path /// /// The path to the sub process executable void setBrowserSubProcessPath(const QString& path); /// /// Gets the browser subprocess path /// const QString browserSubProcessPath() const; /// /// Sets the resource directory path /// /// The resource directory path void setResourceDirectoryPath(const QString& path); /// /// Gets the resource directory path /// const QString resourceDirectoryPath() const; /// /// Sets the locales directory path /// /// The locales directory path void setLocalesDirectoryPath(const QString& path); /// /// Gets the locales directory path /// const QString localesDirectoryPath() const; #endif /// /// Sets the log level /// /// void setLogLevel(const LogLevel lvl); /// /// Gets the log level /// /// The current log level const QCefConfig::LogLevel logLevel() const; /// /// Sets the locale /// /// The locale to use. If empty the default locale of "en-US" will be used. This value is ignored /// on Linux where locale is determined using environment variable parsing with the precedence order: LANGUAGE, /// LC_ALL, LC_MESSAGES and LANG. Also configurable using the "lang" command-line switch. void setLocale(const QString& locale); /// /// Gets the locale /// const QString locale() const; /// /// Sets the user agent /// /// The user agent void setUserAgent(const QString& agent); /// /// Gets the user agent /// const QString userAgent() const; /// /// Sets the cache directory path /// /// The cache path void setCachePath(const QString& path); /// /// Gets the cache directory path /// const QString cachePath() const; #if CEF_VERSION_MAJOR < 115 /// /// Sets the user data directory path /// /// The user data directory path void setUserDataPath(const QString& path); /// /// Gets the user data directory path /// const QString userDataPath() const; #else /// /// Gets the root cache directory path /// const QString rootCachePath() const; /// /// Sets the root cache directory path /// /// The root cache directory path void setRootCachePath(const QString& path); #endif /// /// Sets the bridge object name /// /// The bridge object name /// /// The bridge object represents a Javascript object which will be inserted /// into all browser and frames. This object is designated for communicating /// between Javascript in web content and native context(C/C++) code. /// This object is set as an property of window object. That means it can be /// obtained by calling window.bridgeObject in the Javascript code /// void setBridgeObjectName(const QString& name); /// /// Gets the bridge object name /// const QString bridgeObjectName() const; /// /// Sets the built-in scheme name /// /// The scheme name /// /// The default value is CefView /// void setBuiltinSchemeName(const QString& name); /// /// Gets the built-in scheme object name /// const QString builtinSchemeName() const; /// /// Sets the background color of the web page /// /// The color to be set /// /// This only works if the web page has no background color set. The alpha component value /// will be adjusted to 0 or 255, it means if you pass a value with alpha value /// in the range of [1, 255], it will be accepted as 255. The default value is qRgba(255, 255, 255, 255) /// void setBackgroundColor(const QColor& color); /// /// Gets the background color /// const QVariant backgroundColor() const; /// /// Sets the acceptable language list /// /// Comma delimited ordered list of language codes without any whitespace /// that will be used in the "Accept-Language" HTTP header. void setAcceptLanguageList(const QString& languages); /// /// Get the acceptable language list /// const QString acceptLanguageList() const; /// /// Sets whether to persist session cookie /// /// True if to persist session cookie void setPersistSessionCookies(bool enabled); /// /// Gets whether to persist session cookie /// const QVariant persistSessionCookies() const; #if CEF_VERSION_MAJOR < 128 /// /// Sets whether to persist user preferences /// /// True if to persist user preferences void setPersistUserPreferences(bool enabled); /// /// Gets whether to persist user preferences /// const QVariant persistUserPreferences() const; #endif /// /// Sets the remote debugging port /// /// The port to use /// /// CEF supports the remote debugging with Dev Tools in Chrome/Edge. /// if this value is set then you can debug the web application by /// accessing http://127.0.0.1:port from Chrome/Edge /// void setRemoteDebuggingPort(short port); /// /// Gets the remote debugging port /// const QVariant remoteDebuggingPort() const; }; Q_DECLARE_METATYPE(QCefConfig); #endif