mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-09 08:48:07 +00:00
Bug 1334663 - Add ability to copy and launch URL from password manager. r=MattN,rfeeley
MozReview-Commit-ID: JApe0OhTIg8 --HG-- extra : rebase_source : f53e7a030a17c5580b08605348a30d5061b96cba extra : amend_source : 5808aa783f7a517e931d0df4c69af25b42e71141
This commit is contained in:
parent
5d7760ed1c
commit
cc3fb7fbb2
@ -629,6 +629,15 @@ function FilterPasswords() {
|
||||
removeAllButton.setAttribute("accesskey", kSignonBundle.getString("removeAllShown.accesskey"));
|
||||
}
|
||||
|
||||
function CopySiteUrl() {
|
||||
// Copy selected site url to clipboard
|
||||
let clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
|
||||
getService(Ci.nsIClipboardHelper);
|
||||
let row = signonsTree.currentIndex;
|
||||
let url = signonsTreeView.getCellText(row, {id: "siteCol"});
|
||||
clipboard.copyString(url);
|
||||
}
|
||||
|
||||
function CopyPassword() {
|
||||
// Don't copy passwords if we aren't already showing the passwords & a master
|
||||
// password hasn't been entered.
|
||||
@ -659,6 +668,12 @@ function EditCellInSelectedRow(columnName) {
|
||||
signonsTree.startEditing(row, signonsTree.columns.getColumnFor(columnElement));
|
||||
}
|
||||
|
||||
function LaunchSiteUrl() {
|
||||
let row = signonsTree.currentIndex;
|
||||
let url = signonsTreeView.getCellText(row, {id: "siteCol"});
|
||||
window.openUILinkIn(url, "tab");
|
||||
}
|
||||
|
||||
function UpdateContextMenu() {
|
||||
let singleSelection = (signonsTreeView.selection.count == 1);
|
||||
let menuItems = new Map();
|
||||
@ -676,6 +691,14 @@ function UpdateContextMenu() {
|
||||
|
||||
let selectedRow = signonsTree.currentIndex;
|
||||
|
||||
// Don't display "Launch Site URL" if we're not a browser.
|
||||
if (window.openUILinkIn) {
|
||||
menuItems.get("context-launchsiteurl").removeAttribute("disabled");
|
||||
} else {
|
||||
menuItems.get("context-launchsiteurl").setAttribute("disabled", "true");
|
||||
menuItems.get("context-launchsiteurl").setAttribute("hidden", "true");
|
||||
}
|
||||
|
||||
// Disable "Copy Username" if the username is empty.
|
||||
if (signonsTreeView.getCellText(selectedRow, { id: "userCol" }) != "") {
|
||||
menuItems.get("context-copyusername").removeAttribute("disabled");
|
||||
@ -683,6 +706,7 @@ function UpdateContextMenu() {
|
||||
menuItems.get("context-copyusername").setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
menuItems.get("context-copysiteurl").removeAttribute("disabled");
|
||||
menuItems.get("context-editusername").removeAttribute("disabled");
|
||||
menuItems.get("context-copypassword").removeAttribute("disabled");
|
||||
|
||||
|
@ -17,6 +17,9 @@
|
||||
style="width: 45em;"
|
||||
persist="width height screenX screenY">
|
||||
|
||||
#if defined(MOZ_BUILD_APP_IS_BROWSER)
|
||||
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||
#endif
|
||||
<script type="application/javascript" src="chrome://passwordmgr/content/passwordManager.js"/>
|
||||
|
||||
<stringbundle id="signonBundle"
|
||||
@ -32,6 +35,15 @@
|
||||
<popupset id="signonsTreeContextSet">
|
||||
<menupopup id="signonsTreeContextMenu"
|
||||
onpopupshowing="UpdateContextMenu()">
|
||||
<menuitem id="context-copysiteurl"
|
||||
label="©SiteUrlCmd.label;"
|
||||
accesskey="©SiteUrlCmd.accesskey;"
|
||||
oncommand="CopySiteUrl()"/>
|
||||
<menuitem id="context-launchsiteurl"
|
||||
label="&launchSiteUrlCmd.label;"
|
||||
accesskey="&launchSiteUrlCmd.accesskey;"
|
||||
oncommand="LaunchSiteUrl()"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="context-copyusername"
|
||||
label="©UsernameCmd.label;"
|
||||
accesskey="©UsernameCmd.accesskey;"
|
||||
|
@ -39,6 +39,8 @@ add_task(async function test() {
|
||||
function copyField() {
|
||||
info("Select all");
|
||||
selection.selectAll();
|
||||
assertMenuitemEnabled("copysiteurl", false);
|
||||
assertMenuitemEnabled("launchsiteurl", false);
|
||||
assertMenuitemEnabled("copyusername", false);
|
||||
assertMenuitemEnabled("editusername", false);
|
||||
assertMenuitemEnabled("copypassword", false);
|
||||
@ -46,6 +48,8 @@ add_task(async function test() {
|
||||
|
||||
info("Select the first row (with an empty username)");
|
||||
selection.select(0);
|
||||
assertMenuitemEnabled("copysiteurl", true);
|
||||
assertMenuitemEnabled("launchsiteurl", true);
|
||||
assertMenuitemEnabled("copyusername", false, "empty username");
|
||||
assertMenuitemEnabled("editusername", true);
|
||||
assertMenuitemEnabled("copypassword", true);
|
||||
@ -53,6 +57,8 @@ add_task(async function test() {
|
||||
|
||||
info("Clear the selection");
|
||||
selection.clearSelection();
|
||||
assertMenuitemEnabled("copysiteurl", false);
|
||||
assertMenuitemEnabled("launchsiteurl", false);
|
||||
assertMenuitemEnabled("copyusername", false);
|
||||
assertMenuitemEnabled("editusername", false);
|
||||
assertMenuitemEnabled("copypassword", false);
|
||||
@ -61,10 +67,13 @@ add_task(async function test() {
|
||||
info("Select the third row and making the password column visible");
|
||||
selection.select(2);
|
||||
doc.getElementById("passwordCol").hidden = false;
|
||||
assertMenuitemEnabled("copysiteurl", true);
|
||||
assertMenuitemEnabled("launchsiteurl", true);
|
||||
assertMenuitemEnabled("copyusername", true);
|
||||
assertMenuitemEnabled("editusername", true);
|
||||
assertMenuitemEnabled("copypassword", true);
|
||||
assertMenuitemEnabled("editpassword", true, "password column visible");
|
||||
|
||||
menuitem.doCommand();
|
||||
}
|
||||
|
||||
@ -85,12 +94,20 @@ add_task(async function test() {
|
||||
pwmgrdlg.close();
|
||||
}
|
||||
|
||||
function testSiteUrl() {
|
||||
info("Testing Copy Site URL");
|
||||
waitForClipboard("http://mozilla.org/", function copySiteUrl() {
|
||||
menuitem = doc.getElementById("context-copysiteurl");
|
||||
menuitem.doCommand();
|
||||
}, cleanUp, cleanUp);
|
||||
}
|
||||
|
||||
function testPassword() {
|
||||
info("Testing Copy Password");
|
||||
waitForClipboard("coded", function copyPassword() {
|
||||
menuitem = doc.getElementById("context-copypassword");
|
||||
menuitem.doCommand();
|
||||
}, cleanUp, cleanUp);
|
||||
}, testSiteUrl, testSiteUrl);
|
||||
}
|
||||
|
||||
info("Testing Copy Username");
|
||||
|
@ -31,6 +31,9 @@
|
||||
<!ENTITY focusSearch1.key "f">
|
||||
<!ENTITY focusSearch2.key "k">
|
||||
|
||||
<!ENTITY copySiteUrlCmd.label "Copy URL">
|
||||
<!ENTITY copySiteUrlCmd.accesskey "y">
|
||||
|
||||
<!ENTITY copyPasswordCmd.label "Copy Password">
|
||||
<!ENTITY copyPasswordCmd.accesskey "C">
|
||||
|
||||
@ -42,3 +45,6 @@
|
||||
|
||||
<!ENTITY editUsernameCmd.label "Edit Username">
|
||||
<!ENTITY editUsernameCmd.accesskey "d">
|
||||
|
||||
<!ENTITY launchSiteUrlCmd.label "Visit URL">
|
||||
<!ENTITY launchSiteUrlCmd.accesskey "V">
|
||||
|
Loading…
x
Reference in New Issue
Block a user