Merge lp:~mardy/signon-ui/lp1235259 into lp:signon-ui

Proposed by Alberto Mardegan
Status: Rejected
Rejected by: Alberto Mardegan
Proposed branch: lp:~mardy/signon-ui/lp1235259
Merge into: lp:signon-ui
Diff against target: 286 lines (+207/-15)
6 files modified
src/browser-process/UserAgent.qml (+90/-0)
src/browser-process/browser-process.pro (+3/-1)
src/browser-process/qml.qrc (+2/-0)
src/browser-process/ua-overrides.js (+105/-0)
src/browser-process/webview.qml (+5/-13)
src/request.cpp (+2/-1)
To merge this branch: bzr merge lp:~mardy/signon-ui/lp1235259
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Online Accounts Pending
Review via email: mp+189579@code.launchpad.net

Commit message

Use the same UserAgent as the UbuntuWebView

Code copied from lp:webbroser-app.

Also, let WebKit2 be used on XCB, for testing purposes, when a certain environment variable is defined.

Description of the change

Use the same UserAgent as the UbuntuWebView

Code copied from lp:webbroser-app.

Also, let WebKit2 be used on XCB, for testing purposes, when a certain environment variable is defined.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

PASSED: Continuous integration, rev:112
http://10.97.0.26:8080/job/signon-ui-ci/33/
Executed test runs:
    SUCCESS: http://10.97.0.26:8080/job/signon-ui-saucy-amd64-ci/13

Click here to trigger a rebuild:
http://10.97.0.26:8080/job/signon-ui-ci/33/rebuild

review: Approve (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

Ken already fixed that in another MP.

Unmerged revisions

112. By Alberto Mardegan

Use the same UserAgent as the Ubuntu browser

111. By Alberto Mardegan

Allow using WebKit2 backend on XCB

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'src/browser-process/UserAgent.qml'
2--- src/browser-process/UserAgent.qml 1970-01-01 00:00:00 +0000
3+++ src/browser-process/UserAgent.qml 2013-10-07 11:55:18 +0000
4@@ -0,0 +1,90 @@
5+/*
6+ * Copyright 2013 Canonical Ltd.
7+ *
8+ * This file is part of webbrowser-app.
9+ *
10+ * webbrowser-app is free software; you can redistribute it and/or modify
11+ * it under the terms of the GNU General Public License as published by
12+ * the Free Software Foundation; version 3.
13+ *
14+ * webbrowser-app is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+import QtQuick 2.0
24+import QtQuick.Window 2.0
25+import Ubuntu.Components 0.1
26+import "ua-overrides.js" as Overrides
27+
28+/*
29+ * Useful documentation:
30+ * http://en.wikipedia.org/wiki/User_agent#Format
31+ * https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
32+ * https://wiki.mozilla.org/B2G/User_Agent
33+ * https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js
34+ * https://developers.google.com/chrome/mobile/docs/user-agent
35+ */
36+
37+// This is an Item, not a QtObject, because it needs information about the Screen.
38+Item {
39+ // %1: form factor (Mobile, Tablet, Desktop)
40+ // %2: WebKit version
41+ readonly property string _template: "Mozilla/5.0 (Ubuntu; %1) WebKit/%2"
42+
43+ // See Source/WebCore/Configurations/Version.xcconfig in QtWebKit’s source tree
44+ // TODO: determine this value at runtime
45+ readonly property string _webkitVersion: "537.21"
46+
47+ // FIXME: this is a quick hack that will become increasingly unreliable
48+ // as we support more devices, so we need a better solution for this
49+ // FIXME: only handling phone and tablet for now, need to handle desktop too
50+ readonly property string _formFactor: (Screen.width >= units.gu(60)) ? "Tablet" : "Mobile"
51+
52+ property string defaultUA: _template.arg(_formFactor).arg(_webkitVersion)
53+
54+ property var overrides: Overrides.overrides
55+
56+ function getDomain(url) {
57+ var domain = url.toString()
58+ var indexOfScheme = domain.indexOf("://")
59+ if (indexOfScheme !== -1) {
60+ domain = domain.slice(indexOfScheme + 3)
61+ }
62+ var indexOfPath = domain.indexOf("/")
63+ if (indexOfPath !== -1) {
64+ domain = domain.slice(0, indexOfPath)
65+ }
66+ return domain
67+ }
68+
69+ function getDomains(domain) {
70+ var components = domain.split(".")
71+ var domains = []
72+ for (var i = 0; i < components.length; i++) {
73+ domains.push(components.slice(i).join("."))
74+ }
75+ return domains
76+ }
77+
78+ function getUAString(url) {
79+ var ua = defaultUA
80+ var domains = getDomains(getDomain(url))
81+ for (var i = 0; i < domains.length; i++) {
82+ var domain = domains[i]
83+ if (domain in overrides) {
84+ var form = overrides[domain]
85+ if (typeof form == "string") {
86+ return form
87+ } else if (typeof form == "object") {
88+ return ua.replace(form[0], form[1])
89+ }
90+ }
91+ }
92+ return ua
93+ }
94+}
95
96=== modified file 'src/browser-process/browser-process.pro'
97--- src/browser-process/browser-process.pro 2013-10-04 17:15:49 +0000
98+++ src/browser-process/browser-process.pro 2013-10-07 11:55:18 +0000
99@@ -45,9 +45,11 @@
100 }
101
102 OTHER_FILES += \
103+ ua-overrides.js \
104 webview.qml \
105 KeyboardRectangle.qml \
106- StandardAnimation.qml
107+ StandardAnimation.qml \
108+ UserAgent.qml
109
110 RESOURCES += \
111 qml.qrc
112
113=== modified file 'src/browser-process/qml.qrc'
114--- src/browser-process/qml.qrc 2013-04-19 11:13:03 +0000
115+++ src/browser-process/qml.qrc 2013-10-07 11:55:18 +0000
116@@ -1,8 +1,10 @@
117 <!DOCTYPE RCC><RCC version="1.0">
118 <qresource>
119+ <file>ua-overrides.js</file>
120 <file>webview.qml</file>
121 <file>KeyboardRectangle.qml</file>
122 <file>StandardAnimation.qml</file>
123+ <file>UserAgent.qml</file>
124 </qresource>
125 </RCC>
126
127
128=== added file 'src/browser-process/ua-overrides.js'
129--- src/browser-process/ua-overrides.js 1970-01-01 00:00:00 +0000
130+++ src/browser-process/ua-overrides.js 2013-10-07 11:55:18 +0000
131@@ -0,0 +1,105 @@
132+/*
133+ * Copyright 2013 Canonical Ltd.
134+ *
135+ * This file is part of webbrowser-app.
136+ *
137+ * webbrowser-app is free software; you can redistribute it and/or modify
138+ * it under the terms of the GNU General Public License as published by
139+ * the Free Software Foundation; version 3.
140+ *
141+ * webbrowser-app is distributed in the hope that it will be useful,
142+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
143+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
144+ * GNU General Public License for more details.
145+ *
146+ * You should have received a copy of the GNU General Public License
147+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
148+ */
149+
150+.pragma library
151+
152+// B2G’s list of overrides: https://github.com/mozilla-b2g/gaia/blob/master/build/ua-override-prefs.js
153+
154+// List of user agent string overrides in the form of an object.
155+// Each key is a domain name for which the default user agent string doesn’t
156+// work well enough. Values can either be a string (full override) or an array
157+// containing two values that are passed to the String.replace method (the
158+// first value may be either a string or a regular expression, the second value
159+// must be a string).
160+
161+// Examples of valid entries:
162+// "example.org": "full override"
163+// "example.com": ["Ubuntu", "Ubuntu Edge"]
164+// "google.com": [/mobi/i, "b"]
165+
166+// The original list was initially built from the top 100 entries
167+// at http://www.alexa.com/topsites (2013-08-16), using Chrome on
168+// Android as a reference.
169+
170+var overrides = {
171+ "google.com": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
172+ "google.co.in": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
173+ "google.de": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
174+ "google.co.uk": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
175+ "google.fr": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
176+ "google.com.br": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
177+ "google.co.jp": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
178+ "google.com.hk": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
179+ "google.ru": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
180+ "google.it": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
181+ "google.es": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
182+ "google.com.mx": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
183+ "google.ca": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
184+ "google.com.tr": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
185+ "google.com.au": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
186+ "google.pl": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
187+
188+ "m.youtube.com": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
189+
190+ "twitter.com": ["Mobile)", "Mobile) Firefox"],
191+
192+ // while this issue gets resolved (https://bugs.launchpad.net/ubuntu/+source/ubuntu-keyboard/+bug/1233207)
193+ "login.ubuntu.com": [/Mobile\) WebKit\/[.0-9]*/, "Android 4.3) AppleWebKit Mobile Safari"],
194+
195+ "yahoo.com": ["Mobile", "Android; Mobile"],
196+ "baidu.com": ["Mobile", "Android; Mobile"],
197+ "qq.com": [/WebKit\/[.0-9]*/, "Apple$& Mobile"],
198+ "amazon.com": ["Mobile", "Android; Mobile"],
199+ "linkedin.com": ["Mobile", "Android; Mobile"],
200+ "blogspot.com": ["Mobile", "Android; Mobile"],
201+ "taobao.com": ["Mobile", "Android; Mobile"],
202+ "bing.com": ["Mobile", "Android; Mobile"],
203+ "yahoo.co.jp": ["Ubuntu", "Linux; Android 4; Galaxy Build/"],
204+ "yandex.ru": ["Mobile", "Android; Mobile"],
205+ "sina.com.cn": ["Mobile", "Android; Mobile"],
206+ "ebay.com": ["Mobile", "Android; Mobile"],
207+ "tumblr.com": ["Mobile", "Android; Mobile"],
208+ "msn.com": ["Mobile", "Android; Mobile"],
209+ "mail.ru": ["Ubuntu", "Linux; Android 4; Galaxy Build/"],
210+ "hao123.com": ["Mobile", "Android; Mobile"],
211+ "ask.com": ["Mobile", "Android; Mobile"],
212+ "blogger.com": ["Mobile", "Android; Mobile"],
213+ "imdb.com": ["Mobile", "Android; Mobile"],
214+ "amazon.co.jp": ["Mobile", "Android; Mobile"],
215+ "tmall.com": ["Mobile", "Android; Mobile"],
216+ "fc2.com": ["Mobile", "Android; Mobile"],
217+ "soso.com": ["Mobile", "Android; Mobile"],
218+ "delta-search.com": ["Mobile", "Android; Mobile"],
219+ "odnoklassniki.ru": ["Mobile", "Android; Mobile"],
220+ "alibaba.com": ["Mobile", "Android; Mobile"],
221+ "flickr.com": ["Mobile", "Android; Mobile"],
222+ "amazon.de": ["Mobile", "Android; Mobile"],
223+ "blogspot.in": ["Mobile", "Android; Mobile"],
224+ "ifeng.com": ["Mobile", "Android; Mobile"],
225+ "360.cn": ["Mobile", "Android; Mobile"],
226+ "youku.com": ["Mobile", "Android; Mobile"],
227+ "ebay.de": ["Mobile", "Android; Mobile"],
228+ "uol.com.br": ["Mobile", "Android; Mobile"],
229+ "aol.com": ["Mobile", "Android; Mobile"],
230+ "alipay.com": ["Mobile", "Android; Mobile"],
231+ "dailymotion.com": ["Mobile", "Android; Mobile Safari"],
232+ "amazon.co.uk": ["Mobile", "Android; Mobile"],
233+ "ebay.co.uk": ["Mobile", "Android; Mobile"],
234+ "facebook.com": [/WebKit\/[.0-9]*/, "Apple$& Firefox/18"],
235+ "nytimes.com": ["Mobile", "Android; Mobile Safari"],
236+};
237
238=== modified file 'src/browser-process/webview.qml'
239--- src/browser-process/webview.qml 2013-10-01 11:03:28 +0000
240+++ src/browser-process/webview.qml 2013-10-07 11:55:18 +0000
241@@ -39,19 +39,7 @@
242 bottom: osk.top
243 }
244 focus: true
245- experimental.userAgent: {
246- // FIXME: using iOS 5.0's iPhone/iPad user-agent strings
247- // (source: http://stackoverflow.com/questions/7825873/what-is-the-ios-5-0-user-agent-string),
248- // this should be changed to a more neutral user-agent in the
249- // future as we don't want websites to recommend installing
250- // their iPhone/iPad apps.
251- if (browser.formFactor === formFactor.phone) {
252- return "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
253- } else if (browser.formFactor === formFactor.tablet) {
254- return "Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"
255- }
256- }
257-
258+ experimental.userAgent: userAgent.defaultUA
259 experimental.preferences.developerExtrasEnabled: false
260 experimental.preferences.navigatorQtObjectEnabled: true
261
262@@ -65,6 +53,10 @@
263 }
264 }
265 onUrlChanged: request.currentUrl = url
266+
267+ UserAgent {
268+ id: userAgent
269+ }
270 }
271
272 KeyboardRectangle {
273
274=== modified file 'src/request.cpp'
275--- src/request.cpp 2013-05-02 19:17:06 +0000
276+++ src/request.cpp 2013-10-07 11:55:18 +0000
277@@ -315,7 +315,8 @@
278 /* We need to use the RemoteRequest implementation in UbuntuTouch,
279 * because displaying of QtWidgets is not working there. This is a
280 * workaround which can be revisited later. */
281- if (QGuiApplication::platformName() != "xcb") {
282+ if (QGuiApplication::platformName() != "xcb" ||
283+ qgetenv("SSOUI_USE_WEBKIT2") == QByteArray("1")) {
284 return new RemoteRequest("browser-process",
285 connection, message, parameters, parent);
286 }

Subscribers

People subscribed via source and target branches

to all changes: