Skip to content

Commit 9d34f77

Browse files
committed
Merge pull request EFForg#173 from semenko/pageaction-cleanups
Chrome: cleanup pageAction icon code
2 parents 3f01abb + cf2cfec commit 9d34f77

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

chromium/background.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ for (r in rs) {
2222
}
2323
*/
2424

25-
// Add the HTTPS Everywhere icon to the URL address bar.
26-
// TODO: Switch from pageAction to browserAction?
27-
function displayPageAction(tabId) {
28-
if (tabId !== -1) {
29-
chrome.tabs.get(tabId, function(tab) {
30-
if(typeof(tab) === "undefined") {
31-
log(DBUG, "Not a real tab. Skipping showing pageAction.");
32-
}
33-
else {
34-
chrome.pageAction.show(tabId);
35-
}
36-
});
37-
}
38-
}
39-
4025
function AppliedRulesets() {
4126
this.active_tab_rules = {};
4227

@@ -414,13 +399,21 @@ wr.onResponseStarted.addListener(onResponseStarted,
414399
// Note: We can't use any other hook (onCreated, onActivated, etc.) because Chrome resets the
415400
// pageActions on URL change. We should strongly consider switching from pageAction to browserAction.
416401
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
417-
displayPageAction(tabId);
402+
if (changeInfo.status === "loading") {
403+
chrome.pageAction.show(tabId);
404+
}
418405
});
419406

420407
// Pre-rendered tabs / instant experiments sometimes skip onUpdated.
421408
// See http://crbug.com/109557
422409
chrome.tabs.onReplaced.addListener(function(addedTabId, removedTabId) {
423-
displayPageAction(addedTabId);
410+
chrome.tabs.get(addedTabId, function(tab) {
411+
if(typeof(tab) === "undefined") {
412+
log(DBUG, "Not a real tab. Skipping showing pageAction.");
413+
} else {
414+
chrome.pageAction.show(tabId);
415+
}
416+
});
424417
});
425418

426419
// Listen for cookies set/updated and secure them if applicable. This function is async/nonblocking,

0 commit comments

Comments
 (0)