зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
5b0fdb451b
Коммит
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,73 +909,86 @@ class nsContextMenu {
|
|||
}
|
||||
|
||||
initPasswordManagerItems() {
|
||||
let loginFillInfo = this.contentData && this.contentData.loginFillInfo;
|
||||
let documentURI = this.contentData.documentURIObject;
|
||||
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 we could not find a password field we
|
||||
// don't want to show the form fill option.
|
||||
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.
|
||||
// XXX: Bug 1529025 to respect signon.rememberSignons
|
||||
let disableFill =
|
||||
!loginFillInfo ||
|
||||
!Services.logins ||
|
||||
!Services.logins.isLoggedIn ||
|
||||
loginFillInfo.passwordField.disabled ||
|
||||
(!this.onPassword && loginFillInfo.usernameField.disabled);
|
||||
// Disable the fill option if the user hasn't unlocked with their master password
|
||||
// or if the password field or target field are disabled.
|
||||
// XXX: Bug 1529025 to respect signon.rememberSignons
|
||||
let disableFill =
|
||||
!loginFillInfo ||
|
||||
!Services.logins ||
|
||||
!Services.logins.isLoggedIn ||
|
||||
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);
|
||||
this.setItemAttr("fill-login", "disabled", disableFill);
|
||||
|
||||
// Set the correct label for the fill menu
|
||||
let fillMenu = document.getElementById("fill-login");
|
||||
if (this.onPassword) {
|
||||
fillMenu.setAttribute("label", fillMenu.getAttribute("label-password"));
|
||||
fillMenu.setAttribute(
|
||||
"accesskey",
|
||||
fillMenu.getAttribute("accesskey-password")
|
||||
);
|
||||
} else {
|
||||
fillMenu.setAttribute("label", fillMenu.getAttribute("label-login"));
|
||||
fillMenu.setAttribute(
|
||||
"accesskey",
|
||||
fillMenu.getAttribute("accesskey-login")
|
||||
// Set the correct label for the fill menu
|
||||
let fillMenu = document.getElementById("fill-login");
|
||||
if (this.onPassword) {
|
||||
fillMenu.setAttribute("label", fillMenu.getAttribute("label-password"));
|
||||
fillMenu.setAttribute(
|
||||
"accesskey",
|
||||
fillMenu.getAttribute("accesskey-password")
|
||||
);
|
||||
} else {
|
||||
fillMenu.setAttribute("label", fillMenu.getAttribute("label-login"));
|
||||
fillMenu.setAttribute(
|
||||
"accesskey",
|
||||
fillMenu.getAttribute("accesskey-login")
|
||||
);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
// Update sub-menu items.
|
||||
let fragment = nsContextMenu.LoginManagerContextMenu.addLoginsToMenu(
|
||||
this.targetIdentifier,
|
||||
this.browser,
|
||||
formOrigin
|
||||
);
|
||||
|
||||
this.showItem("fill-login-no-logins", !fragment);
|
||||
|
||||
if (!fragment) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
if (!showFill || disableFill) {
|
||||
return;
|
||||
}
|
||||
|
||||
let formOrigin = LoginHelper.getLoginOrigin(documentURI.spec);
|
||||
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;
|
||||
}
|
||||
let popup = document.getElementById("fill-login-popup");
|
||||
let insertBeforeElement = document.getElementById("fill-login-no-logins");
|
||||
popup.insertBefore(fragment, insertBeforeElement);
|
||||
}
|
||||
|
||||
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">
|
||||
|
|
Загрузка…
Ссылка в новой задаче