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

Side by Side Diff: ext/background.js

Issue 29793590: Issue 6490 - Wrap browser.browserAction.set* with Promise (Closed)
Patch Set: Created May 29, 2018, 11:07 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 | « no previous file | no next file » | 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-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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 let path = { 316 let path = {
317 16: this._changes.iconPath.replace("$size", "16"), 317 16: this._changes.iconPath.replace("$size", "16"),
318 19: this._changes.iconPath.replace("$size", "19"), 318 19: this._changes.iconPath.replace("$size", "19"),
319 20: this._changes.iconPath.replace("$size", "20"), 319 20: this._changes.iconPath.replace("$size", "20"),
320 32: this._changes.iconPath.replace("$size", "32"), 320 32: this._changes.iconPath.replace("$size", "32"),
321 38: this._changes.iconPath.replace("$size", "38"), 321 38: this._changes.iconPath.replace("$size", "38"),
322 40: this._changes.iconPath.replace("$size", "40") 322 40: this._changes.iconPath.replace("$size", "40")
323 }; 323 };
324 try 324 try
325 { 325 {
326 browser.browserAction.setIcon({tabId: this._tabId, path}); 326 browser.browserAction.setIcon({tabId: this._tabId, path}, () =>
327 {
328 browser.runtime.lastError;
329 });
327 } 330 }
328 catch (e) 331 catch (e)
329 { 332 {
330 // Edge throws if passed icon sizes different than 19,20,38,40px. 333 // Edge throws if passed icon sizes different than 19,20,38,40px.
331 delete path[16]; 334 delete path[16];
332 delete path[32]; 335 delete path[32];
333 browser.browserAction.setIcon({tabId: this._tabId, path}); 336 browser.browserAction.setIcon({tabId: this._tabId, path}, () =>
337 {
338 browser.runtime.lastError;
339 });
334 } 340 }
335 } 341 }
336 } 342 }
337 343
338 if ("badgeText" in this._changes) 344 if ("badgeText" in this._changes)
339 { 345 {
340 // There is no badge on Firefox for Android; the browser action is 346 // There is no badge on Firefox for Android; the browser action is
341 // simply a menu item. 347 // simply a menu item.
342 if ("setBadgeText" in browser.browserAction) 348 if ("setBadgeText" in browser.browserAction)
343 { 349 {
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 return frames.get(0) || null; 576 return frames.get(0) || null;
571 } 577 }
572 }; 578 };
573 } 579 }
574 580
575 return ext.onMessage._dispatch( 581 return ext.onMessage._dispatch(
576 message, sender, sendResponse 582 message, sender, sendResponse
577 ).includes(true); 583 ).includes(true);
578 }); 584 });
579 } 585 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld