Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clairehurst
Tor Browser
Commits
e4cc418c
Verified
Commit
e4cc418c
authored
1 year ago
by
henry
Committed by
Pier Angelo Vendrame
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Bug 41736: Customize toolbar for base-browser.
parent
cbf66655
Branches
main
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
browser/components/customizableui/CustomizableUI.jsm
+121
-3
121 additions, 3 deletions
browser/components/customizableui/CustomizableUI.jsm
browser/components/extensions/parent/ext-browserAction.js
+9
-1
9 additions, 1 deletion
browser/components/extensions/parent/ext-browserAction.js
with
130 additions
and
4 deletions
browser/components/customizableui/CustomizableUI.jsm
+
121
−
3
View file @
e4cc418c
...
@@ -65,6 +65,11 @@ const kSubviewEvents = ["ViewShowing", "ViewHiding"];
...
@@ -65,6 +65,11 @@ const kSubviewEvents = ["ViewShowing", "ViewHiding"];
*/
*/
var kVersion = 17;
var kVersion = 17;
/**
* The current version for base browser.
*/
var kVersionBaseBrowser = 1;
/**
/**
* Buttons removed from built-ins by version they were removed. kVersion must be
* Buttons removed from built-ins by version they were removed. kVersion must be
* bumped any time a new id is added to this. Use the button id as key, and
* bumped any time a new id is added to this. Use the button id as key, and
...
@@ -218,6 +223,7 @@ var CustomizableUIInternal = {
...
@@ -218,6 +223,7 @@ var CustomizableUIInternal = {
this._updateForNewVersion();
this._updateForNewVersion();
this._updateForNewProtonVersion();
this._updateForNewProtonVersion();
this._markObsoleteBuiltinButtonsSeen();
this._markObsoleteBuiltinButtonsSeen();
this._updateForBaseBrowser();
this.registerArea(
this.registerArea(
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
CustomizableUI.AREA_FIXED_OVERFLOW_PANEL,
...
@@ -236,10 +242,15 @@ var CustomizableUIInternal = {
...
@@ -236,10 +242,15 @@ var CustomizableUIInternal = {
Services.policies.isAllowed("removeHomeButtonByDefault")
Services.policies.isAllowed("removeHomeButtonByDefault")
? null
? null
: "home-button",
: "home-button",
"spring",
// Don't want springs either side of the urlbar. tor-browser#41736
"urlbar-container",
"urlbar-container",
"spring",
// save-to-pocket-button is entirely disabled. See tor-browser#18886 and
"save-to-pocket-button",
// tor-browser#31602.
// Base-browser additions tor-browser#41736. If you want to add to, remove
// from, or rearrange this list, then bump the kVersionBaseBrowser and
// update existing saved states in _updateForBaseBrowser.
"security-level-button",
"new-identity-button",
"downloads-button",
"downloads-button",
AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
AppConstants.MOZ_DEV_EDITION ? "developer-button" : null,
"fxa-toolbar-menu-button",
"fxa-toolbar-menu-button",
...
@@ -255,6 +266,10 @@ var CustomizableUIInternal = {
...
@@ -255,6 +266,10 @@ var CustomizableUIInternal = {
},
},
true
true
);
);
// navbarPlacements does not match the initial default XHTML layout.
// Therefore we always need to rebuild the navbar area when
// registerToolbarNode is called. tor-browser#41736
gDirtyAreaCache.add(CustomizableUI.AREA_NAVBAR);
if (AppConstants.MENUBAR_CAN_AUTOHIDE) {
if (AppConstants.MENUBAR_CAN_AUTOHIDE) {
this.registerArea(
this.registerArea(
...
@@ -687,6 +702,104 @@ var CustomizableUIInternal = {
...
@@ -687,6 +702,104 @@ var CustomizableUIInternal = {
}
}
},
},
_updateForBaseBrowser() {
if (!gSavedState) {
// Use the defaults.
return;
}
const currentVersion = gSavedState.currentVersionBaseBrowser;
if (currentVersion < 1) {
// NOTE: In base-browser/tor-browser version 12.5a5, and earlier, the
// toolbar was configured by setting the full JSON string for the default
// "browser.uiCustomization.state" preference value. The disadvantage is
// that we could not update this value in a way that existing users (who
// would have non-default preference values) would also get the desired
// change (e.g. for adding or removing a button).
//
// With tor-browser#41736 we want to switch to changing the toolbar
// dynamically like firefox. Therefore, this first version transfer simply
// gets the toolbar into the same state we wanted before, away from the
// default firefox state.
//
// If an existing user state aligned with the previous default
// "browser.uiCustomization.state" then this shouldn't visibly change
// anything.
// If a user explicitly customized the toolbar to go back to the firefox
// default, then this may undo those changes.
const navbarPlacements =
gSavedState.placements[CustomizableUI.AREA_NAVBAR];
if (navbarPlacements) {
const getBeforeAfterUrlbar = () => {
// NOTE: The urlbar is non-removable from the navbar, so should have
// an index.
const index = navbarPlacements.indexOf("urlbar-container");
let after = index + 1;
if (
after < navbarPlacements.length &&
navbarPlacements[after] === "search-container"
) {
// Skip past the search-container.
after++;
}
return { before: index - 1, after };
};
// Remove the urlbar springs either side of the urlbar.
const { before, after } = getBeforeAfterUrlbar();
if (
after < navbarPlacements.length &&
this.matchingSpecials(navbarPlacements[after], "spring")
) {
// Remove the spring after.
navbarPlacements.splice(after, 1);
// NOTE: The `before` index does not change.
}
if (
before >= 0 &&
this.matchingSpecials(navbarPlacements[before], "spring")
) {
// Remove the spring before.
navbarPlacements.splice(before, 1);
}
// Make sure the security-level-button and new-identity-button appears
// in the toolbar.
for (const id of ["new-identity-button", "security-level-button"]) {
let alreadyAdded = false;
for (const placements of Object.values(gSavedState.placements)) {
if (placements.includes(id)) {
alreadyAdded = true;
break;
}
}
if (alreadyAdded) {
continue;
}
// Add to the nav-bar, after the urlbar-container.
// NOTE: We have already removed the spring after the urlbar.
navbarPlacements.splice(getBeforeAfterUrlbar().after, 0, id);
}
}
// Remove save-to-pocket-button. See tor-browser#18886 and
// tor-browser#31602.
for (const placements of Object.values(gSavedState.placements)) {
let buttonIndex = placements.indexOf("save-to-pocket-button");
if (buttonIndex != -1) {
placements.splice(buttonIndex, 1);
}
}
// Remove unused fields that used to be part of
// "browser.uiCustomization.state".
delete gSavedState.placements["PanelUI-contents"];
delete gSavedState.placements["addon-bar"];
}
},
_placeNewDefaultWidgetsInArea(aArea) {
_placeNewDefaultWidgetsInArea(aArea) {
let futurePlacedWidgets = gFuturePlacements.get(aArea);
let futurePlacedWidgets = gFuturePlacements.get(aArea);
let savedPlacements =
let savedPlacements =
...
@@ -2501,6 +2614,10 @@ var CustomizableUIInternal = {
...
@@ -2501,6 +2614,10 @@ var CustomizableUIInternal = {
gSavedState.currentVersion = 0;
gSavedState.currentVersion = 0;
}
}
if (!("currentVersionBaseBrowser" in gSavedState)) {
gSavedState.currentVersionBaseBrowser = 0;
}
gSeenWidgets = new Set(gSavedState.seen || []);
gSeenWidgets = new Set(gSavedState.seen || []);
gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
gDirtyAreaCache = new Set(gSavedState.dirtyAreaCache || []);
gNewElementCount = gSavedState.newElementCount || 0;
gNewElementCount = gSavedState.newElementCount || 0;
...
@@ -2579,6 +2696,7 @@ var CustomizableUIInternal = {
...
@@ -2579,6 +2696,7 @@ var CustomizableUIInternal = {
seen: gSeenWidgets,
seen: gSeenWidgets,
dirtyAreaCache: gDirtyAreaCache,
dirtyAreaCache: gDirtyAreaCache,
currentVersion: kVersion,
currentVersion: kVersion,
currentVersionBaseBrowser: kVersionBaseBrowser,
newElementCount: gNewElementCount,
newElementCount: gNewElementCount,
};
};
...
...
This diff is collapsed.
Click to expand it.
browser/components/extensions/parent/ext-browserAction.js
+
9
−
1
View file @
e4cc418c
...
@@ -193,6 +193,10 @@ this.browserAction = class extends ExtensionAPIPersistent {
...
@@ -193,6 +193,10 @@ this.browserAction = class extends ExtensionAPIPersistent {
}
}
build
()
{
build
()
{
// The extension ID for NoScript (WebExtension)
const
isNoScript
=
this
.
extension
.
id
===
"
{73a6fe31-595d-460b-a920-fcc0f8843232}
"
;
let
widget
=
CustomizableUI
.
createWidget
({
let
widget
=
CustomizableUI
.
createWidget
({
id
:
this
.
id
,
id
:
this
.
id
,
viewId
:
this
.
viewId
,
viewId
:
this
.
viewId
,
...
@@ -200,7 +204,11 @@ this.browserAction = class extends ExtensionAPIPersistent {
...
@@ -200,7 +204,11 @@ this.browserAction = class extends ExtensionAPIPersistent {
removable
:
true
,
removable
:
true
,
label
:
this
.
action
.
getProperty
(
null
,
"
title
"
),
label
:
this
.
action
.
getProperty
(
null
,
"
title
"
),
tooltiptext
:
this
.
action
.
getProperty
(
null
,
"
title
"
),
tooltiptext
:
this
.
action
.
getProperty
(
null
,
"
title
"
),
defaultArea
:
browserAreas
[
this
.
action
.
getDefaultArea
()],
// Do not want to add the NoScript extension to the toolbar by default.
// tor-browser#41736
defaultArea
:
isNoScript
?
null
:
browserAreas
[
this
.
action
.
getDefaultArea
()],
showInPrivateBrowsing
:
this
.
extension
.
privateBrowsingAllowed
,
showInPrivateBrowsing
:
this
.
extension
.
privateBrowsingAllowed
,
// Don't attempt to load properties from the built-in widget string
// Don't attempt to load properties from the built-in widget string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment