Merge lp:~phablet-team/ubuntu-system-settings/permission-page-url into lp:ubuntu-system-settings

Proposed by Ugo Riboni on 2015-12-08
Status: Merged
Merged at revision: 1596
Proposed branch: lp:~phablet-team/ubuntu-system-settings/permission-page-url
Merge into: lp:ubuntu-system-settings
Diff against target: 89 lines (+46/-0)
2 files modified
plugins/security-privacy/AppAccess.qml (+24/-0)
plugins/security-privacy/PageComponent.qml (+22/-0)
To merge this branch: bzr merge lp:~phablet-team/ubuntu-system-settings/permission-page-url
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) 2015-12-08 Approve on 2015-12-10
PS Jenkins bot continuous-integration Approve on 2015-12-08
Review via email: mp+279883@code.launchpad.net

Commit Message

Allow url-dispatcher access to App Permissions service pages

Description of the Change

Allow URLs like //system/security-privacy?service=camera for accessing app permissions

To post a comment you must log in.
Jonas G. Drange (jonas-drange) wrote :

LGTM and works well.

We can't do security-privacy/access now if I'm reading the code correctly, so let's do that another time.

review: Approve
Matthew Paul Thomas (mpt) wrote :

Yay for fixing this bug. However, URLs of the form settings:///system/security-privacy?service=camera are needlessly brittle. It's generally a bad idea for URLs to contain subjective categorization. This applies to a System Settings screen for the same same reason that it applies to a Web page (e.g. bug bug 1516732): links to it shouldn't break if the categorization changes.

Camera permissions won't necessarily be in "Security & Privacy" forever. (For example, we might give them their own top-level category, or combine them with Online Accounts.) And even if they are, "Security & Privacy" won't necessarily be in "System" forever. If either of those things changes, apps that send you to this screen should still send you to this screen, because the URL should not have changed.

So I suggest that it should not be "settings:///system/security-privacy?service=camera", it should be something like "settings:///permissions?service=camera".

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/security-privacy/AppAccess.qml'
2--- plugins/security-privacy/AppAccess.qml 2015-09-18 14:18:11 +0000
3+++ plugins/security-privacy/AppAccess.qml 2015-12-08 13:33:29 +0000
4@@ -27,6 +27,21 @@
5 id: root
6 title: i18n.tr("App permissions")
7
8+ function openService(service) {
9+ for (var i = 0; i < appsModel.count; i++) {
10+ var item = appsModel.get(i)
11+ if (item.service === service) {
12+ var model = trustStoreModelComponent.createObject(null, { serviceName: item.trustStoreService })
13+ pageStack.push(Qt.resolvedUrl("AppAccessControl.qml"), {
14+ "title": i18n.tr(item.name),
15+ "caption": i18n.tr(item.caption),
16+ "model": model
17+ })
18+ return;
19+ }
20+ }
21+ }
22+
23 Flickable {
24 anchors.fill: parent
25 contentHeight: contentItem.childrenRect.height
26@@ -52,16 +67,19 @@
27 name: QT_TR_NOOP("Camera")
28 caption: QT_TR_NOOP("Apps that have requested access to your camera")
29 trustStoreService: "CameraService"
30+ service: "camera"
31 }
32 ListElement {
33 name: QT_TR_NOOP("Location")
34 caption: QT_TR_NOOP("Apps that have requested access to your location")
35 trustStoreService: "UbuntuLocationService"
36+ service: "location"
37 }
38 ListElement {
39 name: QT_TR_NOOP("Microphone")
40 caption: QT_TR_NOOP("Apps that have requested access to your microphone")
41 trustStoreService: "PulseAudio"
42+ service: "microphone"
43 }
44 }
45
46@@ -113,4 +131,10 @@
47 }
48 }
49 }
50+
51+ Component {
52+ id: trustStoreModelComponent
53+ TrustStoreModel {}
54+ }
55+
56 }
57
58=== modified file 'plugins/security-privacy/PageComponent.qml'
59--- plugins/security-privacy/PageComponent.qml 2015-10-16 13:42:50 +0000
60+++ plugins/security-privacy/PageComponent.qml 2015-12-08 13:33:29 +0000
61@@ -54,6 +54,28 @@
62 return t;
63 }
64
65+ property var pluginOptions
66+ Connections {
67+ target: pageStack
68+ onCurrentPageChanged: {
69+ // If we get called with service=something open the app access page
70+ // for that specific service, if it does exist.
71+ //
72+ // We need to wait until the PageComponent has been pushed to the stack
73+ // before pushing the subpages, otherwise they will be pushed below the
74+ // PageComponent.
75+ if (pageStack.currentPage === root) {
76+ if (pluginOptions && pluginOptions['service']) {
77+ var page = pageStack.push(Qt.resolvedUrl("AppAccess.qml"), {pluginManager: pluginManager})
78+ page.openService(pluginOptions['service'])
79+ }
80+ // Once done, disable this Connections, so that if the user navigates
81+ // back to the root we won't push the subpages again
82+ target = null
83+ }
84+ }
85+ }
86+
87 UbuntuDiagnostics {
88 id: diagnosticsWidget
89 }

Subscribers

People subscribed via source and target branches