Closed Bug 1235352 Opened 10 years ago Closed 10 years ago

Add JavaScript module to check and request runtime permissions

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(firefox46 fixed)

RESOLVED FIXED
Firefox 46
Tracking Status
firefox46 --- fixed

People

(Reporter: sebastian, Assigned: sebastian)

References

Details

(Keywords: dev-doc-complete)

Attachments

(1 file)

Based on the Java implementation of bug 1235347 we'll need a JS module to check and request permissions from JavaScript land.
Attachment #8703557 - Flags: review?(nalexander)
Attachment #8703557 - Flags: review?(nalexander)
Comment on attachment 8703557 [details] MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander https://reviewboard.mozilla.org/r/29387/#review26299 ::: mobile/android/base/java/org/mozilla/gecko/GeckoApp.java:694 (Diff revision 1) > + callback.sendError(null); Fail early if `callback == null`, please. And if `permission == null`. ::: mobile/android/base/java/org/mozilla/gecko/GeckoApp.java:700 (Diff revision 1) > + callback.sendSuccess(null); `false` isn't really an error. Why not always report `true`/`false` and bubble exceptions using `sendError`? ::: mobile/android/modules/RuntimePermissions.jsm:33 (Diff revision 1) > + function() { return true; }, This is a bit of anti-pattern IMO: error is not the same thing as false. Either catch and log the exception here, or have the Java side return true/false and just send it through. Then exceptions bubble as you'd expect...
Comment on attachment 8703557 [details] MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29387/diff/1-2/
Attachment #8703557 - Attachment description: MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r? → MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r?nalexander
Attachment #8703557 - Flags: review?(nalexander)
Comment on attachment 8703557 [details] MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander https://reviewboard.mozilla.org/r/29387/#review27329 Looks good! ::: mobile/android/modules/RuntimePermissions.jsm:28 (Diff revisions 1 - 2) > - * @returns A promise resolving to true if the permission has been granted or false if the permission has been denied. > + * @returns A promise resolving to true if the permissions have been granted or false if the permissions have been denied. nit: "if *all* the permissions have been granted", "if *any of* the permissions have been denied". ::: mobile/android/base/java/org/mozilla/gecko/GeckoApp.java:687 (Diff revision 2) > + String[] permissions = message.getStringArray("permissions"); Can you verify that an empty array returns true, perhaps in the previous commit? It's the edge case that makes `reduce` and friends possible. How hard is it to add a little test for this? I really doubt it's possible, since anything interesting will be prompted for, but if you have any ideas...
Attachment #8703557 - Flags: review?(nalexander) → review+
Comment on attachment 8703557 [details] MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29387/diff/2-3/
Comment on attachment 8703557 [details] MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander Review request updated; see interdiff: https://reviewboard.mozilla.org/r/29387/diff/3-4/
Attachment #8703557 - Attachment description: MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r?nalexander → MozReview Request: Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander
https://hg.mozilla.org/integration/fx-team/rev/3ad64475829692ac813f9e7f70db6d08c017dfaa Bug 1235352 - Add JavaScript module for checking and requesting runtime permissions. r=nalexander
See Also: → 1240741
See Also: → 1240859
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 46
I've added a page on this. Please let me know if it looks OK to you. https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/RuntimePermissions.jsm
Flags: needinfo?(s.kaspari)
(In reply to Will Bamberg [:wbamberg] from comment #10) > I've added a page on this. Please let me know if it looks OK to you. > https://developer.mozilla.org/en-US/Add-ons/Firefox_for_Android/API/ > RuntimePermissions.jsm This is looking good. Thank you! For the constants: This module currently only has constants for the permissions used by Firefox itself. Depending on what the add-on does it might need other permissions. This is the list of Android permissions: http://developer.android.com/intl/zh-cn/reference/android/Manifest.permission.html
Flags: needinfo?(s.kaspari)
OK, so Sebastian confirmed that add-ons can only request permissions in the Firefox manifest, meaning that it only makes sense to use the constants. I've added a couple of sentences to the waitForPermissions() doc on this, and am marking this dev-doc-complete. But please feel free to let me now if you need anything else here.
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: