summaryrefslogtreecommitdiffstats
path: root/mobile/android/modules/RuntimePermissions.jsm
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /mobile/android/modules/RuntimePermissions.jsm
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'mobile/android/modules/RuntimePermissions.jsm')
-rw-r--r--mobile/android/modules/RuntimePermissions.jsm41
1 files changed, 41 insertions, 0 deletions
diff --git a/mobile/android/modules/RuntimePermissions.jsm b/mobile/android/modules/RuntimePermissions.jsm
new file mode 100644
index 000000000..42d8024b1
--- /dev/null
+++ b/mobile/android/modules/RuntimePermissions.jsm
@@ -0,0 +1,41 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
+
+this.EXPORTED_SYMBOLS = ["RuntimePermissions"];
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "Messaging", "resource://gre/modules/Messaging.jsm");
+
+// See: http://developer.android.com/reference/android/Manifest.permission.html
+const CAMERA = "android.permission.CAMERA";
+const WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE";
+const RECORD_AUDIO = "android.permission.RECORD_AUDIO";
+
+var RuntimePermissions = {
+ CAMERA: CAMERA,
+ RECORD_AUDIO: RECORD_AUDIO,
+ WRITE_EXTERNAL_STORAGE: WRITE_EXTERNAL_STORAGE,
+
+ /**
+ * Check whether the permissions have been granted or not. If needed prompt the user to accept the permissions.
+ *
+ * @returns A promise resolving to true if all the permissions have been granted or false if any of the
+ * permissions have been denied.
+ */
+ waitForPermissions: function(permission) {
+ let permissions = [].concat(permission);
+
+ let msg = {
+ type: 'RuntimePermissions:Prompt',
+ permissions: permissions
+ };
+
+ return Messaging.sendRequestForResult(msg);
+ }
+}; \ No newline at end of file