Bug 1491676 - Moves master password dialog strings r=flod,Gijs,zbraniecki

Depends on D8552

Differential Revision: https://phabricator.services.mozilla.com/D8553

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Jack Smith 2018-11-07 18:04:30 +00:00
Родитель 2d9d74604a
Коммит 9e7051f7cd
8 изменённых файлов: 88 добавлений и 55 удалений

Просмотреть файл

@ -0,0 +1,34 @@
# coding=utf8
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
from __future__ import absolute_import
import fluent.syntax.ast as FTL
from fluent.migrate.helpers import transforms_from
from fluent.migrate.helpers import VARIABLE_REFERENCE, TERM_REFERENCE
from fluent.migrate import REPLACE, COPY
def migrate(ctx):
"""Bug 1486937 - Move strings from preferences.properties to Fluent"""
ctx.add_transforms(
"toolkit/toolkit/preferences/preferences.ftl",
"toolkit/toolkit/preferences/preferences.ftl",
transforms_from(
"""
password-not-set =
.value = { COPY(from_path, "password_not_set") }
failed-pw-change = { COPY(from_path, "failed_pw_change") }
incorrect-pw = { COPY(from_path, "incorrect_pw") }
pw-empty-warning = { COPY(from_path, "pw_empty_warning") }
pw-change-ok = { COPY(from_path, "pw_change_ok") } { -pw-empty-warning }
pw-erased-ok = { COPY(from_path, "pw_erased_ok") } { -pw-empty-warning }
pw-not-wanted = { COPY(from_path, "pw_not_wanted") }
pw-change2empty-in-fips-mode = { COPY(from_path, "pw_change2empty_in_fips_mode") }
pw-change-success-title = { COPY(from_path, "pw_change_success_title") }
pw-change-failed-title = { COPY(from_path, "pw_change_failed_title") }
pw-remove-button =
.label = { COPY(from_path, "pw_remove_button") }
""", from_path="toolkit/chrome/mozapps/preferences/preferences.properties"))

Просмотреть файл

@ -1,17 +0,0 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#### Master Password
password_not_set=(not set)
failed_pw_change=Unable to change Master Password.
incorrect_pw=You did not enter the correct current Master Password. Please try again.
pw_change_ok=Master Password successfully changed.
pw_erased_ok=You have deleted your Master Password.
pw_not_wanted=Warning! You have decided not to use a Master Password.
pw_empty_warning=Your stored web and email passwords, form data, and private keys will not be protected.
pw_change2empty_in_fips_mode=You are currently in FIPS mode. FIPS requires a non-empty Master Password.
pw_change_success_title=Password Change Succeeded
pw_change_failed_title=Password Change Failed
pw_remove_button=Remove

Просмотреть файл

@ -0,0 +1,20 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
password-not-set =
.value = (not set)
failed-pw-change = Unable to change Master Password.
incorrect-pw = You did not enter the correct current Master Password. Please try again.
pw-change-ok = Master Password successfully changed.
pw-empty-warning = Your stored web and email passwords, form data, and private keys will not be protected.
pw-erased-ok = You have deleted your Master Password. { pw-empty-warning }
pw-not-wanted = Warning! You have decided not to use a Master Password. { pw-empty-warning }
pw-change2empty-in-fips-mode = You are currently in FIPS mode. FIPS requires a non-empty Master Password.
pw-change-success-title = Password Change Succeeded
pw-change-failed-title = Password Change Failed
pw-remove-button =
.label = Remove

Просмотреть файл

@ -90,7 +90,6 @@
locale/@AB_CD@/mozapps/handling/handling.properties (%chrome/mozapps/handling/handling.properties)
locale/@AB_CD@/mozapps/preferences/changemp.dtd (%chrome/mozapps/preferences/changemp.dtd)
locale/@AB_CD@/mozapps/preferences/removemp.dtd (%chrome/mozapps/preferences/removemp.dtd)
locale/@AB_CD@/mozapps/preferences/preferences.properties (%chrome/mozapps/preferences/preferences.properties)
locale/@AB_CD@/mozapps/profile/createProfileWizard.dtd (%chrome/mozapps/profile/createProfileWizard.dtd)
locale/@AB_CD@/mozapps/profile/profileSelection.properties (%chrome/mozapps/profile/profileSelection.properties)
locale/@AB_CD@/mozapps/profile/profileSelection.dtd (%chrome/mozapps/profile/profileSelection.dtd)

Просмотреть файл

@ -26,8 +26,6 @@ function init() {
function process() {
let bundle = document.getElementById("bundlePreferences");
// If the token is unitialized, don't use the old password box.
// Otherwise, do.
@ -39,7 +37,7 @@ function process() {
let msgBox = document.getElementById("message");
if ((token.needsLogin() && token.needsUserInit) || !token.needsLogin()) {
oldpwbox.setAttribute("hidden", "true");
msgBox.setAttribute("value", bundle.getString("password_not_set"));
document.l10n.setAttributes(msgBox, "password-not-set");
msgBox.setAttribute("hidden", "false");
if (!token.needsLogin()) {
@ -67,13 +65,20 @@ function process() {
checkPasswords();
}
async function createAlert(titleL10nId, messageL10nId) {
const [title, message] = await document.l10n.formatValues([
{id: titleL10nId},
{id: messageL10nId},
]);
Services.prompt.alert(window, title, message);
}
function setPassword() {
var pk11db = Cc[nsPK11TokenDB].getService(nsIPK11TokenDB);
var token = pk11db.getInternalKeyToken();
var oldpwbox = document.getElementById("oldpw");
var initpw = oldpwbox.getAttribute("inited");
var bundle = document.getElementById("bundlePreferences");
var success = false;
@ -98,23 +103,16 @@ function setPassword() {
var secmoddb = Cc[nsPKCS11ModuleDB].getService(nsIPKCS11ModuleDB);
if (secmoddb.isFIPSEnabled) {
// empty passwords are not allowed in FIPS mode
Services.prompt.alert(window,
bundle.getString("pw_change_failed_title"),
bundle.getString("pw_change2empty_in_fips_mode"));
createAlert("pw-change-failed-title", "pw-change2empty-in-fips-mode");
passok = 0;
}
}
if (passok) {
token.changePassword(oldpw, pw1.value);
if (pw1.value == "") {
Services.prompt.alert(window,
bundle.getString("pw_change_success_title"),
bundle.getString("pw_erased_ok")
+ " " + bundle.getString("pw_empty_warning"));
createAlert("pw-change-success-title", "pw-erased-ok");
} else {
Services.prompt.alert(window,
bundle.getString("pw_change_success_title"),
bundle.getString("pw_change_ok"));
createAlert("pw-change-success-title", "pw-change-ok");
}
success = true;
}
@ -122,22 +120,15 @@ function setPassword() {
} else {
oldpwbox.focus();
oldpwbox.setAttribute("value", "");
Services.prompt.alert(window,
bundle.getString("pw_change_failed_title"),
bundle.getString("incorrect_pw"));
createAlert("pw-change-failed-title", "incorrect-pw");
}
} catch (e) {
Services.prompt.alert(window,
bundle.getString("pw_change_failed_title"),
bundle.getString("failed_pw_change"));
createAlert("pw-change-failed-title", "failed-pw-change");
}
} else {
token.initPassword(pw1.value);
if (pw1.value == "") {
Services.prompt.alert(window,
bundle.getString("pw_change_success_title"),
bundle.getString("pw_not_wanted")
+ " " + bundle.getString("pw_empty_warning"));
createAlert("pw-change-success-title", "pw-not-wanted");
}
success = true;
}
@ -145,6 +136,8 @@ function setPassword() {
// Terminate dialog
if (success)
window.close();
return success;
}
function setPasswordStrength() {

Просмотреть файл

@ -22,7 +22,9 @@
<script type="application/javascript" src="chrome://mozapps/content/preferences/changemp.js"/>
<stringbundle id="bundlePreferences" src="chrome://mozapps/locale/preferences/preferences.properties"/>
<linkset>
<link rel="localization" href="toolkit/preferences/preferences.ftl"/>
</linkset>
<description control="pw1">&masterPasswordDescription.label;</description>

Просмотреть файл

@ -8,14 +8,11 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
var gRemovePasswordDialog = {
_token: null,
_bundle: null,
_okButton: null,
_password: null,
init() {
this._bundle = document.getElementById("bundlePreferences");
this._okButton = document.documentElement.getButton("accept");
this._okButton.label = this._bundle.getString("pw_remove_button");
document.l10n.setAttributes(this._okButton, "pw-remove-button");
this._password = document.getElementById("password");
@ -32,19 +29,22 @@ var gRemovePasswordDialog = {
this._okButton.disabled = !this._token.checkPassword(this._password.value);
},
async createAlert(titleL10nId, messageL10nId) {
const [title, message] = await document.l10n.formatValues([
{id: titleL10nId},
{id: messageL10nId},
]);
Services.prompt.alert(window, title, message);
},
removePassword() {
if (this._token.checkPassword(this._password.value)) {
this._token.changePassword(this._password.value, "");
Services.prompt.alert(window,
this._bundle.getString("pw_change_success_title"),
this._bundle.getString("pw_erased_ok")
+ " " + this._bundle.getString("pw_empty_warning"));
this.createAlert("pw-change-success-title", "pw-erased-ok");
} else {
this._password.value = "";
this._password.focus();
Services.prompt.alert(window,
this._bundle.getString("pw_change_failed_title"),
this._bundle.getString("incorrect_pw"));
this.createAlert("pw-change-failed-title", "incorrect-pw");
}
},
};

Просмотреть файл

@ -21,7 +21,9 @@
<script type="application/javascript" src="chrome://mozapps/content/preferences/removemp.js"/>
<stringbundle id="bundlePreferences" src="chrome://mozapps/locale/preferences/preferences.properties"/>
<linkset>
<link rel="localization" href="toolkit/preferences/preferences.ftl"/>
</linkset>
<vbox id="warnings">
<description>&removeWarning1.label;</description>