Merge lp:~3v1n0/ubuntu-system-settings-online-accounts/webview-prefs into lp:ubuntu-system-settings-online-accounts

Proposed by Marco Trevisan (Treviño)
Status: Approved
Approved by: Alberto Mardegan
Approved revision: 238
Proposed branch: lp:~3v1n0/ubuntu-system-settings-online-accounts/webview-prefs
Merge into: lp:ubuntu-system-settings-online-accounts
Diff against target: 66 lines (+15/-1)
3 files modified
plugins/module/OAuth.qml (+3/-1)
plugins/module/OAuthMain.qml (+8/-0)
plugins/module/WebView.qml (+4/-0)
To merge this branch: bzr merge lp:~3v1n0/ubuntu-system-settings-online-accounts/webview-prefs
Reviewer Review Type Date Requested Status
Víctor R. Ruiz (community) Needs Fixing
Alberto Mardegan (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+249877@code.launchpad.net

Commit message

OAuthMain: add ability to clients to change WebView preferences

Sometimes OAuthMain extenders might need to change the webview
preferences, this adds a webViewPreferences property that can
be filled with values for overriding defaults

Description of the change

I had to login to a service that needed the local storage to be available in the WebView when logging in, and this is not enabled by default in the account view.

I'm not sure whether is a good thing to enable that in the WebView for every account, so while I could just override the default OAuth.qml and WebView.qml in my app, this is not the best thing as it could lead to breakage on future changes.

So, I thought that it might be reasonable to add a webViewPreferences that every account that extends OAuthMain can easily change.

In this way I can get things working by just doing:

OAuthMain
{
  webViewPreferences: {"localStorageEnabled": true}
}

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Alberto Mardegan (mardy) wrote :

The code looks good, but do you have an example plugin to test this?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :
Revision history for this message
Alberto Mardegan (mardy) wrote :

Tested, works fine.

review: Approve
Revision history for this message
Víctor R. Ruiz (vrruiz) wrote :

The new feature needs an automated test.

review: Needs Fixing
Revision history for this message
Alberto Mardegan (mardy) wrote :

Marco do you think you could add the test? You can use a fake Ubuntu.WebView and just check that the preferences are propagated to it.

If not, I'll do that, but it will take some time as this is not currently in uour high-priority list.

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Alberto, ok. I'll look into it.

Are there already some tests that I can use as example?

Revision history for this message
Alberto Mardegan (mardy) wrote :

On 20.05.2015 12:19, Marco Trevisan (Treviño) wrote:
> Alberto, ok. I'll look into it.

Thanks! :-)

> Are there already some tests that I can use as example?

Not really, the closest thing I can think of is
tests/client/tst_qml_client.cpp, because I think you'll need a C++ test
which asks the QML engine to run some QML code.

Your test should be in tests/plugin/

Unmerged revisions

238. By Marco Trevisan (Treviño)

OAuthMain: add ability to clients to change WebView preferences

Sometimes OAuthMain extenders might need to change the webview
preferences, this adds a webViewPreferences property that can
be filled with values for overriding defaults

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/module/OAuth.qml'
--- plugins/module/OAuth.qml 2015-01-23 11:13:02 +0000
+++ plugins/module/OAuth.qml 2015-02-16 19:15:28 +0000
@@ -31,6 +31,7 @@
31 property variant accessControlList: ["unconfined"]31 property variant accessControlList: ["unconfined"]
3232
33 property variant authReply33 property variant authReply
34 property variant webViewPreferences
34 property bool isNewAccount: false35 property bool isNewAccount: false
35 property variant __account: account36 property variant __account: account
36 property bool __isAuthenticating: false37 property bool __isAuthenticating: false
@@ -55,7 +56,8 @@
55 if (request) {56 if (request) {
56 console.log("RequestHandler captured request!")57 console.log("RequestHandler captured request!")
57 loader.setSource("WebView.qml", {58 loader.setSource("WebView.qml", {
58 "signonRequest": request59 "signonRequest": request,
60 "webViewPreferences": webViewPreferences
59 })61 })
60 } else {62 } else {
61 console.log("Request destroyed!")63 console.log("Request destroyed!")
6264
=== modified file 'plugins/module/OAuthMain.qml'
--- plugins/module/OAuthMain.qml 2014-03-12 13:20:27 +0000
+++ plugins/module/OAuthMain.qml 2015-02-16 19:15:28 +0000
@@ -28,6 +28,9 @@
28 property Component creationComponent: null28 property Component creationComponent: null
29 property Component editingComponent: null29 property Component editingComponent: null
3030
31 /* To override the WebView preferences */
32 property variant webViewPreferences: {}
33
31 property alias source: loader.source34 property alias source: loader.source
3235
33 signal finished36 signal finished
@@ -40,6 +43,11 @@
40 source: sourceComponent === null ? (account.accountId != 0 ? editingComponentUrl : creationComponentUrl) : ""43 source: sourceComponent === null ? (account.accountId != 0 ? editingComponentUrl : creationComponentUrl) : ""
41 sourceComponent: account.accountId != 0 ? editingComponent : creationComponent44 sourceComponent: account.accountId != 0 ? editingComponent : creationComponent
4245
46 onLoaded: {
47 if (source === creationComponentUrl)
48 loader.item.webViewPreferences = webViewPreferences
49 }
50
43 Connections {51 Connections {
44 target: loader.item52 target: loader.item
45 onFinished: root.finished()53 onFinished: root.finished()
4654
=== modified file 'plugins/module/WebView.qml'
--- plugins/module/WebView.qml 2014-09-30 11:20:11 +0000
+++ plugins/module/WebView.qml 2015-02-16 19:15:28 +0000
@@ -6,10 +6,14 @@
6 id: root6 id: root
77
8 property QtObject signonRequest8 property QtObject signonRequest
9 property variant webViewPreferences
910
10 Component.onCompleted: {11 Component.onCompleted: {
11 signonRequest.authenticated.connect(onAuthenticated)12 signonRequest.authenticated.connect(onAuthenticated)
12 url = signonRequest.startUrl13 url = signonRequest.startUrl
14
15 for (var name in webViewPreferences)
16 preferences[name] = webViewPreferences[name];
13 }17 }
1418
15 onLoadingChanged: {19 onLoadingChanged: {

Subscribers

People subscribed via source and target branches