browser/components/extensions/schemas/browser_action.json
author Noemi Erli <nerli@mozilla.com>
Fri, 15 Nov 2019 18:57:20 +0200
changeset 502238 61ebc1a22544fa44ac2a4f9a2f120488a5f1d614
parent 502231 toolkit/components/extensions/schemas/browser_action.json@597e32ad2f5b95e47aa1f4e03dff78b1bd0b7b39
permissions -rw-r--r--
Backed out 13 changesets (bug 1530402, bug 1533156) for causing raptor failures CLOSED TREE Backed out changeset 6d7b7d22b0c6 (bug 1530402) Backed out changeset acea32ec5975 (bug 1530402) Backed out changeset 597e32ad2f5b (bug 1530402) Backed out changeset 352068fe68bc (bug 1530402) Backed out changeset e0ae4f16f7ed (bug 1530402) Backed out changeset 282b033c7daa (bug 1530402) Backed out changeset 72274a5a821b (bug 1530402) Backed out changeset 3d3366fe476f (bug 1530402) Backed out changeset 7400c3fd2b5f (bug 1530402) Backed out changeset 23d43a425641 (bug 1530402) Backed out changeset 83b9603f5fa1 (bug 1530402) Backed out changeset 50c50a80e881 (bug 1533156) Backed out changeset 5975264fd34b (bug 1530402)

// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

[
  {
    "namespace": "manifest",
    "types": [
      {
        "$extend": "WebExtensionManifest",
        "properties": {
          "browser_action": {
            "type": "object",
            "additionalProperties": { "$ref": "UnrecognizedProperty" },
            "properties": {
              "default_title": {
                "type": "string",
                "optional": true,
                "preprocess": "localize"
              },
              "default_icon": {
                "$ref": "IconPath",
                "optional": true
              },
              "theme_icons": {
                "type": "array",
                "optional": true,
                "minItems": 1,
                "items": { "$ref": "ThemeIcons" },
                "description": "Specifies icons to use for dark and light themes"
              },
              "default_popup": {
                "type": "string",
                "format": "relativeUrl",
                "optional": true,
                "preprocess": "localize"
              },
              "browser_style": {
                "type": "boolean",
                "optional": true,
                "default": false
              },
              "default_area": {
                "description": "Defines the location the browserAction will appear by default.  The default location is navbar.",
                "type": "string",
                "enum": ["navbar", "menupanel", "tabstrip", "personaltoolbar"],
                "optional": true
              }
            },
            "optional": true
          }
        }
      }
    ]
  },
  {
    "namespace": "browserAction",
    "description": "Use browser actions to put icons in the main browser toolbar, to the right of the address bar. In addition to its icon, a browser action can also have a tooltip, a badge, and a popup.",
    "permissions": ["manifest:browser_action"],
    "types": [
      {
        "id": "Details",
        "type": "object",
        "description": "Specifies to which tab or window the value should be set, or from which one it should be retrieved. If no tab nor window is specified, the global value is set or retrieved.",
        "properties": {
          "tabId": {
            "type": "integer",
            "optional": true,
            "minimum": 0,
            "description": "When setting a value, it will be specific to the specified tab, and will automatically reset when the tab navigates. When getting, specifies the tab to get the value from; if there is no tab-specific value, the window one will be inherited."
          },
          "windowId": {
            "type": "integer",
            "optional": true,
            "minimum": -2,
            "description": "When setting a value, it will be specific to the specified window. When getting, specifies the window to get the value from; if there is no window-specific value, the global one will be inherited."
          }
        }
      },
      {
        "id": "ColorArray",
        "type": "array",
        "items": {
          "type": "integer",
          "minimum": 0,
          "maximum": 255
        },
        "minItems": 4,
        "maxItems": 4
      },
      {
        "id": "ImageDataType",
        "type": "object",
        "isInstanceOf": "ImageData",
        "additionalProperties": { "type": "any" },
        "postprocess": "convertImageDataToURL",
        "description": "Pixel data for an image. Must be an ImageData object (for example, from a <code>canvas</code> element)."
      },
      {
        "id": "ColorValue",
        "description": "An array of four integers in the range [0,255] that make up the RGBA color of the badge. For example, opaque red is <code>[255, 0, 0, 255]</code>. Can also be a string with a CSS value, with opaque red being <code>#FF0000</code> or <code>#F00</code>.",
        "choices": [
          {"type": "string"},
          {"$ref": "ColorArray"},
          {"type": "null"}
        ]
      },
      {
        "id": "OnClickData",
        "type": "object",
        "description": "Information sent when a browser action is clicked.",
        "properties": {
          "modifiers": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": ["Shift", "Alt", "Command", "Ctrl", "MacCtrl"]
            },
            "description": "An array of keyboard modifiers that were held while the menu item was clicked."
          },
          "button": {
            "type": "integer",
            "optional": true,
            "description": "An integer value of button by which menu item was clicked."
          }
        }
      }
    ],
    "functions": [
      {
        "name": "setTitle",
        "type": "function",
        "description": "Sets the title of the browser action. This shows up in the tooltip.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "title": {
                "choices": [
                  {"type": "string"},
                  {"type": "null"}
                ],
                "description": "The string the browser action should display when moused over."
              }
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "getTitle",
        "type": "function",
        "description": "Gets the title of the browser action.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          },
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "result",
                "type": "string"
              }
            ]
          }
        ]
      },
      {
        "name": "setIcon",
        "type": "function",
        "description": "Sets the icon for the browser action. The icon can be specified either as the path to an image file or as the pixel data from a canvas element, or as dictionary of either one of those. Either the <b>path</b> or the <b>imageData</b> property must be specified.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "imageData": {
                "choices": [
                  { "$ref": "ImageDataType" },
                  {
                    "type": "object",
                    "patternProperties": {
                      "^[1-9]\\d*$": {"$ref": "ImageDataType"}
                    }
                  }
                ],
                "optional": true,
                "description": "Either an ImageData object or a dictionary {size -> ImageData} representing icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.imageData = foo' is equivalent to 'details.imageData = {'19': foo}'"
              },
              "path": {
                "choices": [
                  { "type": "string" },
                  {
                    "type": "object",
                    "patternProperties": {
                      "^[1-9]\\d*$": { "type": "string" }
                    }
                  }
                ],
                "optional": true,
                "description": "Either a relative image path or a dictionary {size -> relative image path} pointing to icon to be set. If the icon is specified as a dictionary, the actual image to be used is chosen depending on screen's pixel density. If the number of image pixels that fit into one screen space unit equals <code>scale</code>, then image with size <code>scale</code> * 19 will be selected. Initially only scales 1 and 2 will be supported. At least one image must be specified. Note that 'details.path = foo' is equivalent to 'details.imageData = {'19': foo}'"
              }
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "setPopup",
        "type": "function",
        "description": "Sets the html document to be opened as a popup when the user clicks on the browser action's icon.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "popup": {
                "choices": [
                  {"type": "string"},
                  {"type": "null"}
                ],
                "description": "The html file to show in a popup.  If set to the empty string (''), no popup is shown."
              }
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "getPopup",
        "type": "function",
        "description": "Gets the html document set as the popup for this browser action.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          },
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "result",
                "type": "string"
              }
            ]
          }
        ]
      },
      {
        "name": "setBadgeText",
        "type": "function",
        "description": "Sets the badge text for the browser action. The badge is displayed on top of the icon.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "text": {
                "choices": [
                  {"type": "string"},
                  {"type": "null"}
                ],
                "description": "Any number of characters can be passed, but only about four can fit in the space."
              }
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "getBadgeText",
        "type": "function",
        "description": "Gets the badge text of the browser action. If no tab nor window is specified is specified, the global badge text is returned.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          },
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "result",
                "type": "string"
              }
            ]
          }
        ]
      },
      {
        "name": "setBadgeBackgroundColor",
        "type": "function",
        "description": "Sets the background color for the badge.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "color": { "$ref": "ColorValue" }
            }
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "getBadgeBackgroundColor",
        "type": "function",
        "description": "Gets the background color of the browser action badge.",
        "async": "callback",
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          },
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "result",
                "$ref": "ColorArray"
              }
            ]
          }
        ]
      },
      {
        "name": "setBadgeTextColor",
        "type": "function",
        "description": "Sets the text color for the badge.",
        "async": true,
        "parameters": [
          {
            "name": "details",
            "type": "object",
            "$import": "Details",
            "properties": {
              "color": { "$ref": "ColorValue" }
            }
          }
        ]
      },
      {
        "name": "getBadgeTextColor",
        "type": "function",
        "description": "Gets the text color of the browser action badge.",
        "async": true,
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          }
        ]
      },
      {
        "name": "enable",
        "type": "function",
        "description": "Enables the browser action for a tab. By default, browser actions are enabled.",
        "async": "callback",
        "parameters": [
          {
            "type": "integer",
            "optional": true,
            "name": "tabId",
            "minimum": 0,
            "description": "The id of the tab for which you want to modify the browser action."
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "disable",
        "type": "function",
        "description": "Disables the browser action for a tab.",
        "async": "callback",
        "parameters": [
          {
            "type": "integer",
            "optional": true,
            "name": "tabId",
            "minimum": 0,
            "description": "The id of the tab for which you want to modify the browser action."
          },
          {
            "type": "function",
            "name": "callback",
            "optional": true,
            "parameters": []
          }
        ]
      },
      {
        "name": "isEnabled",
        "type": "function",
        "description": "Checks whether the browser action is enabled.",
        "async": true,
        "parameters": [
          {
            "name": "details",
            "$ref": "Details"
          }
        ]
      },
      {
        "name": "openPopup",
        "type": "function",
        "requireUserInput": true,
        "description": "Opens the extension popup window in the active window.",
        "async": true,
        "parameters": []
      }
    ],
    "events": [
      {
        "name": "onClicked",
        "type": "function",
        "description": "Fired when a browser action icon is clicked.  This event will not fire if the browser action has a popup.",
        "parameters": [
          {
            "name": "tab",
            "$ref": "tabs.Tab"
          },
          {
            "name": "info",
            "$ref": "OnClickData",
            "optional": true
          }
        ]
      }
    ]
  }
]