Skip to content

Commit 6ece4f0

Browse files
daleharveydharvey@mozilla.com
authored andcommitted
Bug 1967512 - Implement initial functionality of trust panel. r=desktop-theme-reviewers,urlbar-reviewers,dao,reusable-components-reviewers,Itiel,tgiles,fluent-reviewers,bolsson
Differential Revision: https://phabricator.services.mozilla.com/D250274
1 parent f5e516a commit 6ece4f0

29 files changed

+1160
-6
lines changed

browser/base/content/browser-init.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ var gBrowserInit = {
413413
BookmarkingUI.init();
414414
gURLBar.delayedStartupInit();
415415
gProtectionsHandler.init();
416+
gTrustPanelHandler.init();
416417

417418
let safeMode = document.getElementById("helpSafeMode");
418419
if (Services.appinfo.inSafeMode) {
@@ -1068,6 +1069,7 @@ var gBrowserInit = {
10681069
ctrlTab.uninit();
10691070
gBrowserThumbnails.uninit();
10701071
gProtectionsHandler.uninit();
1072+
gTrustPanelHandler.uninit();
10711073
FullZoom.destroy();
10721074

10731075
Services.obs.removeObserver(gIdentityHandler, "perm-changed");

browser/base/content/browser-siteProtections.js

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,15 @@ class ProtectionCategory {
216216
};
217217
}
218218

219+
/*
220+
* Return the number items blocked by this blocker.
221+
* @returns {Integer} count - The number of items blocked.
222+
*/
223+
async getBlockerCount() {
224+
let { items } = await this._generateSubViewListItems();
225+
return items?.childElementCount ?? 0;
226+
}
227+
219228
/**
220229
* Create a DOM item representing a tracker.
221230
* @param {string} origin - Origin of the tracker.
@@ -320,6 +329,13 @@ class ProtectionCategory {
320329

321330
let Fingerprinting =
322331
new (class FingerprintingProtection extends ProtectionCategory {
332+
iconSrc = "chrome://browser/skin/fingerprint.svg";
333+
l10nKeys = {
334+
title: "fingerprinter",
335+
content: "fingerprinters",
336+
general: "fingerprinter",
337+
};
338+
323339
constructor() {
324340
super(
325341
"fingerprinters",
@@ -393,7 +409,6 @@ let Fingerprinting =
393409

394410
return (state & blockFlag) != 0;
395411
}
396-
397412
// TODO (Bug 1864914): Consider showing suspicious fingerprinting as allowed
398413
// when the fingerprinting protection is disabled.
399414
})();
@@ -409,8 +424,23 @@ let Cryptomining = new ProtectionCategory(
409424
}
410425
);
411426

427+
Cryptomining.l10nId = "trustpanel-cryptomining";
428+
Cryptomining.iconSrc = "chrome://browser/skin/controlcenter/cryptominers.svg";
429+
Cryptomining.l10nKeys = {
430+
title: "cryptominer",
431+
content: "cryptominers",
432+
general: "cryptominer",
433+
};
434+
412435
let TrackingProtection =
413436
new (class TrackingProtection extends ProtectionCategory {
437+
iconSrc = "chrome://browser/skin/canvas.svg";
438+
l10nKeys = {
439+
title: "tracking-content",
440+
content: "tracking-content",
441+
general: "tracking-content",
442+
};
443+
414444
constructor() {
415445
super(
416446
"trackers",
@@ -647,6 +677,13 @@ let TrackingProtection =
647677

648678
let ThirdPartyCookies =
649679
new (class ThirdPartyCookies extends ProtectionCategory {
680+
iconSrc = "chrome://browser/skin/controlcenter/3rdpartycookies.svg";
681+
l10nKeys = {
682+
title: "cookies-trackers",
683+
content: "cross-site-tracking-cookies",
684+
general: "tracking-cookies",
685+
};
686+
650687
constructor() {
651688
super(
652689
"cookies",
@@ -772,6 +809,34 @@ let ThirdPartyCookies =
772809
return this.prefEnabledValues.includes(this.behaviorPref);
773810
}
774811

812+
_generateSubViewListItems() {
813+
let fragment = document.createDocumentFragment();
814+
let contentBlockingLog = gBrowser.selectedBrowser.getContentBlockingLog();
815+
contentBlockingLog = JSON.parse(contentBlockingLog);
816+
let categories = this._processContentBlockingLog(contentBlockingLog);
817+
818+
let categoryNames = ["trackers"];
819+
switch (this.behaviorPref) {
820+
case Ci.nsICookieService.BEHAVIOR_REJECT:
821+
categoryNames.push("firstParty");
822+
// eslint-disable-next-line no-fallthrough
823+
case Ci.nsICookieService.BEHAVIOR_REJECT_FOREIGN:
824+
categoryNames.push("thirdParty");
825+
}
826+
827+
for (let category of categoryNames) {
828+
let itemsToShow = categories[category];
829+
830+
if (!itemsToShow.length) {
831+
continue;
832+
}
833+
for (let info of itemsToShow) {
834+
fragment.appendChild(this._createListItem(info));
835+
}
836+
}
837+
return { items: fragment };
838+
}
839+
775840
updateSubView() {
776841
let contentBlockingLog = gBrowser.selectedBrowser.getContentBlockingLog();
777842
contentBlockingLog = JSON.parse(contentBlockingLog);
@@ -1062,6 +1127,13 @@ let ThirdPartyCookies =
10621127

10631128
let SocialTracking =
10641129
new (class SocialTrackingProtection extends ProtectionCategory {
1130+
iconSrc = "chrome://browser/skin/thumb-down.svg";
1131+
l10nKeys = {
1132+
title: "social-media-trackers",
1133+
content: "social-media-trackers",
1134+
general: "social-tracking",
1135+
};
1136+
10651137
constructor() {
10661138
super(
10671139
"socialblock",

0 commit comments

Comments
 (0)