toolkit/mozapps/preferences/removemp.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
michael@0 2
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 var gRemovePasswordDialog = {
michael@0 8 _token : null,
michael@0 9 _bundle : null,
michael@0 10 _prompt : null,
michael@0 11 _okButton : null,
michael@0 12 _password : null,
michael@0 13 init: function ()
michael@0 14 {
michael@0 15 this._prompt = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
michael@0 16 .getService(Components.interfaces.nsIPromptService);
michael@0 17 this._bundle = document.getElementById("bundlePreferences");
michael@0 18
michael@0 19 this._okButton = document.documentElement.getButton("accept");
michael@0 20 this._okButton.label = this._bundle.getString("pw_remove_button");
michael@0 21
michael@0 22 this._password = document.getElementById("password");
michael@0 23
michael@0 24 var pk11db = Components.classes["@mozilla.org/security/pk11tokendb;1"]
michael@0 25 .getService(Components.interfaces.nsIPK11TokenDB);
michael@0 26 this._token = pk11db.getInternalKeyToken();
michael@0 27
michael@0 28 // Initialize the enabled state of the Remove button by checking the
michael@0 29 // initial value of the password ("" should be incorrect).
michael@0 30 this.validateInput();
michael@0 31 },
michael@0 32
michael@0 33 validateInput: function ()
michael@0 34 {
michael@0 35 this._okButton.disabled = !this._token.checkPassword(this._password.value);
michael@0 36 },
michael@0 37
michael@0 38 removePassword: function ()
michael@0 39 {
michael@0 40 if (this._token.checkPassword(this._password.value)) {
michael@0 41 this._token.changePassword(this._password.value, "");
michael@0 42 this._prompt.alert(window,
michael@0 43 this._bundle.getString("pw_change_success_title"),
michael@0 44 this._bundle.getString("pw_erased_ok")
michael@0 45 + " " + this._bundle.getString("pw_empty_warning"));
michael@0 46 }
michael@0 47 else {
michael@0 48 this._password.value = "";
michael@0 49 this._password.focus();
michael@0 50 this._prompt.alert(window,
michael@0 51 this._bundle.getString("pw_change_failed_title"),
michael@0 52 this._bundle.getString("incorrect_pw"));
michael@0 53 }
michael@0 54 },
michael@0 55 };
michael@0 56

mercurial