зеркало из https://github.com/mozilla/gecko-dev.git
Bug 822712 - SimplePush - Implementation. r=dougt, jst, jlebar
This commit is contained in:
Родитель
e79cec0c47
Коммит
032f5a8a7b
|
@ -388,6 +388,17 @@ pref("dom.mozContacts.enabled", true);
|
|||
// WebAlarms
|
||||
pref("dom.mozAlarms.enabled", true);
|
||||
|
||||
// SimplePush
|
||||
// serverURL to be assigned by services team
|
||||
pref("services.push.serverURL", "");
|
||||
pref("services.push.userAgentID", "");
|
||||
// exponential back-off start is 5 seconds like in HTTP/1.1
|
||||
pref("services.push.retryBaseInterval", 5000);
|
||||
// exponential back-off end is 20 minutes
|
||||
pref("services.push.maxRetryInterval", 1200000);
|
||||
// How long before a DOMRequest errors as timeout
|
||||
pref("services.push.requestTimeout", 10000);
|
||||
|
||||
// NetworkStats
|
||||
#ifdef MOZ_B2G_RIL
|
||||
pref("dom.mozNetworkStats.enabled", true);
|
||||
|
|
|
@ -194,6 +194,7 @@
|
|||
@BINPATH@/components/dom_indexeddb.xpt
|
||||
@BINPATH@/components/dom_offline.xpt
|
||||
@BINPATH@/components/dom_payment.xpt
|
||||
@BINPATH@/components/dom_push.xpt
|
||||
@BINPATH@/components/dom_json.xpt
|
||||
#ifdef MOZ_B2G_RIL
|
||||
@BINPATH@/components/dom_mms.xpt
|
||||
|
@ -505,6 +506,10 @@
|
|||
@BINPATH@/components/Webapps.manifest
|
||||
@BINPATH@/components/AppsService.js
|
||||
@BINPATH@/components/AppsService.manifest
|
||||
@BINPATH@/components/Push.js
|
||||
@BINPATH@/components/Push.manifest
|
||||
@BINPATH@/components/PushService.js
|
||||
@BINPATH@/components/PushService.manifest
|
||||
|
||||
@BINPATH@/components/nsDOMIdentity.js
|
||||
@BINPATH@/components/nsIDService.js
|
||||
|
|
|
@ -197,6 +197,7 @@
|
|||
@BINPATH@/components/dom_indexeddb.xpt
|
||||
@BINPATH@/components/dom_offline.xpt
|
||||
@BINPATH@/components/dom_json.xpt
|
||||
@BINPATH@/components/dom_push.xpt
|
||||
#ifdef MOZ_B2G_RIL
|
||||
@BINPATH@/components/dom_mms.xpt
|
||||
#endif
|
||||
|
@ -504,6 +505,10 @@
|
|||
@BINPATH@/components/Webapps.manifest
|
||||
@BINPATH@/components/AppsService.js
|
||||
@BINPATH@/components/AppsService.manifest
|
||||
@BINPATH@/components/Push.js
|
||||
@BINPATH@/components/Push.manifest
|
||||
@BINPATH@/components/PushService.js
|
||||
@BINPATH@/components/PushService.manifest
|
||||
@BINPATH@/components/nsDOMIdentity.js
|
||||
@BINPATH@/components/nsIDService.js
|
||||
@BINPATH@/components/Identity.manifest
|
||||
|
|
|
@ -1222,6 +1222,7 @@ xpicleanup@BIN_SUFFIX@
|
|||
components/dom_json.xpt
|
||||
components/dom_loadsave.xpt
|
||||
components/dom_offline.xpt
|
||||
components/dom_push.xpt
|
||||
components/dom_range.xpt
|
||||
components/dom_sidebar.xpt
|
||||
components/dom_smil.xpt
|
||||
|
|
|
@ -124,6 +124,11 @@ this.PermissionsTable = { geolocation: {
|
|||
privileged: DENY_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
push: {
|
||||
app: ALLOW_ACTION,
|
||||
privileged: ALLOW_ACTION,
|
||||
certified: ALLOW_ACTION
|
||||
},
|
||||
settings: {
|
||||
app: DENY_ACTION,
|
||||
privileged: DENY_ACTION,
|
||||
|
|
|
@ -8,6 +8,7 @@ DOM_SRCDIRS = \
|
|||
dom/encoding \
|
||||
dom/file \
|
||||
dom/power \
|
||||
dom/push \
|
||||
dom/quota \
|
||||
dom/media \
|
||||
dom/network/src \
|
||||
|
|
|
@ -74,6 +74,12 @@ this.SystemMessagePermissionsTable = {
|
|||
"notification": {
|
||||
"desktop-notification": []
|
||||
},
|
||||
"push": {
|
||||
"push": []
|
||||
},
|
||||
"push-register": {
|
||||
"push": []
|
||||
},
|
||||
"sms-received": {
|
||||
"sms": []
|
||||
},
|
||||
|
|
|
@ -26,6 +26,7 @@ interfaces = [
|
|||
'geolocation',
|
||||
'notification',
|
||||
'permission',
|
||||
'push',
|
||||
'svg',
|
||||
'smil',
|
||||
'apps',
|
||||
|
@ -51,6 +52,7 @@ PARALLEL_DIRS += [
|
|||
'media',
|
||||
'messages',
|
||||
'power',
|
||||
'push',
|
||||
'quota',
|
||||
'settings',
|
||||
'mobilemessage',
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# 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/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
relativesrcdir = @relativesrcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,6 @@
|
|||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
PARALLEL_DIRS += ['src']
|
|
@ -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 one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
Push.js \
|
||||
Push.manifest \
|
||||
PushService.js \
|
||||
PushService.manifest \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
/* 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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
function debug(s) {
|
||||
// dump("-*- Push.js: " + s + "\n");
|
||||
}
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/DOMRequestHelper.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
|
||||
const PUSH_CID = Components.ID("{c7ad4f42-faae-4e8b-9879-780a72349945}");
|
||||
|
||||
/**
|
||||
* The Push component runs in the child process and exposes the SimplePush API
|
||||
* to the web application. The PushService running in the parent process is the
|
||||
* one actually performing all operations.
|
||||
*/
|
||||
function Push()
|
||||
{
|
||||
debug("Push Constructor");
|
||||
}
|
||||
|
||||
Push.prototype = {
|
||||
__proto__: DOMRequestIpcHelper.prototype,
|
||||
|
||||
classID : PUSH_CID,
|
||||
|
||||
QueryInterface : XPCOMUtils.generateQI([Ci.nsIDOMGlobalPropertyInitializer]),
|
||||
|
||||
init: function(aWindow) {
|
||||
debug("init()");
|
||||
|
||||
let principal = aWindow.document.nodePrincipal;
|
||||
|
||||
this._pageURL = principal.URI;
|
||||
|
||||
let appsService = Cc["@mozilla.org/AppsService;1"]
|
||||
.getService(Ci.nsIAppsService);
|
||||
this._app = appsService.getAppByLocalId(principal.appId);
|
||||
this._manifestURL = appsService.getManifestURLByLocalId(principal.appId);
|
||||
if (!this._manifestURL)
|
||||
return null;
|
||||
|
||||
let perm = Services.perms.testExactPermissionFromPrincipal(principal,
|
||||
"push");
|
||||
if (perm != Ci.nsIPermissionManager.ALLOW_ACTION)
|
||||
return null;
|
||||
|
||||
this.initHelper(aWindow, []);
|
||||
|
||||
this.initMessageListener([
|
||||
"PushService:Register:OK",
|
||||
"PushService:Register:KO",
|
||||
"PushService:Unregister:OK",
|
||||
"PushService:Unregister:KO",
|
||||
"PushService:Registrations:OK",
|
||||
"PushService:Registrations:KO"
|
||||
]);
|
||||
|
||||
this._cpmm = Cc["@mozilla.org/childprocessmessagemanager;1"]
|
||||
.getService(Ci.nsISyncMessageSender);
|
||||
|
||||
var self = this;
|
||||
return {
|
||||
register: self.register.bind(self),
|
||||
unregister: self.unregister.bind(self),
|
||||
registrations: self.registrations.bind(self),
|
||||
__exposedProps__: {
|
||||
register: "r",
|
||||
unregister: "r",
|
||||
registrations: "r"
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
debug("receiveMessage()");
|
||||
let request = this.getRequest(aMessage.data.requestID);
|
||||
let json = aMessage.data;
|
||||
if (!request) {
|
||||
debug("No request " + json.requestID);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aMessage.name) {
|
||||
case "PushService:Register:OK":
|
||||
Services.DOMRequest.fireSuccess(request, json.pushEndpoint);
|
||||
break;
|
||||
case "PushService:Register:KO":
|
||||
Services.DOMRequest.fireError(request, json.error);
|
||||
break;
|
||||
case "PushService:Unregister:OK":
|
||||
Services.DOMRequest.fireSuccess(request, json.pushEndpoint);
|
||||
break;
|
||||
case "PushService:Unregister:KO":
|
||||
Services.DOMRequest.fireError(request, json.error);
|
||||
break;
|
||||
case "PushService:Registrations:OK":
|
||||
Services.DOMRequest.fireSuccess(request, json.registrations);
|
||||
break;
|
||||
case "PushService:Registrations:KO":
|
||||
Services.DOMRequest.fireError(request, json.error);
|
||||
break;
|
||||
default:
|
||||
debug("NOT IMPLEMENTED! receiveMessage for " + aMessage.name);
|
||||
}
|
||||
},
|
||||
|
||||
register: function() {
|
||||
debug("register()");
|
||||
var req = this.createRequest();
|
||||
this._cpmm.sendAsyncMessage("Push:Register", {
|
||||
pageURL: this._pageURL.spec,
|
||||
manifestURL: this._manifestURL,
|
||||
requestID: this.getRequestId(req)
|
||||
});
|
||||
return req;
|
||||
},
|
||||
|
||||
unregister: function(aPushEndpoint) {
|
||||
debug("unregister(" + aPushEndpoint + ")");
|
||||
var req = this.createRequest();
|
||||
this._cpmm.sendAsyncMessage("Push:Unregister", {
|
||||
pageURL: this._pageURL.spec,
|
||||
manifestURL: this._manifestURL,
|
||||
requestID: this.getRequestId(req),
|
||||
pushEndpoint: aPushEndpoint
|
||||
});
|
||||
return req;
|
||||
},
|
||||
|
||||
registrations: function() {
|
||||
debug("registrations()");
|
||||
var req = this.createRequest();
|
||||
this._cpmm.sendAsyncMessage("Push:Registrations", {
|
||||
manifestURL: this._manifestURL,
|
||||
requestID: this.getRequestId(req)
|
||||
});
|
||||
return req;
|
||||
}
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Push]);
|
|
@ -0,0 +1,4 @@
|
|||
component {c7ad4f42-faae-4e8b-9879-780a72349945} Push.js
|
||||
contract @mozilla.org/Push;1 {c7ad4f42-faae-4e8b-9879-780a72349945}
|
||||
category JavaScript-navigator-property push @mozilla.org/Push;1
|
||||
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,4 @@
|
|||
component {0ACE8D15-9B15-41F4-992F-C88820421DBF} PushService.js
|
||||
contract @mozilla.org/PushService;1 {0ACE8D15-9B15-41F4-992F-C88820421DBF}
|
||||
category app-startup PushService service,@mozilla.org/PushService;1
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# vim: set filetype=python:
|
||||
# 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/.
|
|
@ -68,6 +68,8 @@ Turn on/off screen, cpu, device power, etc. Listen and inspect resource lock eve
|
|||
|
||||
push
|
||||
{}
|
||||
Push Notifications, 822712
|
||||
Notify application about updates to things it registers interest in.
|
||||
|
||||
settings
|
||||
{read, write}
|
||||
|
|
|
@ -128,6 +128,7 @@
|
|||
@BINPATH@/components/dom_indexeddb.xpt
|
||||
@BINPATH@/components/dom_offline.xpt
|
||||
@BINPATH@/components/dom_json.xpt
|
||||
@BINPATH@/components/dom_push.xpt
|
||||
@BINPATH@/components/dom_browserelement.xpt
|
||||
@BINPATH@/components/dom_power.xpt
|
||||
@BINPATH@/components/dom_quota.xpt
|
||||
|
@ -365,6 +366,10 @@
|
|||
@BINPATH@/components/Webapps.manifest
|
||||
@BINPATH@/components/AppsService.js
|
||||
@BINPATH@/components/AppsService.manifest
|
||||
@BINPATH@/components/Push.js
|
||||
@BINPATH@/components/Push.manifest
|
||||
@BINPATH@/components/PushService.js
|
||||
@BINPATH@/components/PushService.manifest
|
||||
@BINPATH@/components/AppProtocolHandler.js
|
||||
@BINPATH@/components/AppProtocolHandler.manifest
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче