Skip to content

Commit bd44a9c

Browse files
committed
Add new icons and banner. Supersedes EFForg#4100. Code changes by jsha@eff.org
1 parent 5c3b4aa commit bd44a9c

62 files changed

Lines changed: 127 additions & 102 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

chromium/background.js

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,33 @@ var switchPlannerInfo = {};
3838

3939
// Is HTTPSe enabled, or has it been manually disabled by the user?
4040
var isExtensionEnabled = true;
41-
// The setBadgeText API has an abandoned bug: https://crbug.com/170413
42-
chrome.browserAction.setBadgeText({ text: "" });
4341

4442
// Load prefs about whether http nowhere is on. Structure is:
4543
// { httpNowhere: true/false }
4644
var httpNowhereOn = false;
4745
storage.get({httpNowhere: false}, function(item) {
4846
httpNowhereOn = item.httpNowhere;
49-
setIconColor();
47+
updateState();
5048
});
5149
chrome.storage.onChanged.addListener(function(changes, areaName) {
5250
if (areaName === 'sync' || areaName === 'local') {
5351
for (var key in changes) {
5452
if (key === 'httpNowhere') {
5553
httpNowhereOn = changes[key].newValue;
56-
setIconColor();
54+
updateState();
5755
}
5856
}
5957
}
6058
});
59+
chrome.tabs.onActivated.addListener(function() {
60+
updateState();
61+
});
62+
chrome.windows.onFocusChanged.addListener(function() {
63+
updateState();
64+
});
65+
chrome.webNavigation.onCompleted.addListener(function() {
66+
updateState();
67+
});
6168

6269
/**
6370
* Load stored user rules
@@ -88,26 +95,35 @@ loadStoredUserRules();
8895

8996
/**
9097
* Set the icon color correctly
91-
* Depending on http-nowhere it should be red/default
98+
* inactive: extension is enabled, but no rules were triggered on this page.
99+
* blocking: extension is in "block all HTTP requests" mode.
100+
* active: extension is enabled and rewrote URLs on this page.
101+
* disabled: extension is disabled from the popup menu.
92102
*/
93-
var setIconColor = function() {
94-
var newIconPath = httpNowhereOn ? './icon38-red.png' : './icon38.png';
95-
chrome.browserAction.setIcon({
96-
path: newIconPath
103+
var updateState = function() {
104+
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
105+
if (!tabs || tabs.length === 0) {
106+
return;
107+
}
108+
var applied = activeRulesets.getRulesets(tabs[0].id)
109+
var iconState = "inactive";
110+
if (!isExtensionEnabled) {
111+
iconState = "disabled";
112+
} else if (httpNowhereOn) {
113+
iconState = "blocking";
114+
} else if (applied) {
115+
iconState = "active";
116+
}
117+
chrome.browserAction.setIcon({
118+
path: {
119+
"38": "icons/icon-" + iconState + "-38.png"
120+
}
121+
});
122+
chrome.browserAction.setTitle({
123+
title: "HTTPS Everywhere (" + iconState + ")"
124+
});
97125
});
98-
};
99-
100-
/*
101-
for (var v in localStorage) {
102-
log(DBUG, "localStorage["+v+"]: "+localStorage[v]);
103-
}
104-
105-
var rs = all_rules.potentiallyApplicableRulesets("www.google.com");
106-
for (r in rs) {
107-
log(DBUG, rs[r].name +": "+ rs[r].active);
108-
log(DBUG, rs[r].name +": "+ rs[r].default_state);
109126
}
110-
*/
111127

112128
/**
113129
* Adds a new user rule

chromium/devtools.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
chrome.devtools.panels.create("HTTPS Everywhere",
2-
"icon48.png",
2+
"icons/icon-active-38.png",
33
"devtools-panel.html",
44
function(panel) {
55
}

chromium/icons/icon-active-128.png

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-active-128.png

chromium/icons/icon-active-38.png

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-active-38.png

chromium/icons/icon-active-48.png

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-active-48.png
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-blocking-38.png
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-disabled-38.png
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../common/icons/icon-inactive-38.png

chromium/manifest.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
},
77
"author": {
88
"email": "eff.software.projects@gmail.com"
9-
},
9+
},
1010
"background": {
1111
"scripts": [
1212
"rules.js",
@@ -15,35 +15,35 @@
1515
"background.js",
1616
"incognito-cache-clearing.js"
1717
]
18-
},
18+
},
1919
"browser_action": {
2020
"default_icon": {
21-
"38": "icon38.png"
22-
},
23-
"default_popup": "popup.html",
21+
"38": "icons/icon-active-38.png"
22+
},
23+
"default_popup": "popup.html",
2424
"default_title": "__MSG_about_ext_name__"
25-
},
26-
"default_locale": "en",
27-
"description": "__MSG_about_ext_description__",
28-
"devtools_page": "devtools.html",
29-
"homepage_url": "https://www.eff.org/https-everywhere",
25+
},
26+
"default_locale": "en",
27+
"description": "__MSG_about_ext_description__",
28+
"devtools_page": "devtools.html",
29+
"homepage_url": "https://www.eff.org/https-everywhere",
3030
"icons": {
31-
"128": "icon128.png",
32-
"16": "icon16.png",
33-
"48": "icon48.png"
34-
},
35-
"incognito": "spanning",
36-
"manifest_version": 2,
37-
"minimum_chrome_version": "45",
38-
"name": "__MSG_about_ext_name__",
31+
"48": "icons/icon-active-48.png",
32+
"128": "icons/icon-active-128.png"
33+
},
34+
"incognito": "spanning",
35+
"manifest_version": 2,
36+
"minimum_chrome_version": "45",
37+
"name": "__MSG_about_ext_name__",
3938
"permissions": [
40-
"webRequest",
41-
"webRequestBlocking",
42-
"tabs",
43-
"cookies",
44-
"storage",
39+
"webNavigation",
40+
"webRequest",
41+
"webRequestBlocking",
42+
"tabs",
43+
"cookies",
44+
"storage",
4545
"<all_urls>"
4646
],
4747
"update_url": "https://www.eff.org/files/https-everywhere-chrome-updates.xml",
4848
"version": "2016.6.9"
49-
}
49+
}

chromium/popup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,22 @@ function updateEnabledDisabledUI() {
9292
} else {
9393
document.body.className = "disabled"
9494
}
95+
backgroundPage.updateState();
9596
}
9697

9798
// Toggle extension enabled/disabled status
9899
function toggleEnabledDisabled() {
99100
if (backgroundPage.isExtensionEnabled) {
100101
// User wants to disable us
101102
backgroundPage.isExtensionEnabled = false;
102-
chrome.browserAction.setBadgeText({ text: "OFF" });
103103
} else {
104104
// User wants to enable us
105105
backgroundPage.isExtensionEnabled = true;
106-
chrome.browserAction.setBadgeText({ text: "" });
107106
}
108107
updateEnabledDisabledUI();
109108
// The extension state changed, so reload this tab.
110109
chrome.tabs.reload();
110+
window.close();
111111
}
112112

113113
/**

0 commit comments

Comments
 (0)