Skip to content

Commit aa88ad1

Browse files
committed
Fix httpUserAgent setting after the view's initialization
Set user agent override on all WebContents of the specific BrowserContext. Task-number: QTBUG-47976 Change-Id: I4fc6f8d79aff6f372ca48d82642b3eab60f933d1 Reviewed-by: Jocelyn Turcotte (Woboq GmbH) <[email protected]> Reviewed-by: Allan Sandfeld Jensen <[email protected]>
1 parent f91362e commit aa88ad1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/core/browser_context_adapter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#include "browser_context_adapter.h"
3838

39+
#include "content/browser/web_contents/web_contents_impl.h"
3940
#include "content/public/browser/browser_thread.h"
4041
#include "browser_context_qt.h"
4142
#include "content_client_qt.h"
@@ -230,6 +231,12 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent)
230231
if (m_httpUserAgent == userAgent)
231232
return;
232233
m_httpUserAgent = userAgent;
234+
235+
std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents();
236+
Q_FOREACH (content::WebContentsImpl *web_contents, list)
237+
if (web_contents->GetBrowserContext() == m_browserContext.data())
238+
web_contents->SetUserAgentOverride(userAgent.toStdString());
239+
233240
if (m_browserContext->url_request_getter_.get())
234241
m_browserContext->url_request_getter_->updateUserAgent();
235242
}

0 commit comments

Comments
 (0)