Bug 285836 - Add a confirm dialog for delete all cookies draft
authorScott Wu <scottcwwu@gmail.com>
Wed, 18 May 2016 14:59:52 +0800
changeset 368188 b88920769e9664801bacb724333136f66ffe3c75
parent 356700 52072b6bec1416578615ec73027eb80a65d3fcd4
child 521197 1ef545eea9bbdcab93a100ea5c0281e8029c513d
push id18452
push userbmo:scwwu@mozilla.com
push dateWed, 18 May 2016 07:05:12 +0000
bugs285836
milestone49.0a1
Bug 285836 - Add a confirm dialog for delete all cookies MozReview-Commit-ID: 9aVTG5SrFkG
browser/components/preferences/cookies.js
browser/locales/en-US/chrome/browser/preferences/preferences.properties
--- a/browser/components/preferences/cookies.js
+++ b/browser/components/preferences/cookies.js
@@ -717,28 +717,40 @@ var gCookiesWindow = {
       seln.clearSelection();
     else {
       seln.select(nextSelected);
       this._tree.focus();
     }
   },
 
   deleteAllCookies: function () {
+    let prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
+                      getService(Components.interfaces.nsIPromptService);
     if (this._view._filtered) {
       var rowCount = this._view.rowCount;
+      if (!prompts.confirm(null,
+        this._bundle.getString("confirmDeleteCookiesTitle"),
+        this._bundle.getFormattedString("confirmDeleteCookies", [rowCount]))) {
+        return;
+      }
       var deleteItems = [];
       for (var index = 0; index < rowCount; index++) {
         deleteItems.push(this._view._getItemAtIndex(index));
       }
       this._view._removeItemAtIndex(0, rowCount);
       this._view._rowCount = 0;
       this._tree.treeBoxObject.rowCountChanged(0, -rowCount);
       this.performDeletion(deleteItems);
     }
     else {
+      if (!prompts.confirm(null,
+        this._bundle.getString("confirmDeleteCookiesTitle"),
+        this._bundle.getString("confirmDeleteAllCookies"))) {
+        return;
+      }
       this._cm.removeAll();
     }
     this._updateRemoveAllButton();
     this.focusFilterBox();
   },
 
   onCookieKeyPress: function (aEvent) {
     if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -116,16 +116,19 @@ forAnyConnection=Any type of connection
 expireAtEndOfSession=At end of session
 can=Allow
 canAccessFirstParty=Allow first party only
 canSession=Allow for Session
 cannot=Block
 noCookieSelected=<no cookie selected>
 cookiesAll=The following cookies are stored on your computer:
 cookiesFiltered=The following cookies match your search:
+confirmDeleteCookiesTitle=Remove Cookies
+confirmDeleteCookies=%S cookies will be removed. Are you sure?
+confirmDeleteAllCookies=ALL cookies will be removed. Are you sure?
 # LOCALIZATION NOTE (removeSelectedCookies):
 # Semicolon-separated list of plural forms. See:
 # http://developer.mozilla.org/en/docs/Localization_and_Plurals
 # If you need to display the number of selected elements in your language,
 # you can use #1 in your localization as a placeholder for the number.
 # For example this is the English string with numbers:   
 # removeSelectedCookied=Remove #1 Selected;Remove #1 Selected
 removeSelectedCookies=Remove Selected;Remove Selected