Bug 920481 - Call BrowserTabActor.reload when the app is updated to refresh the app. r=paul

This commit is contained in:
Alexandre Poirot 2013-10-19 21:14:47 +02:00
parent d8bf7beb44
commit 3d0405de63
2 changed files with 41 additions and 10 deletions

View File

@ -14,7 +14,7 @@ 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");
@ -174,16 +174,26 @@ let UI = {
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) {

View File

@ -240,3 +240,24 @@ function getTargetForApp(client, webappsActor, manifestURL) {
}
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;