summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/browser_context_adapter.cpp12
-rw-r--r--src/core/browser_context_adapter.h1
-rw-r--r--src/core/web_contents_adapter.cpp1
3 files changed, 14 insertions, 0 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp
index 14f3b1c6c..75a906b35 100644
--- a/src/core/browser_context_adapter.cpp
+++ b/src/core/browser_context_adapter.cpp
@@ -54,6 +54,8 @@
#include <QStringBuilder>
#include <QStandardPaths>
+#include <numeric>
+
namespace {
inline QString buildLocationFromStandardPath(const QString &standardPath, const QString &name) {
QString location = standardPath;
@@ -368,6 +370,16 @@ void BrowserContextAdapter::permissionRequestReply(const QUrl &origin, Permissio
static_cast<PermissionManagerQt*>(browserContext()->GetPermissionManager())->permissionRequestReply(origin, type, reply);
}
+QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const
+{
+ const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(','));
+ return std::accumulate(list.constBegin(), list.constEnd(), QString(),
+ [](const QString &r, const QString &e) {
+ return (r.isEmpty() ? r : r + QString(QLatin1Char(',')))
+ + e.split(QLatin1Char(';')).first();
+ });
+}
+
QString BrowserContextAdapter::httpAcceptLanguage() const
{
return m_httpAcceptLanguage;
diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h
index d58d8a4be..896743f4b 100644
--- a/src/core/browser_context_adapter.h
+++ b/src/core/browser_context_adapter.h
@@ -151,6 +151,7 @@ public:
void permissionRequestReply(const QUrl &origin, PermissionType type, bool reply);
+ QString httpAcceptLanguageWithoutQualities() const;
QString httpAcceptLanguage() const;
void setHttpAcceptLanguage(const QString &httpAcceptLanguage);
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 999fc881c..ae4eabe74 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -377,6 +377,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
const int qtCursorFlashTime = QGuiApplication::styleHints()->cursorFlashTime();
rendererPrefs->caret_blink_interval = 0.5 * static_cast<double>(qtCursorFlashTime) / 1000;
rendererPrefs->user_agent_override = d->browserContextAdapter->httpUserAgent().toStdString();
+ rendererPrefs->accept_languages = d->browserContextAdapter->httpAcceptLanguageWithoutQualities().toStdString();
d->webContents->GetRenderViewHost()->SyncRendererPrefs();
// Create and attach observers to the WebContents.