[Mypal] Add pref to ask for master password on application start.

master
Fedor 2020-10-02 10:35:03 +03:00
parent 48390d973d
commit 63b10ca147
2 changed files with 25 additions and 0 deletions

View File

@ -947,6 +947,9 @@ pref("browser.privatebrowsing.autostart", false);
// bookmarking dialog
pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
// Prompt for master password on application startup?
pref("signon.startup.prompt", false);
// Whether to use a panel that looks like an OS X sheet for customization
#ifdef XP_MACOSX
pref("toolbar.customization.usesheet", true);
@ -1060,6 +1063,7 @@ pref("services.sync.prefs.sync.security.default_personal_cert", true);
pref("services.sync.prefs.sync.security.tls.version.min", true);
pref("services.sync.prefs.sync.security.tls.version.max", true);
pref("services.sync.prefs.sync.signon.rememberSignons", true);
pref("services.sync.prefs.sync.signon.startup.prompt", true);
pref("services.sync.prefs.sync.spellchecker.dictionary", true);
pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
#endif

View File

@ -289,6 +289,7 @@ BrowserGlue.prototype = {
break;
case "profile-after-change":
this._onProfileAfterChange();
this._promptForMasterPassword();
break;
case "browser-search-engine-modified":
if (data != "engine-default" && data != "engine-current") {
@ -411,6 +412,26 @@ BrowserGlue.prototype = {
_onProfileAfterChange: function() {
this._copyDefaultProfileFiles();
},
_promptForMasterPassword: function() {
if (!Services.prefs.getBoolPref("signon.startup.prompt", false))
return;
// Try to avoid the multiple master password prompts on startup scenario
// by prompting for the master password upfront.
let token = Components.classes["@mozilla.org/security/pk11tokendb;1"]
.getService(Components.interfaces.nsIPK11TokenDB)
.getInternalKeyToken();
// Only log in to the internal token if it is already initialized,
// otherwise we get a "Change Master Password" dialog.
try {
if (!token.needsUserInit)
token.login(false);
} catch (ex) {
// If user cancels an exception is expected.
}
},
_onAppDefaults: function() {
// apply distribution customizations (prefs)