Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-47976

WebEngineView: Can't set the httpUserAgent after the view's initialization

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0 Beta
    • 5.5.0
    • WebEngine
    • None
    • aa88ad113669d8daf9c1486487b7c48b39279be5

    Description

      This seems to affect both the HTTP and JavaScript user agent strings. Here are a couple of examples that don't work:

      import QtQuick 2.4
      import QtWebEngine 1.1
      WebEngineView {
          width: 600; height: 600
          url: "http://whatismyuseragent.com"
          Component.onCompleted: {
              profile.httpUserAgent = "foo"
              reload()
          }
      }
      
      import QtQuick 2.4
      import QtWebEngine 1.1
      import QtWebChannel 1.0
      WebEngineView {
          width: 600; height: 600
          url: "http://whatismyuseragent.com"
          profile.httpUserAgent: "foo"
          webChannel.registeredObjects: []
      }
      
      import QtQuick 2.4
      import QtWebEngine 1.1
      WebEngineView {
          width: 600; height: 600
          url: "http://whatismyuseragent.com"
          profile.httpUserAgent: "foo"
          backgroundColor: "red"
      }
      

      Only WebContentsAdapter::initialize seems to set user_agent_override RendererPreferences on the WebContents, BrowserContextAdapter::setHttpUserAgent doesn't seem to get that far.

      A solution could be to call content::WebContents::SetUserAgentOverride on all views of a specific BrowserContextAdapter, but I'm not sure if that list is available from the BrowserContext. It could also work to move the httpUserAgent property to QQuickWebView but that would mean deprecating the profile one, probably not worth it.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            davidsz Szabolcs David
            jturcott Jocelyn Turcotte
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes