Bug 964819 - Be able to mark gcli commands as remote safe and let them show up as command buttons. r=jwalker

This commit is contained in:
Brian Grinstead 2014-09-09 05:55:00 -04:00
parent cfd354388f
commit fb6e55d924
3 changed files with 16 additions and 8 deletions

View File

@ -58,7 +58,8 @@ const ToolboxButtons = [
!target.isAddon && target.activeTab && target.activeTab.traits.frames
)
},
{ id: "command-button-splitconsole" },
{ id: "command-button-splitconsole",
isTargetSupported: target => !target.isAddon },
{ id: "command-button-responsive" },
{ id: "command-button-paintflashing" },
{ id: "command-button-tilt" },
@ -619,11 +620,6 @@ Toolbox.prototype = {
this._buildPickerButton();
}
if (!this.target.isLocalTab) {
this.setToolboxButtonsVisibility();
return Promise.resolve();
}
let spec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
let environment = CommandUtils.createEnvironment(this, '_target');
return CommandUtils.createRequisition(environment).then(requisition => {
@ -631,7 +627,11 @@ Toolbox.prototype = {
return CommandUtils.createButtons(spec, this.target, this.doc,
requisition).then(buttons => {
let container = this.doc.getElementById("toolbox-buttons");
buttons.forEach(container.appendChild.bind(container));
buttons.forEach(button=> {
if (button) {
container.appendChild(button);
}
});
this.setToolboxButtonsVisibility();
});
});
@ -1545,7 +1545,7 @@ Toolbox.prototype = {
// Remove the host UI
outstanding.push(this.destroyHost());
if (this.target.isLocalTab) {
if (this._requisition) {
this._requisition.destroy();
}
this._telemetry.toolClosed("toolbox");

View File

@ -104,6 +104,13 @@ let CommandUtils = {
if (command == null) {
throw new Error("No command '" + typed + "'");
}
// Do not build a button for a non-remote safe command in a non-local target.
if (!target.isLocalTab && !command.isRemoteSafe) {
requisition.clear();
return;
}
if (command.buttonId != null) {
button.id = command.buttonId;
if (command.buttonClass != null) {

View File

@ -14,6 +14,7 @@ exports.items = [
buttonId: "command-button-splitconsole",
buttonClass: "command-button command-button-invertable",
tooltipText: gcli.lookup("splitconsoleTooltip"),
isRemoteSafe: true,
state: {
isChecked: function(target) {
let toolbox = gDevTools.getToolbox(target);