Bug 44265

Summary: [Qt] Ability to set custom userAgent for WebKit2/WebKit
Product: WebKit Reporter: Zoltan Horvath <zoltan>
Component: WebKit2Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, hausmann, kenneth, kimmo.t.kinnunen
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
Patch implementing API to set custom user agent none

Zoltan Horvath
Reported 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
Attachments
Patch implementing API to set custom user agent (1.79 KB, patch)
2010-10-05 06:40 PDT, Kimmo Kinnunen
no flags
Kenneth Rohde Christiansen
Comment 1 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/***
Kimmo Kinnunen
Comment 2 2010-10-05 06:40:43 PDT
Created attachment 69776 [details] Patch implementing API to set custom user agent
WebKit Review Bot
Comment 3 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.
Kenneth Rohde Christiansen
Comment 4 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?
Kimmo Kinnunen
Comment 5 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;
WebKit Commit Bot
Comment 6 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>
WebKit Commit Bot
Comment 7 2010-10-05 08:03:03 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.