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

Unified Diff: ext/background.js

Issue 29509573: Issue 5347 - Check for browserAction API support (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Add comments explaining why Firefox for Android does not support these APIs Created Aug. 16, 2017, 11:44 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
===================================================================
--- a/ext/background.js
+++ b/ext/background.js
@@ -322,43 +322,60 @@
this._tabId = tabId;
this._changes = null;
};
BrowserAction.prototype = {
_applyChanges()
{
if ("iconPath" in this._changes)
{
- chrome.browserAction.setIcon({
- tabId: this._tabId,
- 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")
- }
- });
+ // 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 ("setIcon" in chrome.browserAction)
+ {
+ chrome.browserAction.setIcon({
+ tabId: this._tabId,
+ 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")
+ }
+ });
+ }
}
if ("badgeText" in this._changes)
{
- chrome.browserAction.setBadgeText({
- tabId: this._tabId,
- text: this._changes.badgeText
- });
+ // There is no badge on Firefox for Android; the browser action is
+ // simply a menu item.
+ if ("setBadgeText" in chrome.browserAction)
+ {
+ chrome.browserAction.setBadgeText({
+ tabId: this._tabId,
+ text: this._changes.badgeText
+ });
+ }
}
if ("badgeColor" in this._changes)
{
- chrome.browserAction.setBadgeBackgroundColor({
- tabId: this._tabId,
- color: this._changes.badgeColor
- });
+ // There is no badge on Firefox for Android; the browser action is
+ // simply a menu item.
+ if ("setBadgeBackgroundColor" in chrome.browserAction)
+ {
+ chrome.browserAction.setBadgeBackgroundColor({
+ tabId: this._tabId,
+ color: this._changes.badgeColor
+ });
+ }
}
this._changes = null;
},
_queueChanges()
{
chrome.tabs.get(this._tabId, () =>
{
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld