Merge lp:~abreu-alexandre/webbrowser-app/onnavigationrequested into lp:webbrowser-app
- onnavigationrequested
- Merge into trunk
Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | 485 | ||||||||
Proposed branch: | lp:~abreu-alexandre/webbrowser-app/onnavigationrequested | ||||||||
Merge into: | lp:webbrowser-app | ||||||||
Diff against target: |
351 lines (+205/-98) 3 files modified
src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml (+20/-7) src/app/webcontainer/WebViewImplOxide.qml (+179/-0) src/app/webcontainer/WebappContainerWebview.qml (+6/-91) |
||||||||
To merge this branch: | bzr merge lp:~abreu-alexandre/webbrowser-app/onnavigationrequested | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Ubuntu Phablet Team | Pending | ||
Review via email:
|
Commit message
Add support for Oxide's onNavigationReq
Description of the change
Add support for Oxide's onNavigationReq
It also updates Oxide to 1.0 (pending release)
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
- 480. By Olivier Tilloy
-
Re-enable javascript dialogs, now that they are available in oxide.
- 481. By PS Jenkins bot
-
Releasing 0.23+14.
04.20140403- 0ubuntu1
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:482
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:483
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 482. By Olivier Tilloy
-
Update to oxide 1.0.
- 483. By PS Jenkins bot
-
Releasing 0.23+14.
04.20140407. 1-0ubuntu1 - 484. By Launchpad Translations on behalf of phablet-team
-
Launchpad automatic translations update.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:484
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:485
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 485. By Alexandre Abreu
-
d
- 486. By Alexandre Abreu
-
handle invalid navigation request from popup
- 487. By Alexandre Abreu
-
handle invalid 'about:blank' navigation as gracefully as possible until fixed
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:486
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:487
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml' |
2 | --- src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml 2014-04-07 09:17:37 +0000 |
3 | +++ src/Ubuntu/Components/Extras/Browser/UbuntuWebView02.qml 2014-04-09 01:25:24 +0000 |
4 | @@ -26,7 +26,8 @@ |
5 | WebView { |
6 | id: _webview |
7 | |
8 | - signal newTabRequested(url url) |
9 | + // TODO Should be renamed to newViewRequested |
10 | + signal newTabRequested(var request) |
11 | |
12 | //interactive: !selection.visible |
13 | |
14 | @@ -96,11 +97,22 @@ |
15 | } |
16 | ] |
17 | |
18 | - /*onNavigationRequested: { |
19 | - request.action = WebView.AcceptRequest; |
20 | - |
21 | - navigationRequestedDelegate (request); |
22 | - if (request.action === WebView.IgnoreRequest) |
23 | + onNewViewRequested: { |
24 | + // TODO: at this point request.disposition should be |
25 | + // NewViewRequest.DispositionNewPopup (all dispositions are coerced to it), |
26 | + // not sure if it is safer to add an extra level of filtering to avoid |
27 | + // e.g. NewViewRequest.DispositionCurrentTab being opened |
28 | + // as new tabs (although should never happen) |
29 | + newTabRequested(request) |
30 | + } |
31 | + |
32 | + onNavigationRequested: { |
33 | + request.action = NavigationRequest.ActionAccept; |
34 | + |
35 | + navigationRequestedDelegate(request); |
36 | + |
37 | + /* |
38 | + if (request.action === NavigationRequest.ActionReject) |
39 | return; |
40 | |
41 | var staticUA = _webview.getUAString() |
42 | @@ -109,7 +121,8 @@ |
43 | } else { |
44 | _webview.experimental.userAgent = staticUA |
45 | } |
46 | - }*/ |
47 | + */ |
48 | + } |
49 | |
50 | /*experimental.preferences.navigatorQtObjectEnabled: true |
51 | experimental.userScripts: [Qt.resolvedUrl("hyperlinks.js"), |
52 | |
53 | === added file 'src/app/webcontainer/WebViewImplOxide.qml' |
54 | --- src/app/webcontainer/WebViewImplOxide.qml 1970-01-01 00:00:00 +0000 |
55 | +++ src/app/webcontainer/WebViewImplOxide.qml 2014-04-09 01:25:24 +0000 |
56 | @@ -0,0 +1,179 @@ |
57 | +/* |
58 | + * Copyright 2014 Canonical Ltd. |
59 | + * |
60 | + * This file is part of webbrowser-app. |
61 | + * |
62 | + * webbrowser-app is free software; you can redistribute it and/or modify |
63 | + * it under the terms of the GNU General Public License as published by |
64 | + * the Free Software Foundation; version 3. |
65 | + * |
66 | + * webbrowser-app is distributed in the hope that it will be useful, |
67 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
68 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
69 | + * GNU General Public License for more details. |
70 | + * |
71 | + * You should have received a copy of the GNU General Public License |
72 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
73 | + */ |
74 | + |
75 | +import QtQuick 2.0 |
76 | +import QtQuick.Window 2.0 |
77 | +import com.canonical.Oxide 1.0 |
78 | +import Ubuntu.Components 0.1 |
79 | +import Ubuntu.Components.Extras.Browser 0.2 |
80 | +import Ubuntu.UnityWebApps 0.1 as UnityWebApps |
81 | +import Ubuntu.Components.Popups 0.1 |
82 | +import "../actions" as Actions |
83 | +import ".." |
84 | + |
85 | +WebViewImpl { |
86 | + id: webview |
87 | + |
88 | + property bool developerExtrasEnabled: false |
89 | + property var toolbar: null |
90 | + property string webappName: "" |
91 | + property var webappUrlPatterns: null |
92 | + |
93 | + currentWebview: webview |
94 | + |
95 | + contextualActions: ActionList { |
96 | + Actions.CopyLink { |
97 | + enabled: webview.contextualData.href.toString() |
98 | + onTriggered: Clipboard.push([webview.contextualData.href]) |
99 | + } |
100 | + Actions.CopyImage { |
101 | + enabled: webview.contextualData.img.toString() |
102 | + onTriggered: Clipboard.push([webview.contextualData.img]) |
103 | + } |
104 | + } |
105 | + |
106 | + function isRunningAsANamedWebapp() { |
107 | + return webview.webappName && typeof(webview.webappName) === 'string' && webview.webappName.length != 0 |
108 | + } |
109 | + |
110 | + function haveValidUrlPatterns() { |
111 | + return webappUrlPatterns && webappUrlPatterns.length !== 0 |
112 | + } |
113 | + |
114 | + function shouldAllowNavigationTo(url) { |
115 | + // The list of url patterns defined by the webapp takes precedence over command line |
116 | + if (isRunningAsANamedWebapp()) { |
117 | + if (unityWebapps.model.exists(unityWebapps.name) && |
118 | + unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) { |
119 | + return true; |
120 | + } |
121 | + } |
122 | + |
123 | + // We still take the possible additional patterns specified in the command line |
124 | + // (the in the case of finer grained ones specifically for the container and not |
125 | + // as an 'install source' for the webapp). |
126 | + if (webappUrlPatterns && webappUrlPatterns.length !== 0) { |
127 | + for (var i = 0; i < webappUrlPatterns.length; ++i) { |
128 | + var pattern = webappUrlPatterns[i] |
129 | + if (url.match(pattern)) { |
130 | + return true; |
131 | + } |
132 | + } |
133 | + } |
134 | + |
135 | + return false; |
136 | + } |
137 | + |
138 | + function navigationRequestedDelegate(request) { |
139 | + // Pass-through if we are not running as a named webapp (--webapp='Gmail') |
140 | + // or if we dont have a list of url patterns specified to filter the |
141 | + // browsing actions |
142 | + if ( ! webview.haveValidUrlPatterns() && ! webview.isRunningAsANamedWebapp()) { |
143 | + request.action = NavigationRequest.ActionAccept |
144 | + return |
145 | + } |
146 | + |
147 | + var url = request.url.toString() |
148 | + |
149 | + // Covers some edge cases corresponding to current Oxide potential issues (to be |
150 | + // confirmed) that for e.g GooglePlus when a window.open() happens (or equivalent) |
151 | + // the url that we are given (for the corresponding window.open() is 'about:blank') |
152 | + if (url == 'about:blank') { |
153 | + console.log('Ignoring the request to navigate to "about:blank"') |
154 | + request.action = NavigationRequest.ActionReject |
155 | + return; |
156 | + } |
157 | + |
158 | + request.action = NavigationRequest.ActionReject |
159 | + if (webview.shouldAllowNavigationTo(url)) |
160 | + request.action = NavigationRequest.ActionAccept |
161 | + |
162 | + if ( ! webview.isRunningAsANamedWebapp() && request.disposition === NavigationRequest.DispositionNewPopup) { |
163 | + console.debug('Opening: popup window ' + url + ' in the browser window.') |
164 | + Qt.openUrlExternally(url); |
165 | + return; |
166 | + } |
167 | + |
168 | + if (request.action === NavigationRequest.ActionReject) { |
169 | + console.debug('Opening: ' + url + ' in the browser window.') |
170 | + Qt.openUrlExternally(url) |
171 | + } |
172 | + } |
173 | + |
174 | + function createPopupWindow(request) { |
175 | + popupWebViewFactory.createObject(webview, { request: request, width: 500, height: 800 }); |
176 | + } |
177 | + |
178 | + Component { |
179 | + id: popupWebViewFactory |
180 | + Window { |
181 | + id: popup |
182 | + property alias request: popupBrowser.request |
183 | + UbuntuWebView { |
184 | + id: popupBrowser |
185 | + anchors.fill: parent |
186 | + |
187 | + function navigationRequestedDelegate(request) { |
188 | + var url = request.url.toString() |
189 | + |
190 | + // If we are to browse in the popup to a place where we are not allows |
191 | + if (request.disposition !== NavigationRequest.DispositionNewPopup && |
192 | + ! webview.shouldAllowNavigationTo(url)) { |
193 | + Qt.openUrlExternally(url); |
194 | + popup.close() |
195 | + return; |
196 | + } |
197 | + |
198 | + // Fallback to regulat checks (there is a bit of overlap) |
199 | + webview.navigationRequestedDelegate(request) |
200 | + } |
201 | + |
202 | + onNewTabRequested: { |
203 | + webview.createPopupWindow(request) |
204 | + } |
205 | + } |
206 | + Component.onCompleted: popup.show() |
207 | + } |
208 | + } |
209 | + |
210 | + onNewTabRequested: { |
211 | + createPopupWindow(request) |
212 | + } |
213 | + |
214 | + preferences.localStorageEnabled: true |
215 | + |
216 | + // Small shim needed when running as a webapp to wire-up connections |
217 | + // with the webview (message received, etc…). |
218 | + // This is being called (and expected) internally by the webapps |
219 | + // component as a way to bind to a webview lookalike without |
220 | + // reaching out directly to its internals (see it as an interface). |
221 | + function getUnityWebappsProxies() { |
222 | + var eventHandlers = { |
223 | + onAppRaised: function () { |
224 | + if (webbrowserWindow) { |
225 | + try { |
226 | + webbrowserWindow.raise(); |
227 | + } catch (e) { |
228 | + console.debug('Error while raising: ' + e); |
229 | + } |
230 | + } |
231 | + } |
232 | + }; |
233 | + return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview, eventHandlers) |
234 | + } |
235 | +} |
236 | |
237 | === modified file 'src/app/webcontainer/WebappContainerWebview.qml' |
238 | --- src/app/webcontainer/WebappContainerWebview.qml 2014-03-28 15:42:34 +0000 |
239 | +++ src/app/webcontainer/WebappContainerWebview.qml 2014-04-09 01:25:24 +0000 |
240 | @@ -32,7 +32,7 @@ |
241 | property string webappName: "" |
242 | property var currentWebview: webappContainerWebViewLoader.item |
243 | property var toolbar: null |
244 | - property var webappUrlPatterns: null |
245 | + property var webappUrlPatterns |
246 | |
247 | Loader { |
248 | id: webappContainerWebViewLoader |
249 | @@ -55,97 +55,12 @@ |
250 | Component { |
251 | id: webappContainerWebViewOxide |
252 | |
253 | - WebViewImpl { |
254 | - id: webview |
255 | - |
256 | + WebViewImplOxide { |
257 | + toolbar: containerWebview.toolbar |
258 | url: containerWebview.url |
259 | - currentWebview: webview |
260 | - toolbar: containerWebview.toolbar |
261 | - |
262 | - contextualActions: ActionList { |
263 | - Actions.CopyLink { |
264 | - enabled: webview.contextualData.href.toString() |
265 | - onTriggered: Clipboard.push([webview.contextualData.href]) |
266 | - } |
267 | - Actions.CopyImage { |
268 | - enabled: webview.contextualData.img.toString() |
269 | - onTriggered: Clipboard.push([webview.contextualData.img]) |
270 | - } |
271 | - } |
272 | - |
273 | - function haveValidUrlPatterns() { |
274 | - return webappUrlPatterns && webappUrlPatterns.length !== 0 |
275 | - } |
276 | - |
277 | - /*function navigationRequestedDelegate(request) { |
278 | - if (!request.isMainFrame) { |
279 | - request.action = WebView.AcceptRequest |
280 | - return |
281 | - } |
282 | - |
283 | - // Pass-through if we are not running as a named webapp (--webapp='Gmail') |
284 | - // or if we dont have a list of url patterns specified to filter the |
285 | - // browsing actions |
286 | - if ( ! haveValidUrlPatterns() && ! isRunningAsANamedWebapp()) { |
287 | - request.action = WebView.AcceptRequest |
288 | - return |
289 | - } |
290 | - |
291 | - var action = WebView.IgnoreRequest |
292 | - var url = request.url.toString() |
293 | - |
294 | - // The list of url patterns defined by the webapp takes precedence over command line |
295 | - if (isRunningAsANamedWebapp()) { |
296 | - if (unityWebapps.model.exists(unityWebapps.name) && |
297 | - unityWebapps.model.doesUrlMatchesWebapp(unityWebapps.name, url)) { |
298 | - request.action = WebView.AcceptRequest |
299 | - return; |
300 | - } |
301 | - } |
302 | - |
303 | - // We still take the possible additional patterns specified in the command line |
304 | - // (the in the case of finer grained ones specifically for the container and not |
305 | - // as an 'install source' for the webapp). |
306 | - if (webappUrlPatterns && webappUrlPatterns.length !== 0) { |
307 | - for (var i = 0; i < webappUrlPatterns.length; ++i) { |
308 | - var pattern = webappUrlPatterns[i] |
309 | - if (url.match(pattern)) { |
310 | - action = WebView.AcceptRequest |
311 | - break |
312 | - } |
313 | - } |
314 | - } |
315 | - |
316 | - request.action = action |
317 | - if (action === WebView.IgnoreRequest) { |
318 | - console.debug('Opening: ' + url + ' in the browser window.') |
319 | - Qt.openUrlExternally(url) |
320 | - } |
321 | - }*/ |
322 | - |
323 | - onNewTabRequested: Qt.openUrlExternally(url) |
324 | - |
325 | - preferences.localStorageEnabled: true |
326 | - |
327 | - // Small shim needed when running as a webapp to wire-up connections |
328 | - // with the webview (message received, etc…). |
329 | - // This is being called (and expected) internally by the webapps |
330 | - // component as a way to bind to a webview lookalike without |
331 | - // reaching out directly to its internals (see it as an interface). |
332 | - function getUnityWebappsProxies() { |
333 | - var eventHandlers = { |
334 | - onAppRaised: function () { |
335 | - if (webbrowserWindow) { |
336 | - try { |
337 | - webbrowserWindow.raise(); |
338 | - } catch (e) { |
339 | - console.debug('Error while raising: ' + e); |
340 | - } |
341 | - } |
342 | - } |
343 | - }; |
344 | - return UnityWebAppsUtils.makeProxiesForWebViewBindee(webview, eventHandlers) |
345 | - } |
346 | + webappName: containerWebview.webappName |
347 | + webappUrlPatterns: containerWebview.webappUrlPatterns |
348 | + developerExtrasEnabled: containerWebview.developerExtrasEnabled |
349 | } |
350 | } |
351 | } |
FAILED: Continuous integration, rev:477 jenkins. qa.ubuntu. com/job/ webbrowser- app-ci/ 683/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 4483/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/4084/ console jenkins. qa.ubuntu. com/job/ webbrowser- app-trusty- amd64-ci/ 185/console jenkins. qa.ubuntu. com/job/ webbrowser- app-trusty- armhf-ci/ 185/console jenkins. qa.ubuntu. com/job/ webbrowser- app-trusty- i386-ci/ 185/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/4591/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/4118/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/webbrowser- app-ci/ 683/rebuild
http://