Move chrome-specific calls to chromium.js
// FREEBIE
This commit is contained in:
parent
b1afb79a14
commit
6dcff46e26
2 changed files with 27 additions and 20 deletions
|
@ -9,29 +9,11 @@
|
|||
};
|
||||
|
||||
console.log('background page reloaded');
|
||||
// register some chrome listeners
|
||||
if (chrome.notifications) {
|
||||
chrome.notifications.onClicked.addListener(function() {
|
||||
extension.notification.clear();
|
||||
Whisper.Notifications.onclick();
|
||||
});
|
||||
chrome.notifications.onButtonClicked.addListener(function() {
|
||||
extension.notification.clear();
|
||||
Whisper.Notifications.clear();
|
||||
getInboxCollection().each(function(model) {
|
||||
model.markRead();
|
||||
});
|
||||
});
|
||||
chrome.notifications.onClosed.addListener(function(id, byUser) {
|
||||
if (byUser) {
|
||||
Whisper.Notifications.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
extension.notification.init();
|
||||
|
||||
// Close and reopen existing windows
|
||||
var open = false;
|
||||
chrome.app.window.getAll().forEach(function(appWindow) {
|
||||
extension.windows.getAll().forEach(function(appWindow) {
|
||||
open = true;
|
||||
appWindow.close();
|
||||
});
|
||||
|
|
|
@ -105,6 +105,10 @@
|
|||
}
|
||||
},
|
||||
|
||||
getAll: function() {
|
||||
return chrome.app.window.getAll();
|
||||
},
|
||||
|
||||
getViews: function() {
|
||||
if (chrome.extension) {
|
||||
return chrome.extension.getViews();
|
||||
|
@ -214,6 +218,27 @@
|
|||
|
||||
var notification_pending = Promise.resolve();
|
||||
extension.notification = {
|
||||
init: function() {
|
||||
// register some chrome listeners
|
||||
if (chrome.notifications) {
|
||||
chrome.notifications.onClicked.addListener(function() {
|
||||
extension.notification.clear();
|
||||
Whisper.Notifications.onclick();
|
||||
});
|
||||
chrome.notifications.onButtonClicked.addListener(function() {
|
||||
extension.notification.clear();
|
||||
Whisper.Notifications.clear();
|
||||
getInboxCollection().each(function(model) {
|
||||
model.markRead();
|
||||
});
|
||||
});
|
||||
chrome.notifications.onClosed.addListener(function(id, byUser) {
|
||||
if (byUser) {
|
||||
Whisper.Notifications.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
clear: function() {
|
||||
notification_pending = notification_pending.then(function() {
|
||||
return new Promise(function(resolve) {
|
||||
|
|
Loading…
Reference in a new issue