Bug 523784 - Soft blocked items are not disabled if user clicks "Cancel". r=Unfocused+Pike a=blocking+beltzner
authorMehdi Mulani <mmmulani@uwaterloo.ca>
Sun, 13 Feb 2011 17:19:03 -0800
changeset 62683 a57c236d61de590862835a035fea7494b025c728
parent 62682 d77d5f19628679126ca280ee8c83d7c092236b19
child 62684 64d579f7746b20d1892852362675204d264311db
push id1
push userroot
push dateTue, 10 Dec 2013 15:46:25 +0000
reviewersUnfocused, blocking
bugs523784
milestone2.0b12pre
Bug 523784 - Soft blocked items are not disabled if user clicks "Cancel". r=Unfocused+Pike a=blocking+beltzner
toolkit/locales/en-US/chrome/mozapps/update/updates.properties
toolkit/mozapps/extensions/content/blocklist.js
toolkit/mozapps/extensions/content/blocklist.xul
--- a/toolkit/locales/en-US/chrome/mozapps/update/updates.properties
+++ b/toolkit/locales/en-US/chrome/mozapps/update/updates.properties
@@ -47,16 +47,18 @@ noThanksButton.accesskey=N
 updateButton_minor=Update %S
 updateButton_minor.accesskey=U
 updateButton_major=Get the New Version
 updateButton_major.accesskey=G
 backButton=Back
 backButton.accesskey=B
 acceptTermsButton=Accept Terms
 acceptTermsButton.accesskey=A
+# NOTE: The restartLaterButton string is also used in
+# mozapps/extensions/content/blocklist.js
 restartLaterButton=Restart Later
 restartLaterButton.accesskey=L
 restartNowButton=Restart %S
 restartNowButton.accesskey=R
 
 # LOCALIZATION NOTE: %S is the date the update was installed from the local
 # updates.xml for displaying update history
 statusSucceededFormat=Installed on: %S
--- a/toolkit/mozapps/extensions/content/blocklist.js
+++ b/toolkit/mozapps/extensions/content/blocklist.js
@@ -30,23 +30,34 @@
 # use your version of this file under the terms of the MPL, indicate your
 # decision by deleting the provisions above and replace them with the notice
 # and other provisions required by the GPL or the LGPL. If you do not delete
 # the provisions above, a recipient may use your version of this file under
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 var gArgs;
 
 function init() {
   var hasHardBlocks = false;
   var hasSoftBlocks = false;
   gArgs = window.arguments[0].wrappedJSObject;
 
+  // NOTE: We use strings from the "updates.properties" bundleset to change the
+  // text on the "Cancel" button to "Restart Later". (bug 523784)
+  let bundle = Services.strings.
+              createBundle("chrome://mozapps/locale/update/updates.properties");
+  let cancelButton = document.documentElement.getButton("cancel");
+  cancelButton.setAttribute("label", bundle.GetStringFromName("restartLaterButton"));
+  cancelButton.setAttribute("accesskey",
+                            bundle.GetStringFromName("restartLaterButton.accesskey"));
+
   var richlist = document.getElementById("addonList");
   var list = gArgs.list;
   list.sort(function(a, b) { return String.localeCompare(a.name, b.name); });
   for (let i = 0; i < list.length; i++) {
     let item = document.createElement("richlistitem");
     item.setAttribute("name", list[i].name);
     item.setAttribute("version", list[i].version);
     item.setAttribute("icon", list[i].icon);
@@ -70,18 +81,18 @@ function init() {
 
   var formatter = Components.classes["@mozilla.org/toolkit/URLFormatterService;1"]
                             .getService(Components.interfaces.nsIURLFormatter);
   var url = formatter.formatURLPref("extensions.blocklist.detailsURL");
   var link = document.getElementById("moreInfo");
   link.setAttribute("href", url);
 }
 
-function accept() {
-  gArgs.restart = true;
+function finish(shouldRestartNow) {
+  gArgs.restart = shouldRestartNow;
   var list = gArgs.list;
   var items = document.getElementById("addonList").childNodes;
   for (let i = 0; i < list.length; i++) {
     if (!list[i].blocked)
       list[i].disable = items[i].checked;
   }
   return true;
 }
--- a/toolkit/mozapps/extensions/content/blocklist.xul
+++ b/toolkit/mozapps/extensions/content/blocklist.xul
@@ -47,17 +47,18 @@
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
 %brandDTD;
 <!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/blocklist.dtd">
 %extensionsDTD;
 ]>
 
 <dialog windowtype="Addons:Blocklist" title="&blocklist.title;" align="stretch"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        onload="init();" ondialogaccept="return accept()"
+        onload="init();" ondialogaccept="return finish(true)"
+                         ondialogcancel="return finish(false)"
         buttons="accept,cancel" style="&blocklist.style;"
         buttonlabelaccept="&blocklist.accept.label;"
         buttonaccesskeyaccept="&blocklist.accept.accesskey;">
 
   <script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
   <script type="application/javascript" src="chrome://mozapps/content/extensions/blocklist.js"/>
 
   <hbox align="stretch" flex="1">