From 4bac2cb5084c68354e43fb456e4d20d4f70b223a Mon Sep 17 00:00:00 2001
From: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Date: Tue, 17 Feb 2015 18:18:23 +0100
Subject: [PATCH] Fix Http User-agent string setting

Chromium has multiple places where it reads the user-agent, we were
only setting one, which appears to no longer be used for most cases.
This instead sets it by using the webcontent user-agent override.

Change-Id: I77d4d0a21424feda7a18140fb72baacdd6f816ca
Reviewed-by: Pierre Rossi <pierre.rossi@theqtcompany.com>
---
 src/core/web_contents_adapter.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index 9ed0d7d72..848e8086e 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -392,6 +392,7 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient)
     // Qt returns a flash time (the whole cycle) in ms, chromium expects just the interval in seconds
     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();
     d->webContents->GetRenderViewHost()->SyncRendererPrefs();
 
     // Create and attach observers to the WebContents.
@@ -469,6 +470,7 @@ void WebContentsAdapter::load(const QUrl &url)
     Q_D(WebContentsAdapter);
     content::NavigationController::LoadURLParams params(toGurl(url));
     params.transition_type = ui::PageTransitionFromInt(ui::PAGE_TRANSITION_TYPED | ui::PAGE_TRANSITION_FROM_ADDRESS_BAR);
+    params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE;
     d->webContents->GetController().LoadURLWithParams(params);
     d->webContents->Focus();
 }
-- 
GitLab