зеркало из https://github.com/mozilla/gecko-dev.git
Back out fdeb0c833138 (bug 814226) for Linux bc failures in browser_webapps_permissions.js
CLOSED TREE
This commit is contained in:
Родитель
f62c0089ed
Коммит
321f2d70e2
|
@ -184,10 +184,6 @@ WebappsRegistry.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
get mgmt() {
|
get mgmt() {
|
||||||
if (!this.hasMgmtPrivilege) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this._mgmt)
|
if (!this._mgmt)
|
||||||
this._mgmt = new WebappsApplicationMgmt(this._window);
|
this._mgmt = new WebappsApplicationMgmt(this._window);
|
||||||
return this._mgmt;
|
return this._mgmt;
|
||||||
|
@ -245,19 +241,10 @@ WebappsRegistry.prototype = {
|
||||||
"Webapps:GetSelf:Return:OK",
|
"Webapps:GetSelf:Return:OK",
|
||||||
"Webapps:CheckInstalled:Return:OK" ]);
|
"Webapps:CheckInstalled:Return:OK" ]);
|
||||||
|
|
||||||
let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor)
|
let util = this._window.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||||
.getInterface(Ci.nsIDOMWindowUtils);
|
|
||||||
this._id = util.outerWindowID;
|
this._id = util.outerWindowID;
|
||||||
cpmm.sendAsyncMessage("Webapps:RegisterForMessages",
|
cpmm.sendAsyncMessage("Webapps:RegisterForMessages",
|
||||||
["Webapps:Install:Return:OK"]);
|
["Webapps:Install:Return:OK"]);
|
||||||
|
|
||||||
let principal = aWindow.document.nodePrincipal;
|
|
||||||
let perm = Services.perms
|
|
||||||
.testExactPermissionFromPrincipal(principal, "webapps-manage");
|
|
||||||
|
|
||||||
// Only pages with the webapps-manage permission set can get access to
|
|
||||||
// the mgmt object.
|
|
||||||
this.hasMgmtPrivilege = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
|
classID: Components.ID("{fff440b3-fae2-45c1-bf03-3b5a2e432270}"),
|
||||||
|
@ -603,6 +590,16 @@ WebappsApplication.prototype = {
|
||||||
* mozIDOMApplicationMgmt object
|
* mozIDOMApplicationMgmt object
|
||||||
*/
|
*/
|
||||||
function WebappsApplicationMgmt(aWindow) {
|
function WebappsApplicationMgmt(aWindow) {
|
||||||
|
let principal = aWindow.document.nodePrincipal;
|
||||||
|
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"].getService(Ci.nsIScriptSecurityManager);
|
||||||
|
|
||||||
|
let perm = principal == secMan.getSystemPrincipal()
|
||||||
|
? Ci.nsIPermissionManager.ALLOW_ACTION
|
||||||
|
: Services.perms.testExactPermissionFromPrincipal(principal, "webapps-manage");
|
||||||
|
|
||||||
|
//only pages with perm set can use some functions
|
||||||
|
this.hasPrivileges = perm == Ci.nsIPermissionManager.ALLOW_ACTION;
|
||||||
|
|
||||||
this.initHelper(aWindow, ["Webapps:GetAll:Return:OK",
|
this.initHelper(aWindow, ["Webapps:GetAll:Return:OK",
|
||||||
"Webapps:GetAll:Return:KO",
|
"Webapps:GetAll:Return:KO",
|
||||||
"Webapps:Uninstall:Return:OK",
|
"Webapps:Uninstall:Return:OK",
|
||||||
|
@ -659,7 +656,8 @@ WebappsApplicationMgmt.prototype = {
|
||||||
getAll: function() {
|
getAll: function() {
|
||||||
let request = this.createRequest();
|
let request = this.createRequest();
|
||||||
cpmm.sendAsyncMessage("Webapps:GetAll", { oid: this._id,
|
cpmm.sendAsyncMessage("Webapps:GetAll", { oid: this._id,
|
||||||
requestID: this.getRequestId(request) });
|
requestID: this.getRequestId(request),
|
||||||
|
hasPrivileges: this.hasPrivileges });
|
||||||
return request;
|
return request;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -679,11 +677,17 @@ WebappsApplicationMgmt.prototype = {
|
||||||
},
|
},
|
||||||
|
|
||||||
set oninstall(aCallback) {
|
set oninstall(aCallback) {
|
||||||
|
if (this.hasPrivileges)
|
||||||
this._oninstall = aCallback;
|
this._oninstall = aCallback;
|
||||||
|
else
|
||||||
|
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||||
},
|
},
|
||||||
|
|
||||||
set onuninstall(aCallback) {
|
set onuninstall(aCallback) {
|
||||||
|
if (this.hasPrivileges)
|
||||||
this._onuninstall = aCallback;
|
this._onuninstall = aCallback;
|
||||||
|
else
|
||||||
|
throw new Components.Exception("Denied", Cr.NS_ERROR_FAILURE);
|
||||||
},
|
},
|
||||||
|
|
||||||
receiveMessage: function(aMessage) {
|
receiveMessage: function(aMessage) {
|
||||||
|
|
|
@ -787,7 +787,10 @@ this.DOMApplicationRegistry = {
|
||||||
this.getNotInstalled(msg, mm);
|
this.getNotInstalled(msg, mm);
|
||||||
break;
|
break;
|
||||||
case "Webapps:GetAll":
|
case "Webapps:GetAll":
|
||||||
|
if (msg.hasPrivileges)
|
||||||
this.getAll(msg, mm);
|
this.getAll(msg, mm);
|
||||||
|
else
|
||||||
|
mm.sendAsyncMessage("Webapps:GetAll:Return:KO", msg);
|
||||||
break;
|
break;
|
||||||
case "Webapps:InstallPackage":
|
case "Webapps:InstallPackage":
|
||||||
this.doInstallPackage(msg, mm);
|
this.doInstallPackage(msg, mm);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче