home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / firefox-3.0.14 / chrome / browser.jar / content / browser / preferences / security.js < prev    next >
Encoding:
JavaScript  |  2008-02-09  |  7.1 KB  |  228 lines

  1. //@line 38 "/build/buildd/firefox-3.0-3.0.14+build2+nobinonly/build-tree/mozilla/browser/components/preferences/security.js"
  2.  
  3. var gSecurityPane = {
  4.   _pane: null,
  5.  
  6.   /**
  7.    * Initializes master password UI.
  8.    */
  9.   init: function ()
  10.   {
  11.     this._pane = document.getElementById("paneSecurity");
  12.     this._initMasterPasswordUI();
  13.   },
  14.  
  15.   // ADD-ONS
  16.  
  17.   /*
  18.    * Preferences:
  19.    *
  20.    * xpinstall.whitelist.required
  21.    * - true if a site must be added to a site whitelist before extensions
  22.    *   provided by the site may be installed from it, false if the extension
  23.    *   may be directly installed after a confirmation dialog
  24.    */
  25.  
  26.   /**
  27.    * Enables/disables the add-ons Exceptions button depending on whether
  28.    * or not add-on installation warnings are displayed.
  29.    */
  30.   readWarnAddonInstall: function ()
  31.   {
  32.     var warn = document.getElementById("xpinstall.whitelist.required");
  33.     var exceptions = document.getElementById("addonExceptions");
  34.  
  35.     exceptions.disabled = !warn.value;
  36.  
  37.     // don't override the preference value
  38.     return undefined;
  39.   },
  40.  
  41.   /**
  42.    * Displays the exceptions lists for add-on installation warnings.
  43.    */
  44.   showAddonExceptions: function ()
  45.   {
  46.     var bundlePrefs = document.getElementById("bundlePreferences");
  47.  
  48.     var params = this._addonParams;
  49.     if (!params.windowTitle || !params.introText) {
  50.       params.windowTitle = bundlePrefs.getString("addons_permissions_title");
  51.       params.introText = bundlePrefs.getString("addonspermissionstext");
  52.     }
  53.  
  54.     document.documentElement.openWindow("Browser:Permissions",
  55.                                         "chrome://browser/content/preferences/permissions.xul",
  56.                                         "", params);
  57.   },
  58.  
  59.   /**
  60.    * Parameters for the add-on install permissions dialog.
  61.    */
  62.   _addonParams:
  63.     {
  64.       blockVisible: false,
  65.       sessionVisible: false,
  66.       allowVisible: true,
  67.       prefilledHost: "",
  68.       permissionType: "install"
  69.     },
  70.  
  71.   // PASSWORDS
  72.  
  73.   /*
  74.    * Preferences:
  75.    *
  76.    * signon.rememberSignons
  77.    * - true if passwords are remembered, false otherwise
  78.    */
  79.  
  80.   /**
  81.    * Enables/disables the Exceptions button used to configure sites where
  82.    * passwords are never saved.
  83.    */
  84.   readSavePasswords: function ()
  85.   {
  86.     var pref = document.getElementById("signon.rememberSignons");
  87.     var excepts = document.getElementById("passwordExceptions");
  88.  
  89.     excepts.disabled = !pref.value;
  90.  
  91.     // don't override pref value in UI
  92.     return undefined;
  93.   },
  94.  
  95.   /**
  96.    * Displays a dialog in which the user can view and modify the list of sites
  97.    * where passwords are never saved.
  98.    */
  99.   showPasswordExceptions: function ()
  100.   {
  101.     document.documentElement.openWindow("Toolkit:PasswordManagerExceptions",
  102.                                         "chrome://passwordmgr/content/passwordManagerExceptions.xul",
  103.                                         "", null);
  104.   },
  105.  
  106.   /**
  107.    * Initializes master password UI: the "use master password" checkbox, selects
  108.    * the master password button to show, and enables/disables it as necessary.
  109.    * The master password is controlled by various bits of NSS functionality, so
  110.    * the UI for it can't be controlled by the normal preference bindings.
  111.    */
  112.   _initMasterPasswordUI: function ()
  113.   {
  114.     var noMP = !this._masterPasswordSet();
  115.  
  116.     var button = document.getElementById("changeMasterPassword");
  117.     button.disabled = noMP;
  118.  
  119.     var checkbox = document.getElementById("useMasterPassword");
  120.     checkbox.checked = !noMP;
  121.   },
  122.  
  123.   /**
  124.    * Returns true if the user has a master password set and false otherwise.
  125.    */
  126.   _masterPasswordSet: function ()
  127.   {
  128.     const Cc = Components.classes, Ci = Components.interfaces;
  129.     var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
  130.                    getService(Ci.nsIPKCS11ModuleDB);
  131.     var slot = secmodDB.findSlotByName("");
  132.     if (slot) {
  133.       var status = slot.status;
  134.       var hasMP = status != Ci.nsIPKCS11Slot.SLOT_UNINITIALIZED &&
  135.                   status != Ci.nsIPKCS11Slot.SLOT_READY;
  136.       return hasMP;
  137.     } else {
  138.       // XXX I have no bloody idea what this means
  139.       return false;
  140.     }
  141.   },
  142.  
  143.   /**
  144.    * Enables/disables the master password button depending on the state of the
  145.    * "use master password" checkbox, and prompts for master password removal if
  146.    * one is set.
  147.    */
  148.   updateMasterPasswordButton: function ()
  149.   {
  150.     var checkbox = document.getElementById("useMasterPassword");
  151.     var button = document.getElementById("changeMasterPassword");
  152.     button.disabled = !checkbox.checked;
  153.  
  154.     // unchecking the checkbox should try to immediately remove the master
  155.     // password, because it's impossible to non-destructively remove the master
  156.     // password used to encrypt all the passwords without providing it (by
  157.     // design), and it would be extremely odd to pop up that dialog when the
  158.     // user closes the prefwindow and saves his settings
  159.     if (!checkbox.checked)
  160.       this._removeMasterPassword();
  161.     else
  162.       this.changeMasterPassword();
  163.  
  164.     this._initMasterPasswordUI();
  165.   },
  166.  
  167.   /**
  168.    * Displays the "remove master password" dialog to allow the user to remove
  169.    * the current master password.  When the dialog is dismissed, master password
  170.    * UI is automatically updated.
  171.    */
  172.   _removeMasterPassword: function ()
  173.   {
  174.     const Cc = Components.classes, Ci = Components.interfaces;
  175.     var secmodDB = Cc["@mozilla.org/security/pkcs11moduledb;1"].
  176.                    getService(Ci.nsIPKCS11ModuleDB);
  177.     if (secmodDB.isFIPSEnabled) {
  178.       var promptService = Cc["@mozilla.org/embedcomp/prompt-service;1"].
  179.                           getService(Ci.nsIPromptService);
  180.       var bundle = document.getElementById("bundlePreferences");
  181.       promptService.alert(window,
  182.                           bundle.getString("pw_change_failed_title"),
  183.                           bundle.getString("pw_change2empty_in_fips_mode"));
  184.     }
  185.     else {
  186.       document.documentElement.openSubDialog("chrome://mozapps/content/preferences/removemp.xul",
  187.                                              "", null);
  188.     }
  189.     this._initMasterPasswordUI();
  190.   },
  191.  
  192.   /**
  193.    * Displays a dialog in which the master password may be changed.
  194.    */
  195.   changeMasterPassword: function ()
  196.   {
  197.     document.documentElement.openSubDialog("chrome://mozapps/content/preferences/changemp.xul",
  198.                                            "", null);
  199.     this._initMasterPasswordUI();
  200.   },
  201.  
  202.   /**
  203.    * Shows the sites where the user has saved passwords and the associated login
  204.    * information.
  205.    */
  206.   showPasswords: function ()
  207.   {
  208.     document.documentElement.openWindow("Toolkit:PasswordManager",
  209.                                         "chrome://passwordmgr/content/passwordManager.xul",
  210.                                         "", null);
  211.   },
  212.  
  213.  
  214.   // WARNING MESSAGES
  215.  
  216.   /**
  217.    * Displays the security warnings dialog which allows changing the
  218.    * "submitting unencrypted information", "moving from secure to unsecure",
  219.    * etc. dialogs that every user immediately disables when he sees them.
  220.    */
  221.   showWarningMessageSettings: function ()
  222.   {
  223.     document.documentElement.openSubDialog("chrome://browser/content/preferences/securityWarnings.xul",
  224.                                            "", null);
  225.   }
  226.  
  227. };
  228.