Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/notificationHelper.js

Issue 29371763: Issue 4795 - Use modern JavaScript syntax (Closed)
Patch Set: Use method shorthand Created Jan. 16, 2017, 4:07 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/messaging.js ('k') | lib/prefs.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/notificationHelper.js
diff --git a/lib/notificationHelper.js b/lib/notificationHelper.js
index 84f34b3dcf966543a918bfae43efc78bd6565fbe..2aa46171077449372528d3862ef35926c88f32b0 100644
--- a/lib/notificationHelper.js
+++ b/lib/notificationHelper.js
@@ -17,6 +17,8 @@
/** @module notificationHelper */
+"use strict";
+
let {startIconAnimation, stopIconAnimation} = require("icon");
let {Utils} = require("utils");
let {Notification: NotificationStorage} = require("notification");
@@ -33,25 +35,13 @@ displayMethods.question = ["notification"];
displayMethods.normal = ["notification"];
displayMethods.information = ["icon", "popup"];
-// Chrome on Linux does not fully support chrome.notifications until version 35
-// https://code.google.com/p/chromium/issues/detail?id=291485
-let canUseChromeNotifications = (function()
-{
- let info = require("info");
- if (info.platform == "chromium" && "notifications" in chrome)
- {
- if (navigator.platform.indexOf("Linux") == -1)
- return true;
- if (Services.vc.compare(info.applicationVersion, "35") >= 0)
- return true;
- }
- return false;
-})();
+let platform = require("info").platform;
+let canUseChromeNotifications = platform == "chromium" && "notifications" in chrome;
function prepareNotificationIconAndPopup()
{
let animateIcon = shouldDisplay("icon", activeNotification.type);
- activeNotification.onClicked = function()
+ activeNotification.onClicked = () =>
{
if (animateIcon)
stopIconAnimation();
@@ -135,7 +125,7 @@ function notificationButtonClick(buttonIndex)
break;
case "configure":
Prefs.notifications_showui = true;
- ext.showOptions(function(page)
+ ext.showOptions(page =>
{
page.sendMessage({
type: "app.respond",
@@ -165,14 +155,14 @@ function initChromeNotifications()
if (activeNotification && activeNotification.type != "question" && !("links" in activeNotification))
return;
- chrome.notifications.clear(notificationId, function(wasCleared)
+ chrome.notifications.clear(notificationId, wasCleared =>
{
if (wasCleared)
notificationClosed();
});
}
- chrome.notifications.onButtonClicked.addListener(function(notificationId, buttonIndex)
+ chrome.notifications.onButtonClicked.addListener((notificationId, buttonIndex) =>
{
notificationButtonClick(buttonIndex);
clearActiveNotification(notificationId);
@@ -244,7 +234,7 @@ function showNotification(notification)
/**
* Initializes the notification system.
*/
-exports.initNotifications = function()
+exports.initNotifications = () =>
{
if (canUseChromeNotifications)
initChromeNotifications();
@@ -256,10 +246,7 @@ exports.initNotifications = function()
*
* @return {?object}
*/
-exports.getActiveNotification = function()
-{
- return activeNotification;
-};
+exports.getActiveNotification = () => activeNotification;
let shouldDisplay =
/**
@@ -270,7 +257,7 @@ let shouldDisplay =
* @param {string} notificationType
* @return {boolean}
*/
-exports.shouldDisplay = function(method, notificationType)
+exports.shouldDisplay = (method, notificationType) =>
{
let methods = displayMethods[notificationType] || defaultDisplayMethods;
return methods.indexOf(method) > -1;
« no previous file with comments | « lib/messaging.js ('k') | lib/prefs.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld