aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/webprofile.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/webprofile.h')
-rw-r--r--src/webengine/webprofile.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h
new file mode 100644
index 0000000..37e3419
--- /dev/null
+++ b/src/webengine/webprofile.h
@@ -0,0 +1,94 @@
+/*
+ * This file is part of smolbote. It's copyrighted by the contributors recorded
+ * in the version control history of the file, available from its original
+ * location: https://neueland.iserlohn-fortress.net/gitea/aqua/smolbote
+ *
+ * SPDX-License-Identifier: GPL-3.0
+ */
+
+#ifndef SMOLBOTE_WEBENGINEPROFILE_H
+#define SMOLBOTE_WEBENGINEPROFILE_H
+
+#include <QHash>
+#include <QMap>
+#include <QNetworkCookie>
+#include <QString>
+#include <QUrl>
+#include <QVector>
+#include <QWebEngineProfile>
+#include <QWebEngineSettings>
+#include <profileinterface.h>
+
+class WebProfile : public Profile
+{
+ Q_OBJECT
+
+public:
+ // off-the-record constructor
+ explicit WebProfile(const QString &name, QObject *parent = nullptr);
+ // default constructor
+ explicit WebProfile(const QString &storageName, const QString &name, QObject *parent = nullptr);
+
+ ~WebProfile() = default;
+
+ static void setDefaultProfile(WebProfile *profile)
+ {
+ Q_CHECK_PTR(profile);
+ WebProfile::profile = profile;
+ }
+ static WebProfile *defaultProfile()
+ {
+ Q_CHECK_PTR(WebProfile::profile);
+ return WebProfile::profile;
+ }
+
+ const QString name() const;
+ void setName(const QString &name);
+
+ const QVector<QNetworkCookie> cookies() const
+ {
+ return qAsConst(m_cookies);
+ }
+ const QMap<QByteArray, QByteArray> headers() const
+ {
+ return qAsConst(m_headers);
+ }
+
+ // search url
+ QString search() const;
+ void setSearch(const QString &url);
+
+ // homepage url
+ QUrl homepage() const;
+ void setHomepage(const QUrl &url);
+
+ // new tab url
+ QUrl newtab() const;
+ void setNewtab(const QUrl &url);
+
+ void setCachePath(const QString &path);
+ void setPersistentStoragePath(const QString &path);
+ void setPersistentCookiesPolicy(int policy);
+
+ void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
+ void setHttpCacheMaximumSize(int maxSize);
+ void setHttpCacheType(int type);
+ void setHttpUserAgent(const QString &userAgent);
+ void setHttpHeader(const QString &name, const QString &value);
+ void removeHttpHeader(const QString &name);
+
+ void setSpellCheckEnabled(bool enable);
+
+private:
+ static WebProfile *profile;
+
+ QString m_name;
+ QString m_search = QString("about:blank");
+ QUrl m_homepage = QUrl("about:blank");
+ QUrl m_newtab = QUrl("about:blank");
+
+ QVector<QNetworkCookie> m_cookies;
+ QMap<QByteArray, QByteArray> m_headers;
+};
+
+#endif // SMOLBOTE_WEBENGINEPROFILE_H