Skip to content

Commit e525b32

Browse files
feat: Enable original extensions panel on hide-unified-extensions-button: false, p=#11335
* feat: Enable original extensions panel on hide-unified-extensions-button: false * Update to fix prettier issues * Add site-data attribute for CSS usage * Update to set gUnifiedExtensions._panel * Update to fix prettier issues * Set default panel on onToolbarVisibilityChange * Update panel initialization * Remove extra char * Restore unified-extensions-panel-template deletion * Reduce reimplementation * Update patch against Firefox 145.0.2 * Fix conflict * Add panelUIPosition case * Fix lint * feat: Improve and reduce patch sizes, b=no-bug, c=common --------- Signed-off-by: Blake Gearin <[email protected]> Co-authored-by: mr. m <[email protected]>
1 parent e3d13d5 commit e525b32

File tree

6 files changed

+197
-50
lines changed

6 files changed

+197
-50
lines changed

src/browser/base/content/browser-addons-js.patch

Lines changed: 118 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/base/content/browser-addons.js b/browser/base/content/browser-addons.js
2-
index fadcbfca95ee28140579430c0371baad0e2f216a..7454b801b4ad892d6ad122277eb7c7736e976f9f 100644
2+
index fadcbfca95ee28140579430c0371baad0e2f216a..22a92ca450ef5087610169b15d7f3344c9accddf 100644
33
--- a/browser/base/content/browser-addons.js
44
+++ b/browser/base/content/browser-addons.js
55
@@ -1069,7 +1069,7 @@ var gXPInstallObserver = {
@@ -38,37 +38,131 @@ index fadcbfca95ee28140579430c0371baad0e2f216a..7454b801b4ad892d6ad122277eb7c773
3838
}
3939

4040
return anchorID;
41-
@@ -2657,11 +2657,7 @@ var gUnifiedExtensions = {
42-
// Lazy load the unified-extensions-panel panel the first time we need to
43-
// display it.
44-
if (!this._panel) {
45-
- let template = document.getElementById(
46-
- "unified-extensions-panel-template"
47-
- );
48-
- template.replaceWith(template.content);
49-
- this._panel = document.getElementById("unified-extensions-panel");
50-
+ this._panel = document.getElementById("zen-unified-site-data-panel");
51-
let customizationArea = this._panel.querySelector(
52-
"#unified-extensions-area"
41+
@@ -2547,7 +2547,7 @@ var gUnifiedExtensions = {
42+
requestAnimationFrame(() => this.updateAttention());
43+
},
44+
45+
- onToolbarVisibilityChange(toolbarId, isVisible) {
46+
+ onToolbarVisibilityChange(toolbarId, isVisible, panel = this.panel) {
47+
// A list of extension widget IDs (possibly empty).
48+
let widgetIDs;
49+
50+
@@ -2561,7 +2561,7 @@ var gUnifiedExtensions = {
51+
}
52+
53+
// The list of overflowed extensions in the extensions panel.
54+
- const overflowedExtensionsList = this.panel.querySelector(
55+
+ const overflowedExtensionsList = panel.querySelector(
56+
"#overflowed-extensions-list"
57+
);
58+
59+
@@ -2662,37 +2662,41 @@ var gUnifiedExtensions = {
5360
);
54-
@@ -2714,6 +2710,7 @@ var gUnifiedExtensions = {
55-
// and no alternative content is available for display in the panel.
56-
const policies = this.getActivePolicies();
61+
template.replaceWith(template.content);
62+
this._panel = document.getElementById("unified-extensions-panel");
63+
- let customizationArea = this._panel.querySelector(
64+
- "#unified-extensions-area"
65+
- );
66+
- CustomizableUI.registerPanelNode(
67+
- customizationArea,
68+
- CustomizableUI.AREA_ADDONS
69+
- );
70+
- CustomizableUI.addPanelCloseListeners(this._panel);
71+
-
72+
- this._panel
73+
- .querySelector("#unified-extensions-manage-extensions")
74+
- .addEventListener("command", () => {
75+
- BrowserAddonUI.openAddonsMgr("addons://list/extension");
76+
- });
77+
-
78+
- // Lazy-load the l10n strings. Those strings are used for the CUI and
79+
- // non-CUI extensions in the unified extensions panel.
80+
- document
81+
- .getElementById("unified-extensions-context-menu")
82+
- .querySelectorAll("[data-lazy-l10n-id]")
83+
- .forEach(el => {
84+
- el.setAttribute("data-l10n-id", el.getAttribute("data-lazy-l10n-id"));
85+
- el.removeAttribute("data-lazy-l10n-id");
86+
- });
87+
+ this.initializePanel(this._panel);
88+
}
89+
return this._panel;
90+
},
91+
92+
+ initializePanel(panel) {
93+
+ let customizationArea = panel.querySelector(
94+
+ "#unified-extensions-area"
95+
+ );
96+
+ CustomizableUI.registerPanelNode(
97+
+ customizationArea,
98+
+ CustomizableUI.AREA_ADDONS
99+
+ );
100+
+ CustomizableUI.addPanelCloseListeners(panel);
101+
+
102+
+ panel
103+
+ .querySelector("#unified-extensions-manage-extensions")
104+
+ .addEventListener("command", () => {
105+
+ BrowserAddonUI.openAddonsMgr("addons://list/extension");
106+
+ });
107+
+
108+
+ // Lazy-load the l10n strings. Those strings are used for the CUI and
109+
+ // non-CUI extensions in the unified extensions panel.
110+
+ document
111+
+ .getElementById("unified-extensions-context-menu")
112+
+ .querySelectorAll("[data-lazy-l10n-id]")
113+
+ .forEach(el => {
114+
+ el.setAttribute("data-l10n-id", el.getAttribute("data-lazy-l10n-id"));
115+
+ el.removeAttribute("data-lazy-l10n-id");
116+
+ });
117+
+ },
118+
+
119+
// `aEvent` and `reason` are optional. If `reason` is specified, it should be
120+
// a valid argument to gUnifiedExtensions.recordButtonTelemetry().
121+
- async togglePanel(aEvent, reason) {
122+
+ async togglePanel(aEvent, reason, panel = this._panel, view = "unified-extensions-view", button = this._button) {
123+
if (!CustomizationHandler.isCustomizing()) {
124+
if (aEvent) {
57125
if (
58-
+ false &&
59-
policies.length &&
60-
!this.hasExtensionsInPanel(policies) &&
61-
!this.isPrivateWindowMissingExtensionsWithoutPBMAccess() &&
62-
@@ -2754,7 +2751,7 @@ var gUnifiedExtensions = {
126+
@@ -2729,32 +2733,30 @@ var gUnifiedExtensions = {
127+
this.blocklistAttentionInfo =
128+
await AddonManager.getBlocklistAttentionInfo();
129+
130+
- let panel = this.panel;
131+
-
132+
if (!this._listView) {
133+
this._listView = PanelMultiView.getViewNode(
134+
document,
135+
- "unified-extensions-view"
136+
+ view,
137+
);
138+
this._listView.addEventListener("ViewShowing", this);
139+
this._listView.addEventListener("ViewHiding", this);
140+
}
141+
142+
- if (this._button.open) {
143+
+ if (button.open) {
144+
PanelMultiView.hidePopup(panel);
145+
- this._button.open = false;
146+
+ button.open = false;
147+
} else {
148+
// Overflow extensions placed in collapsed toolbars, if any.
149+
for (const toolbarId of CustomizableUI.getCollapsedToolbarIds(window)) {
150+
// We pass `false` because all these toolbars are collapsed.
151+
- this.onToolbarVisibilityChange(toolbarId, /* isVisible */ false);
152+
+ this.onToolbarVisibilityChange(toolbarId, /* isVisible */ false, panel);
153+
}
154+
155+
panel.hidden = false;
63156
this.recordButtonTelemetry(reason || "extensions_panel_showing");
64157
this.ensureButtonShownBeforeAttachingPanel(panel);
65-
PanelMultiView.openPopup(panel, this._button, {
158+
- PanelMultiView.openPopup(panel, this._button, {
66159
- position: "bottomright topright",
67-
+ position: gZenUIManager.panelUIPosition(panel, this._button),
160+
+ PanelMultiView.openPopup(panel, button, {
161+
+ position: gZenUIManager.panelUIPosition(panel, button),
68162
triggerEvent: aEvent,
69163
});
70164
}
71-
@@ -2941,18 +2938,20 @@ var gUnifiedExtensions = {
165+
@@ -2941,18 +2943,20 @@ var gUnifiedExtensions = {
72166
this._maybeMoveWidgetNodeBack(widgetId);
73167
}
74168

src/browser/base/content/navigator-toolbox-js.patch

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/browser/base/content/navigator-toolbox.js b/browser/base/content/navigator-toolbox.js
2-
index 7b776b15d52367a008ce6bf53dcfcbbe007b7453..d9a3404905b73db7c8f202ab166d5f3c625351f6 100644
2+
index 7b776b15d52367a008ce6bf53dcfcbbe007b7453..da23f716c753f5a43f17bb5ed7a3d335891168c2 100644
33
--- a/browser/base/content/navigator-toolbox.js
44
+++ b/browser/base/content/navigator-toolbox.js
55
@@ -6,7 +6,7 @@
@@ -27,21 +27,28 @@ index 7b776b15d52367a008ce6bf53dcfcbbe007b7453..d9a3404905b73db7c8f202ab166d5f3c
2727
gBrowser.handleNewTabMiddleClick(element, event);
2828
break;
2929

30-
@@ -315,7 +317,7 @@ document.addEventListener(
31-
#pageActionButton,
30+
@@ -316,6 +318,7 @@ document.addEventListener(
3231
#downloads-button,
3332
#fxa-toolbar-menu-button,
34-
- #unified-extensions-button,
33+
#unified-extensions-button,
3534
+ #zen-site-data-icon-button,
3635
#library-button
3736
`);
3837
if (!element) {
39-
@@ -394,7 +396,7 @@ document.addEventListener(
40-
gSync.toggleAccountPanel(element, event);
38+
@@ -398,6 +401,16 @@ document.addEventListener(
39+
gUnifiedExtensions.togglePanel(event);
4140
break;
4241

43-
- case "unified-extensions-button":
4442
+ case "zen-site-data-icon-button":
45-
gUnifiedExtensions.togglePanel(event);
43+
+ gUnifiedExtensions.togglePanel(
44+
+ event,
45+
+ null,
46+
+ window.gZenSiteDataPanel.unifiedPanel,
47+
+ window.gZenSiteDataPanel.unifiedPanelView,
48+
+ window.gZenSiteDataPanel.anchor,
49+
+ );
50+
+ break;
51+
+
52+
case "library-button":
53+
PanelUI.showSubView("appMenu-libraryView", element, event);
4654
break;
47-

src/browser/base/content/zen-panels/site-data.inc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
command="Browser:AddBookmarkAs"
3333
flex="1" />
3434
</hbox>
35-
<vbox class="zen-site-data-section">
35+
<vbox id="zen-site-data-section-addons" class="zen-site-data-section">
3636
<hbox class="zen-site-data-section-header">
3737
<label data-l10n-id="unified-extensions-header-title" flex="1" />
3838
<label data-l10n-id="zen-generic-manage" id="zen-site-data-manage-addons" />
@@ -72,7 +72,7 @@
7272
# for this specific button / id
7373
<toolbarbutton id="unified-extensions-manage-extensions"
7474
class="subviewbutton panel-subview-footer-button unified-extensions-manage-extensions"
75-
data-l10n-id="unified-extensions-manage-extensions"
75+
data-l10n-id="unified-extensions-manage-extensions"
7676
hidden="true" />
7777
</vbox>
7878
<vbox class="zen-site-data-section">
@@ -85,7 +85,7 @@
8585
</vbox>
8686
</vbox>
8787
<hbox id="zen-site-data-footer">
88-
<toolbarbutton id="zen-site-data-security-info"
88+
<toolbarbutton id="zen-site-data-security-info"
8989
class="subviewbutton zen-interactive-button" />
9090
<toolbarbutton id="zen-site-data-actions"
9191
class="subviewbutton zen-interactive-button"

src/zen/common/modules/ZenUIManager.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,9 @@ window.gZenUIManager = {
669669
}
670670
if (
671671
(gZenVerticalTabsManager._hasSetSingleToolbar && gZenVerticalTabsManager._prefsRightSide) ||
672-
(panel?.id === 'zen-unified-site-data-panel' && !gZenVerticalTabsManager._hasSetSingleToolbar)
672+
(panel?.id === 'zen-unified-site-data-panel' &&
673+
!gZenVerticalTabsManager._hasSetSingleToolbar) ||
674+
(panel?.id === 'unified-extensions-panel' && gZenVerticalTabsManager._hasSetSingleToolbar)
673675
) {
674676
block = 'bottomright';
675677
inline = 'topright';

src/zen/common/styles/zen-single-components.css

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -495,20 +495,22 @@ body > #confetti {
495495
}
496496

497497
@media -moz-pref('zen.theme.hide-unified-extensions-button') {
498-
#unified-extensions-button {
498+
#unified-extensions-button:not([showing]) {
499499
display: none !important;
500500
}
501501
}
502502

503-
#unified-extensions-button:not([showing]) {
504-
display: none !important;
503+
@media not -moz-pref('zen.theme.hide-unified-extensions-button') {
504+
#zen-site-data-section-addons {
505+
display: none;
506+
}
505507
}
506508

507509
#zen-site-data-header {
508510
gap: 8px;
509511
align-items: center;
510512
padding: 10px 9px;
511-
padding-bottom: 0;
513+
padding-bottom: 8px;
512514

513515
:root[zen-single-toolbar='true']:not([zen-right-side='true']) & {
514516
flex-direction: row-reverse;
@@ -520,7 +522,7 @@ body > #confetti {
520522
-moz-context-properties: fill;
521523
fill: currentColor;
522524
color: light-dark(rgba(0, 0, 0, 0.8), rgba(255, 255, 255, 0.8));
523-
max-width: 48px;
525+
width: 48px;
524526
height: 32px;
525527
position: relative;
526528

src/zen/urlbar/ZenSiteDataPanel.sys.mjs

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44

55
import { AppConstants } from 'resource://gre/modules/AppConstants.sys.mjs';
66

7+
const ADDONS_BUTTONS_HIDDEN = Services.prefs.getBoolPref(
8+
'zen.theme.hide-unified-extensions-button',
9+
true
10+
);
11+
712
const lazy = {};
813

914
ChromeUtils.defineESModuleGetters(lazy, {
@@ -21,7 +26,19 @@ export class nsZenSiteDataPanel {
2126
this.window = window;
2227
this.document = window.document;
2328

24-
this.panel = this.document.getElementById('zen-unified-site-data-panel');
29+
this.unifiedPanel = this.#initUnifiedPanel();
30+
this.unifiedPanelView = 'unified-extensions-view';
31+
this.extensionsPanelView = 'original-unified-extensions-view';
32+
33+
if (ADDONS_BUTTONS_HIDDEN) {
34+
this.window.gUnifiedExtensions._panel = this.unifiedPanel;
35+
36+
// Remove the old permissions dialog
37+
this.document.getElementById('unified-extensions-panel-template').remove();
38+
} else {
39+
this.extensionsPanel = this.#initExtensionsPanel();
40+
}
41+
2542
this.#init();
2643
}
2744

@@ -34,22 +51,23 @@ export class nsZenSiteDataPanel {
3451
`);
3552
this.anchor = button.querySelector('#zen-site-data-icon-button');
3653
this.document.getElementById('identity-icon-box').before(button);
37-
this.window.gUnifiedExtensions._button = this.anchor;
54+
55+
this.extensionsPanelButton = this.document.getElementById('unified-extensions-button');
56+
this.window.gUnifiedExtensions._button = ADDONS_BUTTONS_HIDDEN
57+
? this.anchor
58+
: this.extensionsPanelButton;
3859

3960
this.document
4061
.getElementById('nav-bar')
4162
.setAttribute('addon-webext-overflowbutton', 'zen-site-data-icon-button');
4263

43-
// Remove the old permissions dialog
44-
this.document.getElementById('unified-extensions-panel-template').remove();
45-
4664
this.#initCopyUrlButton();
4765
this.#initEventListeners();
4866
this.#maybeShowFeatureCallout();
4967
}
5068

5169
#initEventListeners() {
52-
this.panel.addEventListener('popupshowing', this);
70+
this.unifiedPanel.addEventListener('popupshowing', this);
5371
this.document.getElementById('zen-site-data-manage-addons').addEventListener('click', this);
5472
this.document.getElementById('zen-site-data-settings-more').addEventListener('click', this);
5573
this.anchor.addEventListener('click', this);
@@ -124,6 +142,24 @@ export class nsZenSiteDataPanel {
124142
}
125143
}
126144

145+
#initExtensionsPanel() {
146+
const panel = this.window.gUnifiedExtensions.panel;
147+
148+
const extensionsView = panel?.querySelector('#unified-extensions-view');
149+
extensionsView.setAttribute('id', this.extensionsPanelView);
150+
151+
const panelMultiView = panel?.querySelector('panelmultiview');
152+
panelMultiView.setAttribute('mainViewId', this.extensionsPanelView);
153+
154+
return panel;
155+
}
156+
157+
#initUnifiedPanel() {
158+
const panel = this.document.getElementById('zen-unified-site-data-panel');
159+
this.window.gUnifiedExtensions.initializePanel(panel);
160+
return panel;
161+
}
162+
127163
#preparePanel() {
128164
this.#setSitePermissions();
129165
this.#setSiteSecurityInfo();
@@ -498,7 +534,7 @@ export class nsZenSiteDataPanel {
498534
this.window.gZenCommonActions.copyCurrentURLToClipboard();
499535
}
500536
if (AppConstants.platform !== 'macosx') {
501-
this.panel.hidePopup();
537+
this.unifiedPanel.hidePopup();
502538
}
503539
}
504540
}
@@ -556,7 +592,13 @@ export class nsZenSiteDataPanel {
556592
break;
557593
}
558594
case 'zen-site-data-icon-button': {
559-
this.window.gUnifiedExtensions.togglePanel(event);
595+
this.window.gUnifiedExtensions.togglePanel(
596+
event,
597+
null,
598+
this.unifiedPanel,
599+
this.unifiedPanelView,
600+
this.anchor
601+
);
560602
break;
561603
}
562604
default: {

0 commit comments

Comments
 (0)