Skip to content

Commit e8dfd26

Browse files
Revert "Bug 2018009 - Max bandwidth should check usage info and entitlement before defaulting to MAX_IN_GB. r=ip-protection-reviewers,fchasen" for causing bc failures @ browser_ipprotection_alert_manager.js
This reverts commit 9517e4b.
1 parent a83a58a commit e8dfd26

3 files changed

Lines changed: 3 additions & 50 deletions

File tree

browser/components/ipprotection/IPPEnrollAndEntitleManager.sys.mjs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ class IPPEnrollAndEntitleManagerSingleton extends EventTarget {
3838
this.handleEvent = this.#handleEvent.bind(this);
3939
}
4040

41-
get entitlement() {
42-
return this.#entitlement;
43-
}
44-
4541
init() {
4642
// We will use data from the cache until we are fully functional. Then we
4743
// will recompute the state in `initOnStartupCompleted`.

browser/components/ipprotection/IPProtectionAlertManager.sys.mjs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
import { BANDWIDTH } from "chrome://browser/content/ipprotection/ipprotection-constants.mjs";
6-
75
const lazy = {};
86

97
ChromeUtils.defineLazyGetter(lazy, "ipProtectionLocalization", () => {
@@ -12,8 +10,6 @@ ChromeUtils.defineLazyGetter(lazy, "ipProtectionLocalization", () => {
1210

1311
ChromeUtils.defineESModuleGetters(lazy, {
1412
EveryWindow: "resource:///modules/EveryWindow.sys.mjs",
15-
IPPEnrollAndEntitleManager:
16-
"moz-src:///browser/components/ipprotection/IPPEnrollAndEntitleManager.sys.mjs",
1713
IPPProxyManager:
1814
"moz-src:///browser/components/ipprotection/IPPProxyManager.sys.mjs",
1915
IPPProxyStates:
@@ -68,10 +64,7 @@ class IPProtectionAlertManagerClass {
6864
errorBody,
6965
] = lazy.ipProtectionLocalization.formatMessagesSync([
7066
{ id: "vpn-paused-alert-title" },
71-
{
72-
id: "vpn-paused-alert-body",
73-
args: { maxUsage: this.#getMaxBandwidthUsage() },
74-
},
67+
{ id: "vpn-paused-alert-body", args: { maxUsage: 150 } },
7568
{ id: "vpn-paused-alert-close-tabs-button" },
7669
{ id: "vpn-paused-alert-continue-wo-vpn-button" },
7770
{ id: "vpn-error-alert-title" },
@@ -91,26 +84,6 @@ class IPProtectionAlertManagerClass {
9184
return this.#localizationMessages;
9285
}
9386

94-
/**
95-
* Check usage info for the max usage, then entitlement, then default to
96-
* BANDWIDTH.MAX_IN_GB.
97-
*
98-
* @returns {object} An object with max and remaining as numbers
99-
*/
100-
#getMaxBandwidthUsage() {
101-
if (lazy.IPPProxyManager.usageInfo?.max != null) {
102-
return Number(lazy.IPPProxyManager.usageInfo.max) / BANDWIDTH.BYTES_IN_GB;
103-
} else if (lazy.IPPEnrollAndEntitleManager.entitlement?.maxBytes != null) {
104-
// Usage info doesn't exist yet. Check the entitlement
105-
return (
106-
Number(lazy.IPPEnrollAndEntitleManager.entitlement?.maxBytes) /
107-
BANDWIDTH.BYTES_IN_GB
108-
);
109-
}
110-
111-
return BANDWIDTH.MAX_IN_GB;
112-
}
113-
11487
handleEvent(event) {
11588
if (event.type !== "IPPProxyManager:StateChanged") {
11689
return;

browser/components/ipprotection/IPProtectionPanel.sys.mjs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -677,33 +677,17 @@ export class IPProtectionPanel {
677677
/**
678678
* BigInts throw when using JSON.stringify or when using arithmetic with
679679
* numbers so we convert them to numbers here so they max and remaining can
680-
* be safely used. Check usageInfo first, if that doesn't exist, check the
681-
* entitlement. If neither exist, return null.
680+
* be safely used.
682681
*
683682
* @returns {object} An object with max and remaining as numbers
684683
*/
685684
#getBandwidthUsage() {
686-
if (
687-
lazy.BANDWIDTH_USAGE_ENABLED &&
688-
lazy.IPPProxyManager.usageInfo?.max != null
689-
) {
685+
if (lazy.BANDWIDTH_USAGE_ENABLED && lazy.IPPProxyManager.usageInfo) {
690686
return {
691687
max: Number(lazy.IPPProxyManager.usageInfo.max),
692688
remaining: Number(lazy.IPPProxyManager.usageInfo.remaining),
693689
reset: lazy.IPPProxyManager.usageInfo.reset,
694690
};
695-
} else if (
696-
lazy.BANDWIDTH_USAGE_ENABLED &&
697-
lazy.IPPEnrollAndEntitleManager.entitlement?.maxBytes != null
698-
) {
699-
// Usage info doesn't exist yet. Check the entitlement
700-
return {
701-
max: Number(lazy.IPPEnrollAndEntitleManager.entitlement?.maxBytes),
702-
remaining: Number(
703-
lazy.IPPEnrollAndEntitleManager.entitlement?.maxBytes
704-
),
705-
reset: null,
706-
};
707691
}
708692

709693
return null;

0 commit comments

Comments
 (0)