Bug 1188937 - Only add Push API interfaces to build if the feature is enabled. r=kitcambridge

--HG--
extra : commitid : BRZ0gZEecxz
extra : amend_source : fb91b88616e837bf5e09a6a19c31acb1b94e4e64
extra : transplant_source : %84W%27%B8%40A%7F%26%04%0E%C6%A9%13o%25%D4SOD6
This commit is contained in:
Nikhil Marathe 2015-07-29 09:12:51 -07:00
Родитель c288c0dbec
Коммит 079c3d0a1b
3 изменённых файлов: 28 добавлений и 21 удалений

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

@ -516,9 +516,13 @@ Sanitizer.prototype = {
sss.clearAll(); sss.clearAll();
// Clear all push notification subscriptions // Clear all push notification subscriptions
var push = Cc["@mozilla.org/push/NotificationService;1"] try {
.getService(Ci.nsIPushNotificationService); var push = Cc["@mozilla.org/push/NotificationService;1"]
push.clearAll(); .getService(Ci.nsIPushNotificationService);
push.clearAll();
} catch (e) {
dump("Web Push may not be available.\n");
}
TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS"); TelemetryStopwatch.finish("FX_SANITIZE_SITESETTINGS");
}, },

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

@ -25,7 +25,6 @@ interfaces = [
'storage', 'storage',
'json', 'json',
'offline', 'offline',
'push',
'geolocation', 'geolocation',
'notification', 'notification',
'permission', 'permission',
@ -35,6 +34,9 @@ interfaces = [
'gamepad', 'gamepad',
] ]
if not CONFIG['MOZ_SIMPLEPUSH']:
interfaces += ['push']
DIRS += ['interfaces/' + i for i in interfaces] DIRS += ['interfaces/' + i for i in interfaces]
DIRS += [ DIRS += [

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

@ -9,13 +9,6 @@ const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Services.jsm");
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); Cu.import('resource://gre/modules/XPCOMUtils.jsm');
XPCOMUtils.defineLazyServiceGetter(
this,
"PushNotificationService",
"@mozilla.org/push/NotificationService;1",
"nsIPushNotificationService"
);
const bundle = Services.strings.createBundle( const bundle = Services.strings.createBundle(
"chrome://global/locale/aboutServiceWorkers.properties"); "chrome://global/locale/aboutServiceWorkers.properties");
@ -53,6 +46,14 @@ function init() {
return; return;
} }
let pns = undefined;
try {
pns = Cc["@mozilla.org/push/NotificationService;1"]
.getService(Ci.nsIPushNotificationService);
} catch(e) {
dump("Could not acquire PushNotificationService\n");
}
for (let i = 0; i < length; ++i) { for (let i = 0; i < length; ++i) {
let info = data.queryElementAt(i, Ci.nsIServiceWorkerInfo); let info = data.queryElementAt(i, Ci.nsIServiceWorkerInfo);
if (!info) { if (!info) {
@ -60,11 +61,11 @@ function init() {
continue; continue;
} }
display(info); display(info, pns);
} }
} }
function display(info) { function display(info, pushNotificationService) {
let parent = document.getElementById("serviceworkers"); let parent = document.getElementById("serviceworkers");
let div = document.createElement('div'); let div = document.createElement('div');
@ -120,14 +121,14 @@ function display(info) {
createItem(bundle.GetStringFromName('waitingCacheName'), info.waitingCacheName); createItem(bundle.GetStringFromName('waitingCacheName'), info.waitingCacheName);
let pushItem = createItem(bundle.GetStringFromName('pushEndpoint'), bundle.GetStringFromName('waiting')); let pushItem = createItem(bundle.GetStringFromName('pushEndpoint'), bundle.GetStringFromName('waiting'));
PushNotificationService.registration(info.scope, info.principal.originAttributes).then( if (pushNotificationService) {
pushRecord => { pushNotificationService.registration(info.scope, info.principal.originAttributes)
pushItem.data = JSON.stringify(pushRecord); .then(pushRecord => {
}, pushItem.data = JSON.stringify(pushRecord);
error => { }).catch(error => {
dump("about:serviceworkers - push registration failed\n"); dump("about:serviceworkers - retrieving push registration failed\n");
} });
); }
let updateButton = document.createElement("button"); let updateButton = document.createElement("button");
updateButton.appendChild(document.createTextNode(bundle.GetStringFromName('update'))); updateButton.appendChild(document.createTextNode(bundle.GetStringFromName('update')));