Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.

Commit 9a930fa

Browse files
authored
Merge pull request #374 from mozilla/browser-action-title
Add status text to the browser action. Fixes #367
2 parents e8f4696 + 2894718 commit 9a930fa

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/_locales/en_US/messages.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@
55
"extensionDescription": {
66
"message": "A secure, encrypted tunnel to the web to protect yourself everywhere you use Firefox."
77
},
8+
9+
"badgeOnText": {
10+
"message": "Firefox Private Network is On"
11+
},
12+
"badgeOffText": {
13+
"message": "Firefox Private Network is Off"
14+
},
15+
"badgeWarningText": {
16+
"message": "Firefox Private Network is inactive"
17+
},
818

919
"heroProxyOff": {
1020
"message": "OFF"

src/background.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,34 +433,48 @@ class Background {
433433
// This updates any tab that doesn't have an exemption
434434
updateIcon() {
435435
let icon;
436+
let text;
436437
if (this.proxyState === PROXY_STATE_INACTIVE ||
437438
this.proxyState === PROXY_STATE_CONNECTING ||
438439
this.proxyState === PROXY_STATE_OFFLINE) {
439440
icon = "img/badge_off.svg";
441+
text = "badgeOffText";
440442
} else if (this.proxyState === PROXY_STATE_ACTIVE) {
441443
icon = "img/badge_on.svg";
444+
text = "badgeOnText";
442445
} else {
443446
icon = "img/badge_warning.svg";
447+
text = "badgeWarningText";
444448
}
445449

446450
browser.browserAction.setIcon({
447451
path: icon,
448452
});
453+
browser.browserAction.setTitle({
454+
title: this.getTranslation(text),
455+
});
449456
}
450457

451458
// Used to set or remove tab exemption icons
452459
setTabIcon(tabId) {
453460
log(`updating tab icon: ${tabId}`);
454461
// default value here is undefined which resets the icon back when it becomes non exempt again
455462
let path;
463+
// default title resets the tab title
464+
let title = null;
456465
if (this.isTabExempt(tabId)) {
466+
title = this.getTranslation("badgeWarningText");
457467
path = "img/badge_warning.svg";
458468
}
459469

460470
browser.browserAction.setIcon({
461471
path,
462472
tabId
463473
});
474+
browser.browserAction.setTitle({
475+
tabId,
476+
title
477+
});
464478
}
465479

466480
async proxyRequestCallback(requestInfo) {

0 commit comments

Comments
 (0)