// Copyright 2014 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": "accessibilityPrivate",
    "compiler_options": {
      "implemented_in": "chrome/browser/accessibility/accessibility_extension_api.h"
    },
    "description": "none",
    "types": [
      {
        "id": "CheckboxDetails",
        "type": "object",
        "description": "Information about the state of a checkbox.",
        "properties": {
          "isChecked": {"type": "boolean", "description": "True if this checkbox is checked."}
        }
      },
      {
        "id": "ComboBoxDetails",
        "type": "object",
        "description": "Information about the state of a combo box.",
        "properties": {
          "value": {"type": "string", "description": "The value of the combo box."},
          "itemCount": {"type": "integer", "description": "The number of items in the combo box's list."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of the current value, or -1 if the user entered a value not from the list."}
        }
      },
      {
        "id": "ListBoxDetails",
        "type": "object",
        "description": "Information about the state of a list box.",
        "properties": {
          "value": {"type": "string", "description": "The value of the list box."},
          "itemCount": {"type": "integer", "description": "The number of items in the list."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of the selected value, or -1 if no items are selected."}
        }
      },
      {
        "id": "MenuDetails",
        "type": "object",
        "description": "Information about the state of a drop-down menu.",
        "properties": {
        }
      },
      {
        "id": "MenuItemDetails",
        "type": "object",
        "description": "Information about a menu item.",
        "properties": {
          "hasSubmenu": {"type": "boolean", "description": "True if this item opens a submenu."},
          "itemCount": {"type": "integer", "description": "The number of items in the menu."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of this menu item."}
        }
      },
      {
        "id": "RadioButtonDetails",
        "type": "object",
        "description": "Information about the state of a radio button.",
        "properties": {
          "isChecked": {"type": "boolean", "description": "True if this radio button is checked."},
          "itemCount": {"type": "integer", "description": "The number of radio buttons in this group."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of this radio button in this group."}
        }
      },
      {
        "id": "SliderDetails",
        "type": "object",
        "description": "Information about the state of a slider.",
        "properties": {
          "stringValue": {"type": "string", "description": "The value of the slider as a string."}
        }
      },
      {
        "id": "TabDetails",
        "type": "object",
        "description": "Additional accessibility information about a tab.",
        "properties": {
          "itemCount": {"type": "integer", "description": "The number of tabs in this group."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of this tab in this group."}
        }
      },
      {
        "id": "TextBoxDetails",
        "type": "object",
        "description": "Information about the state of a text box.",
        "properties": {
          "value": {"type": "string", "description": "The value of the text box - the entered text."},
          "isPassword": {"type": "boolean", "description": "True if this control contains password text whose contents should be obscured."},
          "selectionStart": {"type": "integer", "description": "The index of the character where the selection starts, if this control contains editable text."},
          "selectionEnd": {"type": "integer", "description": "The index of the character where the selection ends, if this control contains editable text."}
        }
      },
      {
        "id": "TreeDetails",
        "type": "object",
        "description": "Information about the state of a tree control.",
        "properties": {
        }
      },
      {
        "id": "TreeItemDetails",
        "type": "object",
        "description": "Information about a selected tree control item.",
        "properties": {
          "itemDepth": {"type": "integer", "description": "The 0-based depth of this tree item."},
          "itemCount": {"type": "integer", "description": "The number of items in the current depth."},
          "itemIndex": {"type": "integer", "description": "The 0-based index of this tree item at the current tree depth."},
          "childrenCount": {"type": "integer", "description": "The number of children of the current tree item."},
          "isItemExpanded": {"type": "boolean", "description": "True if this if this tree item is expanded."}
        }
      },
      {
        "id": "AlertInfo",
        "type": "object",
        "description": "Information about an alert",
        "properties": {
          "message": {
            "type": "string",
            "description": "The message the alert is showing."
          }
        }
      },
      {
        "id": "AccessibilityObject",
        "type": "object",
        "description": "Parent class for accessibility information about an object.",
        "properties": {
          "type": {
            "type": "string",
            "description": "The type of this object, which determines the contents of 'details'.",
            "enum": ["alert", "button", "checkbox", "combobox", "link", "menu", "menuitem", "radiobutton", "slider", "tab", "textbox", "tree", "treeitem", "window"]
          },
          "name": {
            "type": "string",
            "description": "The localized name of the object, like OK or Password. Do not rely on an exact string match because the text will be in the user's language and may change in the future."
          },
          "context": {
            "type": "string",
            "description": "The localized name of the context for the object, like the name of the surrounding toolbar or group of controls.",
            "optional": true
          },
          "details": {
            "description": "Other details like the state, depending on the type of object.",
            "optional": true,
            "choices": [
              { "$ref": "CheckboxDetails" },
              { "$ref": "ComboBoxDetails" },
              { "$ref": "MenuDetails" },
              { "$ref": "MenuItemDetails" },
              { "$ref": "RadioButtonDetails" },
              { "$ref": "SliderDetails" },
              { "$ref": "TabDetails" },
              { "$ref": "TextBoxDetails" },
              { "$ref": "TreeDetails" },
              { "$ref": "TreeItemDetails" }
            ]
          }
        }
      }
    ],
    "functions": [
      {
        "name": "setAccessibilityEnabled",
        "type": "function",
        "description": "Enables or disables the accessibility extension api. This must be set to true before event listeners or getFocusedControl will work.",
        "parameters": [
          {
            "type": "boolean",
            "name": "enabled",
            "description": "True if accessibility support should be enabled."
          }
        ]
      },
      {
        "name": "setNativeAccessibilityEnabled",
        "type": "function",
        "description": "Enables or disables native accessibility support. Once disabled, it is up to the calling extension to provide accessibility for web contents.",
        "parameters": [
          {
            "type": "boolean",
            "name": "enabled",
            "description": "True if native accessibility support should be enabled."
          }
        ]
      },
      {
        "name": "getFocusedControl",
        "type": "function",
        "description": "Gets information about the currently focused control.",
        "parameters": [
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "control",
                "description": "Details of the currently focused control, or null if nothing is focused.",
                "$ref": "AccessibilityObject",
                "optional": true
              }
            ]
          }
        ]
      },
      {
        "name": "getAlertsForTab",
        "type": "function",
        "description": "Gets alerts being shown on the given tab.",
        "parameters": [
          {
            "name": "tabId",
            "type": "integer",
            "minimum": 0
          },
          {
            "type": "function",
            "name": "callback",
            "parameters": [
              {
                "name": "alerts",
                "type": "array",
                "items": { "$ref": "AlertInfo" },
                "description": "Alerts being shown on the given tab."
              }
            ]
          }
        ]
      }
    ],
    "events": [
      {
        "name": "onWindowOpened",
        "type": "function",
        "description": "Fired when a window is opened.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "window",
            "description": "Information about the window that was opened."
          }
        ]
      },
      {
        "name": "onWindowClosed",
        "type": "function",
        "description": "Fired when a window is closed.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "window",
            "description": "Information about the window that was closed."
          }
        ]
      },
      {
        "name": "onControlFocused",
        "type": "function",
        "description": "Fired when a control is focused.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "control",
            "description": "Details of the control that was focused."
          }
        ]
      },
      {
        "name": "onControlAction",
        "type": "function",
        "description": "Fired when a control's action is taken, like pressing a button or toggling a checkbox.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "control",
            "description": "Details of the control whose action was taken."
          }
        ]
      },
      {
        "name": "onControlHover",
        "type": "function",
        "description": "Fired when a control is hovered over with the mouse, or hit with accessible touch exploration.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "control",
            "description": "Details of the control that was hovered over."
          }
        ]
      },
      {
        "name": "onTextChanged",
        "type": "function",
        "description": "Fired when text changes in an editable text control.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "control",
            "description": "Details of the control where the text changed."
          }
        ]
      },
      {
        "name": "onMenuOpened",
        "type": "function",
        "description": "Fired when a menu is opened.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "menu",
            "description": "Information about the menu that was opened."
          }
        ]
      },
      {
        "name": "onMenuClosed",
        "type": "function",
        "description": "Fired when a menu is closed.",
        "parameters": [
          {
            "$ref": "AccessibilityObject",
            "name": "menu",
            "description": "Information about the menu that was closed."
          }
        ]
      },
      {
        "name": "onChromeVoxLoadStateChanged",
        "type": "function",
        "description": "Fired ChromeVox load state changes.",
        "parameters": [
          {
            "type": "boolean",
            "name": "loading",
            "description": "True if ChromeVox is loading; false if ChromeVox is unloading."
          },
          {
            "type": "boolean",
            "name": "makeAnnouncements",
            "description": "Whether to make introductory announcements."
          }
        ]
      }
    ]
  }
]