Bug 920481 - Call BrowserTabActor.reload when the app is updated to refresh the app. r=paul
☠☠ backed out by dad5e53c31a9 ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Sat, 19 Oct 2013 21:14:47 +0200
changeset 165618 1864e27d5ee46a4269d376ffee1578f577e21c36
parent 165617 54da01870611dd2c226180786f9a222ca1b244be
child 165619 4975704635c9528073a2c9b275b1c617351ab318
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs920481
milestone27.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 920481 - Call BrowserTabActor.reload when the app is updated to refresh the app. r=paul
browser/devtools/app-manager/content/projects.js
toolkit/devtools/apps/app-actor-front.js
--- a/browser/devtools/app-manager/content/projects.js
+++ b/browser/devtools/app-manager/content/projects.js
@@ -9,17 +9,17 @@ const Cr = Components.results;
 Cu.import("resource:///modules/devtools/gDevTools.jsm");
 const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
 const {require} = devtools;
 const {ConnectionManager, Connection} = require("devtools/client/connection-manager");
 const {AppProjects} = require("devtools/app-manager/app-projects");
 const {AppValidator} = require("devtools/app-manager/app-validator");
 const {Services} = Cu.import("resource://gre/modules/Services.jsm");
 const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
-const {installHosted, installPackaged, getTargetForApp} = require("devtools/app-actor-front");
+const {installHosted, installPackaged, getTargetForApp, reloadApp} = require("devtools/app-actor-front");
 const {EventEmitter} = Cu.import("resource:///modules/devtools/shared/event-emitter.js");
 
 const promise = require("sdk/core/promise");
 
 const MANIFEST_EDITOR_ENABLED = "devtools.appmanager.manifestEditor.enabled";
 
 window.addEventListener("message", function(event) {
   try {
@@ -169,26 +169,36 @@ let UI = {
         })
         .then(() => {
            // Install the app to the device if we are connected,
            // and there is no error
            if (project.errorsCount == 0 && this.listTabsResponse) {
              return this.install(project);
            }
          })
-        .then(
-         () => {
+        .then(() => {
            button.disabled = false;
-         },
-         (res) => {
-           button.disabled = false;
-           let message = res.error + ": " + res.message;
-           alert(message);
-           this.connection.log(message);
-         });
+           // Finally try to reload the app if it is already opened
+           this.reload(project);
+        },
+        (res) => {
+          button.disabled = false;
+          let message = res.error + ": " + res.message;
+          alert(message);
+          this.connection.log(message);
+        });
+  },
+
+  reload: function (project) {
+    return reloadApp(this.connection.client,
+              this.listTabsResponse.webappsActor,
+              this._getProjectManifestURL(project)).
+      then(() => {
+        this.connection.log("App reloaded");
+      });
   },
 
   remove: function(location, event) {
     if (event) {
       // We don't want the "click" event to be propagated to the project item.
       // That would trigger `selectProject()`.
       event.stopPropagation();
     }
--- a/toolkit/devtools/apps/app-actor-front.js
+++ b/toolkit/devtools/apps/app-actor-front.js
@@ -235,8 +235,29 @@ function getTargetForApp(client, webapps
         deferred.reject(error);
       });
     }
   });
   return deferred.promise;
 }
 exports.getTargetForApp = getTargetForApp;
 
+function reloadApp(client, webappsActor, manifestURL) {
+  let deferred = promise.defer();
+  getTargetForApp(client,
+                  webappsActor,
+                  manifestURL).
+    then((target) => {
+      // Request the ContentAppActor to reload the app
+      let request = {
+        to: target.form.actor,
+        type: "reload",
+        manifestURL: manifestURL
+      };
+      client.request(request, (res) => {
+        deferred.resolve();
+      });
+    }, () => {
+     deferred.reject("Not running");
+    });
+  return deferred.promise;
+}
+exports.reloadApp = reloadApp;