toolkit/mozapps/preferences/removemp.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial