// 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": "terminalPrivate",
    "compiler_options": {
      "implemented_in": "chrome/browser/extensions/api/terminal/terminal_private_api.h"
    },
    "description": "none",
    "types": [
      {
        "id": "OutputType",
        "type": "string",
        "enum": ["stdout", "stderr", "exit"],
        "description": "Type of the output stream from which output came. When process exits, output type will be set to exit"
      }
    ],
    "functions": [
      {
        "name": "openTerminalProcess",
        "type": "function",
        "description": "Starts new process.",
        "parameters": [
          {
            "type": "string",
            "name": "processName",
            "description": "Name of the process to open. May be 'crosh' or 'vmshell'."
          },
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "name": "args",
            "optional": true,
            "description": "Command line arguments to pass to the process."
          }
        ],
        "returns_async": {
          "name": "callback",
          "description": "Returns id of the launched process. If no process was launched returns -1.",
          "parameters": [
            {
              "name": "id",
              "description": "Id of the launched process.",
              "type": "string"
            }
          ]
        }
      },
      {
        "name": "openVmshellProcess",
        "type": "function",
        "description": "Starts new vmshell process.",
        "parameters": [
          {
            "type": "array",
            "items": {
              "type": "string"
            },
            "name": "args",
            "optional": true,
            "description": "Command line arguments to pass to vmshell."
          }
        ],
        "returns_async": {
          "name": "callback",
          "description": "Returns id of the launched vmshell process. If no process was launched returns -1.",
          "parameters": [
            {
              "name": "id",
              "description": "Id of the launched vmshell process.",
              "type": "string"
            }
          ]
        }
      },
      {
        "name": "closeTerminalProcess",
        "type": "function",
        "description": "Closes previously opened process from either openTerminalProcess or openVmshellProcess.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "Unique id of the process we want to close."
          }
        ],
        "returns_async": {
          "name": "callback",
          "optional": true,
          "description": "Function that gets called when close operation is started for the process. Returns success of the function.",
          "parameters": [
            {
              "name": "success",
              "type": "boolean"
            }
          ]
        }
      },
      {
        "name": "sendInput",
        "type": "function",
        "description": "Sends input that will be routed to stdin of the process with the specified id.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "The id of the process to which we want to send input."
          },
          {
            "name": "input",
            "type": "string",
            "description": "Input we are sending to the process."
          }
        ],
        "returns_async": {
          "name": "callback",
          "optional": true,
          "description": "Callback that will be called when sendInput method ends. Returns success.",
          "parameters": [
            {
              "name": "success",
              "type": "boolean"
            }
          ]
        }
      },
      {
        "name": "onTerminalResize",
        "type": "function",
        "description": "Notify the process with the id id that terminal window size has changed.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "The id of the process."
          },
          {
            "name": "width",
            "type": "integer",
            "description": "New window width (as column count)."
          },
          {
            "name": "height",
            "type": "integer",
            "description": "New window height (as row count)."
          }
        ],
        "returns_async": {
          "name": "callback",
          "optional": true,
          "description": "Callback that will be called when sendInput method ends. Returns success.",
          "parameters": [
            {
              "name": "success",
              "type": "boolean"
            }
          ]
        }
      },
      {
        "name": "ackOutput",
        "type": "function",
        "description": "Called from |onProcessOutput| when the event is dispatched to terminal extension. Observing the terminal process output will be paused after |onProcessOutput| is dispatched until this method is called.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "The id of the process to which |onProcessOutput| was dispatched."
          }
        ]
      },
      {
        "name": "openWindow",
        "type": "function",
        "description": "Open the Terminal tabbed window.",
        "parameters": [
          {
            "name": "data",
            "type": "object",
	    "optional": true,
            "properties": {
              "url": {
                "description": "The url for the new Terminal window.",
                "optional": true,
		"type": "string"
              }
	    }
          }
        ]
      },
      {
        "name": "openOptionsPage",
        "type": "function",
        "description": "Open the Terminal Settings page.",
        "parameters": [],
        "returns_async": {
          "name": "callback",
          "description": "Callback that will be called when complete.",
          "parameters": []
        }
      },
      {
        "name": "getOSInfo",
        "type": "function",
        "description": "Returns an object containing info about ChromeOS settings that affect the Terminal, e.g. which feature flags are enabled.",
        "parameters": [],
        "returns_async": {
          "name": "callback",
          "description": "Callback that will be called with the info object.",
          "parameters": [
            {
              "name": "info",
              "type": "object",
	      "properties": {
	        "tmux_integration": {
                  "description": "True if tmux control mode integration is enabled.",
                  "type": "boolean"
                }
	      },
              "description": "Information about which features are enabled."
            }
          ]
        }
      },
      {
        "name": "getSettings",
        "type": "function",
        "description": "Returns an object (DictionaryValue) containing UI settings such as font style and colors used by terminal and stored as a syncable pref.  The UI currently has ~70 properties and we wish to allow flexibility for these to change in the UI without updating this API, so we allow any properties.",
        "parameters": [],
        "returns_async": {
          "name": "callback",
          "description": "Callback that will be called with settings.",
          "parameters": [
            {
              "name": "settings",
              "type": "object",
              "additionalProperties":
                {
                  "type": "any" ,
                  "preserveNull": true
                },
              "description": "Settings from prefs.",
              "preserveNull": true
            }
          ]
        }
      },
      {
        "name": "setSettings",
        "type": "function",
        "description": "Sets terminal UI settings which are stored as a syncable pref.",
        "parameters": [
          {
            "name": "settings",
            "type": "object",
            "description": "Settings to update into prefs.",
            "additionalProperties":
              {
                "type": "any" ,
                "preserveNull": true
              },
            "preserveNull": true
          }
        ],
        "returns_async": {
          "name": "callback",
          "description": "Callback that will be called when complete.",
          "parameters": []
        }
      },
      {
        "name": "getA11yStatus",
        "type": "function",
        "description": "Returns a boolean indicating whether the accessibility spoken feedback is on.",
        "parameters": [],
        "returns_async": {
          "name": "callback",
          "description": "Callback that will be called with the a11y status.",
          "parameters": [
            {
              "name": "a11yStatus",
              "type": "boolean",
              "description": "True if a11y spoken feedback is on."
            }
          ]
        }
      }
    ],
    "events": [
      {
        "name": "onProcessOutput",
        "type": "function",
        "description": "Fired when an opened process writes something to its output. Observing further process output will be blocked until |ackOutput| for the terminal is called. Internally, first event argument will be ID of the tab that contains terminal instance for which this event is intended. This argument will be stripped before passing the event to the extension.",
        "parameters": [
          {
            "name": "id",
            "type": "string",
            "description": "Id of the process from which the output came."
          },
          {
            "name": "type",
            "$ref": "OutputType",
            "description": "Type of the output stream from which output came. When process exits, output type will be set to exit"
          },
          {
            "name": "text",
            "type": "string",
            "description": "Text that was written to the output stream."
          }
        ]
      },
      {
        "name": "onSettingsChanged",
        "type": "function",
        "description": "Fired when terminal UI settings change.",
        "parameters": [
          {
            "name": "settings",
            "type": "object",
            "description": "Terminal UI Settings with updated values.",
            "additionalProperties":
              {
                "type": "any" ,
                "preserveNull": true
              },
            "preserveNull": true
          }
        ]
      },
      {
        "name": "onA11yStatusChanged",
        "type": "function",
        "description": "Fired when a11y spoken feedback is enabled/disabled.",
        "parameters": [
          {
            "name": "status",
            "type": "boolean",
            "description": "True if a11y spoken feedback is on."
          }
        ]
      }
    ]
  }
]