chromium/third_party/closure_compiler/externs/terminal_private.js

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This file was generated by:
//   tools/json_schema_compiler/compiler.py.
// NOTE: The format of types has changed. 'FooType' is now
//   'chrome.terminalPrivate.FooType'.
// Please run the closure compiler before committing changes.
// See https://chromium.googlesource.com/chromium/src/+/main/docs/closure_compilation.md

/**
 * @fileoverview Externs generated from namespace: terminalPrivate
 * @externs
 */

/** @const */
chrome.terminalPrivate = {};

/**
 * @enum {string}
 */
chrome.terminalPrivate.OutputType = {
  STDOUT: 'stdout',
  STDERR: 'stderr',
  EXIT: 'exit',
};

/**
 * Starts new process.
 * @param {string} processName Name of the process to open. May be 'crosh' or
 *     'vmshell'.
 * @param {?Array<string>|undefined} args Command line arguments to pass to the
 *     process.
 * @param {function(string): void} callback Returns id of the launched process.
 *     If no process was launched returns -1.
 */
chrome.terminalPrivate.openTerminalProcess = function(processName, args, callback) {};

/**
 * Starts new vmshell process.
 * @param {?Array<string>|undefined} args Command line arguments to pass to
 *     vmshell.
 * @param {function(string): void} callback Returns id of the launched vmshell
 *     process. If no process was launched returns -1.
 */
chrome.terminalPrivate.openVmshellProcess = function(args, callback) {};

/**
 * Closes previously opened process from either openTerminalProcess or
 * openVmshellProcess.
 * @param {string} id Unique id of the process we want to close.
 * @param {function(boolean): void=} callback Function that gets called when
 *     close operation is started for the process. Returns success of the
 *     function.
 */
chrome.terminalPrivate.closeTerminalProcess = function(id, callback) {};

/**
 * Sends input that will be routed to stdin of the process with the specified
 * id.
 * @param {string} id The id of the process to which we want to send input.
 * @param {string} input Input we are sending to the process.
 * @param {function(boolean): void=} callback Callback that will be called when
 *     sendInput method ends. Returns success.
 */
chrome.terminalPrivate.sendInput = function(id, input, callback) {};

/**
 * Notify the process with the id id that terminal window size has changed.
 * @param {string} id The id of the process.
 * @param {number} width New window width (as column count).
 * @param {number} height New window height (as row count).
 * @param {function(boolean): void=} callback Callback that will be called when
 *     sendInput method ends. Returns success.
 */
chrome.terminalPrivate.onTerminalResize = function(id, width, height, callback) {};

/**
 * 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.
 * @param {string} id The id of the process to which |onProcessOutput| was
 *     dispatched.
 */
chrome.terminalPrivate.ackOutput = function(id) {};

/**
 * Open a Terminal app window/tab
 * @param {{
 *   url: (string|undefined),
 *   asTab: (boolean|undefined)
 * }=} data
 */
chrome.terminalPrivate.openWindow = function(data) {};

/**
 * Open the Terminal Settings page.
 * @param {function(): void} callback Callback that will be called when
 *     complete.
 */
chrome.terminalPrivate.openOptionsPage = function(callback) {};

/**
 * Open the System Settings at the specified subpage.
 * @param {string} subpage Name of subpage to open.  Currently only 'crostini'
 *     supported.
 * @param {function(): void} callback Callback that will be called when
 *     complete.
 */
chrome.terminalPrivate.openSettingsSubpage = function(subpage, callback) {};

/**
 * Returns an object containing info about ChromeOS settings that affect the
 * Terminal, e.g. which feature flags are enabled.
 * @param {function({
 *   tast: boolean
 * }): void} callback Callback that will be called with the info object.
 */
chrome.terminalPrivate.getOSInfo = function(callback) {};

/**
 * Returns specified pref values, ignoring any not in allowlist.
 * @param {!Array<string>} paths Paths of prefs to fetch.
 * @param {function(Object): void} callback Callback that will be called with
 *     prefs.
 */
chrome.terminalPrivate.getPrefs = function(paths, callback) {};

/**
 * Sets specified prefs, ignoring any not in allowlist.
 * @param {Object} prefs Prefs to update keyed by paths.
 * @param {function(): void} callback Callback that will be called when
 *     complete.
 */
chrome.terminalPrivate.setPrefs = function(prefs, callback) {};

/**
 * 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.
 * @type {!ChromeEvent}
 */
chrome.terminalPrivate.onProcessOutput;

/**
 * Fired when pref changes.
 * @type {!ChromeEvent}
 */
chrome.terminalPrivate.onPrefChanged;