зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset d049a47c24c1 (bug 1264815)
This commit is contained in:
Родитель
cf57bff1c2
Коммит
62db018fa7
|
@ -82,21 +82,12 @@ var NotificationDB = {
|
|||
},
|
||||
|
||||
filterNonAppNotifications: function(notifications) {
|
||||
for (let origin in notifications) {
|
||||
let origins = Object.keys(notifications);
|
||||
for (let origin of origins) {
|
||||
let canPut = notificationStorage.canPut(origin);
|
||||
if (!canPut) {
|
||||
let persistentNotificationCount = 0;
|
||||
for (let id in notifications[origin]) {
|
||||
if (notifications[origin][id].serviceWorkerRegistrationScope) {
|
||||
persistentNotificationCount++;
|
||||
} else {
|
||||
delete notifications[origin][id];
|
||||
}
|
||||
}
|
||||
if (persistentNotificationCount == 0) {
|
||||
if (DEBUG) debug("Origin " + origin + " is not linked to an app manifest, deleting.");
|
||||
delete notifications[origin];
|
||||
}
|
||||
if (DEBUG) debug("Origin " + origin + " is not linked to an app manifest, deleting.");
|
||||
delete notifications[origin];
|
||||
}
|
||||
}
|
||||
return notifications;
|
||||
|
@ -108,9 +99,9 @@ var NotificationDB = {
|
|||
return promise.then(
|
||||
function onSuccess(data) {
|
||||
if (data.length > 0) {
|
||||
// Preprocessing phase intends to cleanly separate any migration-related
|
||||
// Preprocessing phase intends to cleanly separate any migration-related
|
||||
// tasks.
|
||||
this.notifications = this.filterNonAppNotifications(JSON.parse(data));
|
||||
this.notifications = this.filterNonAppNotifications(JSON.parse(data));
|
||||
}
|
||||
|
||||
// populate the list of notifications by tag
|
||||
|
|
|
@ -118,7 +118,7 @@ NotificationStorage.prototype = {
|
|||
this._byTag[origin][tag] = notification;
|
||||
};
|
||||
|
||||
if (serviceWorkerRegistrationScope || this.canPut(origin)) {
|
||||
if (this.canPut(origin)) {
|
||||
cpmm.sendAsyncMessage("Notification:Save", {
|
||||
origin: origin,
|
||||
notification: notification
|
||||
|
|
|
@ -116,8 +116,3 @@ contract @mozilla.org/colorpicker;1 {430b987f-bb9f-46a3-99a5-241749220b29}
|
|||
# AndroidActivitiesGlue.js
|
||||
component {e4deb5f6-d5e3-4fce-bc53-901dd9951c48} AndroidActivitiesGlue.js
|
||||
contract @mozilla.org/dom/activities/ui-glue;1 {e4deb5f6-d5e3-4fce-bc53-901dd9951c48}
|
||||
|
||||
# PersistentNotificationHandler.js
|
||||
component {75390fe7-f8a3-423a-b3b1-258d7eabed40} PersistentNotificationHandler.js
|
||||
contract @mozilla.org/persistent-notification-handler;1 {75390fe7-f8a3-423a-b3b1-258d7eabed40}
|
||||
category persistent-notification-click PersistentNotificationHandler @mozilla.org/persistent-notification-handler;1
|
||||
|
|
|
@ -1,57 +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/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Messaging.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, 'Services', // jshint ignore:line
|
||||
'resource://gre/modules/Services.jsm');
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "notificationStorage",
|
||||
"@mozilla.org/notificationStorage;1",
|
||||
"nsINotificationStorage");
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "serviceWorkerManager",
|
||||
"@mozilla.org/serviceworkers/manager;1",
|
||||
"nsIServiceWorkerManager");
|
||||
|
||||
function PersistentNotificationHandler() {
|
||||
}
|
||||
|
||||
PersistentNotificationHandler.prototype = {
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||
classID: Components.ID("{75390fe7-f8a3-423a-b3b1-258d7eabed40}"),
|
||||
|
||||
observe(subject, topic, data) {
|
||||
if (Services.appinfo.processType == Services.appinfo.PROCESS_TYPE_DEFAULT) {
|
||||
Cu.import("resource://gre/modules/NotificationDB.jsm");
|
||||
}
|
||||
const persistentInfo = JSON.parse(data);
|
||||
|
||||
notificationStorage.getByID(persistentInfo.origin, persistentInfo.id, {
|
||||
handle(id, title, dir, lang, body, tag, icon, data, behavior, serviceWorkerRegistrationScope) {
|
||||
serviceWorkerManager.sendNotificationClickEvent(
|
||||
persistentInfo.originSuffix,
|
||||
serviceWorkerRegistrationScope,
|
||||
id,
|
||||
title,
|
||||
dir,
|
||||
lang,
|
||||
body,
|
||||
tag,
|
||||
icon,
|
||||
data,
|
||||
behavior
|
||||
);
|
||||
notificationStorage.delete(persistentInfo.origin, persistentInfo.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([
|
||||
PersistentNotificationHandler
|
||||
]);
|
|
@ -25,7 +25,6 @@ EXTRA_COMPONENTS += [
|
|||
'ImageBlockingPolicy.js',
|
||||
'LoginManagerPrompter.js',
|
||||
'NSSDialogService.js',
|
||||
'PersistentNotificationHandler.js',
|
||||
'PresentationDevicePrompt.js',
|
||||
'PromptService.js',
|
||||
'SessionStore.js',
|
||||
|
|
|
@ -538,7 +538,6 @@
|
|||
@BINPATH@/components/MobileComponents.manifest
|
||||
@BINPATH@/components/MobileComponents.xpt
|
||||
@BINPATH@/components/NSSDialogService.js
|
||||
@BINPATH@/components/PersistentNotificationHandler.js
|
||||
@BINPATH@/components/PresentationDevicePrompt.js
|
||||
@BINPATH@/components/PromptService.js
|
||||
@BINPATH@/components/SessionStore.js
|
||||
|
|
Загрузка…
Ссылка в новой задаче