mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-22 17:55:50 +00:00
Bug 1595915 - Move the password generation context menu item to the top-level. r=sfoster,fluent-reviewers,flod
Differential Revision: https://phabricator.services.mozilla.com/D60640 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
5b0fdb451b
commit
cb2556b19d
@ -233,6 +233,11 @@
|
||||
data-l10n-id="main-context-menu-view-background-image"
|
||||
oncommand="gContextMenu.viewBGImage(event);"
|
||||
onclick="checkForMiddleClick(this, event);"/>
|
||||
<menuitem id="fill-login-generated-password"
|
||||
data-l10n-id="main-context-menu-generate-new-password"
|
||||
hidden="true"
|
||||
oncommand="gContextMenu.useGeneratedPassword();"/>
|
||||
<menuseparator id="generated-password-separator"/>
|
||||
<menuitem id="context-undo"
|
||||
data-l10n-id="text-action-undo"
|
||||
command="cmd_undo"/>
|
||||
@ -365,12 +370,6 @@
|
||||
label="&noLoginSuggestions.label;"
|
||||
disabled="true"
|
||||
hidden="true"/>
|
||||
<menuseparator id="generated-password-separator"/>
|
||||
<menuitem id="fill-login-generated-password"
|
||||
label="&useGeneratedPassword.label;"
|
||||
accesskey="&useGeneratedPassword.accesskey;"
|
||||
hidden="true"
|
||||
oncommand="gContextMenu.useGeneratedPassword();"/>
|
||||
<menuseparator id="saved-logins-separator"/>
|
||||
<menuitem id="fill-login-saved-passwords"
|
||||
label="&viewSavedLogins.label;"
|
||||
|
@ -909,15 +909,23 @@ class nsContextMenu {
|
||||
}
|
||||
|
||||
initPasswordManagerItems() {
|
||||
let showFill = false;
|
||||
let showGenerate = false;
|
||||
try {
|
||||
let loginFillInfo = this.contentData && this.contentData.loginFillInfo;
|
||||
let documentURI = this.contentData.documentURIObject;
|
||||
|
||||
// If we could not find a password field we
|
||||
// don't want to show the form fill option.
|
||||
let showFill =
|
||||
loginFillInfo &&
|
||||
loginFillInfo.passwordField.found &&
|
||||
!documentURI.schemeIs("about");
|
||||
if (
|
||||
!loginFillInfo ||
|
||||
!loginFillInfo.passwordField.found ||
|
||||
documentURI.schemeIs("about")
|
||||
) {
|
||||
// Both generation and fill will default to disabled.
|
||||
return;
|
||||
}
|
||||
showFill = true;
|
||||
|
||||
// Disable the fill option if the user hasn't unlocked with their master password
|
||||
// or if the password field or target field are disabled.
|
||||
@ -929,8 +937,6 @@ class nsContextMenu {
|
||||
loginFillInfo.passwordField.disabled ||
|
||||
(!this.onPassword && loginFillInfo.usernameField.disabled);
|
||||
|
||||
this.showItem("fill-login-separator", showFill);
|
||||
this.showItem("fill-login", showFill);
|
||||
this.setItemAttr("fill-login", "disabled", disableFill);
|
||||
|
||||
// Set the correct label for the fill menu
|
||||
@ -949,26 +955,27 @@ class nsContextMenu {
|
||||
);
|
||||
}
|
||||
|
||||
if (!showFill || disableFill) {
|
||||
let formOrigin = LoginHelper.getLoginOrigin(documentURI.spec);
|
||||
let isGeneratedPasswordEnabled =
|
||||
LoginHelper.generationAvailable && LoginHelper.generationEnabled;
|
||||
showGenerate =
|
||||
this.onPassword &&
|
||||
isGeneratedPasswordEnabled &&
|
||||
Services.logins.getLoginSavingEnabled(formOrigin);
|
||||
|
||||
if (disableFill) {
|
||||
// No need to update the submenu if the fill item is disabled.
|
||||
return;
|
||||
}
|
||||
|
||||
let formOrigin = LoginHelper.getLoginOrigin(documentURI.spec);
|
||||
// Update sub-menu items.
|
||||
let fragment = nsContextMenu.LoginManagerContextMenu.addLoginsToMenu(
|
||||
this.targetIdentifier,
|
||||
this.browser,
|
||||
formOrigin
|
||||
);
|
||||
let isGeneratedPasswordEnabled =
|
||||
LoginHelper.generationAvailable && LoginHelper.generationEnabled;
|
||||
let canFillGeneratedPassword =
|
||||
this.onPassword &&
|
||||
isGeneratedPasswordEnabled &&
|
||||
Services.logins.getLoginSavingEnabled(formOrigin);
|
||||
|
||||
this.showItem("fill-login-no-logins", !fragment);
|
||||
this.showItem("fill-login-generated-password", canFillGeneratedPassword);
|
||||
this.showItem("generated-password-separator", canFillGeneratedPassword);
|
||||
|
||||
if (!fragment) {
|
||||
return;
|
||||
@ -976,6 +983,12 @@ class nsContextMenu {
|
||||
let popup = document.getElementById("fill-login-popup");
|
||||
let insertBeforeElement = document.getElementById("fill-login-no-logins");
|
||||
popup.insertBefore(fragment, insertBeforeElement);
|
||||
} finally {
|
||||
this.showItem("fill-login-separator", showFill);
|
||||
this.showItem("fill-login", showFill);
|
||||
this.showItem("fill-login-generated-password", showGenerate);
|
||||
this.showItem("generated-password-separator", showGenerate);
|
||||
}
|
||||
}
|
||||
|
||||
initSyncItems() {
|
||||
|
@ -285,6 +285,10 @@ main-context-menu-view-background-image =
|
||||
.label = View Background Image
|
||||
.accesskey = w
|
||||
|
||||
main-context-menu-generate-new-password =
|
||||
.label = Use Generated Password…
|
||||
.accesskey = G
|
||||
|
||||
main-context-menu-keyword =
|
||||
.label = Add a Keyword for this Search…
|
||||
.accesskey = K
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
<!ENTITY fillLoginMenu.label "Fill Login">
|
||||
<!ENTITY fillLoginMenu.accesskey "F">
|
||||
<!ENTITY useGeneratedPassword.label "Use a Securely Generated Password…">
|
||||
<!ENTITY useGeneratedPassword.accesskey "S">
|
||||
<!ENTITY fillPasswordMenu.label "Fill Password">
|
||||
<!ENTITY fillPasswordMenu.accesskey "F">
|
||||
<!ENTITY fillUsernameMenu.label "Fill Username">
|
||||
|
Loading…
Reference in New Issue
Block a user