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
=== modified file 'examples/basic-webview/qml/basic-webview/main.qml'
--- examples/basic-webview/qml/basic-webview/main.qml 2013-06-06 17:32:54 +0000
+++ examples/basic-webview/qml/basic-webview/main.qml 2013-07-11 15:24:29 +0000
@@ -34,7 +34,11 @@
34 }34 }
3535
36 function getUnityWebappsProxies() {36 function getUnityWebappsProxies() {
37 return UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);37 var proxies = UnityWebAppsUtils.makeProxiesForQtWebViewBindee(webView);
38
39 // override the default navigate to request
40 proxies.navigateTo = function(url) {};
41 return proxies;
38 }42 }
3943
40 UnityWebApps {44 UnityWebApps {
4145
=== modified file 'examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml'
--- examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml 2013-06-17 14:46:51 +0000
+++ examples/unity-webapps-example-bbcnews/qml/unity-webapps-example-bbcnews/main.qml 2013-07-11 15:24:29 +0000
@@ -28,8 +28,6 @@
28 WebView {28 WebView {
29 id: webView29 id: webView
3030
31 // test url
32 url: "http://www.bbc.co.uk/news/"
33 anchors.fill: parent31 anchors.fill: parent
34 width: parent.width32 width: parent.width
35 height: parent.height33 height: parent.height
3634
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.js'
--- src/Ubuntu/UnityWebApps/UnityWebApps.js 2013-06-06 17:32:54 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.js 2013-07-11 15:24:29 +0000
@@ -151,7 +151,11 @@
151 },151 },
152152
153 _isValidWebAppsMessage: function(message) {153 _isValidWebAppsMessage: function(message) {
154 return message != null && message.target && message.target === 'unity-webapps-call' && message.name && message.args;154 return message != null &&
155 message.target &&
156 message.target === 'unity-webapps-call' &&
157 message.name &&
158 message.args;
155 }159 }
156 };160 };
157161
158162
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebApps.qml'
--- src/Ubuntu/UnityWebApps/UnityWebApps.qml 2013-07-09 20:40:53 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebApps.qml 2013-07-11 15:24:29 +0000
@@ -162,7 +162,8 @@
162 var properties = [{'name': 'sendToPage', 'type': 'function'},162 var properties = [{'name': 'sendToPage', 'type': 'function'},
163 {'name': 'loadingStartedConnect', 'type': 'function'},163 {'name': 'loadingStartedConnect', 'type': 'function'},
164 {'name': 'messageReceivedConnect', 'type': 'function'},164 {'name': 'messageReceivedConnect', 'type': 'function'},
165 {'name': 'injectUserScripts', 'type': 'function'}];165 {'name': 'injectUserScripts', 'type': 'function'},
166 {'name': 'navigateTo', 'type': 'function'}];
166167
167 var validator = UnityWebAppsJsUtils.makePropertyValidator(properties);168 var validator = UnityWebAppsJsUtils.makePropertyValidator(properties);
168 return validator(proxies);169 return validator(proxies);
@@ -189,6 +190,10 @@
189 internal.backends = null;190 internal.backends = null;
190 }191 }
191192
193 function __isValidWebAppForModel(webappName) {
194 return model != null && model.exists && model.exists(webappName);
195 }
196
192 /*!197 /*!
193 \internal198 \internal
194 Gathers the webapps userscript associated with the webapp whose199 Gathers the webapps userscript associated with the webapp whose
@@ -196,9 +201,9 @@
196201
197 Returns the list of URIs for the associated scripts to be injected202 Returns the list of URIs for the associated scripts to be injected
198 */203 */
199 function __gatherWebAppUserscripts(webappName) {204 function __gatherWebAppUserscriptsIfAny(webappName) {
200 var userscripts = [];205 var userscripts = [];
201 if (model != null && model.exists && model.exists(webappName)) {206 if (__isValidWebAppForModel(webappName)) {
202 var idx = model.getWebappIndex(webappName);207 var idx = model.getWebappIndex(webappName);
203 userscripts = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Scripts);208 userscripts = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Scripts);
204209
@@ -208,13 +213,35 @@
208 return userscripts;213 return userscripts;
209 }214 }
210215
216 /*!
217 \internal
218
219 If the component has been binded to a proper bindee (exposes proper interface)
220 and the webapps bridge has been initialized, this make sure that the bindee
221 is requested to navigate to a given 'homepage' url for the associated
222 webapp.
223 */
224 function __navigateToWebappHomepageInBindee(webappName) {
225 if (__isValidWebAppForModel(webappName) && internal.instance) {
226 var idx = model.getWebappIndex(webappName);
227 var homepage = model.data(idx, UbuntuUnityWebApps.UnityWebappsAppModel.Homepage);
228
229 console.debug('Requesting the bindee to navigate to: ' + homepage);
230
231 var bindeeProxies = bindee.getUnityWebappsProxies();
232 bindeeProxies.navigateTo(homepage);
233 }
234 }
235
211 Component.onCompleted: {236 Component.onCompleted: {
212 webapps.__unbind();237 webapps.__unbind();
213 webapps.__bind(bindee, __gatherWebAppUserscripts(name));238 webapps.__bind(bindee, __gatherWebAppUserscriptsIfAny(name));
214239
215 if (name != "") {240 if (name != "") {
216 UnityBackends.clearAll();241 UnityBackends.clearAll();
217 UnityBackends.createAllWithAsync(webapps, {name: name});242 UnityBackends.createAllWithAsync(webapps, {name: name});
243
244 __navigateToWebappHomepageInBindee(name);
218 }245 }
219 }246 }
220247
@@ -224,7 +251,7 @@
224 */251 */
225 onBindeeChanged: {252 onBindeeChanged: {
226 __unbind();253 __unbind();
227 __bind(bindee, __gatherWebAppUserscripts(name));254 __bind(bindee, __gatherWebAppUserscriptsIfAny(name));
228 }255 }
229256
230 /*!257 /*!
@@ -253,11 +280,12 @@
253280
254 TODO lazily create the 'backends' on a getUnityObject281 TODO lazily create the 'backends' on a getUnityObject
255 TODO the backends should prop be on the qml side and provided to here282 TODO the backends should prop be on the qml side and provided to here
283 TODO move elsewhere (in js file)
256 */284 */
257 function __makeBackendProxies () {285 function __makeBackendProxies () {
258 var initialized = false;286 var initialized = false;
259 return {287 return {
260 init: function (params) {console.debug('calls init')288 init: function (params) {
261 UnityBackends.signalOnBackendReady("base", function () {289 UnityBackends.signalOnBackendReady("base", function () {
262 initialized = true;290 initialized = true;
263 // base.init(params);291 // base.init(params);
264292
=== modified file 'src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js'
--- src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2013-06-06 17:32:54 +0000
+++ src/Ubuntu/UnityWebApps/UnityWebAppsUtils.js 2013-07-11 15:24:29 +0000
@@ -32,6 +32,9 @@
32 scripts.push(userScriptUrls[i]);32 scripts.push(userScriptUrls[i]);
33 webViewId.experimental.userScripts = scripts;33 webViewId.experimental.userScripts = scripts;
34 },34 },
35 navigateTo: function(url) {
36 webViewId.url = url;
37 },
35 sendToPage: function (message) {38 sendToPage: function (message) {
36 webViewId.experimental.postMessage(message);39 webViewId.experimental.postMessage(message);
37 },40 },
3841
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2013-07-09 19:02:23 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.cpp 2013-07-11 15:24:29 +0000
@@ -111,6 +111,7 @@
111 {111 {
112 roles[Name] = "name";112 roles[Name] = "name";
113 roles[Domain] = "domain";113 roles[Domain] = "domain";
114 roles[Homepage] = "homepage";
114 roles[Urls] = "urls";115 roles[Urls] = "urls";
115 roles[ScriptsContent] = "content";116 roles[ScriptsContent] = "content";
116 roles[Scripts] = "scripts";117 roles[Scripts] = "scripts";
@@ -361,6 +362,9 @@
361 case Domain:362 case Domain:
362 return webapp.data.manifest.domain;363 return webapp.data.manifest.domain;
363364
365 case Homepage:
366 return webapp.data.manifest.homepage;
367
364 case Urls:368 case Urls:
365 return webapp.data.manifest.includes;369 return webapp.data.manifest.includes;
366370
367371
=== modified file 'src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h'
--- src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2013-07-09 19:02:23 +0000
+++ src/Ubuntu/UnityWebApps/plugin/unity-webapps-app-model.h 2013-07-11 15:24:29 +0000
@@ -53,6 +53,7 @@
53 Name = Qt::UserRole + 1,53 Name = Qt::UserRole + 1,
54 Domain,54 Domain,
55 Urls,55 Urls,
56 Homepage,
56 Scripts,57 Scripts,
57 ScriptsContent58 ScriptsContent
58 };59 };
5960
=== modified file 'tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py'
--- tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2013-07-09 20:33:17 +0000
+++ tests/integration/autopilot/unity_webapps_qml/tests/test_injectedOnWebapp.py 2013-07-11 15:24:29 +0000
@@ -42,7 +42,18 @@
42 def test_notificationApiFound(self):42 def test_notificationApiFound(self):
43 expression = """43 expression = """
44 var unity = window.external.getUnityObject(1.0);44 var unity = window.external.getUnityObject(1.0);
45 return unity.Notification != null && unity.Notification.show != null;45 return unity.Notification != null && unity.Notification.showNotification != null;
46 """
47 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
48
49 def test_messagingIndicatorApiFound(self):
50 expression = """
51 var unity = window.external.getUnityObject(1.0);
52 return unity.MessagingIndicator != null &&
53 unity.MessagingIndicator.addAction != null &&
54 unity.MessagingIndicator.clearIndicator != null &&
55 unity.MessagingIndicator.clearIndicators != null &&
56 unity.MessagingIndicator.showIndicator != null;
46 """57 """
47 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))58 self.assertThat(lambda: self.eval_expression_in_page_unsafe(expression), Eventually(NotEquals(None)))
4859
4960
=== modified file 'tests/tests.pro'
--- tests/tests.pro 2013-07-09 20:24:05 +0000
+++ tests/tests.pro 2013-07-11 15:24:29 +0000
@@ -5,5 +5,6 @@
5OTHER_FILES += \5OTHER_FILES += \
6 $$system(ls ./integration/autopilot/qml/*) \6 $$system(ls ./integration/autopilot/qml/*) \
7 $$system(ls ./integration/autopilot/html/*) \7 $$system(ls ./integration/autopilot/html/*) \
8 $$system(ls ./integration/autopilot/data/installed-webapps/*) \
8 $$system(ls ./integration/autopilot/unity_webapps_qml/emulators/*.py) \9 $$system(ls ./integration/autopilot/unity_webapps_qml/emulators/*.py) \
9 $$system(ls ./integration/autopilot/unity_webapps_qml/tests/*.py)10 $$system(ls ./integration/autopilot/unity_webapps_qml/tests/*.py)
1011
=== modified file 'tests/unit/test_plugin/tst_webappsAppModel.cpp'
--- tests/unit/test_plugin/tst_webappsAppModel.cpp 2013-07-09 19:02:23 +0000
+++ tests/unit/test_plugin/tst_webappsAppModel.cpp 2013-07-11 15:24:29 +0000
@@ -50,7 +50,6 @@
50 UnityWebappsAppModel50 UnityWebappsAppModel
51 model;51 model;
52 model.setSearchPath("./data/no-installed-webapps");52 model.setSearchPath("./data/no-installed-webapps");
53 qDebug() << model.rowCount();
54 QVERIFY(model.rowCount() == 0);53 QVERIFY(model.rowCount() == 0);
55}54}
5655
5756
=== modified file 'tests/unit/test_qml/tst_dispatch.qml'
--- tests/unit/test_qml/tst_dispatch.qml 2013-06-06 17:32:54 +0000
+++ tests/unit/test_qml/tst_dispatch.qml 2013-07-11 15:24:29 +0000
@@ -134,6 +134,8 @@
134 },134 },
135 sendToPage: function (message) {135 sendToPage: function (message) {
136 },136 },
137 navigateTo: function (url) {
138 },
137 loadingStartedConnect: function (onLoadingStarted) {139 loadingStartedConnect: function (onLoadingStarted) {
138 mockedWebView.loadingStarted.connect(onLoadingStarted);140 mockedWebView.loadingStarted.connect(onLoadingStarted);
139 loadingStartedConnected();141 loadingStartedConnected();
140142
=== modified file 'tests/unit/test_qml/tst_init.qml'
--- tests/unit/test_qml/tst_init.qml 2013-06-06 17:32:54 +0000
+++ tests/unit/test_qml/tst_init.qml 2013-07-11 15:24:29 +0000
@@ -93,6 +93,8 @@
93 },93 },
94 sendToPage: function (message) {94 sendToPage: function (message) {
95 },95 },
96 navigateTo: function (url) {
97 },
96 loadingStartedConnect: function (onLoadingStarted) {98 loadingStartedConnect: function (onLoadingStarted) {
97 mockedWebView.loadingStarted.connect(onLoadingStarted);99 mockedWebView.loadingStarted.connect(onLoadingStarted);
98 loadingStartedConnected();100 loadingStartedConnected();

Subscribers

People subscribed via source and target branches

to all changes: