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

Unified Diff: ext/background.js

Issue 29995555: Issue 7253 - Pre-render icons for badge on Chromium (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Remove icons from metadata.chrome Created Feb. 3, 2019, 8:32 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 | « no previous file | icons/abp-19.png » ('j') | lib/icon.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
===================================================================
--- a/ext/background.js
+++ b/ext/background.js
@@ -326,35 +326,41 @@
// Firefox for Android displays the browser action not as an icon but
// as a menu item. There is no icon, but such an option may be added
// in the future.
// https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
if (change == "iconPath" && "setIcon" in browser.browserAction)
{
let path = {
16: this._changes.iconPath.replace("$size", "16"),
- 19: this._changes.iconPath.replace("$size", "19"),
20: this._changes.iconPath.replace("$size", "20"),
32: this._changes.iconPath.replace("$size", "32"),
- 38: this._changes.iconPath.replace("$size", "38"),
40: this._changes.iconPath.replace("$size", "40")
};
try
{
return browser.browserAction.setIcon({tabId: this._tabId, path});
}
catch (e)
{
// Edge throws if passed icon sizes different than 19,20,38,40px.
delete path[16];
delete path[32];
return browser.browserAction.setIcon({tabId: this._tabId, path});
}
}
+ if (change == "iconImageData" && "setIcon" in browser.browserAction)
+ {
+ return browser.browserAction.setIcon({
+ tabId: this._tabId,
+ imageData: this._changes.iconImageData
+ });
+ }
+
// There is no badge on Firefox for Android; the browser action is
// simply a menu item.
if (change == "badgeText" && "setBadgeText" in browser.browserAction)
return browser.browserAction.setBadgeText({
tabId: this._tabId,
text: this._changes.badgeText
});
@@ -394,19 +400,23 @@
{
// If the tab is prerendered, browser.browserAction.set* fails
// and we have to delay our changes until the currently visible tab
// is replaced with the prerendered tab.
browser.tabs.onReplaced.addListener(onReplaced);
});
}
},
- setIcon(path)
+ setIcon(path, imageData = null)
{
- this._addChange("iconPath", path);
+ // Use ImageData if available.
+ if (imageData)
Sebastian Noack 2019/02/03 08:47:16 Maybe it would be better, to just have two differe
Manish Jethani 2019/02/03 09:10:22 Done.
+ this._addChange("iconImageData", imageData);
+ else
+ this._addChange("iconPath", path);
},
setBadge(badge)
{
if (!badge)
{
this._addChange("badgeText", "");
}
else
« no previous file with comments | « no previous file | icons/abp-19.png » ('j') | lib/icon.js » ('J')

Powered by Google App Engine
This is Rietveld