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

Delta Between Two Patch Sets: ext/background.js

Issue 29557724: Issue 4699 - Edge does not support 16px and 32px icons (Closed)
Left Patch Set: Created Sept. 27, 2017, 7:36 p.m.
Right Patch Set: Remove the code duplication Created Sept. 27, 2017, 9: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 | no next file » | 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 _applyChanges() 336 _applyChanges()
337 { 337 {
338 if ("iconPath" in this._changes) 338 if ("iconPath" in this._changes)
339 { 339 {
340 // Firefox for Android displays the browser action not as an icon but 340 // Firefox for Android displays the browser action not as an icon but
341 // as a menu item. There is no icon, but such an option may be added in 341 // as a menu item. There is no icon, but such an option may be added in
342 // the future. 342 // the future.
343 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746 343 // https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
344 if ("setIcon" in chrome.browserAction) 344 if ("setIcon" in chrome.browserAction)
345 { 345 {
346 let path = {
347 16: this._changes.iconPath.replace("$size", "16"),
348 19: this._changes.iconPath.replace("$size", "19"),
349 20: this._changes.iconPath.replace("$size", "20"),
350 32: this._changes.iconPath.replace("$size", "32"),
351 38: this._changes.iconPath.replace("$size", "38"),
352 40: this._changes.iconPath.replace("$size", "40")
353 };
346 try 354 try
347 { 355 {
348 chrome.browserAction.setIcon({ 356 chrome.browserAction.setIcon({tabId: this._tabId, path});
349 tabId: this._tabId,
350 path: {
351 16: this._changes.iconPath.replace("$size", "16"),
352 19: this._changes.iconPath.replace("$size", "19"),
353 20: this._changes.iconPath.replace("$size", "20"),
354 32: this._changes.iconPath.replace("$size", "32"),
355 38: this._changes.iconPath.replace("$size", "38"),
356 40: this._changes.iconPath.replace("$size", "40")
357 }
358 });
359 } 357 }
360 catch (e) 358 catch (e)
361 { 359 {
362 // Edge throws if passed icon sizes different than 19,20,38,40px. 360 // Edge throws if passed icon sizes different than 19,20,38,40px.
363 chrome.browserAction.setIcon({ 361 delete path[16];
364 tabId: this._tabId, 362 delete path[32];
365 path: { 363 chrome.browserAction.setIcon({tabId: this._tabId, path});
366 19: this._changes.iconPath.replace("$size", "19"),
367 20: this._changes.iconPath.replace("$size", "20"),
368 38: this._changes.iconPath.replace("$size", "38"),
369 40: this._changes.iconPath.replace("$size", "40")
370 }
371 });
372 } 364 }
Sebastian Noack 2017/09/27 21:00:40 We can avoid duplication here: let path = {
373 } 365 }
374 } 366 }
375 367
376 if ("badgeText" in this._changes) 368 if ("badgeText" in this._changes)
377 { 369 {
378 // There is no badge on Firefox for Android; the browser action is 370 // There is no badge on Firefox for Android; the browser action is
379 // simply a menu item. 371 // simply a menu item.
380 if ("setBadgeText" in chrome.browserAction) 372 if ("setBadgeText" in chrome.browserAction)
381 { 373 {
382 chrome.browserAction.setBadgeText({ 374 chrome.browserAction.setBadgeText({
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 ext.windows = { 785 ext.windows = {
794 create(createData, callback) 786 create(createData, callback)
795 { 787 {
796 chrome.windows.create(createData, createdWindow => 788 chrome.windows.create(createData, createdWindow =>
797 { 789 {
798 afterTabLoaded(callback)(createdWindow.tabs[0]); 790 afterTabLoaded(callback)(createdWindow.tabs[0]);
799 }); 791 });
800 } 792 }
801 }; 793 };
802 }()); 794 }());
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld