Skip to content
Snippets Groups Projects
Commit 83797a6f authored by henry's avatar henry Committed by Richard Pospesel
Browse files

fixup! Bug 40926: Implemented the New Identity feature

Bug 42211: Migrate to Fluent.
parent 369e1367
Branches
Tags
No related merge requests found
......@@ -57,6 +57,7 @@
<toolbarseparator/>
<toolbarbutton id="appMenu-new-identity"
class="subviewbutton"
data-l10n-id="appmenuitem-new-identity"
key="new-identity-key"/>
<toolbarseparator/>
<toolbarbutton id="appMenu-bookmarks-button"
......
......@@ -30,7 +30,7 @@
key="key_privatebrowsing" data-l10n-id="menu-file-new-private-window"/>
<menuseparator/>
<menuitem id="menu_newIdentity"
key="new-identity-key"/>
key="new-identity-key" data-l10n-id="menu-new-identity"/>
<menuseparator/>
<menuitem id="menu_openLocation"
hidden="true"
......
......@@ -590,7 +590,8 @@
ondragover="newWindowButtonObserver.onDragOver(event)"
ondragenter="newWindowButtonObserver.onDragOver(event)"/>
<toolbarbutton id="new-identity-button" class="toolbarbutton-1 chromeclass-toolbar-additional"/>
<toolbarbutton id="new-identity-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
data-l10n-id="toolbar-new-identity"/>
<toolbarbutton id="fullscreen-button" class="toolbarbutton-1 chromeclass-toolbar-additional"
observes="View:FullScreen"
......
......@@ -5,20 +5,13 @@
document.addEventListener("dialogaccept", () => {
const retvals = window.arguments[0];
retvals.confirmed = true;
retvals.neverAskAgain = document.querySelector("#neverAskAgain").checked;
retvals.neverAskAgain = document.getElementById("neverAskAgain").checked;
});
document.addEventListener("DOMContentLoaded", () => {
const { NewIdentityStrings } = window.arguments[0];
const dialog = document.querySelector("#newIdentityDialog");
const dialog = document.getElementById("newIdentityDialog");
dialog.querySelector("#infoTitle").textContent =
NewIdentityStrings.new_identity_prompt_title;
dialog.querySelector("#infoBody").textContent =
NewIdentityStrings.new_identity_prompt;
dialog.querySelector("#neverAskAgain").label =
NewIdentityStrings.new_identity_ask_again;
const accept = dialog.getButton("accept");
accept.label = NewIdentityStrings.new_identity_restart;
document.l10n.setAttributes(accept, "new-identity-dialog-confirm");
accept.classList.add("danger-button");
});
......@@ -21,9 +21,8 @@
>
<dialog id="newIdentityDialog" buttons="accept,cancel" defaultButton="accept">
<linkset>
<!-- Without this document.l10n is not initialized, and we need it for the
cancel button. -->
<html:link rel="localization" href="branding/brand.ftl" />
<html:link rel="localization" href="browser/base-browser.ftl" />
</linkset>
<div xmlns="http://www.w3.org/1999/xhtml">
......@@ -33,13 +32,18 @@
<xul:image id="infoIcon" />
</div>
<div id="infoContainer">
<xul:description id="infoTitle" />
<xul:description
id="infoTitle"
data-l10n-id="new-identity-dialog-title"
/>
<xul:description
id="infoBody"
context="contentAreaContextMenu"
noinitialfocus="true"
data-l10n-id="new-identity-dialog-description"
/>
<xul:checkbox
id="neverAskAgain"
data-l10n-id="new-identity-dialog-never-ask-checkbox"
/>
<xul:checkbox id="neverAskAgain" />
</div>
</div>
</div>
......
"use strict";
/* globals CustomizableUI Services gFindBarInitialized gFindBar
OpenBrowserWindow PrivateBrowsingUtils XPCOMUtils
*/
XPCOMUtils.defineLazyGetter(this, "NewIdentityStrings", () => {
const brandBundle = Services.strings.createBundle(
"chrome://branding/locale/brand.properties"
);
const brandShortName = brandBundle.GetStringFromName("brandShortName");
const fallbackBundle = Services.strings.createBundle(
"resource:///chrome/en-US/locale/browser/newIdentity.properties"
);
const strings = {};
const brandedStrings = ["new_identity_prompt", "new_identity_restart"];
for (let { key } of fallbackBundle.getSimpleEnumeration()) {
strings[key] = fallbackBundle.GetStringFromName(key);
}
try {
const bundle = Services.strings.createBundle(
"chrome://browser/locale/newIdentity.properties"
);
for (const key of Object.keys(strings)) {
try {
strings[key] = bundle.GetStringFromName(key);
} catch (e) {}
}
} catch (e) {
console.warn("Could not load localized New Identity strings");
}
for (let key of brandedStrings) {
strings[key] = strings[key].replaceAll("%S", brandShortName);
}
return strings;
});
/* eslint-env mozilla/browser-window */
// Use a lazy getter because NewIdentityButton is declared more than once
// otherwise.
......@@ -471,11 +437,6 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
// malformed URL, bail out
return;
}
const label =
NewIdentityStrings.new_identity_home_notification.replace(
"%S",
displayAddress
);
const callback = () => {
Services.prefs.setStringPref(trustedHomePref, homeURL);
win.BrowserHome();
......@@ -484,12 +445,15 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
notificationBox.appendNotification(
"new-identity-safe-home",
{
label,
label: {
"l10n-id": "new-identity-blocked-home-notification",
"l10n-args": { url: displayAddress },
},
priority: notificationBox.PRIORITY_INFO_MEDIUM,
},
[
{
label: NewIdentityStrings.new_identity_home_load_button,
"l10n-id": "new-identity-blocked-home-ignore-button",
callback,
},
]
......@@ -550,37 +514,20 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
const button =
document.getElementById("new-identity-button") ||
window.gNavToolbox.palette.querySelector("#new-identity-button");
if (button) {
button.setAttribute("tooltiptext", NewIdentityStrings.new_identity);
// Include an equal label, shown in the overflow menu or during
// customization.
button.setAttribute("label", NewIdentityStrings.new_identity);
button.addEventListener("command", () => {
button?.addEventListener("command", () => {
this.onCommand();
});
}
const viewCache = document.getElementById("appMenu-viewCache").content;
const appButton = viewCache.querySelector("#appMenu-new-identity");
if (appButton) {
appButton.setAttribute(
"label",
NewIdentityStrings.new_identity_sentence_case
);
appButton.addEventListener("command", () => {
document
.getElementById("appMenu-viewCache")
.content.querySelector("#appMenu-new-identity")
?.addEventListener("command", () => {
this.onCommand();
});
}
const menu = document.querySelector("#menu_newIdentity");
if (menu) {
menu.setAttribute("label", NewIdentityStrings.new_identity);
menu.setAttribute(
"accesskey",
NewIdentityStrings.new_identity_menu_accesskey
);
menu.addEventListener("command", () => {
document
.getElementById("menu_newIdentity")
?.addEventListener("command", () => {
this.onCommand();
});
}
},
uninit() {},
......@@ -598,7 +545,6 @@ XPCOMUtils.defineLazyGetter(this, "NewIdentityButton", () => {
const shouldConfirm = Services.prefs.getBoolPref(prefConfirm, true);
if (shouldConfirm) {
const params = {
NewIdentityStrings,
confirmed: false,
neverAskAgain: false,
};
......
new_identity = New Identity
# This is the string for the hamburger menu
new_identity_sentence_case = New identity
# %S is the application name. Keep it as a placeholder
new_identity_prompt_title = Reset your identity?
new_identity_prompt = %S will close all windows and tabs. All website sessions will be lost. \nRestart %S now to reset your identity?
new_identity_restart = Restart %S
new_identity_ask_again = Never ask me again
# Shown in the File menu (use Alt to show File, if you do not see)
new_identity_menu_accesskey = I
new_identity_home_notification = Tor Browser blocked your homepage (%S) from loading because it might recognize your previous session.
# %S is replaced with the custom homepage URL's domain if applicable, or some short-hand of it otherwise
new_identity_home_load_button = Load it anyway
......@@ -33,5 +33,4 @@
locale/browser/feeds/subscribe.properties (%chrome/browser/feeds/subscribe.properties)
locale/browser/syncSetup.properties (%chrome/browser/syncSetup.properties)
locale/browser/securityLevel.properties (%chrome/browser/securityLevel.properties)
locale/browser/newIdentity.properties (%chrome/browser/newIdentity.properties)
% locale browser-region @AB_CD@ %locale/browser-region/
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment