summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/preferences/removemp.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/mozapps/preferences/removemp.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/mozapps/preferences/removemp.js')
-rw-r--r--toolkit/mozapps/preferences/removemp.js56
1 files changed, 56 insertions, 0 deletions
diff --git a/toolkit/mozapps/preferences/removemp.js b/toolkit/mozapps/preferences/removemp.js
new file mode 100644
index 000000000..1f6356eac
--- /dev/null
+++ b/toolkit/mozapps/preferences/removemp.js
@@ -0,0 +1,56 @@
+// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
+
+/* 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/. */
+
+var gRemovePasswordDialog = {
+ _token : null,
+ _bundle : null,
+ _prompt : null,
+ _okButton : null,
+ _password : null,
+ init: function ()
+ {
+ this._prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
+ .getService(Components.interfaces.nsIPromptService);
+ this._bundle = document.getElementById("bundlePreferences");
+
+ this._okButton = document.documentElement.getButton("accept");
+ this._okButton.label = this._bundle.getString("pw_remove_button");
+
+ this._password = document.getElementById("password");
+
+ var pk11db = Components.classes["@mozilla.org/security/pk11tokendb;1"]
+ .getService(Components.interfaces.nsIPK11TokenDB);
+ this._token = pk11db.getInternalKeyToken();
+
+ // Initialize the enabled state of the Remove button by checking the
+ // initial value of the password ("" should be incorrect).
+ this.validateInput();
+ },
+
+ validateInput: function ()
+ {
+ this._okButton.disabled = !this._token.checkPassword(this._password.value);
+ },
+
+ removePassword: function ()
+ {
+ if (this._token.checkPassword(this._password.value)) {
+ this._token.changePassword(this._password.value, "");
+ this._prompt.alert(window,
+ this._bundle.getString("pw_change_success_title"),
+ this._bundle.getString("pw_erased_ok")
+ + " " + this._bundle.getString("pw_empty_warning"));
+ }
+ else {
+ this._password.value = "";
+ this._password.focus();
+ this._prompt.alert(window,
+ this._bundle.getString("pw_change_failed_title"),
+ this._bundle.getString("incorrect_pw"));
+ }
+ },
+};
+