Bug 1143939 - Add single-item delete to about:passwords context menu. r=ally
authorChenxia Liu <liuche@mozilla.com>
Thu, 26 Mar 2015 10:42:34 -0700
changeset 264793 a47e2631d62b097d767ebed77f2255996cf4a473
parent 264792 28bc7e898980ff509f986ebb8a76df6b41f55914
child 264794 ed5addaca0c1afc446703f6985ee8ad999f2be02
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersally
bugs1143939
milestone39.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1143939 - Add single-item delete to about:passwords context menu. r=ally
mobile/android/chrome/content/aboutPasswords.js
mobile/android/locales/en-US/chrome/aboutPasswords.properties
--- a/mobile/android/chrome/content/aboutPasswords.js
+++ b/mobile/android/chrome/content/aboutPasswords.js
@@ -131,32 +131,48 @@ let Passwords = {
 
     loginItem.addEventListener("click", () => {
       let prompt = new Prompt({
         window: window,
       });
       let menuItems = [
         { label: gStringBundle.GetStringFromName("passwordsMenu.copyPassword") },
         { label: gStringBundle.GetStringFromName("passwordsMenu.copyUsername") },
-        { label: gStringBundle.GetStringFromName("passwordsMenu.details") } ];
+        { label: gStringBundle.GetStringFromName("passwordsMenu.details") },
+        { label: gStringBundle.GetStringFromName("passwordsMenu.delete") } ];
 
       prompt.setSingleChoiceItems(menuItems);
       prompt.show((data) => {
         // Switch on indices of buttons, as they were added when creating login item.
         switch (data.button) {
           case 0:
             copyStringAndToast(login.password, gStringBundle.GetStringFromName("passwordsDetails.passwordCopied"));
             break;
           case 1:
             copyStringAndToast(login.username, gStringBundle.GetStringFromName("passwordsDetails.usernameCopied"));
             break;
           case 2:
             this._showDetails(loginItem);
             history.pushState({ id: login.guid }, document.title);
             break;
+          case 3:
+            let confirmPrompt = new Prompt({
+              window: window,
+              message: gStringBundle.GetStringFromName("passwordsDialog.confirmDelete"),
+              buttons: [
+                gStringBundle.GetStringFromName("passwordsDialog.confirm"),
+                gStringBundle.GetStringFromName("passwordsDialog.cancel") ]
+            });
+            confirmPrompt.show((data) => {
+              switch (data.button) {
+                case 0:
+                  // Corresponds to "confirm" button.
+                  Services.logins.removeLogin(login);
+              }
+            });
         }
       });
 
     }, true);
 
     // Create item icon.
     let img = document.createElement("div");
     img.className = "icon";
--- a/mobile/android/locales/en-US/chrome/aboutPasswords.properties
+++ b/mobile/android/locales/en-US/chrome/aboutPasswords.properties
@@ -1,13 +1,18 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 passwordsMenu.copyPassword=Copy password
 passwordsMenu.copyUsername=Copy username
 passwordsMenu.details=Details
+passwordsMenu.delete=Delete
+
+passwordsDialog.confirmDelete=Delete this login?
+passwordsDialog.confirm=OK
+passwordsDialog.cancel=Cancel
 
 passwordsDetails.age=Age: %S days
 
 passwordsDetails.copyFailed=Copy failed
 passwordsDetails.passwordCopied=Password copied
 passwordsDetails.usernameCopied=Username copied