Bug 707564 followup #2. Make the push code actually follow the contract for JS-implemented webidl in an attempt to reopen the CLOSED TREE. r=khuey

This commit is contained in:
Boris Zbarsky 2013-08-04 01:47:30 -04:00
Родитель 87c6485b2e
Коммит bed367b9a1
2 изменённых файлов: 11 добавлений и 10 удалений

Просмотреть файл

@ -41,9 +41,6 @@ Push.prototype = {
init: function(aWindow) { init: function(aWindow) {
debug("init()"); debug("init()");
if (!Services.prefs.getBoolPref("services.push.enabled"))
return null;
let principal = aWindow.document.nodePrincipal; let principal = aWindow.document.nodePrincipal;
this._pageURL = principal.URI; this._pageURL = principal.URI;
@ -52,13 +49,19 @@ Push.prototype = {
.getService(Ci.nsIAppsService); .getService(Ci.nsIAppsService);
this._app = appsService.getAppByLocalId(principal.appId); this._app = appsService.getAppByLocalId(principal.appId);
this._manifestURL = appsService.getManifestURLByLocalId(principal.appId); this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
if (!this._manifestURL) if (!this._manifestURL) {
return null; // Now what? XXXbz should this be tested in a Func for this
// interface so it wouldn't appear at all?
return;
}
let perm = Services.perms.testExactPermissionFromPrincipal(principal, let perm = Services.perms.testExactPermissionFromPrincipal(principal,
"push"); "push");
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) if (perm != Ci.nsIPermissionManager.ALLOW_ACTION) {
return null; // Now what? XXXbz should this be tested in a Func for this
// interface so it wouldn't appear at all?
return;
}
this.initDOMRequestHelper(aWindow, [ this.initDOMRequestHelper(aWindow, [
"PushService:Register:OK", "PushService:Register:OK",
@ -71,8 +74,6 @@ Push.prototype = {
this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"] this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
.getService(Ci.nsISyncMessageSender); .getService(Ci.nsISyncMessageSender);
var self = this;
}, },
receiveMessage: function(aMessage) { receiveMessage: function(aMessage) {

Просмотреть файл

@ -4,7 +4,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. * You can obtain one at http://mozilla.org/MPL/2.0/.
*/ */
[NoInterfaceObject, NavigatorProperty="push", JSImplementation="@mozilla.org/push/PushManager;1"] [NoInterfaceObject, NavigatorProperty="push", JSImplementation="@mozilla.org/push/PushManager;1", Pref="services.push.enabled"]
interface PushManager { interface PushManager {
DOMRequest register(); DOMRequest register();
DOMRequest unregister(DOMString pushEndpoint); DOMRequest unregister(DOMString pushEndpoint);