Merge lp:~abreu-alexandre/unity-webapps-qml/automatic-update-of-url-for-webapp into lp:unity-webapps-qml

Proposed by Alexandre Abreu
Status: Merged
Approved by: Alexandre Abreu
Approved revision: 18
Merged at revision: 20
Proposed branch: lp:~abreu-alexandre/unity-webapps-qml/automatic-update-of-url-for-webapp
Merge into: lp:unity-webapps-qml
Diff against target: 264 lines (+69/-12)
12 files modified
examples/basic-webview/qml/basic-webview/main.qml (+5/-1)
examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml (+0/-2)
src/Ubuntu/UnityWebApps/UnityWebApps.js (+5/-1)
src/Ubuntu/UnityWebApps/UnityWebApps.qml (+34/-6)
src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js (+3/-0)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp (+4/-0)
src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h (+1/-0)
tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py (+12/-1)
tests/tests.pro (+1/-0)
tests/unit/test_plugin/tst_webappsAppModel.cpp (+0/-1)
tests/unit/test_qml/tst_dispatch.qml (+2/-0)
tests/unit/test_qml/tst_init.qml (+2/-0)
To merge this branch: bzr merge lp:~abreu-alexandre/unity-webapps-qml/automatic-update-of-url-for-webapp
Reviewer Review Type Date Requested Status
Alexandre Abreu (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+174224@code.launchpad.net

Description of the change

Automatic update of url to webapp homepage

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandre Abreu (abreu-alexandre) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'examples/basic-webview/qml/basic-webview/main.qml'
2--- examples/basic-webview/qml/basic-webview/main.qml 2013-06-06 17:32:54 +0000
3+++ examples/basic-webview/qml/basic-webview/main.qml 2013-07-11 15:24:29 +0000
4@@ -34,7 +34,11 @@
5 }
6
7 function getUnityWebappsProxies() {
8- return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
9+ var proxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
10+
11+ // override the default navigate to request
12+ proxies.navigateTo = function(url) {};
13+ return proxies;
14 }
15
16 UnityWebApps {
17
18=== modified file 'examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml'
19--- examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml 2013-06-17 14:46:51 +0000
20+++ examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml 2013-07-11 15:24:29 +0000
21@@ -28,8 +28,6 @@
22 WebView {
23 id: webView
24
25- // test url
26- url: "http://www.bbc.co.uk/news/"
27 anchors.fill: parent
28 width: parent.width
29 height: parent.height
30
31=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
32--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2013-06-06 17:32:54 +0000
33+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2013-07-11 15:24:29 +0000
34@@ -151,7 +151,11 @@
35 },
36
37 _isValidWebAppsMessage: function(message) {
38- return message != null && message.target && message.target === 'unity-webapps-call' && message.name && message.args;
39+ return message != null &&
40+ message.target &&
41+ message.target === 'unity-webapps-call' &&
42+ message.name &&
43+ message.args;
44 }
45 };
46
47
48=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
49--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2013-07-09 20:40:53 +0000
50+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2013-07-11 15:24:29 +0000
51@@ -162,7 +162,8 @@
52 var properties = [{'name': 'sendToPage', 'type': 'function'},
53 {'name': 'loadingStartedConnect', 'type': 'function'},
54 {'name': 'messageReceivedConnect', 'type': 'function'},
55- {'name': 'injectUserScripts', 'type': 'function'}];
56+ {'name': 'injectUserScripts', 'type': 'function'},
57+ {'name': 'navigateTo', 'type': 'function'}];
58
59 var validator = UnityWebAppsJsUtils.makePropertyValidator(properties);
60 return validator(proxies);
61@@ -189,6 +190,10 @@
62 internal.backends = null;
63 }
64
65+ function __isValidWebAppForModel(webappName) {
66+ return model != null && model.exists && model.exists(webappName);
67+ }
68+
69 /*!
70 \internal
71 Gathers the webapps userscript associated with the webapp whose
72@@ -196,9 +201,9 @@
73
74 Returns the list of URIs for the associated scripts to be injected
75 */
76- function __gatherWebAppUserscripts(webappName) {
77+ function __gatherWebAppUserscriptsIfAny(webappName) {
78 var userscripts = [];
79- if (model != null && model.exists && model.exists(webappName)) {
80+ if (__isValidWebAppForModel(webappName)) {
81 var idx = model.getWebappIndex(webappName);
82 userscripts = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Scripts);
83
84@@ -208,13 +213,35 @@
85 return userscripts;
86 }
87
88+ /*!
89+ \internal
90+
91+ If the component has been binded to a proper bindee (exposes proper interface)
92+ and the webapps bridge has been initialized, this make sure that the bindee
93+ is requested to navigate to a given 'homepage' url for the associated
94+ webapp.
95+ */
96+ function __navigateToWebappHomepageInBindee(webappName) {
97+ if (__isValidWebAppForModel(webappName) && internal.instance) {
98+ var idx = model.getWebappIndex(webappName);
99+ var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage);
100+
101+ console.debug('Requesting the bindee to navigate to: ' + homepage);
102+
103+ var bindeeProxies = bindee.getUnityWebappsProxies();
104+ bindeeProxies.navigateTo(homepage);
105+ }
106+ }
107+
108 Component.onCompleted: {
109 webapps.__unbind();
110- webapps.__bind(bindee, __gatherWebAppUserscripts(name));
111+ webapps.__bind(bindee, __gatherWebAppUserscriptsIfAny(name));
112
113 if (name != "") {
114 UnityBackends.clearAll();
115 UnityBackends.createAllWithAsync(webapps, {name: name});
116+
117+ __navigateToWebappHomepageInBindee(name);
118 }
119 }
120
121@@ -224,7 +251,7 @@
122 */
123 onBindeeChanged: {
124 __unbind();
125- __bind(bindee, __gatherWebAppUserscripts(name));
126+ __bind(bindee, __gatherWebAppUserscriptsIfAny(name));
127 }
128
129 /*!
130@@ -253,11 +280,12 @@
131
132 TODO lazily create the 'backends' on a getUnityObject
133 TODO the backends should prop be on the qml side and provided to here
134+ TODO move elsewhere (in js file)
135 */
136 function __makeBackendProxies () {
137 var initialized = false;
138 return {
139- init: function (params) {console.debug('calls init')
140+ init: function (params) {
141 UnityBackends.signalOnBackendReady("base", function () {
142 initialized = true;
143 // base.init(params);
144
145=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
146--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2013-06-06 17:32:54 +0000
147+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2013-07-11 15:24:29 +0000
148@@ -32,6 +32,9 @@
149 scripts.push(userScriptUrls[i]);
150 webViewId.experimental.userScripts = scripts;
151 },
152+ navigateTo: function(url) {
153+ webViewId.url = url;
154+ },
155 sendToPage: function (message) {
156 webViewId.experimental.postMessage(message);
157 },
158
159=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp'
160--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2013-07-09 19:02:23 +0000
161+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2013-07-11 15:24:29 +0000
162@@ -111,6 +111,7 @@
163 {
164 roles[Name] = "name";
165 roles[Domain] = "domain";
166+ roles[Homepage] = "homepage";
167 roles[Urls] = "urls";
168 roles[ScriptsContent] = "content";
169 roles[Scripts] = "scripts";
170@@ -361,6 +362,9 @@
171 case Domain:
172 return webapp.data.manifest.domain;
173
174+ case Homepage:
175+ return webapp.data.manifest.homepage;
176+
177 case Urls:
178 return webapp.data.manifest.includes;
179
180
181=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h'
182--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2013-07-09 19:02:23 +0000
183+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2013-07-11 15:24:29 +0000
184@@ -53,6 +53,7 @@
185 Name = Qt::UserRole + 1,
186 Domain,
187 Urls,
188+ Homepage,
189 Scripts,
190 ScriptsContent
191 };
192
193=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py'
194--- tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2013-07-09 20:33:17 +0000
195+++ tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2013-07-11 15:24:29 +0000
196@@ -42,7 +42,18 @@
197 def test_notificationApiFound(self):
198 expression = """
199 var unity = window.external.getUnityObject(1.0);
200- return unity.Notification != null && unity.Notification.show != null;
201+ return unity.Notification != null && unity.Notification.showNotification != null;
202+ """
203+ self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
204+
205+ def test_messagingIndicatorApiFound(self):
206+ expression = """
207+ var unity = window.external.getUnityObject(1.0);
208+ return unity.MessagingIndicator != null &&
209+ unity.MessagingIndicator.addAction != null &&
210+ unity.MessagingIndicator.clearIndicator != null &&
211+ unity.MessagingIndicator.clearIndicators != null &&
212+ unity.MessagingIndicator.showIndicator != null;
213 """
214 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
215
216
217=== modified file 'tests/tests.pro'
218--- tests/tests.pro 2013-07-09 20:24:05 +0000
219+++ tests/tests.pro 2013-07-11 15:24:29 +0000
220@@ -5,5 +5,6 @@
221 OTHER_FILES += \
222 $$system(ls ./integration/autopilot/qml/*) \
223 $$system(ls ./integration/autopilot/html/*) \
224+ $$system(ls ./integration/autopilot/data/installed-webapps/*) \
225 $$system(ls ./integration/autopilot/unity_webapps_qml/emulators/*.py) \
226 $$system(ls ./integration/autopilot/unity_webapps_qml/tests/*.py)
227
228=== modified file 'tests/unit/test_plugin/tst_webappsAppModel.cpp'
229--- tests/unit/test_plugin/tst_webappsAppModel.cpp 2013-07-09 19:02:23 +0000
230+++ tests/unit/test_plugin/tst_webappsAppModel.cpp 2013-07-11 15:24:29 +0000
231@@ -50,7 +50,6 @@
232 UnityWebappsAppModel
233 model;
234 model.setSearchPath("./data/no-installed-webapps");
235- qDebug() << model.rowCount();
236 QVERIFY(model.rowCount() == 0);
237 }
238
239
240=== modified file 'tests/unit/test_qml/tst_dispatch.qml'
241--- tests/unit/test_qml/tst_dispatch.qml 2013-06-06 17:32:54 +0000
242+++ tests/unit/test_qml/tst_dispatch.qml 2013-07-11 15:24:29 +0000
243@@ -134,6 +134,8 @@
244 },
245 sendToPage: function (message) {
246 },
247+ navigateTo: function (url) {
248+ },
249 loadingStartedConnect: function (onLoadingStarted) {
250 mockedWebView.loadingStarted.connect(onLoadingStarted);
251 loadingStartedConnected();
252
253=== modified file 'tests/unit/test_qml/tst_init.qml'
254--- tests/unit/test_qml/tst_init.qml 2013-06-06 17:32:54 +0000
255+++ tests/unit/test_qml/tst_init.qml 2013-07-11 15:24:29 +0000
256@@ -93,6 +93,8 @@
257 },
258 sendToPage: function (message) {
259 },
260+ navigateTo: function (url) {
261+ },
262 loadingStartedConnect: function (onLoadingStarted) {
263 mockedWebView.loadingStarted.connect(onLoadingStarted);
264 loadingStartedConnected();

Subscribers

People subscribed via source and target branches

to all changes: