diff --git a/b2g/components/ContentPermissionPrompt.js b/b2g/components/ContentPermissionPrompt.js index f6f7fdd794b..0cd5b704c9f 100644 --- a/b2g/components/ContentPermissionPrompt.js +++ b/b2g/components/ContentPermissionPrompt.js @@ -34,11 +34,6 @@ var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptS let permissionSpecificChecker = {}; -XPCOMUtils.defineLazyServiceGetter(this, - "PermSettings", - "@mozilla.org/permissionSettings;1", - "nsIDOMPermissionSettings"); - XPCOMUtils.defineLazyServiceGetter(this, "AudioManager", "@mozilla.org/telephony/audiomanager;1", diff --git a/dom/base/Navigator.cpp b/dom/base/Navigator.cpp index b1ebbf3b5c2..eccf89380d0 100644 --- a/dom/base/Navigator.cpp +++ b/dom/base/Navigator.cpp @@ -2296,6 +2296,14 @@ Navigator::HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal) Preferences::GetBool("dom.mozDownloads.enabled"); } +/* static */ +bool +Navigator::HasPermissionSettingsSupport(JSContext* /* unused */, JSObject* aGlobal) +{ + nsCOMPtr win = GetWindowFromGlobal(aGlobal); + return CheckPermission(win, "permissions"); +} + /* static */ already_AddRefed Navigator::GetWindowFromGlobal(JSObject* aGlobal) diff --git a/dom/base/Navigator.h b/dom/base/Navigator.h index 3e00791e157..48954e4fe84 100644 --- a/dom/base/Navigator.h +++ b/dom/base/Navigator.h @@ -306,6 +306,8 @@ public: static bool HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal); + static bool HasPermissionSettingsSupport(JSContext* aCx, JSObject* aGlobal); + nsPIDOMWindow* GetParentObject() const { return GetWindow(); diff --git a/dom/interfaces/permission/moz.build b/dom/interfaces/permission/moz.build index 8d328b8d413..eeb1daf133f 100644 --- a/dom/interfaces/permission/moz.build +++ b/dom/interfaces/permission/moz.build @@ -5,7 +5,6 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. XPIDL_SOURCES += [ - 'nsIDOMPermissionSettings.idl', 'nsIPermissionPromptService.idl', ] diff --git a/dom/interfaces/permission/nsIDOMPermissionSettings.idl b/dom/interfaces/permission/nsIDOMPermissionSettings.idl deleted file mode 100644 index b518189e3d7..00000000000 --- a/dom/interfaces/permission/nsIDOMPermissionSettings.idl +++ /dev/null @@ -1,21 +0,0 @@ -/* 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/. */ - -#include "domstubs.idl" - -interface nsIDOMDOMRequest; - -[scriptable, uuid(18390770-02ab-11e2-a21f-0800200c9a66)] -interface nsIDOMPermissionSettings : nsISupports -{ - DOMString get(in DOMString permission, in DOMString manifestURI, in DOMString origin, in bool browserFlag); - - void set(in DOMString permission, in DOMString value, in DOMString manifestURI, in DOMString origin, in bool browserFlag); - - bool isExplicit(in DOMString permission, in DOMString manifestURI, in DOMString origin, in bool browserFlag); - - // Removing a permission is only allowed for pages with a different origin than the app - // and pages that have browserFlag=true, so remove() doesn't have a browserFlag parameter. - void remove(in DOMString permission, in DOMString manifestURI, in DOMString origin); -}; diff --git a/dom/interfaces/permission/nsIPermissionPromptService.idl b/dom/interfaces/permission/nsIPermissionPromptService.idl index f349011669f..773c25b0629 100644 --- a/dom/interfaces/permission/nsIPermissionPromptService.idl +++ b/dom/interfaces/permission/nsIPermissionPromptService.idl @@ -14,7 +14,7 @@ interface nsIPermissionPromptService : nsISupports { /** * Checks if the capability requires a permission, fires the corresponding cancel() - * or allow() method in aRequest after consulting nsIDOMPermissionSettings, etc. + * or allow() method in aRequest after consulting PermissionSettings, etc. */ void getPermission(in nsIContentPermissionRequest aRequest); }; diff --git a/dom/permission/PermissionPromptService.js b/dom/permission/PermissionPromptService.js index a90f63eddce..ebb0080fdac 100644 --- a/dom/permission/PermissionPromptService.js +++ b/dom/permission/PermissionPromptService.js @@ -26,11 +26,6 @@ const PERMISSIONPROMPTSERVICE_CONTRACTID = "@mozilla.org/permission-prompt-servi const PERMISSIONPROMPTSERVICE_CID = Components.ID("{e5f953b3-a6ca-444e-a88d-cdc81383741c}"); const permissionPromptService = Ci.nsIPermissionPromptService; -XPCOMUtils.defineLazyServiceGetter(this, - "PermSettings", - "@mozilla.org/permissionSettings;1", - "nsIDOMPermissionSettings"); - var permissionManager = Cc["@mozilla.org/permissionmanager;1"].getService(Ci.nsIPermissionManager); var secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager); diff --git a/dom/permission/PermissionSettings.js b/dom/permission/PermissionSettings.js index f3791c961c6..50bb3303a24 100644 --- a/dom/permission/PermissionSettings.js +++ b/dom/permission/PermissionSettings.js @@ -22,7 +22,6 @@ var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService(Ci.nsISyncM const PERMISSIONSETTINGS_CONTRACTID = "@mozilla.org/permissionSettings;1"; const PERMISSIONSETTINGS_CID = Components.ID("{cd2cf7a1-f4c1-487b-8c1b-1a71c7097431}"); -const nsIDOMPermissionSettings = Ci.nsIDOMPermissionSettings; function PermissionSettings() { @@ -129,27 +128,8 @@ PermissionSettings.prototype = { }); }, - init: function init(aWindow) { - debug("init"); - - // Set navigator.mozPermissionSettings to null. - let perm = Services.perms.testExactPermissionFromPrincipal(aWindow.document.nodePrincipal, "permissions"); - if (!Services.prefs.getBoolPref("dom.mozPermissionSettings.enabled") - || perm != Ci.nsIPermissionManager.ALLOW_ACTION) { - return null; - } - - debug("Permission to get/set permissions granted!"); - }, - classID : PERMISSIONSETTINGS_CID, - QueryInterface : XPCOMUtils.generateQI([nsIDOMPermissionSettings, Ci.nsIDOMGlobalPropertyInitializer]), - - classInfo : XPCOMUtils.generateCI({classID: PERMISSIONSETTINGS_CID, - contractID: PERMISSIONSETTINGS_CONTRACTID, - classDescription: "PermissionSettings", - interfaces: [nsIDOMPermissionSettings], - flags: Ci.nsIClassInfo.DOM_OBJECT}) + QueryInterface : XPCOMUtils.generateQI([]) } this.NSGetFactory = XPCOMUtils.generateNSGetFactory([PermissionSettings]) diff --git a/dom/permission/PermissionSettings.manifest b/dom/permission/PermissionSettings.manifest index 5229dea655f..eb53813ff9c 100644 --- a/dom/permission/PermissionSettings.manifest +++ b/dom/permission/PermissionSettings.manifest @@ -1,3 +1,2 @@ component {cd2cf7a1-f4c1-487b-8c1b-1a71c7097431} PermissionSettings.js contract @mozilla.org/permissionSettings;1 {cd2cf7a1-f4c1-487b-8c1b-1a71c7097431} -category JavaScript-navigator-property mozPermissionSettings @mozilla.org/permissionSettings;1 diff --git a/dom/permission/tests/test_permissions.html b/dom/permission/tests/test_permissions.html index 144fff76e39..8d629c3da17 100644 --- a/dom/permission/tests/test_permissions.html +++ b/dom/permission/tests/test_permissions.html @@ -20,7 +20,7 @@ var gData = [ { perm: ["permissions"], obj: "mozPermissionSettings", - idl: "nsIDOMPermissionSettings", + webidl: "PermissionSettings", settings: [["dom.mozPermissionSettings.enabled", true]], }, ] diff --git a/dom/tests/mochitest/general/test_interfaces.html b/dom/tests/mochitest/general/test_interfaces.html index 89cb89f5aa0..0a1c3784174 100644 --- a/dom/tests/mochitest/general/test_interfaces.html +++ b/dom/tests/mochitest/general/test_interfaces.html @@ -743,6 +743,8 @@ var interfaceNamesInGlobalScope = "PerformanceTiming", // IMPORTANT: Do not change this list without review from a DOM peer! "PeriodicWave", +// IMPORTANT: Do not change this list without review from a DOM peer! + {name: "PermissionSettings", b2g: true, permission: "permissions"}, // IMPORTANT: Do not change this list without review from a DOM peer! "PhoneNumberService", // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/PermissionSettings.webidl b/dom/webidl/PermissionSettings.webidl new file mode 100644 index 00000000000..33aacba3dbf --- /dev/null +++ b/dom/webidl/PermissionSettings.webidl @@ -0,0 +1,20 @@ +/* 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 at http://mozilla.org/MPL/2.0/. */ + +[JSImplementation="@mozilla.org/permissionSettings;1", + Func="Navigator::HasPermissionSettingsSupport", + Pref="dom.mozPermissionSettings.enabled", + NavigatorProperty="mozPermissionSettings"] +interface PermissionSettings +{ + DOMString get(DOMString permission, DOMString manifestURI, DOMString origin, boolean browserFlag); + + void set(DOMString permission, DOMString value, DOMString manifestURI, DOMString origin, boolean browserFlag); + + boolean isExplicit(DOMString permission, DOMString manifestURI, DOMString origin, boolean browserFlag); + + // Removing a permission is only allowed for pages with a different origin than the app + // and pages that have browserFlag=true, so remove() doesn't have a browserFlag parameter. + void remove(DOMString permission, DOMString manifestURI, DOMString origin); +}; diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build index 0f3040348f8..847b0399881 100644 --- a/dom/webidl/moz.build +++ b/dom/webidl/moz.build @@ -271,6 +271,7 @@ WEBIDL_FILES = [ 'PerformanceNavigation.webidl', 'PerformanceTiming.webidl', 'PeriodicWave.webidl', + 'PermissionSettings.webidl', 'PhoneNumberService.webidl', 'Plugin.webidl', 'PluginArray.webidl',