Bug 1007367 - webide main process support. r=jryans

This commit is contained in:
Paul Rouget 2014-08-01 14:47:37 +02:00
parent 105e7f235e
commit a59dd635ce
4 changed files with 46 additions and 2 deletions

View File

@ -57,7 +57,7 @@ function updateUI() {
return;
}
if (project.type != "runtimeApp") {
if (project.type != "runtimeApp" && project.type != "mainProcess") {
document.querySelector("#toolbar").classList.remove("hidden");
document.querySelector("#locationHeader").classList.remove("hidden");
document.querySelector("#location").textContent = project.location;
@ -87,6 +87,8 @@ function updateUI() {
document.querySelector("#type").textContent = manifest.type || "web";
document.querySelector("#manifestURLHeader").classList.remove("hidden");
document.querySelector("#manifestURL").textContent = manifestURL;
} else if (project.type == "mainProcess") {
document.querySelector("#type").textContent = project.name;
} else {
document.querySelector("#type").textContent = project.type + " " + (manifest.type || "web");
}

View File

@ -106,6 +106,7 @@ let UI = {
// if a modification happened, it happened when the window was
// not focused.
if (AppManager.selectedProject &&
AppManager.selectedProject.type != "mainProcess" &&
AppManager.selectedProject.type != "runtimeApp") {
AppManager.validateProject(AppManager.selectedProject);
}
@ -557,6 +558,9 @@ let UI = {
} else {
playCmd.removeAttribute("disabled");
}
} else if (AppManager.selectedProject.type == "mainProcess") {
playCmd.setAttribute("disabled", "true");
stopCmd.setAttribute("disabled", "true");
} else {
if (AppManager.selectedProject.errorsCount == 0) {
playCmd.removeAttribute("disabled");
@ -823,6 +827,22 @@ let Cmds = {
runtimeAppsNode.firstChild.remove();
}
if (AppManager.isMainProcessDebuggable()) {
let panelItemNode = document.createElement("toolbarbutton");
panelItemNode.className = "panel-item";
panelItemNode.setAttribute("label", Strings.GetStringFromName("mainProcess_label"));
panelItemNode.setAttribute("image", AppManager.DEFAULT_PROJECT_ICON);
runtimeAppsNode.appendChild(panelItemNode);
panelItemNode.addEventListener("click", () => {
UI.hidePanels();
AppManager.selectedProject = {
type: "mainProcess",
name: Strings.GetStringFromName("mainProcess_label"),
icon: AppManager.DEFAULT_PROJECT_ICON
};
}, true);
}
let sortedApps = AppManager.webAppsStore.object.all;
sortedApps = sortedApps.sort((a, b) => {
return a.name > b.name;

View File

@ -8,6 +8,8 @@ title_app=Firefox WebIDE: %S
runtimeButton_label=Select Runtime
projectButton_label=Open App
mainProcess_label=Main Process
local_runtime=Local Runtime
remote_runtime=Remote Runtime
remote_runtime_promptTitle=Remote Runtime

View File

@ -6,6 +6,7 @@ const {Cu} = require("chrome");
let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const {Devices} = Cu.import("resource://gre/modules/devtools/Devices.jsm");
const {Services} = Cu.import("resource://gre/modules/Services.jsm");
const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
@ -191,6 +192,9 @@ exports.AppManager = AppManager = {
},
isProjectRunning: function() {
if (this.selectedProject.type == "mainProcess") {
return true;
}
let manifest = this.getProjectManifestURL(this.selectedProject);
return manifest && this._runningApps.has(manifest);
},
@ -206,6 +210,14 @@ exports.AppManager = AppManager = {
},
getTarget: function() {
if (this.selectedProject.type == "mainProcess") {
return devtools.TargetFactory.forRemoteTab({
form: this._listTabsResponse,
client: this.connection.client,
chrome: true
});
}
let manifest = this.getProjectManifestURL(this.selectedProject);
if (!manifest) {
console.error("Can't find manifestURL for selected project");
@ -261,7 +273,9 @@ exports.AppManager = AppManager = {
if (this.selectedProject) {
if (this.selectedProject.type == "runtimeApp") {
this.runRuntimeApp();
} else {
}
if (this.selectedProject.type == "packaged" ||
this.selectedProject.type == "hosted") {
this.validateProject(this.selectedProject);
}
}
@ -286,6 +300,7 @@ exports.AppManager = AppManager = {
this._selectedRuntime = value;
if (!value &&
this.selectedProject &&
this.selectedProject.type == "mainProcess" &&
this.selectedProject.type == "runtimeApp") {
this.selectedProject = null;
}
@ -333,6 +348,11 @@ exports.AppManager = AppManager = {
return deferred.promise;
},
isMainProcessDebuggable: function() {
return this._listTabsResponse &&
this._listTabsResponse.consoleActor;
},
get deviceFront() {
if (!this._listTabsResponse) {
return null;