Merge lp:~abreu-alexandre/webbrowser-app/simple-user-agent-override into lp:webbrowser-app

Proposed by Alexandre Abreu
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 723
Merged at revision: 740
Proposed branch: lp:~abreu-alexandre/webbrowser-app/simple-user-agent-override
Merge into: lp:webbrowser-app
Diff against target: 115 lines (+26/-4)
4 files modified
src/app/webcontainer/WebApp.qml (+12/-2)
src/app/webcontainer/webapp-container.cpp (+10/-2)
src/app/webcontainer/webapp-container.h (+1/-0)
src/app/webcontainer/webapp-container.qml (+3/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/webbrowser-app/simple-user-agent-override
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+236030@code.launchpad.net

Commit message

Add a simple mechanism (simpler than the one already in place) to override user agents for a given webapp.

Description of the change

Add a simple mechanism (simpler than the one already in place) to override user agents for a given webapp.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Please revert the changes to po/webbrowser-app.pot.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
720. By PS Jenkins bot

Resync trunk

Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good overall (I still need to test the functionality). See a couple of inline comments.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Functional testing is ok.

721. By Launchpad Translations on behalf of phablet-team

Launchpad automatic translations update.

722. By Alexandre Abreu

Updates

Revision history for this message
Alexandre Abreu (abreu-alexandre) wrote :

updated

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks mostly ok. See my comments inline.

review: Needs Fixing
723. By Alexandre Abreu

fixes

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/webcontainer/WebApp.qml'
2--- src/app/webcontainer/WebApp.qml 2014-09-26 06:12:53 +0000
3+++ src/app/webcontainer/WebApp.qml 2014-09-29 18:45:29 +0000
4@@ -38,6 +38,7 @@
5 property alias webappUrlPatterns: webview.webappUrlPatterns
6 property alias popupRedirectionUrlPrefix: webview.popupRedirectionUrlPrefix
7 property alias webviewOverrideFile: webview.webviewOverrideFile
8+ property string localUserAgentOverride: ""
9
10 property bool backForwardButtonsVisible: false
11 property bool chromeVisible: false
12@@ -57,6 +58,16 @@
13 }
14 ]
15
16+ function getLocalUserAgentOverrideIfAny() {
17+ if (localUserAgentOverride.length !== 0)
18+ return localUserAgentOverride
19+
20+ if (webappName && unityWebapps.model.exists(webappName))
21+ return unityWebapps.model.userAgentOverrideFor(webappName)
22+
23+ return ""
24+ }
25+
26 Item {
27 anchors.fill: parent
28
29@@ -71,8 +82,7 @@
30 }
31 height: parent.height - osk.height - (webapp.chromeless ? 0 : chromeLoader.item.visibleHeight)
32 developerExtrasEnabled: webapp.developerExtrasEnabled
33- localUserAgentOverride: webappName && unityWebapps.model.exists(webappName) ?
34- unityWebapps.model.userAgentOverrideFor(webappName) : ""
35+ localUserAgentOverride: getLocalUserAgentOverrideIfAny()
36 }
37
38 Loader {
39
40=== modified file 'src/app/webcontainer/webapp-container.cpp'
41--- src/app/webcontainer/webapp-container.cpp 2014-09-03 20:07:28 +0000
42+++ src/app/webcontainer/webapp-container.cpp 2014-09-29 18:45:29 +0000
43@@ -137,6 +137,10 @@
44 m_window->setProperty("popupRedirectionUrlPrefix", m_popupRedirectionUrlPrefix);
45 }
46
47+ if (!m_userAgentOverride.isEmpty()) {
48+ m_window->setProperty("localUserAgentOverride", m_userAgentOverride);
49+ }
50+
51 // Experimental, unsupported API, to override the webview
52 QFileInfo overrideFile("webview-override.qml");
53 if (overrideFile.exists()) {
54@@ -192,6 +196,7 @@
55 " [--enable-back-forward]"
56 " [--enable-addressbar]"
57 " [--store-session-cookies]"
58+ " [--user-agent-string=USER_AGENT]"
59 " [URL]" << endl;
60 out << "Options:" << endl;
61 out << " -h, --help display this help message and exit" << endl;
62@@ -206,6 +211,7 @@
63 out << " --webappUrlPatterns=URL_PATTERNS list of comma-separated url patterns (wildcard based) that the webapp is allowed to navigate to" << endl;
64 out << " --accountProvider=PROVIDER_NAME Online account provider for the application if the application is to reuse a local account." << endl;
65 out << " --store-session-cookies store session cookies on disk" << endl;
66+ out << " --user-agent-string=USER_AGENT overrides the default User Agent with the provided one." << endl;
67 out << "Chrome options (if none specified, no chrome is shown by default):" << endl;
68 out << " --enable-back-forward enable the display of the back and forward buttons (implies --enable-addressbar)" << endl;
69 out << " --enable-addressbar enable the display of a minimal chrome (favicon and title)" << endl;
70@@ -244,9 +250,11 @@
71 } else if (argument == "--local-webapp-manifest") {
72 m_localWebappManifest = true;
73 } else if (argument.startsWith("--popup-redirection-url-prefix=")) {
74- m_popupRedirectionUrlPrefix = argument.split("--popup-redirection-url-prefix=")[1];;
75+ m_popupRedirectionUrlPrefix = argument.split("--popup-redirection-url-prefix=")[1];
76 } else if (argument.startsWith("--local-cookie-db-path=")) {
77- m_localCookieStoreDbPath = argument.split("--local-cookie-db-path=")[1];;
78+ m_localCookieStoreDbPath = argument.split("--local-cookie-db-path=")[1];
79+ } else if (argument.startsWith("--user-agent-string=")) {
80+ m_userAgentOverride = argument.split("--user-agent-string=")[1];
81 }
82 }
83 }
84
85=== modified file 'src/app/webcontainer/webapp-container.h'
86--- src/app/webcontainer/webapp-container.h 2014-08-13 16:23:36 +0000
87+++ src/app/webcontainer/webapp-container.h 2014-09-29 18:45:29 +0000
88@@ -58,6 +58,7 @@
89 bool m_localWebappManifest;
90 QString m_popupRedirectionUrlPrefix;
91 QString m_localCookieStoreDbPath;
92+ QString m_userAgentOverride;
93 QScopedPointer<WebappContainerHelper> m_webappContainerHelper;
94
95 static const QString URL_PATTERN_SEPARATOR;
96
97=== modified file 'src/app/webcontainer/webapp-container.qml'
98--- src/app/webcontainer/webapp-container.qml 2014-09-26 06:13:05 +0000
99+++ src/app/webcontainer/webapp-container.qml 2014-09-29 18:45:29 +0000
100@@ -43,6 +43,7 @@
101 property string popupRedirectionUrlPrefix: ""
102 property url webviewOverrideFile: ""
103 property var __webappCookieStore: null
104+ property string localUserAgentOverride: ""
105
106 contentOrientation: Screen.orientation
107
108@@ -78,6 +79,8 @@
109 webappModelSearchPath: root.webappModelSearchPath
110 webappUrlPatterns: root.webappUrlPatterns
111
112+ localUserAgentOverride: root.localUserAgentOverride
113+
114 popupRedirectionUrlPrefix: root.popupRedirectionUrlPrefix
115 webviewOverrideFile: root.webviewOverrideFile
116

Subscribers

People subscribed via source and target branches

to status/vote changes: