Bug 44265 - [Qt] Ability to set custom userAgent for WebKit2/WebKit
Summary: [Qt] Ability to set custom userAgent for WebKit2/WebKit
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit2 (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-19 07:50 PDT by Zoltan Horvath
Modified: 2010-10-05 08:03 PDT (History)
4 users (show)

See Also:


Attachments
Patch implementing API to set custom user agent (1.79 KB, patch)
2010-10-05 06:40 PDT, Kimmo Kinnunen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zoltan Horvath 2010-08-19 07:50:25 PDT
We need to add ability to set custom user agents for WebKit2.
WebKit2's API was added in http://trac.webkit.org/changeset/65644 , bug #44215 .

Currently, we have a good QString QWebPage::userAgentForUrl(const QUrl& url) function. We might make a callback function e.g. setUserAgentFunction(...) and it might be useful to have generally a QString qWebKitDefaultUserAgentForPlatform() function (it would be like qWebKitVersion methods), and then even the current implementation could call to that.

Another way is just to copy the code from qwebpage.cpp and make it for WebKit2 only for now.

We should discuss these.

Zoltan
Comment 1 Kenneth Rohde Christiansen 2010-08-19 08:31:38 PDT
We could copy the current code into a (build with webkit2 only) qWebKitDefaultUserAgentForPlatform() method, and then use that for WebKit2.

I am in favor of the qWebKitDefaultUserAgentForPlatform() method in general, so what do you think Simon? time for QtWebKitGlobal.h ? :-)

Btw, we also want to write "MeeGo Handset UX" when Q_WS_MAEMO_6 (or what ever it is called on Harmattan) is defined - and Mobile Safari as well.

I think we want something similar to Android:

Mozilla/5.0 (Linux; U; Android 2.1; en-us; Nexus One Build/ERD62) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17 –Nexus 

We currently do:

"Mozilla/5.0 (%Platform%; %Security%; %Subplatform%; %Locale%) AppleWebKit/%WebKitVersion% (KHTML, like Gecko) %AppVersion Safari/%WebKitVersion%"

So I guess the following would be nice:

Mozilla/5.0 (MeeGo Handset UX; U; Linux armv7l; en-US; *vendor addition*) AppleWebKit/*** (KHTML, like Gecko) Mobile Safari/***
Comment 2 Kimmo Kinnunen 2010-10-05 06:40:43 PDT
Created attachment 69776 [details]
Patch implementing API to set custom user agent
Comment 3 WebKit Review Bot 2010-10-05 06:41:13 PDT
Comment on attachment 69776 [details]
Patch implementing API to set custom user agent

Rejecting patch 69776 from commit-queue.

kimmo.t.kinnunen@nokia.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/WebKitTools/Scripts/webkitpy/common/config/committers.py.

- If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.

- If you have committer rights please correct the error in WebKitTools/Scripts/webkitpy/common/config/committers.py by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.
Comment 4 Kenneth Rohde Christiansen 2010-10-05 06:43:27 PDT
Comment on attachment 69776 [details]
Patch implementing API to set custom user agent

Did you test if setting setCustomUserAgent(QString()) turns off the custom user agent?
Comment 5 Kimmo Kinnunen 2010-10-05 07:12:30 PDT
(In reply to comment #4)
> (From update of attachment 69776 [details])
> Did you test if setting setCustomUserAgent(QString()) turns off the custom user agent?

It actually doesn't. That causes user agent to be just "Mozilla/5.0" instead of 
"Mozilla/5.0 (Macintosh; ..."

That's probably another bug where string constructed from a null QString gets converted to a empty string?

String WebPage::userAgent() const
{
    if (!m_customUserAgent.isNull())
        return m_customUserAgent;
Comment 6 WebKit Commit Bot 2010-10-05 08:02:57 PDT
Comment on attachment 69776 [details]
Patch implementing API to set custom user agent

Clearing flags on attachment: 69776

Committed r69108: <http://trac.webkit.org/changeset/69108>
Comment 7 WebKit Commit Bot 2010-10-05 08:03:03 PDT
All reviewed patches have been landed.  Closing bug.