Microsoft is acquiring GitHub. Decentraleyes is leaving GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Resolve #228 by implementing a new icon state

parent a986800e
......@@ -123,15 +123,24 @@ stateManager._removeTab = function (tabIdentifier) {
stateManager._updateTab = function (details) {
let tabIdentifier, frameIdentifier;
let tabDomain, domainIsWhitelisted, tabIdentifier, frameIdentifier;
tabDomain = helpers.extractDomainFromUrl(details.url);
domainIsWhitelisted = stateManager._domainIsWhitelisted(tabDomain);
tabIdentifier = details.tabId;
frameIdentifier = details.frameId;
tabIdentifier = details.tabId;
if (tabIdentifier === -1 || frameIdentifier !== 0) {
if (frameIdentifier !== 0 || tabIdentifier === -1) {
return;
}
if (domainIsWhitelisted) {
stateManager._setIconDisabled(tabIdentifier);
} else {
stateManager._setIconDefault(tabIdentifier);
}
chrome.browserAction.setTitle({
'tabId': tabIdentifier,
'title': 'Decentraleyes'
......@@ -182,12 +191,62 @@ stateManager._removeIconBadgeFromTab = function (tab) {
stateManager._clearBadgeText(tab.id);
};
stateManager._domainIsWhitelisted = function (domain) {
if (domain !== null) {
let whitelistRecord, isWhitelisted;
whitelistRecord = requestAnalyzer.whitelistedDomains[domain];
isWhitelisted = Boolean(whitelistRecord);
return isWhitelisted;
}
return false;
};
stateManager._setIconDefault = function (tabIdentifier) {
wrappers.setIcon({
'path': stateManager.defaultIconPath,
'tabId': tabIdentifier
});
};
stateManager._setIconDisabled = function (tabIdentifier) {
wrappers.setIcon({
'path': stateManager.disabledIconPath,
'tabId': tabIdentifier
});
};
/**
* Initializations
*/
stateManager.requests = {};
stateManager.tabs = {};
stateManager.defaultIconPath = {
'18': chrome.runtime.getURL('icons/action/icon18-default.png'),
'19': chrome.runtime.getURL('icons/action/icon19-default.png'),
'32': chrome.runtime.getURL('icons/action/icon32-default.png'),
'36': chrome.runtime.getURL('icons/action/icon36-default.png'),
'38': chrome.runtime.getURL('icons/action/icon38-default.png'),
'64': chrome.runtime.getURL('icons/action/icon64-default.png')
};
stateManager.disabledIconPath = {
'18': chrome.runtime.getURL('icons/action/icon18-disabled.png'),
'19': chrome.runtime.getURL('icons/action/icon19-disabled.png'),
'32': chrome.runtime.getURL('icons/action/icon32-disabled.png'),
'36': chrome.runtime.getURL('icons/action/icon36-disabled.png'),
'38': chrome.runtime.getURL('icons/action/icon38-disabled.png'),
'64': chrome.runtime.getURL('icons/action/icon64-disabled.png')
};
stateManager.validHosts = [];
for (let mapping in mappings) {
......
......@@ -32,12 +32,12 @@
"browser_action": {
"default_icon": {
"18": "icons/action/icon18.png",
"19": "icons/action/icon19.png",
"32": "icons/action/icon32.png",
"36": "icons/action/icon36.png",
"38": "icons/action/icon38.png",
"64": "icons/action/icon64.png"
"18": "icons/action/icon18-default.png",
"19": "icons/action/icon19-default.png",
"32": "icons/action/icon32-default.png",
"36": "icons/action/icon36-default.png",
"38": "icons/action/icon38-default.png",
"64": "icons/action/icon64-default.png"
},
"default_popup": "pages/popup/popup.html",
"browser_style": false
......
......@@ -36,3 +36,10 @@ wrappers.setBadgeText = function (details) {
chrome.browserAction.setBadgeText(details);
}
};
wrappers.setIcon = function (details) {
if (chrome.browserAction.setIcon !== undefined) {
chrome.browserAction.setIcon(details);
}
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment