Bug 554938 - Some cleanup and fixes for new Add-on Manager features [r=vingtetun]
authorMark Finkle <mfinkle@mozilla.com>
Thu, 25 Mar 2010 13:22:26 -0400
changeset 66062 241ab7a30820096db3ca2ac8bbbbff7255376332
parent 66061 0c6ea23fd90b07f8a60026f5142137a4e4c73852
child 66063 4e83c7829c39566ee161d499abad5083a0355c5e
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvingtetun
bugs554938
Bug 554938 - Some cleanup and fixes for new Add-on Manager features [r=vingtetun]
mobile/chrome/content/bindings/extensions.xml
mobile/chrome/content/browser.xul
mobile/chrome/content/extensions.js
mobile/locales/en-US/chrome/browser.properties
mobile/themes/hildon/platform.css
mobile/themes/wince/platform.css
--- a/mobile/chrome/content/bindings/extensions.xml
+++ b/mobile/chrome/content/bindings/extensions.xml
@@ -194,17 +194,17 @@
                       oncommand="ExtensionsView.installFromRepo(document.getBindingParent(this));"/>
         </xul:hbox>
         <xul:progressmeter class="show-on-install" mode="normal" value="0" xbl:inherits="value=progress"/>
       </xul:vbox>
     </content>
   </binding>
 
   <binding id="extension-message" extends="chrome://browser/content/bindings.xml#richlistitem">
-    <content orient="vertical" align="center">
+    <content orient="vertical" align="center" nohighlight="true">
       <xul:hbox align="center">
         <xul:image src="chrome://browser/skin/images/throbber.png" xbl:inherits="hidden=hidethrobber"/>
         <xul:label class="normal" xbl:inherits="value=message"/>
       </xul:hbox>
       <xul:button xbl:inherits="label=button,hidden=hidebutton" oncommand="ExtensionsView.resetSearch();"/>
     </content>
   </binding>
 
@@ -221,22 +221,19 @@
   </binding>
 
   <binding id="extension-search-no-rating">
     <content>
     </content>
   </binding>
 
   <binding id="extension-search-showmore" extends="chrome://browser/content/bindings.xml#richlistitem">
-    <content orient="vertical">
-      <xul:hbox align="start">
+    <content orient="vertical" nohighlight="true">
+      <xul:hbox align="center">
         <xul:image class="addon-showmore-image" xbl:inherits="src=image"/>
-        <xul:vbox flex="1">
-          <xul:label class="title" xbl:inherits="value=title"/>
-          <xul:description class="normal" xbl:inherits="xbl:text=description" flex="1"/>
-        </xul:vbox>
+        <xul:label class="title" xbl:inherits="value=label"/>
         <xul:spacer flex="1"/>
         <xul:button label="&addonShowPage.label;" oncommand="ExtensionsView.showMoreResults(document.getBindingParent(this));"/>
       </xul:hbox>
     </content>
   </binding>
 
 </bindings>
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -343,21 +343,21 @@
       </box>
       <deck id="panel-items" selectedIndex="2" flex="1">
         <vbox id="addons-container" flex="1">
           <hbox id="addons-header" class="panel-header">
             <label value="&addonsHeader.label;"/>
           </hbox>
           <notificationbox id="addons-messages" flex="1">
             <richlistbox id="addons-list" flex="1" onselect="ExtensionsView.hideOnSelect(event)">
-              <richlistitem id="addons-local" class="section-header" align="center">
+              <richlistitem id="addons-local" class="section-header" align="center" nohighlight="true">
                 <label value="&addonsLocal.label;" flex="1"/>
                 <spacer flex="1"/>
               </richlistitem>
-              <richlistitem id="addons-repo" class="section-header">
+              <richlistitem id="addons-repo" class="section-header" nohighlight="true">
                 <label value="&addonsRepo.label;" flex="1"/>
                 <textbox id="addons-search-text" emptytext="&addonsSearch2.emptytext;" type="search" searchbutton="false"
                          oncommand="ExtensionsView.getAddonsFromRepo(this.value);"/>
               </richlistitem>
             </richlistbox>
           </notificationbox>
         </vbox>
 
--- a/mobile/chrome/content/extensions.js
+++ b/mobile/chrome/content/extensions.js
@@ -159,23 +159,27 @@ var ExtensionsView = {
           return true;
         }
       } ];
     }
 
     this._msg.appendNotification(aMsg, aValue, "", this._msg.PRIORITY_WARNING_LOW, buttons).hideclose = !aShowCloseButton;
   },
 
-  showRestart: function ev_showRestart() {
+  showRestart: function ev_showRestart(aMode) {
     // Increment the count in case the view is not completely initialized
     this._restartCount++;
 
+    // Pick the right message key from the properties file
+    aMode = aMode || "normal";
+
     if (this._msg) {
       let strings = Elements.browserBundle;
-      this.showMessage(strings.getString("notificationRestart.label"), "restart-app",
+      let message = "notificationRestart." + aMode;
+      this.showMessage(strings.getString(message), "restart-app",
                        strings.getString("notificationRestart.button"), false, "addons-restart-app");
     }
   },
 
   hideRestart: function ev_hideRestart() {
     this._restartCount--;
     if (this._restartCount == 0 && this._msg) {
       let notification = this._msg.getNotificationWithValue("restart-app");
@@ -600,37 +604,32 @@ var ExtensionsView = {
 
     let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);
 
     if (!aIsRecommended) {
       if (aTotalResults > aAddons.length) {
         let showmore = document.createElement("richlistitem");
         showmore.setAttribute("typeName", "showmore");
 
-        let titleBase = strings.getString("addonsSearchMore.label");
-        let title = PluralForm.get(aTotalResults, titleBase).replace("#1", aTotalResults);
-        showmore.setAttribute("title", title);
-
-        let descBase = strings.getString("addonsSearchMore.description");
-        let desc = PluralForm.get(aAddons.length, descBase).replace("#1", aAddons.length);
-        showmore.setAttribute("description", desc);
+        let labelBase = strings.getString("addonsSearchMore.label");
+        let label = PluralForm.get(aTotalResults, labelBase).replace("#1", aTotalResults);
+        showmore.setAttribute("label", label);
 
         let url = gPrefService.getCharPref("extensions.getAddons.search.browseURL");
         url = url.replace(/%TERMS%/g, encodeURIComponent(this.searchBox.value));
         url = formatter.formatURL(url);
         showmore.setAttribute("url", url);
         this._list.appendChild(showmore);
       }
 
       this.displaySectionMessage("repo", null, strings.getString("addonsSearchSuccess2.button"), true);
     } else {
       let showmore = document.createElement("richlistitem");
       showmore.setAttribute("typeName", "showmore");
-      showmore.setAttribute("title", strings.getString("addonsBrowseAll.label"));
-      showmore.setAttribute("description", strings.getString("addonsBrowseAll.description"));
+      showmore.setAttribute("label", strings.getString("addonsBrowseAll.label"));
 
       let url = formatter.formatURLPref("extensions.getAddons.browseAddons");
       showmore.setAttribute("url", url);
       this._list.appendChild(showmore);
     }
   },
 
   showPage: function ev_showPage(aItem) {
@@ -672,45 +671,52 @@ var ExtensionsView = {
 
     switch (aTopic) {
       case "addon-update-started":
         element.setAttribute("updateStatus", strings.getString("addonUpdate.checking"));
         break;
       case "addon-update-ended":
         let status = parseInt(aData);
         let updateable = false;
+        let statusMsg = null;
         const nsIAUCL = Ci.nsIAddonUpdateCheckListener;
         switch (status) {
           case nsIAUCL.STATUS_UPDATE:
-            var statusMsg = strings.getFormattedString("addonUpdate.updating", [addon.version]);
+            statusMsg = strings.getFormattedString("addonUpdate.updating", [addon.version]);
             updateable = true;
             break;
           case nsIAUCL.STATUS_VERSIONINFO:
             statusMsg = strings.getString("addonUpdate.compatibility");
             break;
           case nsIAUCL.STATUS_FAILURE:
             statusMsg = strings.getString("addonUpdate.error");
             break;
           case nsIAUCL.STATUS_DISABLED:
             statusMsg = strings.getString("addonUpdate.disabled");
             break;
           case nsIAUCL.STATUS_APP_MANAGED:
           case nsIAUCL.STATUS_NO_UPDATE:
-            statusMsg = strings.getString("addonUpdate.noupdate");
+            // Ignore if no updated was found. Just let the message go blank.
+            //statusMsg = strings.getString("addonUpdate.noupdate");
             break;
           case nsIAUCL.STATUS_NOT_MANAGED:
             statusMsg = strings.getString("addonUpdate.notsupported");
             break;
           case nsIAUCL.STATUS_READ_ONLY:
             statusMsg = strings.getString("addonUpdate.notsupported");
             break;
           default:
-            statusMsg = strings.getString("addonUpdate.noupdate");
+            // Ignore if no updated was found. Just let the message go blank.
+            //statusMsg = strings.getString("addonUpdate.noupdate");
         }
-        element.setAttribute("updateStatus", statusMsg);
+
+        if (statusMsg)
+          element.setAttribute("updateStatus", statusMsg);
+        else
+          element.removeAttribute("updateStatus");
 
         // Tag the add-on so the XPInstallDownloadManager knows it's an update
         if (updateable)
           element.setAttribute("updating", "true");
         break;
     }
   }
 };
@@ -794,16 +800,17 @@ XPInstallDownloadManager.prototype = {
       items.push(item);
 
       // Advance the enumerator
       let certName = aParams.GetString(i++);
     }
 
     this._failed = [];
     this._succeeded = [];
+    this._updating = false;
 
     ExtensionsView.installFromXPI(items, aManager);
 
     if (ExtensionsView.visible)
       return;
 
     let strings = Elements.browserBundle;
     var alerts = Cc["@mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
@@ -816,16 +823,17 @@ XPInstallDownloadManager.prototype = {
   onDownloadStarted: function(aAddon) { },
   onDownloadEnded: function(aAddon) { },
   onInstallStarted: function(aAddon) { },
   onCompatibilityCheckStarted: function(aAddon) { },
   onCompatibilityCheckEnded: function(aAddon, aStatus) { },
 
   _failed: [],
   _succeeded: [],
+  _updating: false,
   onInstallEnded: function(aAddon, aStatus) {
     // Track success/failure for each addon
     if (Components.isSuccessCode(aStatus))
       this._succeeded.push(aAddon.id);
     else
       this._failed.push(aAddon.id);
 
     if (!ExtensionsView.visible)
@@ -837,25 +845,28 @@ XPInstallDownloadManager.prototype = {
 
     element.setAttribute("status", (Components.isSuccessCode(aStatus) ? "success" : "fail"));
 
     // If we are updating an add-on, change the status
     if (element.hasAttribute("updating")) {
       let strings = Elements.browserBundle;
       element.setAttribute("updateStatus", strings.getFormattedString("addonUpdate.updated", [aAddon.version]));
       element.removeAttribute("updating");
+
+      // Remember that we are updating so we can customize the restart message
+      this._updating = true;
     }
   },
 
   onInstallsCompleted: function() {
     let strings = Elements.browserBundle;
 
     // If even one add-on succeeded, display the restart notif
     if (this._succeeded.length > 0)
-      ExtensionsView.showRestart();
+      ExtensionsView.showRestart(this._updating ? "update" : "normal");
 
     if (ExtensionsView.visible)
       return;
 
     let message = strings.getString("alertAddonsInstalled");
     if (this._succeeded.length == 0 && this._failed.length > 0)
       message = strings.getString("alertAddonsFail");
 
--- a/mobile/locales/en-US/chrome/browser.properties
+++ b/mobile/locales/en-US/chrome/browser.properties
@@ -63,17 +63,18 @@ alertAddonsFail=Installation failed
 # #1 number of add-ons
 alertAddonsDisabled=#1 incompatible add-on was disabled;#1 incompatible add-ons were disabled
 
 alertDownloads=Downloads
 alertDownloadsStart=Downloading: %S
 alertDownloadsDone=%S has finished downloading
 
 # Notifications
-notificationRestart.label=Restart to complete changes
+notificationRestart.normal=Restart to complete changes.
+notificationRestart.update=Add-ons updated. Restart to complete changes.
 notificationRestart.button=Restart
 
 # Popup Blocker
 popupWarning=%S prevented this site from opening a pop-up window.
 popupWarningMultiple=%S prevented this site from opening %S pop-up windows.
 popupButtonAllowOnce=Show
 popupButtonAlwaysAllow2=Always Show
 popupButtonNeverWarn2=Never Show
--- a/mobile/themes/hildon/platform.css
+++ b/mobile/themes/hildon/platform.css
@@ -431,17 +431,17 @@ richlistitem description.normal-bold {
   white-space: pre-wrap;
 }
 
 richlistitem[selected="true"] {
   color: black;
   background-color: white;
 }
 
-richlistitem:active:not([selected="true"]):not([typeName="message"]):not(.section-header) {
+richlistitem:active:not([selected="true"]):not([nohighlight="true"]) {
   background-color: #8db8d8;
 }
 
 richlistitem.section-header,
 richlistitem[selected="true"].section-header {
   font-weight: bold;
   color: #000;
   background-color: lightgray;
--- a/mobile/themes/wince/platform.css
+++ b/mobile/themes/wince/platform.css
@@ -628,17 +628,17 @@ richlistitem description.normal-bold {
   white-space: pre-wrap;
 }
 
 richlistitem[selected="true"] {
   color: black;
   background-color: white;
 }
 
-richlistitem:active:not([selected="true"]):not([typeName="message"]):not(.section-header) {
+richlistitem:active:not([selected="true"]):not([nohighlight="true"]) {
   background-color: #8db8d8;
 }
 
 richlistitem.section-header,
 richlistitem[selected="true"].section-header {
   font-weight: bold;
   color: #000;
   background-color: lightgray;