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

Side by Side Diff: lib/notificationHelper.js

Issue 5733084272001024: Issue 2368 - Update adblockplus dependency to revision feb391127fe4 (Closed)
Patch Set: Make URL mandatory Created June 12, 2015, 5 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « dependencies ('k') | webrequest.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 122
123 chrome.notifications.onButtonClicked.addListener(function(notificationId, butt onIndex) 123 chrome.notifications.onButtonClicked.addListener(function(notificationId, butt onIndex)
124 { 124 {
125 notificationButtonClick(buttonIndex); 125 notificationButtonClick(buttonIndex);
126 clearActiveNotification(notificationId); 126 clearActiveNotification(notificationId);
127 }); 127 });
128 chrome.notifications.onClicked.addListener(clearActiveNotification); 128 chrome.notifications.onClicked.addListener(clearActiveNotification);
129 chrome.notifications.onClosed.addListener(notificationClosed); 129 chrome.notifications.onClosed.addListener(notificationClosed);
130 } 130 }
131 131
132 /** 132 function showNotification(notification)
133 * Initializes the notification system.
134 */
135 exports.initNotifications = function()
136 { 133 {
137 if (canUseChromeNotifications)
138 initChromeNotifications();
139 initAntiAdblockNotification();
140 };
141
142 let showNextNotification =
143 /**
144 * Shows the next notification from the queue if any.
145 *
146 * @param {URL} [url] URL to match notifications to
147 */
148 exports.showNextNotification = function(url)
149 {
150 let notification = NotificationStorage.getNextToShow(url && stringifyURL(url)) ;
151 if (!notification || activeNotification && activeNotification.id == notificati on.id) 134 if (!notification || activeNotification && activeNotification.id == notificati on.id)
152 return; 135 return;
153 136
154 activeNotification = notification; 137 activeNotification = notification;
155 if (activeNotification.type == "critical" || activeNotification.type == "quest ion") 138 if (activeNotification.type == "critical" || activeNotification.type == "quest ion")
156 { 139 {
157 let texts = NotificationStorage.getLocalizedTexts(notification); 140 let texts = NotificationStorage.getLocalizedTexts(notification);
158 let title = texts.title || ""; 141 let title = texts.title || "";
159 let message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : ""; 142 let message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : "";
160 let iconUrl = ext.getURL("icons/detailed/abp-128.png"); 143 let iconUrl = ext.getURL("icons/detailed/abp-128.png");
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if (activeNotification.type == "question") 203 if (activeNotification.type == "question")
221 notificationButtonClick(approved ? 0 : 1); 204 notificationButtonClick(approved ? 0 : 1);
222 else if (approved) 205 else if (approved)
223 openNotificationLinks(); 206 openNotificationLinks();
224 } 207 }
225 } 208 }
226 prepareNotificationIconAndPopup(); 209 prepareNotificationIconAndPopup();
227 }; 210 };
228 211
229 /** 212 /**
213 * Initializes the notification system.
214 */
215 exports.initNotifications = function()
216 {
217 if (canUseChromeNotifications)
218 initChromeNotifications();
219 initAntiAdblockNotification();
220 };
221
222 /**
223 * Shows the next notification for the supplied URL, if any.
Sebastian Noack 2015/06/12 17:14:19 Mind removing ", if any", since its mandatory now?
Felix Dahlke 2015/06/12 17:56:11 The "if any" was targeted at the notification, sin
Sebastian Noack 2015/06/12 18:12:51 Argh, you are right. I misread it. I think it make
Felix Dahlke 2015/06/12 18:24:08 Since the caller is not doing anything with the no
224 *
225 * @param {URL} [url] URL to match notifications to
Sebastian Noack 2015/06/12 17:14:19 Square brackets mean optional, which it isn't anym
Felix Dahlke 2015/06/12 17:56:11 Done.
226 */
227 exports.showNextNotificationForUrl = function(url)
228 {
229 NotificationStorage.showNext(stringifyURL(url));
230 }
231
232 /**
230 * Gets the active notification to be shown if any. 233 * Gets the active notification to be shown if any.
231 * 234 *
232 * @return {?object} 235 * @return {?object}
233 */ 236 */
234 exports.getActiveNotification = function() 237 exports.getActiveNotification = function()
235 { 238 {
236 return activeNotification; 239 return activeNotification;
237 }; 240 };
238 241
239 setTimeout(showNextNotification, 3 * 60 * 1000); 242 NotificationStorage.addShowListener(function(notification)
243 {
244 showNotification(notification);
245 });
OLDNEW
« no previous file with comments | « dependencies ('k') | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld