Bug 1160361 - Load tilt commands from ToolboxButtons to avoid in non-Firefox. r=bgrins

This commit is contained in:
J. Ryan Stinnett 2015-05-06 12:34:28 -05:00
Родитель c4c5d2e928
Коммит 055a395833
2 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@ -70,7 +70,7 @@ XPCOMUtils.defineLazyGetter(this, "is64Bit", () => {
// White-list buttons that can be toggled to prevent adding prefs for
// addons that have manually inserted toolbarbuttons into DOM.
// (By default, supported target is only local tab)
const ToolboxButtons = [
const ToolboxButtons = exports.ToolboxButtons = [
{ id: "command-button-pick",
isTargetSupported: target =>
target.getTrait("highlightable")
@ -83,7 +83,8 @@ const ToolboxButtons = [
isTargetSupported: target => !target.isAddon },
{ id: "command-button-responsive" },
{ id: "command-button-paintflashing" },
{ id: "command-button-tilt" },
{ id: "command-button-tilt",
commands: "devtools/tilt/tilt-commands" },
{ id: "command-button-scratchpad" },
{ id: "command-button-eyedropper" },
{ id: "command-button-screenshot" },

Просмотреть файл

@ -54,7 +54,6 @@ exports.baseModules = [
* modules that are *not* owned by a tool.
*/
exports.devtoolsModules = [
"devtools/tilt/tilt-commands",
"gcli/commands/addon",
"gcli/commands/appcache",
"gcli/commands/calllog",
@ -88,6 +87,20 @@ try {
exports.devtoolsToolModules = [];
}
/**
* Register commands from toolbox buttons with 'command: [ "some/module" ]'
* definitions. The map/reduce incantation squashes the array of arrays to a
* single array.
*/
try {
const { ToolboxButtons } = require("devtools/framework/toolbox");
exports.devtoolsButtonModules = ToolboxButtons.map(def => def.commands || [])
.reduce((prev, curr) => prev.concat(curr), []);
} catch(e) {
// "devtools/framework/toolbox" is only accessible from Firefox
exports.devtoolsButtonModules = [];
}
/**
* Add modules to a system for use in a content process (but don't call load)
*/
@ -95,6 +108,7 @@ exports.addAllItemsByModule = function(system) {
system.addItemsByModule(exports.baseModules, { delayedLoad: true });
system.addItemsByModule(exports.devtoolsModules, { delayedLoad: true });
system.addItemsByModule(exports.devtoolsToolModules, { delayedLoad: true });
system.addItemsByModule(exports.devtoolsButtonModules, { delayedLoad: true });
const { mozDirLoader } = require("gcli/commands/cmd");
system.addItemsByModule("mozcmd", { delayedLoad: true, loader: mozDirLoader });