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

Delta Between Two Patch Sets: lib/notificationHelper.js

Issue 29726570: Issue 6496 - Account for browsers that don't support notifications with buttons (Closed)
Left Patch Set: Created March 18, 2018, 11:10 p.m.
Right Patch Set: Fixed typo in comment Created March 19, 2018, 4:58 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | lib/subscriptionInit.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 iconUrl, 202 iconUrl,
203 message, 203 message,
204 buttons: activeButtons.map(button => ({title: button.title})), 204 buttons: activeButtons.map(button => ({title: button.title})),
205 // We use the highest priority to prevent the notification 205 // We use the highest priority to prevent the notification
206 // from closing automatically. 206 // from closing automatically.
207 priority: 2 207 priority: 2
208 }; 208 };
209 209
210 // Firefox and Opera don't support buttons. Firefox throws synchronously, 210 // Firefox and Opera don't support buttons. Firefox throws synchronously,
211 // while Opera gives an asynchronous error. Wrapping the promise like 211 // while Opera gives an asynchronous error. Wrapping the promise like
212 // this, turns the synchronus error on Firefox into a promise rejection. 212 // this, turns the synchronous error on Firefox into a promise rejection.
kzar 2018/03/19 08:34:59 Nit: Spelling of "synchronous"
Sebastian Noack 2018/03/19 16:58:23 Done.
213 new Promise(resolve => 213 new Promise(resolve =>
214 { 214 {
215 resolve(browser.notifications.create(notificationOptions)); 215 resolve(browser.notifications.create(notificationOptions));
216 }).catch(() => 216 }).catch(() =>
217 { 217 {
218 // Without buttons, showing notifications of the type "question" is 218 // Without buttons, showing notifications of the type "question" is
219 // pointless. For other notifications, retry with the buttons removed. 219 // pointless. For other notifications, retry with the buttons removed.
220 if (activeNotification.type != "question") 220 if (activeNotification.type != "question")
221 { 221 {
222 delete notificationOptions.buttons; 222 delete notificationOptions.buttons;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 let methods = displayMethods[notificationType] || defaultDisplayMethods; 300 let methods = displayMethods[notificationType] || defaultDisplayMethods;
301 return methods.includes(method); 301 return methods.includes(method);
302 }; 302 };
303 303
304 ext.pages.onLoading.addListener(page => 304 ext.pages.onLoading.addListener(page =>
305 { 305 {
306 NotificationStorage.showNext(stringifyURL(page.url)); 306 NotificationStorage.showNext(stringifyURL(page.url));
307 }); 307 });
308 308
309 NotificationStorage.addShowListener(showNotification); 309 NotificationStorage.addShowListener(showNotification);
LEFTRIGHT

Powered by Google App Engine
This is Rietveld