mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 920481 - Call BrowserTabActor.reload when the app is updated to refresh the app. r=paul
This commit is contained in:
parent
d8bf7beb44
commit
3d0405de63
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user