mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 985796 - Port the permission settings API to WebIDL; r=bzbarsky
This commit is contained in:
parent
3a71461211
commit
0b275ae564
@ -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",
|
||||
|
@ -2296,6 +2296,14 @@ Navigator::HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal)
|
||||
Preferences::GetBool("dom.mozDownloads.enabled");
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
Navigator::HasPermissionSettingsSupport(JSContext* /* unused */, JSObject* aGlobal)
|
||||
{
|
||||
nsCOMPtr<nsPIDOMWindow> win = GetWindowFromGlobal(aGlobal);
|
||||
return CheckPermission(win, "permissions");
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<nsPIDOMWindow>
|
||||
Navigator::GetWindowFromGlobal(JSObject* aGlobal)
|
||||
|
@ -306,6 +306,8 @@ public:
|
||||
|
||||
static bool HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static bool HasPermissionSettingsSupport(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
nsPIDOMWindow* GetParentObject() const
|
||||
{
|
||||
return GetWindow();
|
||||
|
@ -5,7 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMPermissionSettings.idl',
|
||||
'nsIPermissionPromptService.idl',
|
||||
]
|
||||
|
||||
|
@ -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);
|
||||
};
|
@ -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);
|
||||
};
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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])
|
||||
|
@ -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
|
||||
|
@ -20,7 +20,7 @@ var gData = [
|
||||
{
|
||||
perm: ["permissions"],
|
||||
obj: "mozPermissionSettings",
|
||||
idl: "nsIDOMPermissionSettings",
|
||||
webidl: "PermissionSettings",
|
||||
settings: [["dom.mozPermissionSettings.enabled", true]],
|
||||
},
|
||||
]
|
||||
|
@ -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!
|
||||
|
20
dom/webidl/PermissionSettings.webidl
Normal file
20
dom/webidl/PermissionSettings.webidl
Normal file
@ -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);
|
||||
};
|
@ -271,6 +271,7 @@ WEBIDL_FILES = [
|
||||
'PerformanceNavigation.webidl',
|
||||
'PerformanceTiming.webidl',
|
||||
'PeriodicWave.webidl',
|
||||
'PermissionSettings.webidl',
|
||||
'PhoneNumberService.webidl',
|
||||
'Plugin.webidl',
|
||||
'PluginArray.webidl',
|
||||
|
Loading…
Reference in New Issue
Block a user