Bug 899353 - Show progress while installing apps. r=felipc
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Mon, 09 Sep 2013 08:57:37 -0400
changeset 146190 aa991b7afb094c0a6b6f628461a80c4825e28306
parent 146189 c3b01d22caa9c7ddd8472333dbdba3e4f1ffe353
child 146191 9f377abbf13e9749811e45a6650538d5de669222
push id25244
push userryanvm@gmail.com
push dateMon, 09 Sep 2013 20:03:14 +0000
treeherdermozilla-central@f320b8c034bd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipc
bugs899353
milestone26.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 899353 - Show progress while installing apps. r=felipc
browser/base/content/popup-notifications.inc
browser/locales/en-US/chrome/browser/browser.properties
browser/modules/webappsUI.jsm
browser/themes/linux/browser.css
browser/themes/osx/browser.css
browser/themes/windows/browser.css
--- a/browser/base/content/popup-notifications.inc
+++ b/browser/base/content/popup-notifications.inc
@@ -24,16 +24,22 @@
                accesskey="&getUserMedia.selectMicrophone.accesskey;"
                control="webRTC-selectMicrophone-menulist"/>
         <menulist id="webRTC-selectMicrophone-menulist">
           <menupopup id="webRTC-selectMicrophone-menupopup"/>
         </menulist>
       </popupnotificationcontent>
     </popupnotification>
 
+    <popupnotification id="webapps-install-progress-notification" hidden="true">
+      <popupnotificationcontent id="webapps-install-progress-content" orient="vertical" align="start">
+        <separator class="thin"/>
+      </popupnotificationcontent>
+    </popupnotification>
+
     <popupnotification id="geolocation-notification" hidden="true">
       <popupnotificationcontent orient="vertical" align="start">
         <separator class="thin"/>
         <label id="geolocation-learnmore-link" class="text-link"/>
       </popupnotificationcontent>
     </popupnotification>
 
     <popupnotification id="servicesInstall-notification" hidden="true">
--- a/browser/locales/en-US/chrome/browser/browser.properties
+++ b/browser/locales/en-US/chrome/browser/browser.properties
@@ -402,16 +402,17 @@ dataReportingNotification.button.label  
 dataReportingNotification.button.accessKey  = C
 
 # Webapps notification popup
 webapps.install = Install
 webapps.install.accesskey = I
 #LOCALIZATION NOTE (webapps.requestInstall) %1$S is the web app name, %2$S is the site from which the web app is installed
 webapps.requestInstall = Do you want to install "%1$S" from this site (%2$S)?
 webapps.install.success = Application Installed
+webapps.install.inprogress = Installation in progress
 
 # LOCALIZATION NOTE (fullscreen.entered): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
 fullscreen.entered=%S is now fullscreen.
 # LOCALIZATION NOTE (fullscreen.rememberDecision): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
 fullscreen.rememberDecision=Remember decision for %S
 
 service.toolbarbutton.label=Services
 service.toolbarbutton.tooltiptext=Services
--- a/browser/modules/webappsUI.jsm
+++ b/browser/modules/webappsUI.jsm
@@ -112,23 +112,41 @@ this.webappsUI = {
     }
   },
 
   doInstall: function(aData, aWindow) {
     let browser = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
                          .getInterface(Ci.nsIWebNavigation)
                          .QueryInterface(Ci.nsIDocShell)
                          .chromeEventHandler;
-    let chromeWin = browser.ownerDocument.defaultView;
+    let chromeDoc = browser.ownerDocument;
+    let chromeWin = chromeDoc.defaultView;
+    let popupProgressContent =
+      chromeDoc.getElementById("webapps-install-progress-content");
+
     let bundle = chromeWin.gNavigatorBundle;
 
+    let notification;
+
     let mainAction = {
       label: bundle.getString("webapps.install"),
       accessKey: bundle.getString("webapps.install.accesskey"),
       callback: () => {
+        notification.remove();
+
+        notification = chromeWin.PopupNotifications.
+                        show(browser,
+                             "webapps-install-progress",
+                             bundle.getString("webapps.install.inprogress"),
+                             "webapps-notification-icon");
+
+        let progressMeter = chromeDoc.createElement("progressmeter");
+        progressMeter.setAttribute("mode", "undetermined");
+        popupProgressContent.appendChild(progressMeter);
+
         let manifestURL = aData.app.manifestURL;
         if (aData.app.manifest && aData.app.manifest.appcache_path) {
           this.downloads[manifestURL] = Promise.defer();
         }
 
         let app = WebappsInstaller.init(aData);
 
         if (app) {
@@ -145,16 +163,18 @@ this.webappsUI = {
                   if (this.downloads[manifestURL]) {
                     yield this.downloads[manifestURL].promise;
                   }
                   installationSuccessNotification(aData, app, bundle);
                 } catch (ex) {
                   Cu.reportError("Error installing webapp: " + ex);
                   // TODO: Notify user that the installation has failed
                 } finally {
+                  popupProgressContent.removeChild(progressMeter);
+                  notification.remove();
                   delete this.downloads[manifestURL];
                 }
               }.bind(this));
             });
         } else {
           DOMApplicationRegistry.denyInstall(aData);
         }
       }
@@ -169,18 +189,21 @@ this.webappsUI = {
       host = requestingURI.host;
     } catch(e) {
       host = requestingURI.spec;
     }
 
     let message = bundle.getFormattedString("webapps.requestInstall",
                                             [manifest.name, host], 2);
 
-    chromeWin.PopupNotifications.show(browser, "webapps-install", message,
-                                    "webapps-notification-icon", mainAction);
+    notification = chromeWin.PopupNotifications.show(browser,
+                                                     "webapps-install",
+                                                     message,
+                                                     "webapps-notification-icon",
+                                                     mainAction);
 
   }
 }
 
 function installationSuccessNotification(aData, app, aBundle) {
   let launcher = {
     observe: function(aSubject, aTopic) {
       if (aTopic == "alertclickcallback") {
--- a/browser/themes/linux/browser.css
+++ b/browser/themes/linux/browser.css
@@ -1179,16 +1179,17 @@ toolbar[iconsize="small"] #webrtc-status
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 
 .popup-notification-icon[popupid="password-save"],
 .popup-notification-icon[popupid="password-change"] {
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 
+.popup-notification-icon[popupid="webapps-install-progress"],
 .popup-notification-icon[popupid="webapps-install"] {
   list-style-image: url(chrome://global/skin/icons/webapps-64.png);
 }
 
 .popup-notification-icon[popupid="mixed-content-blocked"] {
   list-style-image: url(chrome://browser/skin/mixed-content-blocked-64.png);
 }
 
--- a/browser/themes/osx/browser.css
+++ b/browser/themes/osx/browser.css
@@ -3400,16 +3400,17 @@ toolbarbutton.chevron > .toolbarbutton-m
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 
 .popup-notification-icon[popupid="password-save"],
 .popup-notification-icon[popupid="password-change"] {
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 
+.popup-notification-icon[popupid="webapps-install-progress"],
 .popup-notification-icon[popupid="webapps-install"] {
   list-style-image: url(chrome://global/skin/icons/webapps-64.png);
 }
 
 .popup-notification-icon[popupid="mixed-content-blocked"] {
   list-style-image: url(chrome://browser/skin/mixed-content-blocked-64.png);
 }
 @media (min-resolution: 2dppx) {
--- a/browser/themes/windows/browser.css
+++ b/browser/themes/windows/browser.css
@@ -2453,16 +2453,17 @@ toolbarbutton.bookmark-item[dragover="tr
   list-style-image: url(chrome://global/skin/icons/question-64.png);
 }
 
 .popup-notification-icon[popupid="password-save"],
 .popup-notification-icon[popupid="password-change"] {
   list-style-image: url(chrome://mozapps/skin/passwordmgr/key-64.png);
 }
 
+.popup-notification-icon[popupid="webapps-install-progress"],
 .popup-notification-icon[popupid="webapps-install"] {
   list-style-image: url(chrome://global/skin/icons/webapps-64.png);
 }
 
 .popup-notification-icon[popupid="mixed-content-blocked"] {
   list-style-image: url(chrome://browser/skin/mixed-content-blocked-64.png);
 }