2015-10-02 06:10:00 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
/* global alert, BrowserToolboxProcess, gDevTools, React, TargetFactory,
|
|
|
|
Toolbox */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
loader.lazyRequireGetter(this, "React",
|
2015-10-30 10:42:00 +00:00
|
|
|
"devtools/client/shared/vendor/react");
|
2015-10-02 06:10:00 +00:00
|
|
|
loader.lazyRequireGetter(this, "TargetFactory",
|
|
|
|
"devtools/client/framework/target", true);
|
|
|
|
loader.lazyRequireGetter(this, "Toolbox",
|
|
|
|
"devtools/client/framework/toolbox", true);
|
|
|
|
loader.lazyRequireGetter(this, "Services");
|
|
|
|
|
|
|
|
loader.lazyImporter(this, "BrowserToolboxProcess",
|
2015-10-13 23:18:43 +00:00
|
|
|
"resource://devtools/client/framework/ToolboxProcess.jsm");
|
2016-02-11 12:29:47 +00:00
|
|
|
loader.lazyRequireGetter(this, "gDevTools",
|
|
|
|
"devtools/client/framework/devtools", true);
|
2015-10-02 06:10:00 +00:00
|
|
|
|
|
|
|
const Strings = Services.strings.createBundle(
|
2015-11-04 21:35:53 +00:00
|
|
|
"chrome://devtools/locale/aboutdebugging.properties");
|
2015-10-02 06:10:00 +00:00
|
|
|
|
|
|
|
exports.TargetComponent = React.createClass({
|
|
|
|
displayName: "TargetComponent",
|
|
|
|
|
|
|
|
debug() {
|
2016-02-04 20:58:02 +00:00
|
|
|
let { client, target } = this.props;
|
2015-10-02 06:10:00 +00:00
|
|
|
switch (target.type) {
|
|
|
|
case "extension":
|
|
|
|
BrowserToolboxProcess.init({ addonID: target.addonID });
|
|
|
|
break;
|
|
|
|
case "serviceworker":
|
|
|
|
// Fall through.
|
|
|
|
case "sharedworker":
|
|
|
|
// Fall through.
|
|
|
|
case "worker":
|
|
|
|
let workerActor = this.props.target.actorID;
|
|
|
|
client.attachWorker(workerActor, (response, workerClient) => {
|
|
|
|
gDevTools.showToolbox(TargetFactory.forWorker(workerClient),
|
2015-12-15 11:10:53 +00:00
|
|
|
"jsdebugger", Toolbox.HostType.WINDOW)
|
|
|
|
.then(toolbox => {
|
|
|
|
toolbox.once("destroy", () => workerClient.detach());
|
|
|
|
});
|
2015-10-02 06:10:00 +00:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
alert("Not implemented yet!");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
2016-02-04 20:58:02 +00:00
|
|
|
let { target, debugDisabled } = this.props;
|
2015-10-02 06:10:00 +00:00
|
|
|
return React.createElement("div", { className: "target" },
|
|
|
|
React.createElement("img", {
|
2015-11-15 04:59:00 +00:00
|
|
|
className: "target-icon",
|
2015-10-02 06:10:00 +00:00
|
|
|
src: target.icon }),
|
|
|
|
React.createElement("div", { className: "target-details" },
|
|
|
|
React.createElement("div", { className: "target-name" }, target.name),
|
|
|
|
React.createElement("div", { className: "target-url" }, target.url)
|
|
|
|
),
|
2016-01-28 23:13:48 +00:00
|
|
|
React.createElement("button", {
|
|
|
|
className: "debug-button",
|
|
|
|
onClick: this.debug,
|
|
|
|
disabled: debugDisabled,
|
|
|
|
}, Strings.GetStringFromName("debug"))
|
2015-10-02 06:10:00 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|