Bug 853356 - gUM video prompt for Contact API prompt. r=fabrice
authorAlfredo Yang <ayang@mozilla.com>
Sun, 09 Feb 2014 15:34:43 -0500
changeset 186004 572b469e40b62ee995da4ff19aba2ec992aeb8d2
parent 186003 b987d99d861ada90942361a4d5fa8d4048f79617
child 186005 7a823e498a9ba1b4ac835b3376063d55fe059508
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs853356
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 853356 - gUM video prompt for Contact API prompt. r=fabrice
dom/permission/PermissionPromptHelper.jsm
dom/permission/PermissionPromptService.js
--- a/dom/permission/PermissionPromptHelper.jsm
+++ b/dom/permission/PermissionPromptHelper.jsm
@@ -69,20 +69,28 @@ this.PermissionPromptHelper = {
 
     if (permValue == Ci.nsIPermissionManager.DENY_ACTION ||
         permValue == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
       aCallbacks.cancel();
       return;
     }
 
     if (permValue == Ci.nsIPermissionManager.PROMPT_ACTION) {
+      // create an array with a nsIContentPermissionType element
+      let type = {
+        type: msg.type,
+        access: msg.access ? msg.access : "unused",
+        QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType])
+      };
+      let typeArray = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
+      typeArray.appendElement(type, false);
+
       // create a nsIContentPermissionRequest
       let request = {
-        type: msg.type,
-        access: msg.access ? msg.access : "unused",
+        types: typeArray,
         principal: principal,
         QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionRequest]),
         allow: aCallbacks.allow,
         cancel: aCallbacks.cancel,
         window: Services.wm.getOuterWindowWithId(msg.windowID)
       };
 
       permissionPromptService.getPermission(request);
--- a/dom/permission/PermissionPromptService.js
+++ b/dom/permission/PermissionPromptService.js
@@ -63,18 +63,26 @@ PermissionPromptService.prototype = {
    **/
   getPermission: function PS_getPermission(aRequest)
   {
     if (!(aRequest instanceof Ci.nsIContentPermissionRequest)) {
       throw new Error("PermissionService.getPermission: "
                       + "2nd argument must be type 'nsIContentPermissionRequest'");
     }
 
-    let type = aRequest.access !== "unused" ? aRequest.type + "-" + aRequest.access
-                                            : aRequest.type;
+    // Only allow exactly one permission request here.
+    let types = aRequest.types.QueryInterface(Ci.nsIArray);
+    if (types.length != 1) {
+      aRequest.cancel();
+      return;
+    }
+    let reqType = types.queryElementAt(0, Ci.nsIContentPermissionType);
+
+    let type = reqType.access !== "unused" ? reqType.type + "-" + reqType.access
+                                           : reqType.type;
     let perm =
       permissionManager.testExactPermissionFromPrincipal(aRequest.principal, type);
 
     switch (perm) {
       case Ci.nsIPermissionManager.ALLOW_ACTION:
         aRequest.allow();
         break;
       case Ci.nsIPermissionManager.PROMPT_ACTION: