AUTOMATED - new files under control

This commit is contained in:
uazo
2024-03-10 10:27:59 +00:00
committed by GitHub
parent d62bb78c21
commit dbacbb5d25
2219 changed files with 98926 additions and 1 deletions
+102
View File
@@ -0,0 +1,102 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.alarms</code> API to schedule code to run
// periodically or at a specified time in the future.
namespace alarms {
dictionary Alarm {
// Name of this alarm.
DOMString name;
// Time at which this alarm was scheduled to fire, in milliseconds past the
// epoch (e.g. <code>Date.now() + n</code>). For performance reasons, the
// alarm may have been delayed an arbitrary amount beyond this.
double scheduledTime;
// If not null, the alarm is a repeating alarm and will fire again in
// <var>periodInMinutes</var> minutes.
double? periodInMinutes;
};
// TODO(mpcomplete): rename to CreateInfo when http://crbug.com/123073 is
// fixed.
dictionary AlarmCreateInfo {
// Time at which the alarm should fire, in milliseconds past the epoch
// (e.g. <code>Date.now() + n</code>).
double? when;
// Length of time in minutes after which the <code>onAlarm</code> event
// should fire.
//
// <!-- TODO: need minimum=0 -->
double? delayInMinutes;
// If set, the onAlarm event should fire every <var>periodInMinutes</var>
// minutes after the initial event specified by <var>when</var> or
// <var>delayInMinutes</var>. If not set, the alarm will only fire once.
//
// <!-- TODO: need minimum=0 -->
double? periodInMinutes;
};
callback VoidCallback = void ();
callback AlarmCallback = void (optional Alarm alarm);
callback AlarmListCallback = void (Alarm[] alarms);
callback ClearCallback = void (boolean wasCleared);
interface Functions {
// Creates an alarm. Near the time(s) specified by <var>alarmInfo</var>,
// the <code>onAlarm</code> event is fired. If there is another alarm with
// the same name (or no name if none is specified), it will be cancelled and
// replaced by this alarm.
//
// In order to reduce the load on the user's machine, Chrome limits alarms
// to at most once every 30 seconds but may delay them an arbitrary amount
// more. That is, setting <code>delayInMinutes</code> or
// <code>periodInMinutes</code> to less than <code>0.5</code> will not be
// honored and will cause a warning. <code>when</code> can be set to less
// than 30 seconds after "now" without warning but won't actually cause the
// alarm to fire for at least 30 seconds.
//
// To help you debug your app or extension, when you've loaded it unpacked,
// there's no limit to how often the alarm can fire.
//
// |name|: Optional name to identify this alarm. Defaults to the empty
// string.
// |alarmInfo|: Describes when the alarm should fire. The initial time must
// be specified by either <var>when</var> or <var>delayInMinutes</var> (but
// not both). If <var>periodInMinutes</var> is set, the alarm will repeat
// every <var>periodInMinutes</var> minutes after the initial event. If
// neither <var>when</var> or <var>delayInMinutes</var> is set for a
// repeating alarm, <var>periodInMinutes</var> is used as the default for
// <var>delayInMinutes</var>.
// |callback|: Invoked when the alarm has been created.
[supportsPromises] static void create(
optional DOMString name,
AlarmCreateInfo alarmInfo,
optional VoidCallback callback);
// Retrieves details about the specified alarm.
// |name|: The name of the alarm to get. Defaults to the empty string.
[supportsPromises] static void get(optional DOMString name,
AlarmCallback callback);
// Gets an array of all the alarms.
[supportsPromises] static void getAll(AlarmListCallback callback);
// Clears the alarm with the given name.
// |name|: The name of the alarm to clear. Defaults to the empty string.
[supportsPromises] static void clear(optional DOMString name,
optional ClearCallback callback);
// Clears all alarms.
[supportsPromises] static void clearAll(optional ClearCallback callback);
};
interface Events {
// Fired when an alarm has elapsed. Useful for event pages.
// |alarm|: The alarm that has elapsed.
static void onAlarm(Alarm alarm);
};
};
@@ -0,0 +1,66 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is used by the app window API internally to pass through messages to
// the shell window.
namespace app.currentWindowInternal {
// Null or undefined indicates that a value should not change.
dictionary Bounds {
long? left;
long? top;
long? width;
long? height;
};
// Null or undefined indicates that a value should not change. A value of 0
// will clear the constraints.
dictionary SizeConstraints {
long? minWidth;
long? minHeight;
long? maxWidth;
long? maxHeight;
};
dictionary RegionRect {
long left;
long top;
long width;
long height;
};
dictionary Region {
RegionRect[]? rects;
};
interface Functions {
static void focus();
static void fullscreen();
static void minimize();
static void maximize();
static void restore();
static void drawAttention();
static void clearAttention();
static void show(optional boolean focused);
static void hide();
static void setBounds(DOMString boundsType, Bounds bounds);
static void setSizeConstraints(DOMString boundsType,
SizeConstraints constraints);
static void setIcon(DOMString icon_url);
static void setShape(Region region);
static void setAlwaysOnTop(boolean always_on_top);
static void setVisibleOnAllWorkspaces(boolean always_visible);
static void setActivateOnPointer(boolean activate_on_pointer);
};
interface Events {
static void onClosed();
static void onBoundsChanged();
static void onFullscreened();
static void onMinimized();
static void onMaximized();
static void onRestored();
static void onAlphaEnabledChanged();
};
};
@@ -0,0 +1,163 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.app.runtime</code> API to manage the app lifecycle.
// The app runtime manages app installation, controls the event page, and can
// shut down the app at anytime.
namespace app.runtime {
[inline_doc] dictionary LaunchItem {
// Entry for the item.
[instanceOf=Entry] object entry;
// The MIME type of the file.
DOMString? type;
};
// Enumeration of app launch sources.
// This should be kept in sync with AppLaunchSource in
// components/services/app_service/public/mojom/types.mojom, and
// GetLaunchSourceEnum() in
// extensions/browser/api/app_runtime/app_runtime_api.cc.
// Note the enumeration is used in UMA histogram so entries
// should not be re-ordered or removed.
enum LaunchSource {
untracked,
app_launcher,
new_tab_page,
reload,
restart,
load_and_launch,
command_line,
file_handler,
url_handler,
system_tray,
about_page,
keyboard,
extensions_page,
management_api,
ephemeral_app,
background,
kiosk,
chrome_internal,
test,
installed_notification,
context_menu,
arc,
intent_url,
app_home_page
};
// An app can be launched with a specific action in mind, for example, to
// create a new note. The type of action the app was launched
// with is available inside of the |actionData| field from the LaunchData
// instance.
enum ActionType {
// The user wants to quickly take a new note.
new_note
};
// Optional data that includes action-specific launch information.
dictionary ActionData {
ActionType actionType;
// <p>Whether the action was requested on Chrome OS lock screen.</p>
// <p>
// Launch events with this valued set to <code>true</code> are fired
// in lock screen context, where apps have reduced access to extension
// APIs, but are able to create windows on lock screen.
// </p>
// <p>
// Note that this value will be set to <code>true</code> only if the app
// is set as the lock screen enabled action handler by the user.
// </p>
[nodoc] boolean? isLockScreenAction;
// Currently, used only with lock screen actions. If set, indicates whether
// the app should attempt to restore state from when the action was last
// handled.
[nodoc] boolean? restoreLastActionState;
};
// Optional data for the launch. Either <code>items</code>, or
// the pair (<code>url, referrerUrl</code>) can be present for any given
// launch.
[inline_doc] dictionary LaunchData {
// The ID of the file or URL handler that the app is being invoked with.
// Handler IDs are the top-level keys in the <code>file_handlers</code>
// and/or <code>url_handlers</code> dictionaries in the manifest.
DOMString? id;
// The file entries for the <code>onLaunched</code> event triggered by a
// matching file handler in the <code>file_handlers</code> manifest key.
LaunchItem[]? items;
// The URL for the <code>onLaunched</code> event triggered by a matching
// URL handler in the <code>url_handlers</code> manifest key.
DOMString? url;
// The referrer URL for the <code>onLaunched</code> event triggered by a
// matching URL handler in the <code>url_handlers</code> manifest key.
DOMString? referrerUrl;
// Whether the app is launched in a Chrome OS Demo Mode session. Used for
// default-installed Demo Mode Chrome apps.
[nodoc] boolean? isDemoSession;
// Whether the app is being launched in a <a
// href="https://support.google.com/chromebook/answer/3134673">Chrome OS
// kiosk session</a>.
boolean? isKioskSession;
// Whether the app is being launched in a <a
// href="https://support.google.com/chrome/a/answer/3017014">Chrome OS
// public session</a>.
boolean? isPublicSession;
// Where the app is launched from.
LaunchSource? source;
// Contains data that specifies the <code>ActionType</code> this app was
// launched with. This is null if the app was not launched with a specific
// action intent.
ActionData? actionData;
};
// This object specifies details and operations to perform on the embedding
// request. The app to be embedded can make a decision on whether or not to
// allow the embedding and what to embed based on the embedder making the
// request.
dictionary EmbedRequest {
DOMString embedderId;
// Optional developer specified data that the app to be embedded can use
// when making an embedding decision.
any? data;
// Allows <code>embedderId</code> to embed this app in an &lt;appview&gt;
// element. The <code>url</code> specifies the content to embed.
[nocompile] static void allow(DOMString url);
// Prevents <code> embedderId</code> from embedding this app in an
// &lt;appview&gt; element.
[nocompile] static void deny();
};
interface Events {
// Fired when an embedding app requests to embed this app. This event is
// only available on dev channel with the flag --enable-app-view.
static void onEmbedRequested(EmbedRequest request);
// Fired when an app is launched from the launcher.
static void onLaunched(optional LaunchData launchData);
// Fired at Chrome startup to apps that were running when Chrome last shut
// down, or when apps have been requested to restart from their previous
// state for other reasons (e.g. when the user revokes access to an app's
// retained files the runtime will restart the app). In these situations if
// apps do not have an <code>onRestarted</code> handler they will be sent
// an <code>onLaunched </code> event instead.
static void onRestarted();
};
};
@@ -0,0 +1,501 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.app.window</code> API to create windows. Windows
// have an optional frame with title bar and size controls. They are not
// associated with any Chrome browser windows. See the <a
// href="https://github.com/GoogleChrome/chrome-app-samples/tree/master/samples/window-state">
// Window State Sample</a> for a demonstration of these options.
namespace app.window {
// Previously named Bounds.
dictionary ContentBounds {
long? left;
long? top;
long? width;
long? height;
};
dictionary BoundsSpecification {
// The X coordinate of the content or window.
long? left;
// The Y coordinate of the content or window.
long? top;
// The width of the content or window.
long? width;
// The height of the content or window.
long? height;
// The minimum width of the content or window.
long? minWidth;
// The minimum height of the content or window.
long? minHeight;
// The maximum width of the content or window.
long? maxWidth;
// The maximum height of the content or window.
long? maxHeight;
};
dictionary Bounds {
// This property can be used to read or write the current X coordinate of
// the content or window.
long left;
// This property can be used to read or write the current Y coordinate of
// the content or window.
long top;
// This property can be used to read or write the current width of the
// content or window.
long width;
// This property can be used to read or write the current height of the
// content or window.
long height;
// This property can be used to read or write the current minimum width of
// the content or window. A value of <code>null</code> indicates
// 'unspecified'.
long? minWidth;
// This property can be used to read or write the current minimum height of
// the content or window. A value of <code>null</code> indicates
// 'unspecified'.
long? minHeight;
// This property can be used to read or write the current maximum width of
// the content or window. A value of <code>null</code> indicates
// 'unspecified'.
long? maxWidth;
// This property can be used to read or write the current maximum height of
// the content or window. A value of <code>null</code> indicates
// 'unspecified'.
long? maxHeight;
// Set the left and top position of the content or window.
static void setPosition(long left, long top);
// Set the width and height of the content or window.
static void setSize(long width, long height);
// Set the minimum size constraints of the content or window. The minimum
// width or height can be set to <code>null</code> to remove the constraint.
// A value of <code>undefined</code> will leave a constraint unchanged.
static void setMinimumSize(long minWidth, long minHeight);
// Set the maximum size constraints of the content or window. The maximum
// width or height can be set to <code>null</code> to remove the constraint.
// A value of <code>undefined</code> will leave a constraint unchanged.
static void setMaximumSize(long maxWidth, long maxHeight);
};
dictionary FrameOptions {
// Frame type: <code>none</code> or <code>chrome</code> (defaults to
// <code>chrome</code>).
//
// For <code>none</code>, the <code>-webkit-app-region</code> CSS property
// can be used to apply draggability to the app's window.
//
// <code>-webkit-app-region: drag</code> can be used to mark regions
// draggable. <code>no-drag</code> can be used to disable this style on
// nested elements.
DOMString? type;
// Allows the frame color to be set. Frame coloring is only available if the
// frame type is <code>chrome</code>.
//
// Frame coloring is new in Chrome 36.
DOMString? color;
// Allows the frame color of the window when active to be set. Frame
// coloring is only available if the frame type is <code>chrome</code>.
//
// Frame coloring is only available if the frame type is
// <code>chrome</code>.
//
// Frame coloring is new in Chrome 36.
DOMString? activeColor;
// Allows the frame color of the window when inactive to be set differently
// to the active color. Frame
// coloring is only available if the frame type is <code>chrome</code>.
//
// <code>inactiveColor</code> must be used in conjunction with <code>
// color</code>.
//
// Frame coloring is new in Chrome 36.
DOMString? inactiveColor;
};
// State of a window: normal, fullscreen, maximized, minimized.
enum State { normal, fullscreen, maximized, minimized };
// Specifies the type of window to create.
enum WindowType {
// Default window type.
shell,
// OS managed window (Deprecated).
panel
};
[noinline_doc] dictionary CreateWindowOptions {
// Id to identify the window. This will be used to remember the size
// and position of the window and restore that geometry when a window
// with the same id is later opened.
// If a window with a given id is created while another window with the same
// id already exists, the currently opened window will be focused instead of
// creating a new window.
DOMString? id;
// Used to specify the initial position, initial size and constraints of the
// window's content (excluding window decorations).
// If an <code>id</code> is also specified and a window with a matching
// <code>id</code> has been shown before, the remembered bounds will be used
// instead.
//
// Note that the padding between the inner and outer bounds is determined by
// the OS. Therefore setting the same bounds property for both the
// <code>innerBounds</code> and <code>outerBounds</code> will result in an
// error.
//
// This property is new in Chrome 36.
BoundsSpecification? innerBounds;
// Used to specify the initial position, initial size and constraints of the
// window (including window decorations such as the title bar and frame).
// If an <code>id</code> is also specified and a window with a matching
// <code>id</code> has been shown before, the remembered bounds will be used
// instead.
//
// Note that the padding between the inner and outer bounds is determined by
// the OS. Therefore setting the same bounds property for both the
// <code>innerBounds</code> and <code>outerBounds</code> will result in an
// error.
//
// This property is new in Chrome 36.
BoundsSpecification? outerBounds;
// Default width of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? defaultWidth;
// Default height of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? defaultHeight;
// Default X coordinate of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? defaultLeft;
// Default Y coordinate of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? defaultTop;
// Width of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? width;
// Height of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? height;
// X coordinate of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? left;
// Y coordinate of the window.
[nodoc, deprecated="Use $(ref:BoundsSpecification)."] long? top;
// Minimum width of the window.
[deprecated="Use innerBounds or outerBounds."] long? minWidth;
// Minimum height of the window.
[deprecated="Use innerBounds or outerBounds."] long? minHeight;
// Maximum width of the window.
[deprecated="Use innerBounds or outerBounds."] long? maxWidth;
// Maximum height of the window.
[deprecated="Use innerBounds or outerBounds."] long? maxHeight;
// Type of window to create.
[deprecated="All app windows use the 'shell' window type"] WindowType? type;
// Creates a special ime window. This window is not focusable and can be
// stacked above virtual keyboard window. This is restriced to component ime
// extensions.
// Requires the <code>app.window.ime</code> API permission.
[nodoc] boolean? ime;
// If true, the window will have its own shelf icon. Otherwise the window
// will be grouped in the shelf with other windows that are associated with
// the app. Defaults to false. If showInShelf is set to true you need to
// specify an id for the window.
boolean? showInShelf;
// URL of the window icon. A window can have its own icon when showInShelf
// is set to true. The URL should be a global or an extension local URL.
DOMString? icon;
// Frame type: <code>none</code> or <code>chrome</code> (defaults to
// <code>chrome</code>). For <code>none</code>, the
// <code>-webkit-app-region</code> CSS property can be used to apply
// draggability to the app's window. <code>-webkit-app-region: drag</code>
// can be used to mark regions draggable. <code>no-drag</code> can be used
// to disable this style on nested elements.
//
// Use of <code>FrameOptions</code> is new in M36.
(DOMString or FrameOptions)? frame;
// Size and position of the content in the window (excluding the titlebar).
// If an id is also specified and a window with a matching id has been shown
// before, the remembered bounds of the window will be used instead.
[deprecated="Use innerBounds or outerBounds."] ContentBounds? bounds;
// Enable window background transparency.
// Only supported in ash. Requires the <code>app.window.alpha</code> API
// permission.
[nodoc] boolean? alphaEnabled;
// The initial state of the window, allowing it to be created already
// fullscreen, maximized, or minimized. Defaults to 'normal'.
State? state;
// If true, the window will be created in a hidden state. Call show() on
// the window to show it once it has been created. Defaults to false.
boolean? hidden;
// If true, the window will be resizable by the user. Defaults to true.
boolean? resizable;
// By default if you specify an id for the window, the window will only be
// created if another window with the same id doesn't already exist. If a
// window with the same id already exists that window is activated instead.
// If you do want to create multiple windows with the same id, you can
// set this property to false.
[deprecated="Multiple windows with the same id is no longer supported."] boolean? singleton;
// If true, the window will stay above most other windows. If there are
// multiple windows of this kind, the currently focused window will be in
// the foreground. Requires the <code>alwaysOnTopWindows</code>
// permission. Defaults to false.
//
// Call <code>setAlwaysOnTop()</code> on the window to change this property
// after creation.
boolean? alwaysOnTop;
// If true, the window will be focused when created. Defaults to true.
boolean? focused;
// If true, and supported by the platform, the window will be visible on all
// workspaces.
boolean? visibleOnAllWorkspaces;
// <p>If set, the action that is intended to be handled by the window on
// lockscreen. This has to be set to create an app window visible on the
// lock screen. The app window should be created only in response to an
// app launch request for handling an action from the lock screen. App
// window creation will fail if the app was not launched to handle the
// action.
// </p>
// <p>This is <b>Chrome OS only</b>.</p>
[nodoc] app.runtime.ActionType? lockScreenAction;
};
// Called in the creating window (parent) before the load event is called in
// the created window (child). The parent can set fields or functions on the
// child usable from onload. E.g. background.js:
//
// <code>function(createdWindow) { createdWindow.contentWindow.foo =
// function () { }; };</code>
//
// window.js:
//
// <code>window.onload = function () { foo(); }</code>
callback CreateWindowCallback =
void ([instanceOf=AppWindow] object createdWindow);
[noinline_doc] dictionary AppWindow {
// Focus the window.
static void focus();
// Fullscreens the window.
//
// The user will be able to restore the window by pressing ESC. An
// application can prevent the fullscreen state to be left when ESC is
// pressed by requesting the <code>app.window.fullscreen.overrideEsc</code>
// permission and canceling the event by calling .preventDefault(), in the
// keydown and keyup handlers, like this:
//
// <code>window.onkeydown = window.onkeyup = function(e) { if (e.keyCode ==
// 27 /* ESC */) { e.preventDefault(); } };</code>
//
// Note <code>window.fullscreen()</code> will cause the entire window to
// become fullscreen and does not require a user gesture. The HTML5
// fullscreen API can also be used to enter fullscreen mode (see
// <a href="http://developer.chrome.com/apps/api_other.html">Web APIs</a>
// for more details).
static void fullscreen();
// Is the window fullscreen? This will be true if the window has been
// created fullscreen or was made fullscreen via the
// <code>AppWindow</code> or HTML5 fullscreen APIs.
static boolean isFullscreen();
// Minimize the window.
static void minimize();
// Is the window minimized?
static boolean isMinimized();
// Maximize the window.
static void maximize();
// Is the window maximized?
static boolean isMaximized();
// Restore the window, exiting a maximized, minimized, or fullscreen state.
static void restore();
// Move the window to the position (|left|, |top|).
[deprecated="Use outerBounds."] static void moveTo(long left, long top);
// Resize the window to |width|x|height| pixels in size.
[deprecated="Use outerBounds."] static void resizeTo(long width, long height);
// Draw attention to the window.
static void drawAttention();
// Clear attention to the window.
static void clearAttention();
// Close the window.
static void close();
// Show the window. Does nothing if the window is already visible.
// Focus the window if |focused| is set to true or omitted.
static void show(optional boolean focused);
// Hide the window. Does nothing if the window is already hidden.
static void hide();
// Get the window's inner bounds as a $(ref:ContentBounds) object.
[nocompile, deprecated="Use innerBounds or outerBounds."] static ContentBounds getBounds();
// Set the window's inner bounds.
[nocompile, deprecated="Use innerBounds or outerBounds."] static void setBounds(ContentBounds bounds);
// Set the app icon for the window (experimental).
// Currently this is only being implemented on Ash.
// TODO(stevenjb): Investigate implementing this on Windows and OSX.
[nodoc] static void setIcon(DOMString iconUrl);
// Is the window always on top?
static boolean isAlwaysOnTop();
// Accessors for testing.
[nodoc] boolean hasFrameColor;
[nodoc] long activeFrameColor;
[nodoc] long inactiveFrameColor;
// Set whether the window should stay above most other windows. Requires the
// <code>alwaysOnTopWindows</code> permission.
static void setAlwaysOnTop(boolean alwaysOnTop);
// Can the window use alpha transparency?
// TODO(jackhou): Document this properly before going to stable.
[nodoc] static boolean alphaEnabled();
// Set whether the window is visible on all workspaces. (Only for platforms
// that support this).
static void setVisibleOnAllWorkspaces(boolean alwaysVisible);
// The JavaScript 'window' object for the created child.
[instanceOf=Window] object contentWindow;
// The id the window was created with.
DOMString id;
// The position, size and constraints of the window's content, which does
// not include window decorations.
// This property is new in Chrome 36.
Bounds innerBounds;
// The position, size and constraints of the window, which includes window
// decorations, such as the title bar and frame.
// This property is new in Chrome 36.
Bounds outerBounds;
};
interface Functions {
// The size and position of a window can be specified in a number of
// different ways. The most simple option is not specifying anything at
// all, in which case a default size and platform dependent position will
// be used.
//
// To set the position, size and constraints of the window, use the
// <code>innerBounds</code> or <code>outerBounds</code> properties. Inner
// bounds do not include window decorations. Outer bounds include the
// window's title bar and frame. Note that the padding between the inner and
// outer bounds is determined by the OS. Therefore setting the same property
// for both inner and outer bounds is considered an error (for example,
// setting both <code>innerBounds.left</code> and
// <code>outerBounds.left</code>).
//
// To automatically remember the positions of windows you can give them ids.
// If a window has an id, This id is used to remember the size and position
// of the window whenever it is moved or resized. This size and position is
// then used instead of the specified bounds on subsequent opening of a
// window with the same id. If you need to open a window with an id at a
// location other than the remembered default, you can create it hidden,
// move it to the desired location, then show it.
[supportsPromises] static void create(DOMString url,
optional CreateWindowOptions options,
optional CreateWindowCallback callback);
// Returns an $(ref:AppWindow) object for the
// current script context (ie JavaScript 'window' object). This can also be
// called on a handle to a script context for another page, for example:
// otherWindow.chrome.app.window.current().
[nocompile] static AppWindow current();
[nocompile, nodoc] static void initializeAppWindow(object state);
// Gets an array of all currently created app windows. This method is new in
// Chrome 33.
[nocompile] static AppWindow[] getAll();
// Gets an $(ref:AppWindow) with the given id. If no window with the given id
// exists null is returned. This method is new in Chrome 33.
[nocompile] static AppWindow get(DOMString id);
// Whether the current platform supports windows being visible on all
// workspaces.
[nocompile] static boolean canSetVisibleOnAllWorkspaces();
};
interface Events {
// Fired when the window is resized.
[nocompile] static void onBoundsChanged();
// Fired when the window is closed. Note, this should be listened to from
// a window other than the window being closed, for example from the
// background page. This is because the window being closed will be in the
// process of being torn down when the event is fired, which means not all
// APIs in the window's script context will be functional.
[nocompile] static void onClosed();
// Fired when the window is fullscreened (either via the
// <code>AppWindow</code> or HTML5 APIs).
[nocompile] static void onFullscreened();
// Fired when the window is maximized.
[nocompile] static void onMaximized();
// Fired when the window is minimized.
[nocompile] static void onMinimized();
// Fired when the window is restored from being minimized or maximized.
[nocompile] static void onRestored();
// Fired when the window's ability to use alpha transparency changes.
[nocompile, nodoc] static void onAlphaEnabledChanged();
};
};
+162
View File
@@ -0,0 +1,162 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.audio</code> API is provided to allow users to
// get information about and control the audio devices attached to the
// system.
// This API is currently only available in kiosk mode for ChromeOS.
namespace audio {
// Type of stream an audio device provides.
enum StreamType {
INPUT,
OUTPUT
};
// Available audio device types.
enum DeviceType {
HEADPHONE,
MIC,
USB,
BLUETOOTH,
HDMI,
INTERNAL_SPEAKER,
INTERNAL_MIC,
FRONT_MIC,
REAR_MIC,
KEYBOARD_MIC,
HOTWORD,
LINEOUT,
POST_MIX_LOOPBACK,
POST_DSP_LOOPBACK,
ALSA_LOOPBACK,
OTHER
};
dictionary AudioDeviceInfo {
// The unique identifier of the audio device.
DOMString id;
// Stream type associated with this device.
StreamType streamType;
// Type of the device.
DeviceType deviceType;
// The user-friendly name (e.g. "USB Microphone").
DOMString displayName;
// Device name.
DOMString deviceName;
// True if this is the current active device.
boolean isActive;
// The sound level of the device, volume for output, gain for input.
long level;
// The stable/persisted device id string when available.
DOMString? stableDeviceId;
};
dictionary DeviceFilter {
// If set, only audio devices whose stream type is included in this list
// will satisfy the filter.
StreamType[]? streamTypes;
// If set, only audio devices whose active state matches this value will
// satisfy the filter.
boolean? isActive;
};
dictionary DeviceProperties {
// <p>
// The audio device's desired sound level. Defaults to the device's
// current sound level.
// </p>
// <p>If used with audio input device, represents audio device gain.</p>
// <p>If used with audio output device, represents audio device volume.</p>
long? level;
};
dictionary DeviceIdLists {
// <p>List of input devices specified by their ID.</p>
// <p>To indicate input devices should be unaffected, leave this property
// unset.</p>
DOMString[]? input;
// <p>List of output devices specified by their ID.</p>
// <p>To indicate output devices should be unaffected, leave this property
// unset.</p>
DOMString[]? output;
};
dictionary MuteChangedEvent {
// The type of the stream for which the mute value changed. The updated mute
// value applies to all devices with this stream type.
StreamType streamType;
// Whether or not the stream is now muted.
boolean isMuted;
};
dictionary LevelChangedEvent {
// ID of device whose sound level has changed.
DOMString deviceId;
// The device's new sound level.
long level;
};
callback GetDevicesCallback = void(AudioDeviceInfo[] devices);
callback GetMuteCallback = void(boolean value);
callback EmptyCallback = void();
interface Functions {
// Gets a list of audio devices filtered based on |filter|.
// |filter|: Device properties by which to filter the list of returned
// audio devices. If the filter is not set or set to <code>{}</code>,
// returned device list will contain all available audio devices.
// |callback|: Reports the requested list of audio devices.
[supportsPromises] static void getDevices(optional DeviceFilter filter,
GetDevicesCallback callback);
// Sets lists of active input and/or output devices.
// |ids|: <p>Specifies IDs of devices that should be active. If either the
// input or output list is not set, devices in that category are
// unaffected.
// </p>
// <p>It is an error to pass in a non-existent device ID.</p>
[supportsPromises] static void setActiveDevices(DeviceIdLists ids,
EmptyCallback callback);
// Sets the properties for the input or output device.
[supportsPromises] static void setProperties(DOMString id,
DeviceProperties properties,
EmptyCallback callback);
// Gets the system-wide mute state for the specified stream type.
// |streamType|: Stream type for which mute state should be fetched.
// |callback|: Callback reporting whether mute is set or not for specified
// stream type.
[supportsPromises] static void getMute(StreamType streamType,
GetMuteCallback callback);
// Sets mute state for a stream type. The mute state will apply to all audio
// devices with the specified audio stream type.
// |streamType|: Stream type for which mute state should be set.
// |isMuted|: New mute value.
[supportsPromises] static void setMute(StreamType streamType,
boolean isMuted,
optional EmptyCallback callback);
};
interface Events {
// Fired when sound level changes for an active audio device.
static void onLevelChanged(LevelChangedEvent event);
// Fired when the mute state of the audio input or output changes.
// Note that mute state is system-wide and the new value applies to every
// audio device with specified stream type.
static void onMuteChanged(MuteChangedEvent event);
// Fired when audio devices change, either new devices being added, or
// existing devices being removed.
// |devices|: List of all present audio devices after the change.
static void onDeviceListChanged(AudioDeviceInfo[] devices);
};
};
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,167 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// This is the implementation layer of the chrome.automation API, and is
// essentially a translation of the internal accessibility tree update system
// into an extension API.
namespace automationInternal {
// Data for an accessibility event and/or an atomic change to an accessibility
// tree. See ui/accessibility/ax_tree_update.h for an extended explanation of
// the tree update format.
[nocompile] dictionary AXEventParams {
// The tree id of the web contents that this update is for.
DOMString treeID;
// ID of the node that the event applies to.
long targetID;
// The type of event that this update represents.
DOMString eventType;
// The source of this event.
DOMString eventFrom;
// The mouse coordinates when this event fired.
double mouseX;
double mouseY;
// ID of an action request resulting in this event.
long actionRequestID;
};
dictionary AXTextLocationParams {
DOMString treeID;
long nodeID;
boolean result;
long left;
long top;
long width;
long height;
long requestID;
};
// Arguments required for all actions supplied to performAction.
dictionary PerformActionRequiredParams {
DOMString treeID;
long automationNodeID;
// This can be either automation::ActionType or
// automation_internal::ActionTypePrivate.
DOMString actionType;
long? requestID;
};
// Arguments for the customAction action. Those args are passed to
// performAction as opt_args.
dictionary PerformCustomActionParams {
long customActionID;
};
// Arguments for the setSelection action supplied to performAction.
dictionary SetSelectionParams {
// Reuses ActionRequiredParams automationNodeID to mean anchor node id,
// and treeID to apply to both anchor and focus node ids.
long focusNodeID;
long anchorOffset;
long focusOffset;
};
// Arguments for the replaceSelectedText action supplied to performAction.
dictionary ReplaceSelectedTextParams {
DOMString value;
};
// Arguments for the setValue action supplied to performAction.
dictionary SetValueParams {
DOMString value;
};
// Arguments for the scrollToPoint action supplied to performAction.
dictionary ScrollToPointParams {
long x;
long y;
};
// Arguments for the scrollToPositionAtRowColumn action supplied to performAction.
dictionary ScrollToPositionAtRowColumnParams {
long row;
long column;
};
// Arguments for the SetScrollOffset action supplied to performAction.
dictionary SetScrollOffsetParams {
long x;
long y;
};
// Arguments for the getImageData action.
dictionary GetImageDataParams {
long maxWidth;
long maxHeight;
};
// Arguments for the hitTest action.
dictionary HitTestParams {
long x;
long y;
DOMString eventToFire;
};
// Arguments for getTextLocation action.
dictionary GetTextLocationDataParams {
long startIndex;
long endIndex;
};
// Callback called when enableDesktop() returns. Returns the accessibility
// tree id of the desktop tree.
callback EnableDesktopCallback = void(DOMString tree_id);
// Callback called when disableDesktop() returns. It is safe to clear
// accessibility api state at that point.
callback DisableDesktopCallback = void();
interface Functions {
// Enable automation of the tree with the given id.
static void enableTree(DOMString tree_id);
// Enables desktop automation.
[supportsPromises] static void enableDesktop(
EnableDesktopCallback callback);
// Disables desktop automation.
static void disableDesktop(DisableDesktopCallback callback);
// Performs an action on an automation node.
static void performAction(PerformActionRequiredParams args,
object opt_args);
};
interface Events {
// Fired when an accessibility event occurs
static void onAccessibilityEvent(AXEventParams update);
static void onAccessibilityTreeDestroyed(DOMString treeID);
static void onGetTextLocationResult(AXTextLocationParams params);
static void onTreeChange(long observerID,
DOMString treeID,
long nodeID,
DOMString changeType);
static void onChildTreeID(DOMString treeID);
static void onNodesRemoved(DOMString treeID, long[] nodeIDs);
static void onAccessibilityTreeSerializationError(DOMString treeID);
static void onActionResult(DOMString treeID, long requestID, boolean result);
static void onAllAutomationEventListenersRemoved();
};
};
+185
View File
@@ -0,0 +1,185 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.bluetooth</code> API to connect to a Bluetooth
// device. All functions report failures via chrome.runtime.lastError.
namespace bluetooth {
// Allocation authorities for Vendor IDs.
enum VendorIdSource {bluetooth, usb};
// Common device types recognized by Chrome.
enum DeviceType {computer, phone, modem, audio, carAudio, video, peripheral,
joystick, gamepad, keyboard, mouse, tablet,
keyboardMouseCombo};
// Types for filtering bluetooth devices.
enum FilterType {all, known};
// Transport type of the bluetooth device.
enum Transport {invalid, classic, le, dual};
// Information about the state of the Bluetooth adapter.
dictionary AdapterState {
// The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'.
DOMString address;
// The human-readable name of the adapter.
DOMString name;
// Indicates whether or not the adapter has power.
boolean powered;
// Indicates whether or not the adapter is available (i.e. enabled).
boolean available;
// Indicates whether or not the adapter is currently discovering.
boolean discovering;
};
// Callback from the <code>getAdapterState</code> method.
// |adapterInfo| : Object containing the adapter information.
callback AdapterStateCallback = void(AdapterState adapterInfo);
// Information about the state of a known Bluetooth device. Note: this
// dictionary is also used in bluetooth_private.idl
dictionary Device {
// The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
DOMString address;
// The human-readable name of the device.
DOMString? name;
// The class of the device, a bit-field defined by
// http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
long? deviceClass;
// The Device ID record of the device, where available.
VendorIdSource? vendorIdSource;
long? vendorId;
long? productId;
long? deviceId;
// The type of the device, if recognized by Chrome. This is obtained from
// the |deviceClass| field and only represents a small fraction of the
// possible device types. When in doubt you should use the |deviceClass|
// field directly.
DeviceType? type;
// Indicates whether or not the device is paired with the system.
boolean? paired;
// Indicates whether the device is currently connected to the system.
boolean? connected;
// Indicates whether the device is currently connecting to the system.
boolean? connecting;
// Indicates whether the device is connectable.
boolean? connectable;
// UUIDs of protocols, profiles and services advertised by the device.
// For classic Bluetooth devices, this list is obtained from EIR data and
// SDP tables. For Low Energy devices, this list is obtained from AD and
// GATT primary services. For dual mode devices this may be obtained from
// both.
DOMString[]? uuids;
// The received signal strength, in dBm. This field is avaliable and valid
// only during discovery. Outside of discovery it's value is not specified.
long? inquiryRssi;
// The transmitted power level. This field is avaliable only for LE devices
// that include this field in AD. It is avaliable and valid only during
// discovery.
long? inquiryTxPower;
// The transport type of the bluetooth device.
Transport? transport;
// The remaining battery of the device.
long? batteryPercentage;
};
dictionary BluetoothFilter {
// Type of filter to apply to the device list. Default is all.
FilterType? filterType;
// Maximum number of bluetoth devices to return. Default is 0 (no limit)
// if unspecified.
long? limit;
};
// Callback from the <code>getDevice</code> method.
// |deviceInfo| : Object containing the device information.
callback GetDeviceCallback = void(Device deviceInfo);
// Callback from the <code>getDevices</code> method.
// |deviceInfos| : Array of object containing device information.
callback GetDevicesCallback = void(Device[] deviceInfos);
// Callback from the <code>startDiscovery</code> method.
callback StartDiscoveryCallback = void();
// Callback from the <code>stopDiscovery</code> method.
callback StopDiscoveryCallback = void();
// These functions all report failures via chrome.runtime.lastError.
interface Functions {
// Get information about the Bluetooth adapter.
// |callback| : Called with an AdapterState object describing the adapter
// state.
[supportsPromises] static void getAdapterState(
AdapterStateCallback callback);
// Get information about a Bluetooth device known to the system.
// |deviceAddress| : Address of device to get.
// |callback| : Called with the Device object describing the device.
[supportsPromises] static void getDevice(DOMString deviceAddress,
GetDeviceCallback callback);
// Get a list of Bluetooth devices known to the system, including paired
// and recently discovered devices.
// |filter|: Some criteria to filter the list of returned bluetooth devices.
// If the filter is not set or set to <code>{}</code>, returned device list
// will contain all bluetooth devices. Right now this is only supported in
// ChromeOS, for other platforms, a full list is returned.
// |callback| : Called when the search is completed.
[supportsPromises] static void getDevices(optional BluetoothFilter filter,
GetDevicesCallback callback);
// Start discovery. Newly discovered devices will be returned via the
// onDeviceAdded event. Previously discovered devices already known to
// the adapter must be obtained using getDevices and will only be updated
// using the |onDeviceChanged| event if information about them changes.
//
// Discovery will fail to start if this application has already called
// startDiscovery. Discovery can be resource intensive: stopDiscovery
// should be called as soon as possible.
// |callback| : Called to indicate success or failure.
[supportsPromises] static void startDiscovery(
optional StartDiscoveryCallback callback);
// Stop discovery.
// |callback| : Called to indicate success or failure.
[supportsPromises] static void stopDiscovery(
optional StopDiscoveryCallback callback);
};
interface Events {
// Fired when the state of the Bluetooth adapter changes.
// |state| : The new state of the adapter.
static void onAdapterStateChanged(AdapterState state);
// Fired when information about a new Bluetooth device is available.
static void onDeviceAdded(Device device);
// Fired when information about a known Bluetooth device has changed.
static void onDeviceChanged(Device device);
// Fired when a Bluetooth device that was previously discovered has been
// out of range for long enough to be considered unavailable again, and
// when a paired device is removed.
static void onDeviceRemoved(Device device);
};
};
@@ -0,0 +1,596 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.bluetoothLowEnergy</code> API is used to communicate with
// Bluetooth Smart (Low Energy) devices using the
// <a href="https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx">
// Generic Attribute Profile (GATT)</a>.
namespace bluetoothLowEnergy {
// Values representing the possible properties of a characteristic.
// Characteristic permissions are inferred from these properties.
// Please see the Bluetooth 4.x spec to see the meaning of each individual
// property.
enum CharacteristicProperty {
broadcast, read, writeWithoutResponse, write, notify, indicate,
authenticatedSignedWrites, extendedProperties, reliableWrite,
writableAuxiliaries, encryptRead, encryptWrite, encryptAuthenticatedRead,
encryptAuthenticatedWrite
};
// Values representing possible permissions for a descriptor.
// Please see the Bluetooth 4.x spec to see the meaning of each individual
// permission.
enum DescriptorPermission {
read, write, encryptedRead, encryptedWrite, encryptedAuthenticatedRead,
encryptedAuthenticatedWrite
};
// Type of advertisement. If 'broadcast' is chosen, the sent advertisement
// type will be ADV_NONCONN_IND and the device will broadcast with a random
// MAC Address. If set to 'peripheral', the advertisement type will be
// ADV_IND or ADV_SCAN_IND and the device will broadcast with real Bluetooth
// Adapter's MAC Address.
enum AdvertisementType {broadcast, peripheral};
// Represents a bluetooth central device that is connected to the local GATT
// server.
dictionary Device {
// The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
DOMString address;
// The human-readable name of the device.
DOMString? name;
// The class of the device, a bit-field defined by
// http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
long? deviceClass;
};
// Represents a peripheral's Bluetooth GATT Service, a collection of
// characteristics and relationships to other services that encapsulate
// the behavior of part of a device.
dictionary Service {
// The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb.
DOMString uuid;
// Indicates whether the type of this service is primary or secondary.
boolean isPrimary;
// Returns the identifier assigned to this service. Use the instance ID to
// distinguish between services from a peripheral with the same UUID and
// to make function calls that take in a service identifier. Present, if
// this instance represents a remote service.
DOMString? instanceId;
// The device address of the remote peripheral that the GATT service belongs
// to. Present, if this instance represents a remote service.
DOMString? deviceAddress;
};
// Represents a GATT characteristic, which is a basic data element that
// provides further information about a peripheral's service.
dictionary Characteristic {
// The UUID of the characteristic, e.g.
// 00002a37-0000-1000-8000-00805f9b34fb.
DOMString uuid;
// The GATT service this characteristic belongs to.
Service? service;
// The properties of this characteristic.
CharacteristicProperty[] properties;
// Returns the identifier assigned to this characteristic. Use the instance
// ID to distinguish between characteristics from a peripheral with the same
// UUID and to make function calls that take in a characteristic identifier.
// Present, if this instance represents a remote characteristic.
DOMString? instanceId;
// The currently cached characteristic value. This value gets updated when
// the value of the characteristic is read or updated via a notification
// or indication.
ArrayBuffer? value;
};
// Represents a GATT characteristic descriptor, which provides further
// information about a characteristic's value.
dictionary Descriptor {
// The UUID of the characteristic descriptor, e.g.
// 00002902-0000-1000-8000-00805f9b34fb.
DOMString uuid;
// The GATT characteristic this descriptor belongs to.
Characteristic? characteristic;
// The permissions of this descriptor.
DescriptorPermission[] permissions;
// Returns the identifier assigned to this descriptor. Use the instance ID
// to distinguish between descriptors from a peripheral with the same UUID
// and to make function calls that take in a descriptor identifier. Present,
// if this instance represents a remote characteristic.
DOMString? instanceId;
// The currently cached descriptor value. This value gets updated when
// the value of the descriptor is read.
ArrayBuffer? value;
};
// The connection properties specified during a call to $(ref:connect).
dictionary ConnectProperties {
// Flag indicating whether a connection to the device is left open when the
// event page of the application is unloaded (see <a
// href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is <code>false.</code>
boolean persistent;
};
// Optional characteristic notification session properties specified during a
// call to $(ref:startCharacteristicNotifications).
dictionary NotificationProperties {
// Flag indicating whether the app should receive notifications when the
// event page of the application is unloaded (see <a
// href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is <code>false</code>.
boolean persistent;
};
// Represents an entry of the "Manufacturer Specific Data" field of Bluetooth
// LE advertisement data.
dictionary ManufacturerData {
long id;
long[] data;
};
// Represents an entry of the "Service Data" field of Bluetooth LE advertisement
// data.
dictionary ServiceData {
DOMString uuid;
long[] data;
};
// Represents a Bluetooth LE advertisement instance.
dictionary Advertisement {
// Type of advertisement.
AdvertisementType type;
// List of UUIDs to include in the "Service UUIDs" field of the Advertising
// Data. These UUIDs can be of the 16bit, 32bit or 128 formats.
DOMString[]? serviceUuids;
// List of manufacturer specific data to be included in "Manufacturer Specific
// Data" fields of the advertising data.
ManufacturerData[]? manufacturerData;
// List of UUIDs to include in the "Solicit UUIDs" field of the Advertising
// Data. These UUIDs can be of the 16bit, 32bit or 128 formats.
DOMString[]? solicitUuids;
// List of service data to be included in "Service Data" fields of the advertising
// data.
ServiceData[]? serviceData;
};
// Represents a an attribute read/write request.
dictionary Request {
// Unique ID for this request. Use this ID when responding to this request.
long requestId;
// Device that send this request.
Device device;
// Value to write (if this is a write request).
ArrayBuffer? value;
};
// Represents a response to an attribute read/write request.
dictionary Response {
// Id of the request this is a response to.
long requestId;
// If this is an error response, this should be true.
boolean isError;
// Response value. Write requests and error responses will ignore this
// parameter.
ArrayBuffer? value;
};
// Represents a notification to be sent to a remote device.
dictionary Notification {
// New value of the characteristic.
ArrayBuffer value;
// Optional flag for sending an indication instead of a notification.
boolean? shouldIndicate;
};
callback CharacteristicCallback = void(Characteristic result);
callback CreateCharacteristicCallback = void(DOMString characteristicId);
callback CharacteristicsCallback = void(Characteristic[] result);
callback DescriptorCallback = void(Descriptor result);
callback CreateDescriptorCallback = void(DOMString descriptorId);
callback DescriptorsCallback = void(Descriptor[] result);
callback ResultCallback = void();
callback ServiceCallback = void(Service result);
callback CreateServiceCallback = void(DOMString serviceId);
callback ServicesCallback = void(Service[] result);
callback RegisterAdvertisementCallback = void (long advertisementId);
// These functions all report failures via chrome.runtime.lastError.
interface Functions {
// Establishes a connection between the application and the device with the
// given address. A device may be already connected and its GATT services
// available without calling <code>connect</code>, however, an app that
// wants to access GATT services of a device should call this function to
// make sure that a connection to the device is maintained. If the device
// is not connected, all GATT services of the device will be discovered
// after a successful call to <code>connect</code>.
// |deviceAddress|: The Bluetooth address of the remote device to which a
// GATT connection should be opened.
// |properties|: Connection properties (optional).
// |callback|: Called when the connect request has completed.
[supportsPromises] static void connect(
DOMString deviceAddress,
optional ConnectProperties properties,
ResultCallback callback);
// Closes the app's connection to the device with the given address. Note
// that this will not always destroy the physical link itself, since there
// may be other apps with open connections.
// |deviceAddress|: The Bluetooth address of the remote device.
// |callback|: Called when the disconnect request has completed.
[supportsPromises] static void disconnect(DOMString deviceAddress,
optional ResultCallback callback);
// Get the GATT service with the given instance ID.
// |serviceId|: The instance ID of the requested GATT service.
// |callback|: Called with the requested Service object.
[supportsPromises] static void getService(DOMString serviceId,
ServiceCallback callback);
// Create a locally hosted GATT service. This service can be registered
// to be available on a local GATT server.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |service|: The service to create.
// |callback|: Called with the created services's unique ID.
[supportsPromises] static void createService(
Service service,
CreateServiceCallback callback);
// Get all the GATT services that were discovered on the remote device with
// the given device address.
//
// <em>Note:</em> If service discovery is not yet complete on the device,
// this API will return a subset (possibly empty) of services. A work around
// is to add a time based delay and/or call repeatedly until the expected
// number of services is returned.
//
// |deviceAddress|: The Bluetooth address of the remote device whose GATT
// services should be returned.
// |callback|: Called with the list of requested Service objects.
[supportsPromises] static void getServices(DOMString deviceAddress,
ServicesCallback callback);
// Get the GATT characteristic with the given instance ID that belongs to
// the given GATT service, if the characteristic exists.
// |characteristicId|: The instance ID of the requested GATT
// characteristic.
// |callback|: Called with the requested Characteristic object.
[supportsPromises] static void getCharacteristic(
DOMString characteristicId,
CharacteristicCallback callback);
// Create a locally hosted GATT characteristic. This characteristic must
// be hosted under a valid service. If the service ID is not valid, the
// lastError will be set.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |characteristic|: The characteristic to create.
// |serviceId|: ID of the service to create this characteristic for.
// |callback|: Called with the created characteristic's unique ID.
[supportsPromises] static void createCharacteristic(
Characteristic characteristic,
DOMString serviceId,
CreateCharacteristicCallback callback);
// Get a list of all discovered GATT characteristics that belong to the
// given service.
// |serviceId|: The instance ID of the GATT service whose characteristics
// should be returned.
// |callback|: Called with the list of characteristics that belong to the
// given service.
[supportsPromises] static void getCharacteristics(
DOMString serviceId,
CharacteristicsCallback callback);
// Get a list of GATT services that are included by the given service.
// |serviceId|: The instance ID of the GATT service whose included
// services should be returned.
// |callback|: Called with the list of GATT services included from the
// given service.
[supportsPromises] static void getIncludedServices(
DOMString serviceId,
ServicesCallback callback);
// Get the GATT characteristic descriptor with the given instance ID.
// |descriptorId|: The instance ID of the requested GATT characteristic
// descriptor.
// |callback|: Called with the requested Descriptor object.
[supportsPromises] static void getDescriptor(DOMString descriptorId,
DescriptorCallback callback);
// Create a locally hosted GATT descriptor. This descriptor must
// be hosted under a valid characteristic. If the characteristic ID is not
// valid, the lastError will be set.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |descriptor|: The descriptor to create.
// |characteristicId|: ID of the characteristic to create this descriptor
// for.
// |callback|: Called with the created descriptor's unique ID.
[supportsPromises] static void createDescriptor(
Descriptor descriptor,
DOMString characteristicId,
CreateDescriptorCallback callback);
// Get a list of GATT characteristic descriptors that belong to the given
// characteristic.
// |characteristicId|: The instance ID of the GATT characteristic whose
// descriptors should be returned.
// |callback|: Called with the list of descriptors that belong to the given
// characteristic.
[supportsPromises] static void getDescriptors(DOMString characteristicId,
DescriptorsCallback callback);
// Retrieve the value of a specified characteristic from a remote
// peripheral.
// |characteristicId|: The instance ID of the GATT characteristic whose
// value should be read from the remote device.
// |callback|: Called with the Characteristic object whose value was
// requested. The <code>value</code> field of the returned Characteristic
// object contains the result of the read request.
[supportsPromises] static void readCharacteristicValue(
DOMString characteristicId,
CharacteristicCallback callback);
// Write the value of a specified characteristic from a remote peripheral.
// |characteristicId|: The instance ID of the GATT characteristic whose
// value should be written to.
// |value|: The value that should be sent to the remote characteristic as
// part of the write request.
// |callback|: Called when the write request has completed.
[supportsPromises] static void writeCharacteristicValue(
DOMString characteristicId,
ArrayBuffer value,
ResultCallback callback);
// Enable value notifications/indications from the specified characteristic.
// Once enabled, an application can listen to notifications using the
// $(ref:onCharacteristicValueChanged) event.
// |characteristicId|: The instance ID of the GATT characteristic that
// notifications should be enabled on.
// |properties|: Notification session properties (optional).
// |callback|: Called when the request has completed.
[supportsPromises] static void startCharacteristicNotifications(
DOMString characteristicId,
optional NotificationProperties properties,
ResultCallback callback);
// Disable value notifications/indications from the specified
// characteristic. After a successful call, the application will stop
// receiving notifications/indications from this characteristic.
// |characteristicId|: The instance ID of the GATT characteristic on which
// this app's notification session should be stopped.
// |callback|: Called when the request has completed (optional).
[supportsPromises] static void stopCharacteristicNotifications(
DOMString characteristicId,
optional ResultCallback callback);
// Notify a remote device of a new value for a characteristic. If the
// shouldIndicate flag in the notification object is true, an indication
// will be sent instead of a notification. Note, the characteristic needs
// to correctly set the 'notify' or 'indicate' property during creation for
// this call to succeed.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |characteristicId|: The characteristic to send the notication for.
// |notifcation|: The notification to send.
// |callback|: Callback called once the notification or indication has
// been sent successfully.
[supportsPromises] static void notifyCharacteristicValueChanged(
DOMString characteristicId,
Notification notification,
ResultCallback callback);
// Retrieve the value of a specified characteristic descriptor from a remote
// peripheral.
// |descriptorId|: The instance ID of the GATT characteristic descriptor
// whose value should be read from the remote device.
// |callback|: Called with the Descriptor object whose value was requested.
// The <code>value</code> field of the returned Descriptor object contains
// the result of the read request.
[supportsPromises] static void readDescriptorValue(
DOMString descriptorId,
DescriptorCallback callback);
// Write the value of a specified characteristic descriptor from a remote
// peripheral.
// |descriptorId|: The instance ID of the GATT characteristic descriptor
// whose value should be written to.
// |value|: The value that should be sent to the remote descriptor as part
// of the write request.
// |callback|: Called when the write request has completed.
[supportsPromises] static void writeDescriptorValue(
DOMString descriptorId,
ArrayBuffer value,
ResultCallback callback);
// Register the given service with the local GATT server. If the service
// ID is invalid, the lastError will be set.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |serviceId|: Unique ID of a created service.
// |callback|: Callback with the result of the register operation.
[supportsPromises] static void registerService(DOMString serviceId,
ResultCallback callback);
// Unregister the given service with the local GATT server. If the service
// ID is invalid, the lastError will be set.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |serviceId|: Unique ID of a current registered service.
// |callback|: Callback with the result of the register operation.
[supportsPromises] static void unregisterService(DOMString serviceId,
ResultCallback callback);
// Remove the specified service, unregistering it if it was registered.
// If the service ID is invalid, the lastError will be set.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |serviceId|: Unique ID of a current registered service.
// |callback|: Callback called once the service is removed.
[supportsPromises] static void removeService(
DOMString serviceId,
optional ResultCallback callback);
// Create an advertisement and register it for advertising. To call this
// function, the app must have the bluetooth:low_energy and
// bluetooth:peripheral permissions set to true. Additionally this API
// is only available to auto launched apps in Kiosk Mode or by setting
// the '--enable-ble-advertising-in-apps' command-line switch.
// See https://developer.chrome.com/apps/manifest/bluetooth
// Note: On some hardware, central and peripheral modes at the same time is
// supported but on hardware that doesn't support this, making this call
// will switch the device to peripheral mode. In the case of hardware which
// does not support both central and peripheral mode, attempting to use the
// device in both modes will lead to undefined behavior or prevent other
// central-role applications from behaving correctly (including the
// discovery of Bluetooth Low Energy devices).
// |advertisement|: The advertisement to advertise.
// |callback|: Called once the registeration is done and we've started
// advertising. Returns the id of the created advertisement.
[supportsPromises] static void registerAdvertisement(
Advertisement advertisement,
RegisterAdvertisementCallback callback);
// Unregisters an advertisement and stops its advertising. If the
// advertisement fails to unregister the only way to stop advertising
// might be to restart the device.
// |advertisementId|: Id of the advertisement to unregister.
// |callback|: Called once the advertisement is unregistered and is no
// longer being advertised.
[supportsPromises] static void unregisterAdvertisement(
long advertisementId,
ResultCallback callback);
// Resets advertising on the current device. It will unregister and
// stop all existing advertisements.
// |callback|: Called once the advertisements are reset.
[supportsPromises] static void resetAdvertising(ResultCallback callback);
// Set's the interval betweeen two consecutive advertisements. Note:
// This is a best effort. The actual interval may vary non-trivially
// from the requested intervals. On some hardware, there is a minimum
// interval of 100ms. The minimum and maximum values cannot exceed the
// the range allowed by the Bluetooth 4.2 specification.
// |minInterval|: Minimum interval between advertisments (in
// milliseconds). This cannot be lower than 20ms (as per the spec).
// |maxInterval|: Maximum interval between advertisments (in
// milliseconds). This cannot be more than 10240ms (as per the spec).
// |callback|: Called once the interval has been set.
[supportsPromises] static void setAdvertisingInterval(
long minInterval,
long maxInterval,
ResultCallback callback);
// Sends a response for a characteristic or descriptor read/write
// request.
// This function is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |response|: The response to the request.
static void sendRequestResponse(Response response);
};
interface Events {
// Fired whan a new GATT service has been discovered on a remote device.
// |service|: The GATT service that was added.
static void onServiceAdded(Service service);
// Fired when the state of a remote GATT service changes. This involves any
// characteristics and/or descriptors that get added or removed from the
// service, as well as "ServiceChanged" notifications from the remote
// device.
// |service|: The GATT service whose state has changed.
static void onServiceChanged(Service service);
// Fired when a GATT service that was previously discovered on a remote
// device has been removed.
// |service|: The GATT service that was removed.
static void onServiceRemoved(Service service);
// Fired when the value of a remote GATT characteristic changes, either as
// a result of a read request, or a value change notification/indication
// This event will only be sent if the app has enabled notifications by
// calling $(ref:startCharacteristicNotifications).
// |characteristic|: The GATT characteristic whose value has changed.
static void onCharacteristicValueChanged(Characteristic characteristic);
// Fired when the value of a remote GATT characteristic descriptor changes,
// usually as a result of a read request. This event exists
// mostly for convenience and will always be sent after a successful
// call to $(ref:readDescriptorValue).
// |descriptor|: The GATT characteristic descriptor whose value has
// changed.
static void onDescriptorValueChanged(Descriptor descriptor);
// Fired when a connected central device requests to read the value of a
// characteristic registered on the local GATT server. Not responding
// to this request for a long time may lead to a disconnection.
// This event is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |request|: Request data for this request.
// |characteristic|: The GATT characteristic whose value is requested.
static void onCharacteristicReadRequest(
Request request, DOMString characteristicId);
// Fired when a connected central device requests to write the value of a
// characteristic registered on the local GATT server. Not responding
// to this request for a long time may lead to a disconnection.
// This event is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |request|: Request data for this request.
// |characteristic|: The GATT characteristic whose value is being written.
static void onCharacteristicWriteRequest(
Request request, DOMString characteristicId);
// Fired when a connected central device requests to read the value of a
// descriptor registered on the local GATT server. Not responding to
// this request for a long time may lead to a disconnection.
// This event is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |request|: Request data for this request.
// |descriptor|: The GATT descriptor whose value is requested.
static void onDescriptorReadRequest(
Request request, DOMString descriptorId);
// Fired when a connected central device requests to write the value of a
// descriptor registered on the local GATT server. Not responding to
// this request for a long time may lead to a disconnection.
// This event is only available if the app has both the
// bluetooth:low_energy and the bluetooth:peripheral permissions set to
// true. The peripheral permission may not be available to all apps.
// |request|: Request data for this request.
// |descriptor|: The GATT descriptor whose value is being written.
static void onDescriptorWriteRequest(
Request request, DOMString descriptorId);
};
};
@@ -0,0 +1,189 @@
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.bluetoothPrivate</code> API to control the Bluetooth
// adapter state and handle device pairing.
// NOTE: This IDL is dependent on bluetooth.idl.
[implemented_in = "extensions/browser/api/bluetooth/bluetooth_private_api.h"]
namespace bluetoothPrivate {
// Events that can occur during pairing. The method used for pairing varies
// depending on the capability of the two devices.
enum PairingEventType {
// An alphanumeric PIN code is required to be entered by the user.
requestPincode,
// Display a PIN code to the user.
displayPincode,
// A numeric passkey is required to be entered by the user.
requestPasskey,
// Display a zero padded 6 digit numeric passkey that the user entered on
// the remote device. This event may occur multiple times during pairing to
// update the entered passkey.
displayPasskey,
// The number of keys inputted by the user on the remote device when
// entering a passkey. This event may be called multiple times during
// pairing to update the number of keys inputted.
keysEntered,
// Requests that a 6 digit passkey be displayed and the user confirms that
// both devies show the same passkey.
confirmPasskey,
// Requests authorization for a pairing under the just-works model. It is up
// to the app to ask for user confirmation.
requestAuthorization,
// Pairing is completed.
complete
};
// Results for connect(). See function declaration for details.
enum ConnectResultType {
alreadyConnected,
authCanceled,
authFailed,
authRejected,
authTimeout,
failed,
inProgress,
success,
unknownError,
unsupportedDevice,
notReady,
alreadyExists,
notConnected,
doesNotExist,
invalidArgs
};
// Valid pairing responses.
enum PairingResponse {
confirm, reject, cancel
};
enum TransportType {
le, bredr, dual
};
// A pairing event received from a Bluetooth device.
dictionary PairingEvent {
PairingEventType pairing;
bluetooth.Device device;
DOMString? pincode;
long? passkey;
long? enteredKey;
};
dictionary NewAdapterState {
// The human-readable name of the adapter.
DOMString? name;
// Whether or not the adapter has power.
boolean? powered;
// Whether the adapter is discoverable by other devices.
boolean? discoverable;
};
dictionary SetPairingResponseOptions {
// The remote device to send the pairing response.
bluetooth.Device device;
// The response type.
PairingResponse response;
// A 1-16 character alphanumeric set in response to
// <code>requestPincode</code>.
DOMString? pincode;
// An integer between 0-999999 set in response to
// <code>requestPasskey</code>.
long? passkey;
};
dictionary DiscoveryFilter {
// Transport type.
TransportType? transport;
// uuid of service or array of uuids
(DOMString or DOMString[])? uuids;
// RSSI ranging value. Only devices with RSSI higher than this value will be
// reported.
long? rssi;
// Pathloss ranging value. Only devices with pathloss lower than this value
// will be reported.
long? pathloss;
};
callback VoidCallback = void();
callback ConnectCallback = void(ConnectResultType result);
// These functions all report failures via chrome.runtime.lastError.
interface Functions {
// Changes the state of the Bluetooth adapter.
// |adapterState|: The new state of the adapter.
// |callback|: Called when all the state changes have been completed.
[supportsPromises] static void setAdapterState(
NewAdapterState adapterState,
optional VoidCallback callback);
[supportsPromises] static void setPairingResponse(
SetPairingResponseOptions options,
optional VoidCallback callback);
// Tears down all connections to the given device.
[supportsPromises] static void disconnectAll(
DOMString deviceAddress,
optional VoidCallback callback);
// Forgets the given device.
[supportsPromises] static void forgetDevice(DOMString deviceAddress,
optional VoidCallback callback);
// Set or clear discovery filter.
[supportsPromises] static void setDiscoveryFilter(
DiscoveryFilter discoveryFilter,
optional VoidCallback callback);
// Connects to the given device. This will only throw an error if the
// device address is invalid or the device is already connected. Otherwise
// this will succeed and invoke |callback| with ConnectResultType.
[supportsPromises] static void connect(DOMString deviceAddress,
optional ConnectCallback callback);
// Pairs the given device.
[supportsPromises] static void pair(DOMString deviceAddress,
optional VoidCallback callback);
// Record that a pairing attempt finished. Ignores cancellations.
static void recordPairing(bluetooth.Transport transport,
long pairingDurationMs,
optional ConnectResultType result);
// Record that a user-initiated reconnection attempt to an already paired
// device finished. Ignores cancellations.
static void recordReconnection(optional ConnectResultType result);
// Record that a user selected a device to connect to.
static void recordDeviceSelection(long selectionDurationMs,
boolean wasPaired,
bluetooth.Transport transport);
};
interface Events {
// Fired when a pairing event occurs.
// |pairingEvent|: A pairing event.
[maxListeners=1] static void onPairing(PairingEvent pairingEvent);
// Fired when a Bluetooth device changed its address.
static void onDeviceAddressChanged(bluetooth.Device device,
DOMString oldAddress);
};
};
@@ -0,0 +1,320 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.bluetoothSocket</code> API to send and receive data
// to Bluetooth devices using RFCOMM and L2CAP connections.
namespace bluetoothSocket {
// The socket properties specified in the $ref:create or $ref:update
// function. Each property is optional. If a property value is not specified,
// a default value is used when calling $ref:create, or the existing value is
// preserved when calling $ref:update.
dictionary SocketProperties {
// Flag indicating whether the socket is left open when the event page of
// the application is unloaded (see <a
// href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is <code>false.</code> When the
// application is loaded, any sockets previously opened with persistent=true
// can be fetched with $ref:getSockets.
boolean? persistent;
// An application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. The default value is 4096.
long? bufferSize;
};
// Result of <code>create</code> call.
dictionary CreateInfo {
// The ID of the newly created socket. Note that socket IDs created
// from this API are not compatible with socket IDs created from other APIs,
// such as the <code>$(ref:sockets.tcp)</code> API.
long socketId;
};
// Callback from the <code>create</code> method.
// |createInfo| : The result of the socket creation.
callback CreateCallback = void (CreateInfo createInfo);
// Callback from the <code>update</code> method.
callback UpdateCallback = void ();
// Callback from the <code>setPaused</code> method.
callback SetPausedCallback = void ();
// Options that may be passed to the <code>listenUsingRfcomm</code> and
// <code>listenUsingL2cap</code> methods. Each property is optional with a
// default being used if not specified.
dictionary ListenOptions {
// The RFCOMM Channel used by <code>listenUsingRfcomm</code>. If specified,
// this channel must not be previously in use or the method call will fail.
// When not specified, an unused channel will be automatically allocated.
long? channel;
// The L2CAP PSM used by <code>listenUsingL2cap</code>. If specified, this
// PSM must not be previously in use or the method call with fail. When
// not specified, an unused PSM will be automatically allocated.
long? psm;
// Length of the socket's listen queue. The default value depends on the
// operating system's host subsystem.
long? backlog;
};
// Callback from the <code>listenUsingRfcomm</code> and
// <code>listenUsingL2cap</code> methods.
callback ListenCallback = void ();
// Callback from the <code>connect</code> method.
callback ConnectCallback = void ();
// Callback from the <code>disconnect</code> method.
callback DisconnectCallback = void ();
// Callback from the <code>close</code> method.
callback CloseCallback = void ();
// Callback from the <code>send</code> method.
// |bytesSent| : The number of bytes sent.
callback SendCallback = void (long bytesSent);
// Result of the <code>getInfo</code> method.
dictionary SocketInfo {
// The socket identifier.
long socketId;
// Flag indicating if the socket remains open when the event page of the
// application is unloaded (see <code>SocketProperties.persistent</code>).
// The default value is "false".
boolean persistent;
// Application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. If no buffer size has been
// specified explictly, the value is not provided.
long? bufferSize;
// Flag indicating whether a connected socket blocks its peer from sending
// more data, or whether connection requests on a listening socket are
// dispatched through the <code>onAccept</code> event or queued up in the
// listen queue backlog.
// See <code>setPaused</code>. The default value is "false".
boolean paused;
// Flag indicating whether the socket is connected to a remote peer.
boolean connected;
// If the underlying socket is connected, contains the Bluetooth address of
// the device it is connected to.
DOMString? address;
// If the underlying socket is connected, contains information about the
// service UUID it is connected to, otherwise if the underlying socket is
// listening, contains information about the service UUID it is listening
// on.
DOMString? uuid;
};
// Callback from the <code>getInfo</code> method.
// |socketInfo| : Object containing the socket information.
callback GetInfoCallback = void (SocketInfo socketInfo);
// Callback from the <code>getSockets</code> method.
// |socketInfos| : Array of object containing socket information.
callback GetSocketsCallback = void (SocketInfo[] sockets);
// Data from an <code>onAccept</code> event.
dictionary AcceptInfo {
// The server socket identifier.
long socketId;
// The client socket identifier, i.e. the socket identifier of the newly
// established connection. This socket identifier should be used only with
// functions from the <code>chrome.bluetoothSocket</code> namespace. Note
// the client socket is initially paused and must be explictly un-paused by
// the application to start receiving data.
long clientSocketId;
};
enum AcceptError {
// A system error occurred and the connection may be unrecoverable.
system_error,
// The socket is not listening.
not_listening
};
// Data from an <code>onAcceptError</code> event.
dictionary AcceptErrorInfo {
// The server socket identifier.
long socketId;
// The error message.
DOMString errorMessage;
// An error code indicating what went wrong.
AcceptError error;
};
// Data from an <code>onReceive</code> event.
dictionary ReceiveInfo {
// The socket identifier.
long socketId;
// The data received, with a maxium size of <code>bufferSize</code>.
ArrayBuffer data;
};
enum ReceiveError {
// The connection was disconnected.
disconnected,
// A system error occurred and the connection may be unrecoverable.
system_error,
// The socket has not been connected.
not_connected
};
// Data from an <code>onReceiveError</code> event.
dictionary ReceiveErrorInfo {
// The socket identifier.
long socketId;
// The error message.
DOMString errorMessage;
// An error code indicating what went wrong.
ReceiveError error;
};
// These functions all report failures via chrome.runtime.lastError.
interface Functions {
// Creates a Bluetooth socket.
// |properties| : The socket properties (optional).
// |callback| : Called when the socket has been created.
[supportsPromises] static void create(optional SocketProperties properties,
CreateCallback callback);
// Updates the socket properties.
// |socketId| : The socket identifier.
// |properties| : The properties to update.
// |callback| : Called when the properties are updated.
[supportsPromises] static void update(long socketId,
SocketProperties properties,
optional UpdateCallback callback);
// Enables or disables a connected socket from receiving messages from its
// peer, or a listening socket from accepting new connections. The default
// value is "false". Pausing a connected socket is typically used by an
// application to throttle data sent by its peer. When a connected socket
// is paused, no <code>onReceive</code>event is raised. When a socket is
// connected and un-paused, <code>onReceive</code> events are raised again
// when messages are received. When a listening socket is paused, new
// connections are accepted until its backlog is full then additional
// connection requests are refused. <code>onAccept</code> events are raised
// only when the socket is un-paused.
[supportsPromises] static void setPaused(
long socketId,
boolean paused,
optional SetPausedCallback callback);
// Listen for connections using the RFCOMM protocol.
// |socketId| : The socket identifier.
// |uuid| : Service UUID to listen on.
// |options| : Optional additional options for the service.
// |callback| : Called when listen operation completes.
[supportsPromises] static void listenUsingRfcomm(
long socketId,
DOMString uuid,
optional ListenOptions options,
ListenCallback callback);
// Listen for connections using the L2CAP protocol.
// |socketId| : The socket identifier.
// |uuid| : Service UUID to listen on.
// |options| : Optional additional options for the service.
// |callback| : Called when listen operation completes.
[supportsPromises] static void listenUsingL2cap(
long socketId,
DOMString uuid,
optional ListenOptions options,
ListenCallback callback);
// Connects the socket to a remote Bluetooth device. When the
// <code>connect</code> operation completes successfully,
// <code>onReceive</code> events are raised when data is received from the
// peer. If a network error occur while the runtime is receiving packets,
// a <code>onReceiveError</code> event is raised, at which point no more
// <code>onReceive</code> event will be raised for this socket until the
// <code>setPaused(false)</code> method is called.
// |socketId| : The socket identifier.
// |address| : The address of the Bluetooth device.
// |uuid| : The UUID of the service to connect to.
// |callback| : Called when the connect attempt is complete.
[supportsPromises] static void connect(long socketId,
DOMString address,
DOMString uuid,
ConnectCallback callback);
// Disconnects the socket. The socket identifier remains valid.
// |socketId| : The socket identifier.
// |callback| : Called when the disconnect attempt is complete.
[supportsPromises] static void disconnect(
long socketId,
optional DisconnectCallback callback);
// Disconnects and destroys the socket. Each socket created should be
// closed after use. The socket id is no longer valid as soon at the
// function is called. However, the socket is guaranteed to be closed only
// when the callback is invoked.
// |socketId| : The socket identifier.
// |callback| : Called when the <code>close</code> operation completes.
[supportsPromises] static void close(long socketId,
optional CloseCallback callback);
// Sends data on the given Bluetooth socket.
// |socketId| : The socket identifier.
// |data| : The data to send.
// |callback| : Called with the number of bytes sent.
[supportsPromises] static void send(long socketId,
ArrayBuffer data,
optional SendCallback callback);
// Retrieves the state of the given socket.
// |socketId| : The socket identifier.
// |callback| : Called when the socket state is available.
[supportsPromises] static void getInfo(long socketId,
GetInfoCallback callback);
// Retrieves the list of currently opened sockets owned by the application.
// |callback| : Called when the list of sockets is available.
[supportsPromises] static void getSockets(GetSocketsCallback callback);
};
interface Events {
// Event raised when a connection has been established for a given socket.
// |info| : The event data.
static void onAccept(AcceptInfo info);
// Event raised when a network error occurred while the runtime was waiting
// for new connections on the given socket. Once this event is raised, the
// socket is set to <code>paused</code> and no more <code>onAccept</code>
// events are raised for this socket.
// |info| : The event data.
static void onAcceptError(AcceptErrorInfo info);
// Event raised when data has been received for a given socket.
// |info| : The event data.
static void onReceive(ReceiveInfo info);
// Event raised when a network error occured while the runtime was waiting
// for data on the socket. Once this event is raised, the socket is set to
// <code>paused</code> and no more <code>onReceive</code> events are raised
// for this socket.
// |info| : The event data.
static void onReceiveError(ReceiveErrorInfo info);
};
};
@@ -0,0 +1,65 @@
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Private API for HDMI CEC functionality.
[platforms=("chromeos")]
namespace cecPrivate {
enum DisplayCecPowerState {
// There was an error querying the power state of the display.
error,
// The kernel adapter for the CEC endpoint isn't configured (no EDID set).
adapterNotConfigured,
// No device ACKed the request on the CEC bus.
noDevice,
// The display is a powered on state.
on,
// The display is in standby mode.
standby,
// The display is currently transitioning to an awake state. It can't be
// relied on to show any output yet.
transitioningToOn,
// The display is currently transitioning to standby.
transitioningToStandby,
// Found a CEC endpoint but unable to determine the power state.
unknown
};
callback DisplayCecPowerStateCallback =
void(DisplayCecPowerState[] powerStates);
callback ChangePowerStateCallback = void();
interface Functions {
// Attempt to put all HDMI CEC compatible devices in standby.
//
// This is not guaranteed to have any effect on the connected displays.
// Displays that do not support HDMI CEC will not be affected.
//
// |callback| will be run as soon as all displays have been requested to
// change their power state.
[supportsPromises] static void sendStandBy(
optional ChangePowerStateCallback callback);
// Attempt to announce this device as the active input source towards all
// HDMI CEC enabled displays connected, waking them from standby if
// necessary.
//
// |callback| will be run as soon as all displays have been requested to
// change their power state.
[supportsPromises] static void sendWakeUp(
optional ChangePowerStateCallback callback);
// Queries all HDMI CEC capable displays for their current power state.
[supportsPromises] static void queryDisplayCecPowerState(
DisplayCecPowerStateCallback callback);
};
};
@@ -0,0 +1,55 @@
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.clipboard</code> API is provided to allow users to
// access data of the clipboard. This is a temporary solution for
// chromeos platform apps until open-web alternative is available. It will be
// deprecated once open-web solution is available, which could be in 2017 Q4.
[platforms=("chromeos", "lacros"),
implemented_in="extensions/browser/api/clipboard/clipboard_api.h"]
namespace clipboard {
// Supported image types.
enum ImageType {png, jpeg};
enum DataItemType {textPlain, textHtml};
// Additional data item to be added along with the |image_data| to describe
// the |image_data|.
dictionary AdditionalDataItem {
// Type of the additional data item.
DataItemType type;
// Content of the additional data item. Either the plain text string if
// |type| is "textPlain" or markup string if |type| is "textHtml". The
// data can not exceed 2MB.
DOMString data;
};
interface Events {
// Fired when clipboard data changes.
// Requires clipboard and clipboardRead permissions for adding listener to
// chrome.clipboard.onClipboardDataChanged event.
// After this event fires, the clipboard data is available by calling
// document.execCommand('paste').
static void onClipboardDataChanged();
};
callback SetImageDataCallback = void();
interface Functions {
// Sets image data to clipboard.
//
// |imageData|: The encoded image data.
// |type|: The type of image being passed.
// |additionalItems|: Additional data items for describing image data.
// The callback is called with <code>chrome.runtime.lastError</code>
// set to error code if there is an error.
// Requires clipboard and clipboardWrite permissions.
[supportsPromises] static void setImageData(
ArrayBuffer imageData,
ImageType type,
optional AdditionalDataItem[] additionalItems,
optional SetImageDataCallback callback);
};
};
@@ -0,0 +1,86 @@
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for the "content_scripts" manifest key.
[generate_error_messages]
namespace contentScripts {
// The stage in the document lifecycle when the javascript file is injected.
enum RunAt {
// The browser chooses a time to inject scripts between "document_end" and
// immediately after the window.onload event fires. The exact moment of
// injection depends on how complex the document is and how long it is
// taking to load, and is optimized for page load speed.
// Content scripts running at "document_idle" do not need to listen for the
// window.onload event; they are guaranteed to run after the DOM is
// complete. If a script definitely needs to run after window.onload, the
// extension can check if onload has already fired by using the
// document.readyState property.
document_idle,
// Scripts are injected after any files from css, but before any other DOM
// is constructed or any other script is run.
document_start,
// Scripts are injected immediately after the DOM is complete, but before
// subresources like images and frames have loaded.
document_end
};
// Describes a content script to be injected into a web page.
dictionary ContentScript {
// Specifies which pages this content script will be injected into. See
// <a href="develop/concepts/match-patterns">Match Patterns</a> for more
// details on the syntax of these strings.
DOMString[] matches;
// Excludes pages that this content script would otherwise be injected into.
// See <a href="develop/concepts/match-patterns">Match Patterns</a> for more
// details on the syntax of these strings.
DOMString[]? exclude_matches;
// The list of CSS files to be injected into matching pages. These are
// injected in the order they appear in this array, before any DOM is
// constructed or displayed for the page.
DOMString[]? css;
// The list of JavaScript files to be injected into matching pages. These
// are injected in the order they appear in this array.
DOMString[]? js;
// If specified true, it will inject into all frames, even if the frame is
// not the top-most frame in the tab. Each frame is checked independently
// for URL requirements; it will not inject into child frames if the URL
// requirements are not met. Defaults to false, meaning that only the top
// frame is matched.
boolean? all_frames;
// Whether the script should inject into any frames where the URL belongs to
// a scheme that would never match a specified Match Pattern, including
// about:, data:, blob:, and filesystem: schemes. In these cases, in order
// to determine if the script should inject, the origin of the URL is
// checked. If the origin is `null` (as is the case for data: URLs), then
// the "initiator" or "creator" origin is used (i.e., the origin of the
// frame that created or navigated this frame). Note that this may not
// be the parent frame, if the frame was navigated by another frame in the
// document hierarchy.
boolean? match_origin_as_fallback;
// Whether the script should inject into an about:blank frame where the
// parent or opener frame matches one of the patterns declared in matches.
// Defaults to false.
boolean? match_about_blank;
// Applied after matches to include only those URLs that also match this
// glob. Intended to emulate the
// <a href="http://wiki.greasespot.net/Metadata_Block#.40include">@include
// </a> Greasemonkey keyword.
DOMString[]? include_globs;
// Applied after matches to exclude URLs that match this glob. Intended to
// emulate the
// <a href="https://wiki.greasespot.net/Metadata_Block#.40exclude">@exclude
// </a> Greasemonkey keyword.
DOMString[]? exclude_globs;
// Specifies when JavaScript files are injected into the web page. The
// preferred and default value is <code>document_idle</code>.
RunAt? run_at;
// The JavaScript "world" to run the script in. Defaults to
// <code>ISOLATED</code>. Only available in Manifest V3 extensions.
[nodoc] extensionTypes.ExecutionWorld? world;
};
dictionary ManifestKeys {
ContentScript[] content_scripts;
};
};
@@ -0,0 +1,16 @@
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for manifest keys relating to the cross origin isolation
// response headers.
namespace crossOriginIsolation {
dictionary ResponseHeader {
DOMString? value;
};
dictionary ManifestKeys {
ResponseHeader? cross_origin_embedder_policy;
ResponseHeader? cross_origin_opener_policy;
};
};
@@ -0,0 +1,838 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.declarativeNetRequest</code> API is used to block or modify
// network requests by specifying declarative rules. This lets extensions
// modify network requests without intercepting them and viewing their content,
// thus providing more privacy.
[generate_error_messages]
namespace declarativeNetRequest {
// This describes the resource type of the network request.
enum ResourceType {
main_frame,
sub_frame,
stylesheet,
script,
image,
font,
object,
xmlhttprequest,
ping,
csp_report,
media,
websocket,
webtransport,
webbundle,
other
};
// This describes the HTTP request method of a network request.
enum RequestMethod {
connect,
delete,
get,
head,
options,
patch,
post,
put,
other
};
// This describes whether the request is first or third party to the frame in
// which it originated. A request is said to be first party if it has the same
// domain (eTLD+1) as the frame in which the request originated.
enum DomainType {
// The network request is first party to the frame in which it originated.
firstParty,
// The network request is third party to the frame in which it originated.
thirdParty
};
// This describes the possible operations for a "modifyHeaders" rule.
enum HeaderOperation {
// Adds a new entry for the specified header. This operation is not
// supported for request headers.
append,
// Sets a new value for the specified header, removing any existing headers
// with the same name.
set,
// Removes all entries for the specified header.
remove
};
// Describes the kind of action to take if a given RuleCondition matches.
enum RuleActionType {
// Block the network request.
block,
// Redirect the network request.
redirect,
// Allow the network request. The request won't be intercepted if there is
// an allow rule which matches it.
allow,
// Upgrade the network request url's scheme to https if the request is http
// or ftp.
upgradeScheme,
// Modify request/response headers from the network request.
modifyHeaders,
// Allow all requests within a frame hierarchy, including the frame request
// itself.
allowAllRequests
};
// Describes the reason why a given regular expression isn't supported.
enum UnsupportedRegexReason {
// The regular expression is syntactically incorrect, or uses features
// not available in the
// <a href = "https://github.com/google/re2/wiki/Syntax">RE2 syntax</a>.
syntaxError,
// The regular expression exceeds the memory limit.
memoryLimitExceeded
};
// Describes a single static ruleset.
dictionary Ruleset {
// A non-empty string uniquely identifying the ruleset. IDs beginning with
// '_' are reserved for internal use.
DOMString id;
// The path of the JSON ruleset relative to the extension directory.
DOMString path;
// Whether the ruleset is enabled by default.
boolean enabled;
};
// Represents a query key-value pair.
dictionary QueryKeyValue {
DOMString key;
DOMString value;
// If true, the query key is replaced only if it's already present.
// Otherwise, the key is also added if it's missing. Defaults to false.
boolean? replaceOnly;
};
// Describes modification to the url query.
dictionary QueryTransform {
// The list of query keys to be removed.
DOMString[]? removeParams;
// The list of query key-value pairs to be added or replaced.
QueryKeyValue[]? addOrReplaceParams;
};
// Describes modification to various url components.
[noinline_doc]
dictionary URLTransform {
// The new scheme for the request. Allowed values are "http", "https",
// "ftp" and "chrome-extension".
DOMString? scheme;
// The new host for the request.
DOMString? host;
// The new port for the request. If empty, the existing port is cleared.
DOMString? port;
// The new path for the request. If empty, the existing path is cleared.
DOMString? path;
// The new query for the request. Should be either empty, in which case the
// existing query is cleared; or should begin with '?'.
DOMString? query;
// Add, remove or replace query key-value pairs.
QueryTransform? queryTransform;
// The new fragment for the request. Should be either empty, in which case
// the existing fragment is cleared; or should begin with '#'.
DOMString? fragment;
// The new username for the request.
DOMString? username;
// The new password for the request.
DOMString? password;
};
dictionary Redirect {
// Path relative to the extension directory. Should start with '/'.
DOMString? extensionPath;
// Url transformations to perform.
URLTransform? transform;
// The redirect url. Redirects to JavaScript urls are not allowed.
DOMString? url;
// Substitution pattern for rules which specify a <code>regexFilter</code>.
// The first match of <code>regexFilter</code> within the url will be
// replaced with this pattern. Within <code>regexSubstitution</code>,
// backslash-escaped digits (\1 to \9) can be used to insert the
// corresponding capture groups. \0 refers to the entire matching text.
DOMString? regexSubstitution;
};
// TODO(crbug.com/1141166): Add documentation once feature is complete.
[nodoc] dictionary HeaderInfo {
// The name of the header.
DOMString header;
// If specified, match this rule if the header's value contains at least one
// element in this list.
DOMString[]? values;
// If specified, the rule is not matched if the header exists but its value
// contains at least one element in this list.
DOMString[]? excludedValues;
};
[noinline_doc] dictionary RuleCondition {
// The pattern which is matched against the network request url.
// Supported constructs:
//
// <b>'*'</b> : Wildcard: Matches any number of characters.
//
// <b>'|'</b> : Left/right anchor: If used at either end of the pattern,
// specifies the beginning/end of the url respectively.
//
// <b>'||'</b> : Domain name anchor: If used at the beginning of the pattern,
// specifies the start of a (sub-)domain of the URL.
//
// <b>'^'</b> : Separator character: This matches anything except a letter, a
// digit or one of the following: _ - . %. This can also match
// the end of the URL.
//
// Therefore <code>urlFilter</code> is composed of the following parts:
// (optional Left/Domain name anchor) + pattern + (optional Right anchor).
//
// If omitted, all urls are matched. An empty string is not allowed.
//
// A pattern beginning with <code>||*</code> is not allowed. Use
// <code>*</code> instead.
//
// Note: Only one of <code>urlFilter</code> or <code>regexFilter</code> can
// be specified.
//
// Note: The <code>urlFilter</code> must be composed of only ASCII
// characters. This is matched against a url where the host is encoded in
// the punycode format (in case of internationalized domains) and any other
// non-ascii characters are url encoded in utf-8.
// For example, when the request url is
// http://abc.&#x0440;&#x0444;?q=&#x0444;, the
// <code>urlFilter</code> will be matched against the url
// http://abc.xn--p1ai/?q=%D1%84.
DOMString? urlFilter;
// Regular expression to match against the network request url. This follows
// the <a href = "https://github.com/google/re2/wiki/Syntax">RE2 syntax</a>.
//
// Note: Only one of <code>urlFilter</code> or <code>regexFilter</code> can
// be specified.
//
// Note: The <code>regexFilter</code> must be composed of only ASCII
// characters. This is matched against a url where the host is encoded in
// the punycode format (in case of internationalized domains) and any other
// non-ascii characters are url encoded in utf-8.
DOMString? regexFilter;
// Whether the <code>urlFilter</code> or <code>regexFilter</code>
// (whichever is specified) is case sensitive. Default is false.
boolean? isUrlFilterCaseSensitive;
// The rule will only match network requests originating from the list of
// <code>initiatorDomains</code>. If the list is omitted, the rule is
// applied to requests from all domains. An empty list is not allowed.
//
// Notes:
// <ul>
// <li>Sub-domains like "a.example.com" are also allowed.</li>
// <li>The entries must consist of only ascii characters.</li>
// <li>Use punycode encoding for internationalized domains.</li>
// <li>
// This matches against the request initiator and not the request url.
// </li>
// <li>Sub-domains of the listed domains are also matched.</li>
// </ul>
DOMString[]? initiatorDomains;
// The rule will not match network requests originating from the list of
// <code>excludedInitiatorDomains</code>. If the list is empty or omitted,
// no domains are excluded. This takes precedence over
// <code>initiatorDomains</code>.
//
// Notes:
// <ul>
// <li>Sub-domains like "a.example.com" are also allowed.</li>
// <li>The entries must consist of only ascii characters.</li>
// <li>Use punycode encoding for internationalized domains.</li>
// <li>
// This matches against the request initiator and not the request url.
// </li>
// <li>Sub-domains of the listed domains are also excluded.</li>
// </ul>
DOMString[]? excludedInitiatorDomains;
// The rule will only match network requests when the domain matches one
// from the list of <code>requestDomains</code>. If the list is omitted,
// the rule is applied to requests from all domains. An empty list is not
// allowed.
//
// Notes:
// <ul>
// <li>Sub-domains like "a.example.com" are also allowed.</li>
// <li>The entries must consist of only ascii characters.</li>
// <li>Use punycode encoding for internationalized domains.</li>
// <li>Sub-domains of the listed domains are also matched.</li>
// </ul>
DOMString[]? requestDomains;
// The rule will not match network requests when the domains matches one
// from the list of <code>excludedRequestDomains</code>. If the list is
// empty or omitted, no domains are excluded. This takes precedence over
// <code>requestDomains</code>.
//
// Notes:
// <ul>
// <li>Sub-domains like "a.example.com" are also allowed.</li>
// <li>The entries must consist of only ascii characters.</li>
// <li>Use punycode encoding for internationalized domains.</li>
// <li>Sub-domains of the listed domains are also excluded.</li>
// </ul>
DOMString[]? excludedRequestDomains;
// The rule will only match network requests originating from the list of
// <code>domains</code>.
[deprecated="Use $(ref:initiatorDomains) instead"]
DOMString[]? domains;
// The rule will not match network requests originating from the list of
// <code>excludedDomains</code>.
[deprecated="Use $(ref:excludedInitiatorDomains) instead"]
DOMString[]? excludedDomains;
// List of resource types which the rule can match. An empty list is not
// allowed.
//
// Note: this must be specified for <code>allowAllRequests</code> rules and
// may only include the <code>sub_frame</code> and <code>main_frame</code>
// resource types.
ResourceType[]? resourceTypes;
// List of resource types which the rule won't match. Only one of
// <code>resourceTypes</code> and <code>excludedResourceTypes</code> should
// be specified. If neither of them is specified, all resource types except
// "main_frame" are blocked.
ResourceType[]? excludedResourceTypes;
// List of HTTP request methods which the rule can match. An empty list is
// not allowed.
//
// Note: Specifying a <code>requestMethods</code> rule condition will also
// exclude non-HTTP(s) requests, whereas specifying
// <code>excludedRequestMethods</code> will not.
RequestMethod[]? requestMethods;
// List of request methods which the rule won't match. Only one of
// <code>requestMethods</code> and <code>excludedRequestMethods</code>
// should be specified. If neither of them is specified, all request methods
// are matched.
RequestMethod[]? excludedRequestMethods;
// Specifies whether the network request is first-party or third-party to
// the domain from which it originated. If omitted, all requests are
// accepted.
DomainType? domainType;
// List of $(ref:tabs.Tab.id) which the rule should match. An ID of
// $(ref:tabs.TAB_ID_NONE) matches requests which don't originate from a
// tab. An empty list is not allowed. Only supported for session-scoped
// rules.
long[]? tabIds;
// List of $(ref:tabs.Tab.id) which the rule should not match. An ID of
// $(ref:tabs.TAB_ID_NONE) excludes requests which don't originate from a
// tab. Only supported for session-scoped rules.
long[]? excludedTabIds;
// Rule matches if the request matches any response header in this list (if
// specified).
// TODO(crbug,com/1141166): Add documentation once feature is complete.
[nodoc] HeaderInfo[]? responseHeaders;
// Rule does not match if the request has any of the specified headers.
// TODO(crbug,com/1141166): Add documentation once feature is complete.
[nodoc] DOMString[]? excludedResponseHeaders;
};
dictionary ModifyHeaderInfo {
// The name of the header to be modified.
DOMString header;
// The operation to be performed on a header.
HeaderOperation operation;
// The new value for the header. Must be specified for <code>append</code>
// and <code>set</code> operations.
DOMString? value;
};
[noinline_doc]
dictionary RuleAction {
// The type of action to perform.
RuleActionType type;
// Describes how the redirect should be performed. Only valid for redirect
// rules.
Redirect? redirect;
// The request headers to modify for the request. Only valid if
// RuleActionType is "modifyHeaders".
ModifyHeaderInfo[]? requestHeaders;
// The response headers to modify for the request. Only valid if
// RuleActionType is "modifyHeaders".
ModifyHeaderInfo[]? responseHeaders;
};
dictionary Rule {
// An id which uniquely identifies a rule. Mandatory and should be >= 1.
long id;
// Rule priority. Defaults to 1. When specified, should be >= 1.
long? priority;
// The condition under which this rule is triggered.
RuleCondition condition;
// The action to take if this rule is matched.
RuleAction action;
};
// Uniquely describes a declarative rule specified by the extension.
dictionary MatchedRule {
// A matching rule's ID.
long ruleId;
// ID of the $(ref:Ruleset) this rule belongs to. For a rule originating
// from the set of dynamic rules, this will be equal to
// $(ref:DYNAMIC_RULESET_ID).
DOMString rulesetId;
};
[noinline_doc]
dictionary GetRulesFilter {
// If specified, only rules with matching IDs are included.
long[]? ruleIds;
};
[noinline_doc]
dictionary MatchedRuleInfo {
MatchedRule rule;
// The time the rule was matched. Timestamps will correspond to the
// Javascript convention for times, i.e. number of milliseconds since the
// epoch.
double timeStamp;
// The tabId of the tab from which the request originated if the tab is
// still active. Else -1.
long tabId;
};
dictionary MatchedRulesFilter {
// If specified, only matches rules for the given tab. Matches rules not
// associated with any active tab if set to -1.
long? tabId;
// If specified, only matches rules after the given timestamp.
double? minTimeStamp;
};
dictionary RulesMatchedDetails {
// Rules matching the given filter.
MatchedRuleInfo[] rulesMatchedInfo;
};
[noinline_doc]
dictionary RequestDetails {
// The ID of the request. Request IDs are unique within a browser session.
DOMString requestId;
// The URL of the request.
DOMString url;
// The origin where the request was initiated. This does not change through
// redirects. If this is an opaque origin, the string 'null' will be used.
DOMString? initiator;
// Standard HTTP method.
DOMString method;
// The value 0 indicates that the request happens in the main frame; a
// positive value indicates the ID of a subframe in which the request
// happens. If the document of a (sub-)frame is loaded (<code>type</code> is
// <code>main_frame</code> or <code>sub_frame</code>), <code>frameId</code>
// indicates the ID of this frame, not the ID of the outer frame. Frame IDs
// are unique within a tab.
long frameId;
// The unique identifier for the frame's document, if this request is for a
// frame.
DOMString? documentId;
// The type of the frame, if this request is for a frame.
extensionTypes.FrameType? frameType;
// The lifecycle of the frame's document, if this request is for a
// frame.
extensionTypes.DocumentLifecycle? documentLifecycle;
// ID of frame that wraps the frame which sent the request. Set to -1 if no
// parent frame exists.
long parentFrameId;
// The unique identifier for the frame's parent document, if this request
// is for a frame and has a parent.
DOMString? parentDocumentId;
// The ID of the tab in which the request takes place. Set to -1 if the
// request isn't related to a tab.
long tabId;
// The resource type of the request.
ResourceType type;
};
dictionary TestMatchRequestDetails {
// The URL of the hypothetical request.
DOMString url;
// The initiator URL (if any) for the hypothetical request.
DOMString? initiator;
// Standard HTTP method of the hypothetical request. Defaults to "get" for
// HTTP requests and is ignored for non-HTTP requests.
RequestMethod? method;
// The resource type of the hypothetical request.
ResourceType type;
// The ID of the tab in which the hypothetical request takes place. Does
// not need to correspond to a real tab ID. Default is -1, meaning that
// the request isn't related to a tab.
long? tabId;
};
dictionary MatchedRuleInfoDebug {
MatchedRule rule;
// Details about the request for which the rule was matched.
RequestDetails request;
};
[nodoc] dictionary DNRInfo {
Ruleset[] rule_resources;
};
[nodoc] dictionary ManifestKeys {
DNRInfo declarative_net_request;
};
dictionary RegexOptions {
// The regular expresson to check.
DOMString regex;
// Whether the <code>regex</code> specified is case sensitive. Default is
// true.
boolean? isCaseSensitive;
// Whether the <code>regex</code> specified requires capturing. Capturing is
// only required for redirect rules which specify a
// <code>regexSubstition</code> action. The default is false.
boolean? requireCapturing;
};
dictionary IsRegexSupportedResult {
boolean isSupported;
// Specifies the reason why the regular expression is not supported. Only
// provided if <code>isSupported</code> is false.
UnsupportedRegexReason? reason;
};
dictionary TestMatchOutcomeResult {
// The rules (if any) that match the hypothetical request.
MatchedRule[] matchedRules;
};
dictionary UpdateRuleOptions {
// IDs of the rules to remove. Any invalid IDs will be ignored.
long[]? removeRuleIds;
// Rules to add.
Rule[]? addRules;
};
dictionary UpdateRulesetOptions {
// The set of ids corresponding to a static $(ref:Ruleset) that should be
// disabled.
DOMString[]? disableRulesetIds;
// The set of ids corresponding to a static $(ref:Ruleset) that should be
// enabled.
DOMString[]? enableRulesetIds;
};
dictionary UpdateStaticRulesOptions {
// The id corresponding to a static $(ref:Ruleset).
DOMString rulesetId;
// Set of ids corresponding to rules in the $(ref:Ruleset) to disable.
long[]? disableRuleIds;
// Set of ids corresponding to rules in the $(ref:Ruleset) to enable.
long[]? enableRuleIds;
};
dictionary GetDisabledRuleIdsOptions {
// The id corresponding to a static $(ref:Ruleset).
DOMString rulesetId;
};
dictionary TabActionCountUpdate {
// The tab for which to update the action count.
long tabId;
// The amount to increment the tab's action count by. Negative values will
// decrement the count.
long increment;
};
dictionary ExtensionActionOptions {
// Whether to automatically display the action count for a page as the
// extension's badge text. This preference is persisted across sessions.
boolean? displayActionCountAsBadgeText;
// Details of how the tab's action count should be adjusted.
TabActionCountUpdate? tabUpdate;
};
callback EmptyCallback = void();
callback GetAllowedPagesCallback = void(DOMString[] result);
callback GetRulesCallback = void(Rule[] rules);
callback GetMatchedRulesCallback = void(RulesMatchedDetails details);
callback GetEnabledRulesetsCallback = void(DOMString[] rulesetIds);
callback GetDisabledRuleIdsCallback = void(long[] disabledRuleIds);
callback IsRegexSupportedCallback = void(IsRegexSupportedResult result);
callback GetAvailableStaticRuleCountCallback = void(long count);
callback TestMatchOutcomeCallback = void(TestMatchOutcomeResult result);
interface Functions {
// Modifies the current set of dynamic rules for the extension.
// The rules with IDs listed in <code>options.removeRuleIds</code> are first
// removed, and then the rules given in <code>options.addRules</code> are
// added. Notes:
// <ul>
// <li>This update happens as a single atomic operation: either all
// specified rules are added and removed, or an error is returned.</li>
// <li>These rules are persisted across browser sessions and across
// extension updates.</li>
// <li>Static rules specified as part of the extension package can not be
// removed using this function.</li>
// <li>$(ref:MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES) is the maximum number
// of combined dynamic and session rules an extension can add.</li>
// </ul>
// |callback|: Called once the update is complete or has failed. In case of
// an error, $(ref:runtime.lastError) will be set and no change will be made
// to the rule set. This can happen for multiple reasons, such as invalid
// rule format, duplicate rule ID, rule count limit exceeded, internal
// errors, and others.
[supportsPromises] static void updateDynamicRules(
UpdateRuleOptions options,
optional EmptyCallback callback);
// Returns the current set of dynamic rules for the extension. Callers can
// optionally filter the list of fetched rules by specifying a
// <code>filter</code>.
// |filter|: An object to filter the list of fetched rules.
// |callback|: Called with the set of dynamic rules. An error might be
// raised in case of transient internal errors.
[supportsPromises] static void getDynamicRules(
optional GetRulesFilter filter,
GetRulesCallback callback);
// Modifies the current set of session scoped rules for the extension.
// The rules with IDs listed in <code>options.removeRuleIds</code> are first
// removed, and then the rules given in <code>options.addRules</code> are
// added. Notes:
// <ul>
// <li>This update happens as a single atomic operation: either all
// specified rules are added and removed, or an error is returned.</li>
// <li>These rules are not persisted across sessions and are backed in
// memory.</li>
// <li>$(ref:MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES) is the maximum number
// of combined dynamic and session rules an extension can add.</li>
// </ul>
// |callback|: Called once the update is complete or has failed. In case of
// an error, $(ref:runtime.lastError) will be set and no change will be made
// to the rule set. This can happen for multiple reasons, such as invalid
// rule format, duplicate rule ID, rule count limit exceeded, and others.
[supportsPromises] static void updateSessionRules(
UpdateRuleOptions options,
optional EmptyCallback callback);
// Returns the current set of session scoped rules for the extension.
// Callers can optionally filter the list of fetched rules by specifying a
// <code>filter</code>.
// |filter|: An object to filter the list of fetched rules.
// |callback|: Called with the set of session scoped rules.
[supportsPromises] static void getSessionRules(
optional GetRulesFilter filter,
GetRulesCallback callback);
// Updates the set of enabled static rulesets for the extension. The
// rulesets with IDs listed in <code>options.disableRulesetIds</code> are
// first removed, and then the rulesets listed in
// <code>options.enableRulesetIds</code> are added.<br/>
// Note that the set of enabled static rulesets is persisted across sessions
// but not across extension updates, i.e. the <code>rule_resources</code>
// manifest key will determine the set of enabled static rulesets on each
// extension update.
// |callback|: Called once the update is complete. In case of an error,
// $(ref:runtime.lastError) will be set and no change will be made to set of
// enabled rulesets. This can happen for multiple reasons, such as invalid
// ruleset IDs, rule count limit exceeded, or internal errors.
[supportsPromises] static void updateEnabledRulesets(
UpdateRulesetOptions options,
optional EmptyCallback callback);
// Returns the ids for the current set of enabled static rulesets.
// |callback|: Called with a list of ids, where each id corresponds to an
// enabled static $(ref:Ruleset).
[supportsPromises] static void getEnabledRulesets(
GetEnabledRulesetsCallback callback);
// Disables and enables individual static rules in a $(ref:Ruleset).
// Changes to rules belonging to a disabled $(ref:Ruleset) will take
// effect the next time that it becomes enabled.
// |callback|: Called once the update is complete. In case of an error,
// $(ref:runtime.lastError) will be set and no change will be made to the
// enabled static rules.
[supportsPromises] static void updateStaticRules(
UpdateStaticRulesOptions options,
optional EmptyCallback callback);
// Returns the list of static rules in the given $(ref:Ruleset) that are
// currently disabled.
// |options|: Specifies the ruleset to query.
// |callback|: Called with a list of ids that correspond to the disabled
// rules in that ruleset.
[supportsPromises] static void getDisabledRuleIds(
GetDisabledRuleIdsOptions options,
GetDisabledRuleIdsCallback callback);
// Returns all rules matched for the extension. Callers can optionally
// filter the list of matched rules by specifying a <code>filter</code>.
// This method is only available to extensions with the
// <code>declarativeNetRequestFeedback</code> permission or having the
// <code>activeTab</code> permission granted for the <code>tabId</code>
// specified in <code>filter</code>.
// Note: Rules not associated with an active document that were matched more
// than five minutes ago will not be returned.
// |filter|: An object to filter the list of matched rules.
// |callback|: Called once the list of matched rules has been fetched. In
// case of an error, $(ref:runtime.lastError) will be set and no rules will
// be returned. This can happen for multiple reasons, such as insufficient
// permissions, or exceeding the quota.
[supportsPromises] static void getMatchedRules(
optional MatchedRulesFilter filter,
GetMatchedRulesCallback callback);
// Configures if the action count for tabs should be displayed as the
// extension action's badge text and provides a way for that action count to
// be incremented.
[supportsPromises] static void setExtensionActionOptions(
ExtensionActionOptions options,
optional EmptyCallback callback);
// Checks if the given regular expression will be supported as a
// <code>regexFilter</code> rule condition.
// |regexOptions|: The regular expression to check.
// |callback|: Called with details consisting of whether the regular
// expression is supported and the reason if not.
[supportsPromises] static void isRegexSupported(
RegexOptions regexOptions,
IsRegexSupportedCallback callback);
// Returns the number of static rules an extension can enable before the
// <a href="#global-static-rule-limit">global static rule limit</a> is
// reached.
[supportsPromises] static void getAvailableStaticRuleCount(
GetAvailableStaticRuleCountCallback callback);
// Checks if any of the extension's declarativeNetRequest rules would match
// a hypothetical request.
// Note: Only available for unpacked extensions as this is only intended to
// be used during extension development.
// |requestDetails|: The request details to test.
// |callback|: Called with the details of matched rules.
[supportsPromises] static void testMatchOutcome(
TestMatchRequestDetails request,
TestMatchOutcomeCallback callback);
};
interface Properties {
// The minimum number of static rules guaranteed to an extension across its
// enabled static rulesets. Any rules above this limit will count towards
// the <a href="#global-static-rule-limit">global static rule limit</a>.
[value=30000] static long GUARANTEED_MINIMUM_STATIC_RULES();
// The maximum number of combined dynamic and session scoped rules an
// extension can add.
[nodoc, value=5000] static long MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES();
// The maximum number of dynamic rules that an extension can add.
[value=30000] static long MAX_NUMBER_OF_DYNAMIC_RULES();
// The maximum number of "unsafe" dynamic rules that an extension can add.
[value=5000] static long MAX_NUMBER_OF_UNSAFE_DYNAMIC_RULES();
// The maximum number of session scoped rules that an extension can add.
[value=5000] static long MAX_NUMBER_OF_SESSION_RULES();
// The maximum number of "unsafe" session scoped rules that an extension can
// add.
[value=5000] static long MAX_NUMBER_OF_UNSAFE_SESSION_RULES();
// Time interval within which <code>MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL
// getMatchedRules</code> calls can be made, specified in minutes.
// Additional calls will fail immediately and set $(ref:runtime.lastError).
// Note: <code>getMatchedRules</code> calls associated with a user gesture
// are exempt from the quota.
[value=10] static long GETMATCHEDRULES_QUOTA_INTERVAL();
// The number of times <code>getMatchedRules</code> can be called within a
// period of <code>GETMATCHEDRULES_QUOTA_INTERVAL</code>.
[value=20] static long MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL();
// The maximum number of regular expression rules that an extension can
// add. This limit is evaluated separately for the set of dynamic rules and
// those specified in the rule resources file.
[value=1000] static long MAX_NUMBER_OF_REGEX_RULES();
// The maximum number of static <code>Rulesets</code> an extension can
// specify as part of the <code>"rule_resources"</code> manifest key.
[value=100] static long MAX_NUMBER_OF_STATIC_RULESETS();
// The maximum number of static <code>Rulesets</code> an extension can
// enable at any one time.
[value=50] static long MAX_NUMBER_OF_ENABLED_STATIC_RULESETS();
// Ruleset ID for the dynamic rules added by the extension.
[value="_dynamic"] static DOMString DYNAMIC_RULESET_ID();
// Ruleset ID for the session-scoped rules added by the extension.
[value="_session"] static DOMString SESSION_RULESET_ID();
};
interface Events {
// Fired when a rule is matched with a request. Only available for unpacked
// extensions with the <code>declarativeNetRequestFeedback</code> permission
// as this is intended to be used for debugging purposes only.
// |info|: The rule that has been matched along with information about the
// associated request.
static void onRuleMatchedDebug(MatchedRuleInfoDebug info);
};
};
@@ -0,0 +1,37 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.diagnostics</code> API to query various properties of
// the environment that may be useful for diagnostics.
namespace diagnostics {
dictionary SendPacketOptions {
// Target IP address.
DOMString ip;
// Packet time to live value. If omitted, the system default value will be
// used.
long? ttl;
// Packet timeout in seconds. If omitted, the system default value will be
// used.
long? timeout;
// Size of the payload. If omitted, the system default value will be used.
long? size;
};
dictionary SendPacketResult {
// The IP of the host which we receives the ICMP reply from.
// The IP may differs from our target IP if the packet's ttl is used up.
DOMString ip;
// Latency in millisenconds.
double latency;
};
callback SendPacketCallback = void(SendPacketResult result);
interface Functions {
// Send a packet of the given type with the given parameters.
[supportsPromises] static void sendPacket(SendPacketOptions options,
SendPacketCallback callback);
};
};
+27
View File
@@ -0,0 +1,27 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.dns</code> API for dns resolution.
namespace dns {
dictionary ResolveCallbackResolveInfo {
// The result code. Zero indicates success.
long resultCode;
// A string representing the IP address literal. Supplied only if resultCode
// indicates success.
DOMString? address;
};
callback ResolveCallback = void (ResolveCallbackResolveInfo resolveInfo);
interface Functions {
// Resolves the given hostname or IP address literal.
// |hostname| : The hostname to resolve.
// |callback| : Called when the resolution operation completes.
[supportsPromises] static void resolve(DOMString hostname,
ResolveCallback callback);
};
};
@@ -0,0 +1,24 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Internal API for the &lt;extensiontoptions&gt; tag
namespace extensionOptionsInternal {
dictionary SizeChangedOptions {
long oldWidth;
long oldHeight;
long newWidth;
long newHeight;
};
dictionary PreferredSizeChangedOptions {
double width;
double height;
};
interface Events {
static void onClose();
static void onLoad();
static void onPreferredSizeChanged(PreferredSizeChangedOptions options);
};
};
@@ -0,0 +1,286 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.feedbackPrivate</code> API to provide Chrome [OS]
// feedback to the Google Feedback servers.
namespace feedbackPrivate {
dictionary AttachedFile {
DOMString name;
[instanceOf=Blob] object? data;
};
dictionary LogsMapEntry {
DOMString key;
DOMString value;
};
// Supported feedback flows.
enum FeedbackFlow {
// Flow for regular user. This is the default.
regular,
// Flow on the ChromeOS login screen. URL entry, file attaching and landing
// page is disabled for this flow.
login,
// Flow when the feedback is requested from the sad tab ("Aw, Snap!") page
// when the renderer crashes.
sadTabCrash,
// Flow for internal Google users.
googleInternal,
// Flow for AI features.
ai
};
dictionary FeedbackInfo {
// File to attach to the feedback report.
AttachedFile? attachedFile;
// An optional tag to label what type this feedback is.
DOMString? categoryTag;
// The feedback text describing the user issue.
DOMString description;
// The placeholder text that will be shown in the description field when
// it's empty.
DOMString? descriptionPlaceholder;
// The e-mail of the user that initiated this feedback.
DOMString? email;
// The URL of the page that this issue was being experienced on.
DOMString? pageUrl;
// Optional product ID to override the Chrome [OS] product id that is
// usually passed to the feedback server.
long? productId;
// Screenshot to send with this feedback.
[instanceOf=Blob] object? screenshot;
// Optional id for performance trace data that can be included in this
// report.
long? traceId;
// An array of key/value pairs providing system information for this
// feedback report.
LogsMapEntry[]? systemInformation;
// True if we have permission to add histograms to this feedback report.
boolean? sendHistograms;
// Optional feedback UI flow. Default is the regular user flow.
FeedbackFlow? flow;
// TODO(rkc): Remove these once we have bindings to send blobs to Chrome.
// Used internally to store the blob uuid after parameter customization.
DOMString? attachedFileBlobUuid;
DOMString? screenshotBlobUuid;
// Whether to use the system-provided window frame or custom frame controls.
boolean? useSystemWindowFrame;
// Whether or not to send bluetooth logs with this report.
boolean? sendBluetoothLogs;
// Whether or not to send tab titles with this report.
boolean? sendTabTitles;
// Whether or not to send Assistant feedback to Assistant server.
boolean? assistantDebugInfoAllowed;
// Whether or not triggered from Assistant.
boolean? fromAssistant;
// Whether or not to include bluetooth logs.
boolean? includeBluetoothLogs;
// Whether to show questionnaire in the report description based on detected
// domain-related keywords (crbug/1241169).
boolean? showQuestionnaire;
// Whether or not triggered for Autofill.
boolean? fromAutofill;
// A JSON formatted string containing autofill metadata for this
// feedback report.
DOMString? autofillMetadata;
// Whether or not |autofillMetadata| should be included in the feedback
// report.
boolean? sendAutofillMetadata;
// Whether or not the content is offensive or unsafe.
boolean? isOffensiveOrUnsafe;
// A JSON formatted string containing ai metadata.
DOMString? aiMetadata;
};
// Possible statuses that can result from sending feedback.
enum Status {success, delayed};
// Landing page types that can be shown after sending feedback.
enum LandingPageType {normal, techstop, noLandingPage};
// Result returned from a $(ref:sendFeedback) call.
dictionary SendFeedbackResult {
// Status of the sending of a feedback report.
Status status;
// The type of landing page shown to the use when the feedback report is
// successfully sent, if one should be shown.
LandingPageType landingPageType;
};
// Allowed log sources on Chrome OS.
enum LogSource {
// Chrome OS system messages.
messages,
// Latest Chrome OS UI logs.
uiLatest,
// Info about display connectors and connected displays from DRM subsystem.
drmModetest,
// USB device list and connectivity graph.
lsusb,
// Logs from daemon for Atrus device.
atrusLog,
// Network log.
netLog,
// Log of system events.
eventLog,
// Update engine log.
updateEngineLog,
// Log of the current power manager session.
powerdLatest,
// Log of the previous power manager session.
powerdPrevious,
// Info about system PCI buses devices.
lspci,
// Info about system network interface.
ifconfig,
// Info about system uptime.
uptime
};
// Source of the feedback.
enum FeedbackSource {quickoffice};
// Input parameters for a readLogSource() call.
dictionary ReadLogSourceParams {
// The log source from which to read.
LogSource source;
// For file-based log sources, read from source without closing the file
// handle. The next time $(ref:readLogSource) is called, the file read will
// continue where it left off. $(ref:readLogSource) can be called with
// <code>incremental=true</code> repeatedly. To subsequently close the file
// handle, pass in <code>incremental=false</code>.
boolean incremental;
// To read from an existing file handle, set this to a valid
// <code>readerId</code> value that was returned from a previous
// $(ref:readLogSource) call. The reader must previously have been created
// for the same value of <code>source</code>. If no <code>readerId</code> is
// provided, $(ref:readLogSource) will attempt to open a new log source
// reader handle.
long? readerId;
};
// Result returned from a $(ref:readLogSource) call.
dictionary ReadLogSourceResult {
// The ID of the log source reader that was created to read from the log
// source. If the reader was destroyed at the end of a read by passing in
// <code>incremental=false</code>, this is always set to 0. If the call was
// to use an existing reader with an existing ID, this will be set to the
// same <code>readerId</code> that was passed into $(ref:readLogSource).
long readerId;
// Each DOMString in this array represents one line of logging that was
// fetched from the log source.
DOMString[] logLines;
};
callback GetUserEmailCallback = void(DOMString email);
callback GetSystemInformationCallback =
void(LogsMapEntry[] systemInformation);
callback SendFeedbackCallback = void(SendFeedbackResult result);
callback ReadLogSourceCallback = void (ReadLogSourceResult result);
interface Functions {
// Returns the email of the currently active or logged in user.
static void getUserEmail(GetUserEmailCallback callback);
// Returns the system information dictionary.
static void getSystemInformation(GetSystemInformationCallback callback);
// Opens the feedback report window.
static void openFeedback(FeedbackSource source);
// Sends a feedback report.
// |loadSystemInfo|: Optional flag when present and is true, the backend
// should load system information before sending the report. This is added
// to reduce user's wait time when sending reports because loading system
// information is slow.
// |formOpenTime|: The epoch time when the feedback form was opened. This is
// used for metrics.
[supportsPromises] static void sendFeedback(FeedbackInfo feedback,
optional boolean loadSystemInfo,
optional double formOpenTime,
SendFeedbackCallback callback);
// Reads from a log source indicated by <code>source</code>.
// <p>If <code>incremental</code> is false:
// <ul>
// <li>Returns the entire contents of the log file.</li>
// <li>Returns <code>readerId</code> value of 0 to callback.</li>
// </ul>
// If <code>incremental</code> is true, and no <code>readerId</code> is
// provided:
// <ul>
// <li>Returns the entire contents of the log file.</li>
// <li>Starts tracking the file read handle, which is returned as a
// nonzero <code>readerId</code> value in the callback.
// </li>
// <li>If can't create a new file handle, returns <code>readerId</code>
// value of 0 in the callback.
// </li>
// </ul>
// If <code>incremental</code> is true, and a valid non-zero
// <code>readerId</code> is provided:
// <ul>
// <li>Returns new lines written to the file since the last time this
// function was called for the same file and <code>readerId</code>.
// </li>
// <li>Returns the same <code>readerId</code> value to the callback.</li>
// </ul>
static void readLogSource(ReadLogSourceParams params,
ReadLogSourceCallback callback);
};
interface Events {
// Fired when the a user requests the launch of the feedback UI. We're
// using an event for this versus using the override API since we want
// to be invoked, but not showing a UI, so the feedback extension can
// take a screenshot of the user's desktop.
static void onFeedbackRequested(FeedbackInfo feedback);
};
};
@@ -0,0 +1,55 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// `file_handlers` manifest key defintion. File Handlers allow developers to
// let extensions interact with files on the operating system. This manifest key
// can be used by developers to register an extension to a given file type.
[generate_error_messages] namespace fileHandlers {
// Icon specification similar to an ImageResource.
dictionary Icon {
// TODO(crbug.com/1362192) Add `DOMString? label;` for accessibility.
// URL from which a user agent can fetch image data.
DOMString src;
// Multiple space-separated size values to also accommodate image formats
// that can act as containers for multiple images of varying dimensions:
// e.g. "16x16", "16x16 32x32".
DOMString? sizes;
// MIME type is purely advisory with no default value.
DOMString? type;
};
// A FileHandler registers the ability to read, stream, or edit files of given
// MIME types and/or file extensions.
dictionary FileHandler {
// A mapping of one or more MIME types to one or more file extensions.
// e.g. "accept": {"text/csv": ".csv"} or {"text/csv": [".csv", ".txt"]}.
object accept;
// Specifies the url after the origin that is the navigation destination for
// file handling launches.
DOMString action;
// Description of the file type.
DOMString name;
// Array of ImageResources. Only icons declared at the manifest level are
// currently supported. The icon for the extension will appear in the "Open"
// menu.
Icon[]? icons;
// Whether multiple files should be opened in a single client or multiple.
// Defaults to `single-client`, which makes all files available in only one
// tab. `multiple-client` opens a new tab for each file.
DOMString? launch_type;
};
dictionary ManifestKeys {
// File Handlers to register onto the target system.
FileHandler[] file_handlers;
};
};
@@ -0,0 +1,185 @@
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.fileSystem</code> API to create, read, navigate,
// and write to the user's local file system. With this API, Chrome Apps can
// read and write to a user-selected location. For example, a text editor app
// can use the API to read and write local documents. All failures are notified
// via chrome.runtime.lastError.
namespace fileSystem {
dictionary AcceptOption {
// This is the optional text description for this option. If not present,
// a description will be automatically generated; typically containing an
// expanded list of valid extensions (e.g. "text/html" may expand to
// "*.html, *.htm").
DOMString? description;
// Mime-types to accept, e.g. "image/jpeg" or "audio/*". One of mimeTypes or
// extensions must contain at least one valid element.
DOMString[]? mimeTypes;
// Extensions to accept, e.g. "jpg", "gif", "crx".
DOMString[]? extensions;
};
enum ChooseEntryType {
// Prompts the user to open an existing file and returns a FileEntry on
// success. From Chrome 31 onwards, the FileEntry will be writable if the
// application has the 'write' permission under 'fileSystem'; otherwise, the
// FileEntry will be read-only.
openFile,
// Prompts the user to open an existing file and returns a writable
// FileEntry on success. Calls using this type will fail with a runtime
// error if the application doesn't have the 'write' permission under
// 'fileSystem'.
openWritableFile,
// Prompts the user to open an existing file or a new file and returns a
// writable FileEntry on success. Calls using this type will fail with a
// runtime error if the application doesn't have the 'write' permission
// under 'fileSystem'.
saveFile,
// Prompts the user to open a directory and returns a DirectoryEntry on
// success. Calls using this type will fail with a runtime error if the
// application doesn't have the 'directory' permission under 'fileSystem'.
// If the application has the 'write' permission under 'fileSystem', the
// returned DirectoryEntry will be writable; otherwise it will be read-only.
// New in Chrome 31.
openDirectory
};
dictionary ChooseEntryOptions {
// Type of the prompt to show. The default is 'openFile'.
ChooseEntryType? type;
// The suggested file name that will be presented to the user as the
// default name to read or write. This is optional.
DOMString? suggestedName;
// The optional list of accept options for this file opener. Each option
// will be presented as a unique group to the end-user.
AcceptOption[]? accepts;
// Whether to accept all file types, in addition to the options specified
// in the accepts argument. The default is true. If the accepts field is
// unset or contains no valid entries, this will always be reset to true.
boolean? acceptsAllTypes;
// Whether to accept multiple files. This is only supported for openFile and
// openWritableFile. The callback to chooseEntry will be called with a list
// of entries if this is set to true. Otherwise it will be called with a
// single Entry.
boolean? acceptsMultiple;
};
dictionary RequestFileSystemOptions {
// The ID of the requested volume.
DOMString volumeId;
// Whether the requested file system should be writable. The default is
// read-only.
boolean? writable;
};
// Represents a mounted volume, which can be accessed via <code>chrome.
// fileSystem.requestFileSystem</code>.
dictionary Volume {
DOMString volumeId;
boolean writable;
};
// Event notifying about an inserted or a removed volume from the system.
dictionary VolumeListChangedEvent {
Volume[] volumes;
};
callback GetDisplayPathCallback = void (DOMString displayPath);
callback EntryCallback = void ([instanceOf=Entry] object entry);
callback EntriesCallback = void (
[instanceOf=Entry] optional object entry,
[instanceOf=FileEntry] optional object[] fileEntries);
callback IsWritableCallback = void (boolean isWritable);
callback IsRestorableCallback = void (boolean isRestorable);
callback RequestFileSystemCallback = void(
[instanceOf=FileSystem] optional object fileSystem);
callback GetVolumeListCallback = void(optional Volume[] volumes);
interface Functions {
// Get the display path of an Entry object. The display path is based on
// the full path of the file or directory on the local file system, but may
// be made more readable for display purposes.
[supportsPromises] static void getDisplayPath(
[instanceOf=Entry] object entry,
GetDisplayPathCallback callback);
// Get a writable Entry from another Entry. This call will fail with a
// runtime error if the application does not have the 'write' permission
// under 'fileSystem'. If entry is a DirectoryEntry, this call will fail if
// the application does not have the 'directory' permission under
// 'fileSystem'.
[doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"]
static void getWritableEntry(
[instanceOf=Entry] object entry,
EntryCallback callback);
// Gets whether this Entry is writable or not.
[supportsPromises] static void isWritableEntry(
[instanceOf=Entry] object entry,
IsWritableCallback callback);
// Ask the user to choose a file or directory.
[doesNotSupportPromises="Multi-parameter callback crbug.com/1313625,
Custom hook sets lastError crbug.com/1504349"]
static void chooseEntry(optional ChooseEntryOptions options,
EntriesCallback callback);
// Returns the file entry with the given id if it can be restored. This call
// will fail with a runtime error otherwise.
[doesNotSupportPromises="Custom hook sets lastError crbug.com/1504349"]
static void restoreEntry(DOMString id,
EntryCallback callback);
// Returns whether the app has permission to restore the entry with the
// given id.
[supportsPromises] static void isRestorable(DOMString id,
IsRestorableCallback callback);
// Returns an id that can be passed to restoreEntry to regain access to a
// given file entry. Only the 500 most recently used entries are retained,
// where calls to retainEntry and restoreEntry count as use. If the app has
// the 'retainEntries' permission under 'fileSystem', entries are retained
// indefinitely. Otherwise, entries are retained only while the app is
// running and across restarts.
static DOMString retainEntry([instanceOf=Entry] object entry);
// Requests access to a file system for a volume represented by <code>
// options.volumeId</code>. If <code>options.writable</code> is set to true,
// then the file system will be writable. Otherwise, it will be read-only.
// The <code>writable</code> option requires the <code>
// "fileSystem": {"write"}</code> permission in the manifest. Available to
// kiosk apps running in kiosk session only. For manual-launch kiosk mode, a
// confirmation dialog will be shown on top of the active app window.
// In case of an error, <code>fileSystem</code> will be undefined, and
// <code>chrome.runtime.lastError</code> will be set.
[supportsPromises] static void requestFileSystem(
RequestFileSystemOptions options,
RequestFileSystemCallback callback);
// Returns a list of volumes available for <code>requestFileSystem()</code>.
// The <code>"fileSystem": {"requestFileSystem"}</code> manifest permission
// is required. Available to kiosk apps running in the kiosk session only.
// In case of an error, <code>volumes</code> will be undefined, and <code>
// chrome.runtime.lastError</code> will be set.
[supportsPromises] static void getVolumeList(
GetVolumeListCallback callback);
};
interface Events {
// Called when a list of available volumes is changed.
static void onVolumeListChanged(VolumeListChangedEvent event);
};
};
+155
View File
@@ -0,0 +1,155 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.hid</code> API to interact with connected HID devices.
// This API provides access to HID operations from within the context of an app.
// Using this API, apps can function as drivers for hardware devices.
//
// Errors generated by this API are reported by setting
// $(ref:runtime.lastError) and executing the function's regular callback. The
// callback's regular parameters will be undefined in this case.
namespace hid {
dictionary HidCollectionInfo {
// HID usage page identifier.
long usagePage;
// Page-defined usage identifier.
long usage;
// Report IDs which belong to the collection and to its children.
long[] reportIds;
};
[noinline_doc] dictionary HidDeviceInfo {
// Opaque device ID.
long deviceId;
// Vendor ID.
long vendorId;
// Product ID.
long productId;
// The product name read from the device, if available.
DOMString productName;
// The serial number read from the device, if available.
DOMString serialNumber;
// Top-level collections from this device's report descriptors.
HidCollectionInfo[] collections;
// Top-level collection's maximum input report size.
long maxInputReportSize;
// Top-level collection's maximum output report size.
long maxOutputReportSize;
// Top-level collection's maximum feature report size.
long maxFeatureReportSize;
// Raw device report descriptor (not available on Windows).
ArrayBuffer reportDescriptor;
};
dictionary HidConnectInfo {
// The opaque ID used to identify this connection in all other functions.
long connectionId;
};
[noinline_doc] dictionary DeviceFilter {
// Device vendor ID.
long? vendorId;
// Device product ID, only checked only if the vendor ID matches.
long? productId;
// HID usage page identifier.
long? usagePage;
// HID usage identifier, checked only if the HID usage page matches.
long? usage;
};
dictionary GetDevicesOptions {
[deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."]
long? vendorId;
[deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."]
long? productId;
// A device matching any given filter will be returned. An empty filter list
// will return all devices the app has permission for.
DeviceFilter[]? filters;
};
callback GetDevicesCallback = void (HidDeviceInfo[] devices);
callback ConnectCallback = void (HidConnectInfo connection);
callback DisconnectCallback = void ();
// |reportId|: The report ID or <code>0</code> if none.
// |data|: The report data, the report ID prefix (if present) is removed.
callback ReceiveCallback = void (long reportId, ArrayBuffer data);
// |data|: The report data, including a report ID prefix if one is sent by the
// device.
callback ReceiveFeatureReportCallback = void (ArrayBuffer data);
callback SendCallback = void();
interface Functions {
// Enumerate connected HID devices.
// |options|: The properties to search for on target devices.
[supportsPromises] static void getDevices(GetDevicesOptions options,
GetDevicesCallback callback);
// Open a connection to an HID device for communication.
// |deviceId|: The $(ref:HidDeviceInfo.deviceId) of the device to open.
[supportsPromises] static void connect(long deviceId,
ConnectCallback callback);
// Disconnect from a device. Invoking operations on a device after calling
// this is safe but has no effect.
// |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
[supportsPromises] static void disconnect(
long connectionId,
optional DisconnectCallback callback);
// Receive the next input report from the device.
// |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
[doesNotSupportPromises="Multi-parameter callback crbug.com/1313625"]
static void receive(long connectionId,
ReceiveCallback callback);
// Send an output report to the device.
//
// <em>Note:</em> Do not include a report ID prefix in <code>data</code>.
// It will be added if necessary.
// |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// |reportId|: The report ID to use, or <code>0</code> if none.
// |data|: The report data.
[supportsPromises] static void send(long connectionId,
long reportId,
ArrayBuffer data,
SendCallback callback);
// Request a feature report from the device.
// |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// |reportId|: The report ID, or <code>0</code> if none.
[supportsPromises] static void receiveFeatureReport(
long connectionId,
long reportId,
ReceiveFeatureReportCallback callback);
// Send a feature report to the device.
//
// <em>Note:</em> Do not include a report ID prefix in <code>data</code>.
// It will be added if necessary.
// |connectionId|: The <code>connectionId</code> returned by $(ref:connect).
// |reportId|: The report ID to use, or <code>0</code> if none.
// |data|: The report data.
[supportsPromises] static void sendFeatureReport(long connectionId,
long reportId,
ArrayBuffer data,
SendCallback callback);
};
interface Events {
// Event generated when a device is added to the system. Events are only
// broadcast to apps and extensions that have permission to access the
// device. Permission may have been granted at install time or when the user
// accepted an optional permission (see $(ref:permissions.request)).
static void onDeviceAdded(HidDeviceInfo device);
// Event generated when a device is removed from the system. See
// $(ref:onDeviceAdded) for which events are delivered.
// |deviceId|: The <code>deviceId</code> property of the device passed to
// $(ref:onDeviceAdded).
static void onDeviceRemoved(long deviceId);
};
};
@@ -0,0 +1,94 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// <p>
// The API that can be used by an app to create and manage data on the
// Chrome OS lock screen.
// </p>
// <p>
// The API usability will depend on the user session state:
// <ul>
// <li>
// When the user session is locked, the API usage will only be allowed
// from the lock screen context.
// </li>
// <li>
// When the user session is not locked, the API usage will only be
// allowed outside the lock screen context - i.e. from the regular app
// context.
// </li>
// </ul>
// </p>
// <p>
// Note that apps have reduced access to Chrome apps APIs from the lock screen
// context.
// </p>
namespace lockScreen.data {
// The basic information about available data items originating from the lock
// screen.
dictionary DataItemInfo {
// The data item ID that can later be used to retrieve and update the
// associated lock screen data.
DOMString id;
};
dictionary DataItemsAvailableEvent {
// <p>Whether the event was dispatched as a result of the user session
// getting unlocked.
// </p>
// <p>For example:
// <ul>
// <li>If the app creates new data items while shown on
// the lock screen, when the user unlocks the screen,
// $(ref:onDataItemsAvailable) event will be dispatched with this
// property set to <code>true</code>.
// </li>
// <li>When the user logs in, if not previously reported lock screen
// data items are found, which could happen if the user session had
// been closed while it was locked, $(ref:onDataItemsAvailable) will
// be dispatched with this property set to <code>false</code>.
// </li>
// </ul>
// </p>
boolean wasLocked;
};
callback DataItemCallback = void(DataItemInfo item);
callback DataItemListCallback = void(DataItemInfo[] items);
callback DataCallback = void(ArrayBuffer data);
callback VoidCallback = void();
interface Functions {
// Creates a new data item reference - available only in lock screen
// contexts.
[supportsPromises] static void create(DataItemCallback callback);
// Gets references to all data items available to the app.
[supportsPromises] static void getAll(DataItemListCallback callback);
// Retrieves content of the data item identified by |id|.
[supportsPromises] static void getContent(DOMString id,
DataCallback callback);
// Sets contents of a data item.
// |id| - Identifies the target data item.
// |data| - The data item contents to set.
[supportsPromises] static void setContent(DOMString id,
ArrayBuffer data,
optional VoidCallback callback);
// Deletes a data item. The data item will not be available through this
// API anymore.
// |id| - Identifies the data item to delete.
[supportsPromises] static void delete(DOMString id,
optional VoidCallback callback);
};
interface Events {
// Dispatched when new data items become available to main, non-lock screen
// app context - this event is not expected to be dispatched to the app in
// the lock screen context.
static void onDataItemsAvailable(DataItemsAvailableEvent event);
};
};
@@ -0,0 +1,608 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Private API for receiving real-time media perception information.
[platforms=("chromeos")]
namespace mediaPerceptionPrivate {
enum Status {
// The media analytics process is waiting to be launched.
UNINITIALIZED,
// The analytics process is running and the media processing pipeline is
// started, but it is not yet receiving image frames. This is a
// transitional state between <code>SUSPENDED</code> and
// <code>RUNNING</code> for the time it takes to warm up the media
// processing pipeline, which can take anywhere from a few seconds to a
// minute.
// Note: <code>STARTED</code> is the initial reply to SetState
// <code>RUNNING</code>.
STARTED,
// The analytics process is running and the media processing pipeling is
// injesting image frames. At this point, MediaPerception signals should
// be coming over D-Bus.
RUNNING,
// Analytics process is running and the media processing pipeline is ready
// to be set to state <code>RUNNING</code>. The D-Bus communications
// are enabled but the media processing pipeline is suspended.
SUSPENDED,
// Enum for restarting the media analytics process using Upstart.
// Calling setState <code>RESTARTING</code> will restart the media process
// to the <code>SUSPENDED</code> state. The app has to set the state to
// <code>RUNNING</code> in order to start receiving media perception
// information again.
RESTARTING,
// Stops the media analytics process via Upstart.
STOPPED,
// Indicates that a ServiceError has occurred.
SERVICE_ERROR
};
enum ServiceError {
// The media analytics process could not be reached. This is likely due to
// a faulty comms configuration or that the process crashed.
SERVICE_UNREACHABLE,
// The media analytics process is not running. The MPP API knows that the
// process has not been started yet.
SERVICE_NOT_RUNNING,
// The media analytics process is busy launching. Wait for setState
// <code>RUNNING</code> or setState <code>RESTARTING</code> callback.
SERVICE_BUSY_LAUNCHING,
// The component is not installed properly.
SERVICE_NOT_INSTALLED,
// Failed to establish a Mojo connection to the service.
MOJO_CONNECTION_FAILURE
};
enum Feature {
AUTOZOOM,
HOTWORD_DETECTION,
OCCUPANCY_DETECTION,
EDGE_EMBEDDINGS,
SOFTWARE_CROPPING
};
dictionary NamedTemplateArgument {
DOMString? name;
(DOMString or double)? value;
};
enum ComponentType {
// The smaller component with limited functionality (smaller size and
// limited models).
LIGHT,
// The fully-featured component with more functionality (larger size and
// more models).
FULL
};
// The status of the media analytics process component on the device.
enum ComponentStatus {
UNKNOWN,
// The component is successfully installed and the image is mounted.
INSTALLED,
// The component failed to download, install or load.
FAILED_TO_INSTALL
};
// Error code associated with a failure to install the media analytics
// component.
enum ComponentInstallationError {
// Component requested does not exist.
UNKNOWN_COMPONENT,
// The update engine fails to install component.
INSTALL_FAILURE,
// Component can not be mounted.
MOUNT_FAILURE,
// The component is not compatible with the device.
COMPATIBILITY_CHECK_FAILED,
// The component was not found - reported for load requests with kSkip
// update policy.
NOT_FOUND
};
dictionary Component {
ComponentType type;
};
// The state of the media analytics downloadable component.
dictionary ComponentState {
ComponentStatus status;
// The version string for the current component.
DOMString? version;
// If the component installation failed, the encountered installation
// error. Not set if the component installation succeeded.
ComponentInstallationError? installationErrorCode;
};
// ------------------- Start of process management definitions. ------------
// New interface for managing the process state of the media perception
// service with the intention of eventually phasing out the setState() call.
enum ProcessStatus {
// The component process state is unknown, for example, if the process is
// waiting to be launched. This is the initial state before
// $(ref:setComponentProcessState) is first called.
UNKNOWN,
// The component process has been started.
// This value can only be passed to $(ref:setComponentProcessState) if the
// process is currently in state <code>STOPPED</code> or
// <code>UNKNOWN</code>.
STARTED,
// The component process has been stopped.
// This value can only be passed to $(ref:setComponentProcessState) if the
// process is currently in state <code>STARTED</code>.
// Note: the process is automatically stopped when the Chrome process
// is closed.
STOPPED,
// Indicates that a ServiceError has occurred.
SERVICE_ERROR
};
dictionary ProcessState {
ProcessStatus? status;
// Return parameter for $(ref:setComponentProcessState) that
// specifies the error type for failure cases.
ServiceError? serviceError;
};
// ------------------- End of process management definitions. --------------
// The parameters for processing a particular video stream.
dictionary VideoStreamParam {
// Identifies the video stream described by these parameters.
DOMString? id;
// Frame width in pixels.
long? width;
// Frame height in pixels.
long? height;
// The frame rate at which this video stream would be processed.
long? frameRate;
};
dictionary Point {
// The horizontal distance from the top left corner of the image.
double? x;
// The vertical distance from the top left corner of the image.
double? y;
};
// The parameters for a whiteboard in the image frame. Corners are given in
// pixel coordinates normalized to the size of the image frame (i.e. in the
// range [(0.0, 0.0), (1.0, 1.0)]. The aspectRatio is the physical aspect
// ratio of the whiteboard (e.g. for a 1m high and 2m wide whiteboard, the
// aspect ratio would be 2).
dictionary Whiteboard {
// The top left corner of the whiteboard in the image frame.
Point? topLeft;
// The top right corner of the whiteboard in the image frame.
Point? topRight;
// The bottom left corner of the whiteboard in the image frame.
Point? bottomLeft;
// The bottom right corner of the whiteboard in the image frame.
Point? bottomRight;
// The physical aspect ratio of the whiteboard.
double? aspectRatio;
};
// The system and configuration state of the analytics process.
dictionary State {
Status status;
// Optional $(ref:setState) parameter. Specifies the video device the media
// analytics process should open while the media processing pipeline is
// starting. To set this parameter, status has to be <code>RUNNING</code>.
DOMString? deviceContext;
// Return parameter for $(ref:setState) or $(ref:getState) that
// specifies the error type for failure cases.
ServiceError? serviceError;
// A list of video streams processed by the analytics process. To set this
// parameter, status has to be <code>RUNNING</code>.
VideoStreamParam[]? videoStreamParam;
// Media analytics configuration. It can only be used when setting state to
// RUNNING.
DOMString? configuration;
// Corners and aspect ratio of the whiteboard in the image frame. Should
// only be set when setting state to <code>RUNNING</code> and configuration
// to whiteboard.
Whiteboard? whiteboard;
// A list of enabled media perception features.
Feature[]? features;
// A list of named parameters to be substituted at start-up. Will
// only have effect when setting state to <code>RUNNING</code>.
NamedTemplateArgument[]? namedTemplateArguments;
};
dictionary BoundingBox {
// Specifies whether the points are normalized to the size of the image.
boolean? normalized;
// The two points that define the corners of a bounding box.
Point? topLeft;
Point? bottomRight;
};
enum DistanceUnits {
UNSPECIFIED,
METERS,
PIXELS
};
// Generic dictionary to encapsulate a distance magnitude and units.
dictionary Distance {
// This field provides flexibility to report depths or distances of
// different entity types with different units.
DistanceUnits? units;
double? magnitude;
};
enum EntityType {
UNSPECIFIED,
FACE,
PERSON,
MOTION_REGION,
LABELED_REGION
};
enum FramePerceptionType {
UNKNOWN_TYPE,
FACE_DETECTION,
PERSON_DETECTION,
MOTION_DETECTION
};
dictionary Entity {
// A unique id associated with the detected entity, which can be used to
// track the entity over time.
long? id;
EntityType? type;
// Label for this entity.
DOMString? entityLabel;
// Minimum box which captures entire detected entity.
BoundingBox? boundingBox;
// A value for the quality of this detection.
double? confidence;
// The estimated depth of the entity from the camera.
Distance? depth;
};
dictionary PacketLatency {
// Label for this packet.
DOMString? packetLabel;
// Packet processing latency in microseconds.
long? latencyUsec;
};
// Type of lighting conditions.
enum LightCondition {
UNSPECIFIED,
// No noticeable change occurred.
NO_CHANGE,
// Light was switched on in the room.
TURNED_ON,
// Light was switched off in the room.
TURNED_OFF,
// Light gradually got dimmer (for example, due to a sunset).
DIMMER,
// Light gradually got brighter (for example, due to a sunrise).
BRIGHTER,
// Black frame was detected - the current frame contains only noise.
BLACK_FRAME
};
// Detection of human presence close to the camera.
dictionary VideoHumanPresenceDetection {
// Indicates a probability in [0, 1] interval that a human is present in
// the video frame.
double? humanPresenceLikelihood;
// Indicates a probability in [0, 1] that motion has been detected in the
// video frame.
double? motionDetectedLikelihood;
// Indicates lighting condition in the video frame.
LightCondition? lightCondition;
// Indicates a probablity in [0, 1] interval that
// <code>lightCondition</code> value is correct.
double? lightConditionLikelihood;
};
// The set of computer vision metadata for an image frame.
dictionary FramePerception {
long? frameId;
long? frameWidthInPx;
long? frameHeightInPx;
// The timestamp associated with the frame (when its recieved by the
// analytics process).
double? timestamp;
// The list of entities detected in this frame.
Entity[]? entities;
// Processing latency for a list of packets.
PacketLatency[]? packetLatency;
// Human presence detection results for a video frame.
VideoHumanPresenceDetection? videoHumanPresenceDetection;
// Indicates what types of frame perception were run.
FramePerceptionType[]? framePerceptionTypes;
};
// An estimate of the direction that the sound is coming from.
dictionary AudioLocalization {
// An angle in radians in the horizontal plane. It roughly points to the
// peak in the probability distribution of azimuth defined below.
double? azimuthRadians;
// A probability distribution for the current snapshot in time that shows
// the likelihood of a sound source being at a particular azimuth. For
// example, <code>azimuthScores = [0.1, 0.2, 0.3, 0.4]</code> means that
// the probability that the sound is coming from an azimuth of 0, pi/2, pi,
// 3*pi/2 is 0.1, 0.2, 0.3 and 0.4, respectively.
double[]? azimuthScores;
};
// Spectrogram of an audio frame.
dictionary AudioSpectrogram {
double[]? values;
};
// Detection of human presence close to the microphone.
dictionary AudioHumanPresenceDetection {
// Indicates a probability in [0, 1] interval that a human has caused a
// sound close to the microphone.
double? humanPresenceLikelihood;
// Estimate of the noise spectrogram.
AudioSpectrogram? noiseSpectrogram;
// Spectrogram of an audio frame.
AudioSpectrogram? frameSpectrogram;
};
enum HotwordType {
UNKNOWN_TYPE,
OK_GOOGLE
};
// A hotword detected in the audio stream.
dictionary Hotword {
// Unique identifier for the hotword instance. Note that a single hotword
// instance can span more than one audio frame. In that case a single
// hotword instance can be reported in multiple Hotword or HotwordDetection
// results. Hotword results associated with the same hotword instance will
// have the same <code>id</code>.
long? id;
// Indicates the type of this hotword.
HotwordType? type;
// Id of the audio frame in which the hotword was detected.
long? frameId;
// Indicates the start time of this hotword in the audio frame.
long? startTimestampMs;
// Indicates the end time of this hotword in the audio frame.
long? endTimestampMs;
// Indicates a probability in [0, 1] interval that this hotword is present
// in the audio frame.
double? confidence;
};
// Detection of hotword in the audio stream.
dictionary HotwordDetection {
Hotword[]? hotwords;
};
// Audio perception results for an audio frame.
dictionary AudioPerception {
// A timestamp in microseconds attached when this message was generated.
double? timestampUs;
// Audio localization results for an audio frame.
AudioLocalization? audioLocalization;
// Audio human presence detection results for an audio frame.
AudioHumanPresenceDetection? audioHumanPresenceDetection;
// Hotword detection results.
HotwordDetection? hotwordDetection;
};
// Detection of human presence based on both audio and video inputs.
dictionary AudioVisualHumanPresenceDetection {
// Indicates a probability in [0, 1] interval that a human is present.
double? humanPresenceLikelihood;
};
// Perception results based on both audio and video inputs.
dictionary AudioVisualPerception {
// A timestamp in microseconds attached when this message was generated.
double? timestampUs;
// Human presence detection results.
AudioVisualHumanPresenceDetection? audioVisualHumanPresenceDetection;
};
// Stores metadata such as version of media perception features.
dictionary Metadata {
DOMString? visualExperienceControllerVersion;
};
dictionary MediaPerception {
// The time the media perception data was emitted by the media processing
// pipeline. This value will be greater than the timestamp stored within
// the FramePerception dictionary and the difference between them can be
// viewed as the processing time for a single frame.
double? timestamp;
// An array of framePerceptions.
FramePerception[]? framePerceptions;
// An array of audio perceptions.
AudioPerception[]? audioPerceptions;
// An array of audio-visual perceptions.
AudioVisualPerception[]? audioVisualPerceptions;
// Stores metadata such as version of media perception features.
Metadata? metadata;
};
enum ImageFormat {
// Image represented by RGB data channels.
RAW,
PNG,
JPEG
};
dictionary ImageFrame {
long? width;
long? height;
ImageFormat? format;
long? dataLength;
// The bytes of the image frame.
ArrayBuffer? frame;
};
dictionary PerceptionSample {
// The video analytics FramePerception for the associated image frame
// data.
FramePerception? framePerception;
// The image frame data for the associated FramePerception object.
ImageFrame? imageFrame;
// The audio perception results for an audio frame.
AudioPerception? audioPerception;
// Perception results based on both audio and video inputs.
AudioVisualPerception? audioVisualPerception;
// Stores metadata such as version of media perception features.
Metadata? metadata;
};
dictionary Diagnostics {
// Return parameter for $(ref:getDiagnostics) that specifies the error
// type for failure cases.
ServiceError? serviceError;
// A buffer of image frames and the associated video analytics information
// that can be used to diagnose a malfunction.
PerceptionSample[]? perceptionSamples;
};
callback StateCallback = void(State state);
callback DiagnosticsCallback = void(Diagnostics diagnostics);
callback ComponentStateCallback = void(ComponentState componentState);
callback ProcessStateCallback = void(ProcessState processState);
interface Functions {
// Gets the status of the media perception process.
// |callback| : The current state of the system.
[supportsPromises] static void getState(StateCallback callback);
// Sets the desired state of the system.
// |state| : A dictionary with the desired new state. The only settable
// states are <code>RUNNING</code>, <code>SUSPENDED</code>, and
// <code>RESTARTING</code>.
// |callback| : Invoked with the State of the system after setting it. Can
// be used to verify the state was set as desired.
[supportsPromises] static void setState(State state,
StateCallback callback);
// Get a diagnostics buffer out of the video analytics process.
// |callback| : Returns a Diagnostics dictionary object.
[supportsPromises] static void getDiagnostics(DiagnosticsCallback callback);
// Attempts to download and load the media analytics component. This
// function should be called every time a client starts using this API. If
// the component is already loaded, the callback will simply return that
// information. The process must be <code>STOPPED</code> for this function
// to succeed.
// Note: If a different component type is desired, this function can
// be called with the new desired type and the new component will be
// downloaded and installed.
// |component| : The desired component to install and load.
// |callback| : Returns the state of the component.
[supportsPromises] static void setAnalyticsComponent(
Component component,
ComponentStateCallback callback);
// Manages the lifetime of the component process. This function should
// only be used if the component is installed. It will fail if the
// component is not installed.
// |processState| : The desired state for the component process.
// |callback| : Reports the new state of the process, which is expected to
// be the same as the desired state, unless something goes wrong.
[supportsPromises] static void setComponentProcessState(
ProcessState processState,
ProcessStateCallback callback);
};
interface Events {
// Fired when media perception information is received from the media
// analytics process.
// |mediaPerception| : The dictionary which contains a dump of everything
// the analytics process has detected or determined from the incoming media
// streams.
static void onMediaPerception(MediaPerception mediaPerception);
};
};
@@ -0,0 +1,71 @@
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Mime handler API.
[nodoc] namespace mimeHandlerPrivate {
dictionary StreamInfo {
// The MIME type of the intercepted URL request.
DOMString mimeType;
// The original URL that was intercepted.
DOMString originalUrl;
// The URL that the stream can be read from.
DOMString streamUrl;
// The ID of the tab that opened the stream. If the stream is not opened in
// a tab, it will be -1.
long tabId;
// The HTTP response headers of the intercepted request stored as a
// dictionary mapping header name to header value. If a header name appears
// multiple times, the header values are merged in the dictionary and
// separated by a ", ". Non-ASCII headers are dropped.
object responseHeaders;
// Whether the stream is embedded within another document.
boolean embedded;
};
dictionary PdfPluginAttributes {
// The background color in ARGB format for painting. Since the background
// color is an unsigned 32-bit integer which can be outside the range of
// "long" type, define it as a "double" type here.
double backgroundColor;
// Indicates whether the plugin allows to execute JavaScript and maybe XFA.
// Loading XFA for PDF forms will automatically be disabled if this flag is
// false.
boolean allowJavascript;
};
callback GetStreamDetailsCallback = void (StreamInfo streamInfo);
callback SetShowBeforeUnloadDialogCallback = void ();
interface Functions {
// Returns the StreamInfo for the stream for this context if there is one.
[nocompile, doesNotSupportPromises=
"Custom hook sets lastError crbug.com/1504349"]
static void getStreamInfo(GetStreamDetailsCallback callback);
// Sets PDF plugin attributes in the stream for this context if there is
// one.
[nocompile] static void setPdfPluginAttributes(
PdfPluginAttributes pdfPluginAttributes);
// Instructs the PluginDocument, if running in one, to show a dialog in
// response to beforeunload events.
[nocompile, doesNotSupportPromises=
"Custom hook sets lastError crbug.com/1504349"]
static void setShowBeforeUnloadDialog(
boolean showDialog,
optional SetShowBeforeUnloadDialogCallback callback);
};
interface Events {
// Fired when the browser wants the listener to perform a save.
// |streamUrl|: Unique ID for the instance that should perform the save.
static void onSave(DOMString streamUrl);
};
};
@@ -0,0 +1,13 @@
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The chrome.mojoPrivate API provides access to the mojo modules.
namespace mojoPrivate {
interface Functions {
// Returns a promise that will resolve to an asynchronously
// loaded module.
[nocompile] static any requireAsync(DOMString name);
};
};
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+22
View File
@@ -0,0 +1,22 @@
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for the "oauth2" manifest key.
namespace oauth2 {
dictionary OAuth2Info {
// Whether the approval UI should be skipped. Only available to allowlisted
// extensions/apps.
[nodoc] boolean? auto_approve;
// Client ID of the corresponding extension/app.
DOMString? client_id;
// Scopes the extension/app needs access to.
DOMString[] scopes;
};
dictionary ManifestKeys {
OAuth2Info oauth2;
};
};
@@ -0,0 +1,88 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>offscreen</code> API to create and manage offscreen documents.
namespace offscreen {
enum Reason {
// A reason used for testing purposes only.
TESTING,
// Specifies that the offscreen document is responsible for playing audio.
AUDIO_PLAYBACK,
// Specifies that the offscreen document needs to embed and script an
// iframe in order to modify the iframe's content.
IFRAME_SCRIPTING,
// Specifies that the offscreen document needs to embed an iframe and
// scrape its DOM to extract information.
DOM_SCRAPING,
// Specifies that the offscreen document needs to interact with Blob
// objects (including <code>URL.createObjectURL()</code>).
BLOBS,
// Specifies that the offscreen document needs to use the
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/DOMParser>DOMParser API</a>.
DOM_PARSER,
// Specifies that the offscreen document needs to interact with
// media streams from user media (e.g. <code>getUserMedia()</code>).
USER_MEDIA,
// Specifies that the offscreen document needs to interact with
// media streams from display media (e.g. <code>getDisplayMedia()</code>).
DISPLAY_MEDIA,
// Specifies that the offscreen document needs to use
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API>WebRTC APIs</a>.
WEB_RTC,
// Specifies that the offscreen document needs to interact with the
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API>Clipboard API</a>.
CLIPBOARD,
// Specifies that the offscreen document needs access to
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage">localStorage</a>.
LOCAL_STORAGE,
// Specifies that the offscreen document needs to spawn workers.
WORKERS,
// Specifies that the offscreen document needs to use
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API">navigator.getBattery</a>.
BATTERY_STATUS,
// Specifies that the offscreen document needs to use
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia">window.matchMedia</a>.
MATCH_MEDIA,
// Specifies that the offscreen document needs to use
// <a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigator/geolocation">navigator.geolocation</a>.
GEOLOCATION
};
dictionary CreateParameters {
// The reason(s) the extension is creating the offscreen document.
Reason[] reasons;
// The (relative) URL to load in the document.
DOMString url;
// A developer-provided string that explains, in more detail, the need for
// the background context. The user agent _may_ use this in display to the
// user.
DOMString justification;
};
callback VoidCallback = void();
callback BooleanCallback = void(boolean result);
interface Functions {
// Creates a new offscreen document for the extension.
// |parameters|: The parameters describing the offscreen document to create.
// |callback|: Invoked when the offscreen document is created and has
// completed its initial page load.
[supportsPromises] static void createDocument(
CreateParameters parameters,
VoidCallback callback);
// Closes the currently-open offscreen document for the extension.
// |callback|: Invoked when the offscreen document has been closed.
[supportsPromises] static void closeDocument(VoidCallback callback);
// Determines whether the extension has an active document.
// TODO(https://crbug.com/1339382): This probably isn't something we want to
// ship in its current form (hence the nodoc). Instead of this, we should
// integrate offscreen documents into a service worker-compatible getViews()
// alternative. But this is pretty useful in testing environments.
// |callback|: Invoked with the result of whether the extension has an
// active offscreen document.
[supportsPromises, nodoc] static void hasDocument(BooleanCallback callback);
};
};
+35
View File
@@ -0,0 +1,35 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.power</code> API to override the system's power
// management features.
namespace power {
callback VoidCallback = void ();
[noinline_doc] enum Level {
// Prevents the system from sleeping in response to user inactivity.
system,
// Prevents the display from being turned off or dimmed, or the system
// from sleeping in response to user inactivity.
display
};
interface Functions {
// Requests that power management be temporarily disabled. |level|
// describes the degree to which power management should be disabled.
// If a request previously made by the same app is still active, it
// will be replaced by the new request.
static void requestKeepAwake(Level level);
// Releases a request previously made via requestKeepAwake().
static void releaseKeepAwake();
// Reports a user activity in order to awake the screen from a dimmed or
// turned off state or from a screensaver. Exits the screensaver if it is
// currently active.
[platforms=("chromeos", "lacros"), supportsPromises]
static void reportActivity(optional VoidCallback callback);
};
};
@@ -0,0 +1,114 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.printerProvider</code> API exposes events used by print
// manager to query printers controlled by extensions, to query their
// capabilities and to submit print jobs to these printers.
namespace printerProvider {
// Error codes returned in response to $(ref:onPrintRequested) event.
enum PrintError {
// Specifies that the operation was completed successfully.
OK,
// Specifies that a general failure occured.
FAILED,
// Specifies that the print ticket is invalid. For example, the ticket is
// inconsistent with some capabilities, or the extension is not able to
// handle all settings from the ticket.
INVALID_TICKET,
// Specifies that the document is invalid. For example, data may be
// corrupted or the format is incompatible with the extension.
INVALID_DATA
};
// Printer description for $(ref:onGetPrintersRequested) event.
dictionary PrinterInfo {
// Unique printer ID.
DOMString id;
// Printer's human readable name.
DOMString name;
// Printer's human readable description.
DOMString? description;
};
// Printing request parameters. Passed to $(ref:onPrintRequested) event.
[noinline_doc] dictionary PrintJob {
// ID of the printer which should handle the job.
DOMString printerId;
// The print job title.
DOMString title;
// Print ticket in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cjt">
// CJT format</a>.
// <aside class="aside flow bg-state-info-bg color-state-info-text">
// <div class="flow">The CJT reference is marked as deprecated. It is
// deprecated for Google Cloud Print only. is not deprecated for
// ChromeOS printing.
// </div>
// </aside>
object ticket;
// The document content type. Supported formats are
// <code>"application/pdf"</code> and <code>"image/pwg-raster"</code>.
DOMString contentType;
// Blob containing the document data to print. Format must match
// |contentType|.
[instanceOf=Blob] object document;
};
callback PrintersCallback = void(PrinterInfo[] printerInfo);
callback PrinterInfoCallback = void(optional PrinterInfo printerInfo);
// |capabilities|: Device capabilities in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
// format</a>.
callback CapabilitiesCallback = void(object capabilities);
callback PrintCallback = void(PrintError result);
interface Events {
// Event fired when print manager requests printers provided by extensions.
// |resultCallback|: Callback to return printer list. Every listener must
// call callback exactly once.
static void onGetPrintersRequested(PrintersCallback resultCallback);
// Event fired when print manager requests information about a USB device
// that may be a printer.
// <p><em>Note:</em> An application should not rely on this event being
// fired more than once per device. If a connected device is supported it
// should be returned in the $(ref:onGetPrintersRequested) event.</p>
// |device|: The USB device.
// |resultCallback|: Callback to return printer info. The receiving listener
// must call callback exactly once. If the parameter to this callback is
// undefined that indicates that the application has determined that the
// device is not supported.
static void onGetUsbPrinterInfoRequested(
usb.Device device,
PrinterInfoCallback resultCallback);
// Event fired when print manager requests printer capabilities.
// |printerId|: Unique ID of the printer whose capabilities are requested.
// |resultCallback|: Callback to return device capabilities in
// <a href="https://developers.google.com/cloud-print/docs/cdd#cdd">CDD
// format</a>.
// The receiving listener must call callback exectly once.
static void onGetCapabilityRequested(DOMString printerId,
CapabilitiesCallback resultCallback);
// Event fired when print manager requests printing.
// |printJob|: The printing request parameters.
// |resultCallback|: Callback that should be called when the printing
// request is completed.
static void onPrintRequested(PrintJob printJob,
PrintCallback resultCallback);
};
};
@@ -0,0 +1,58 @@
// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// printerProviderInternal
// Internal API used to run callbacks passed to chrome.printerProvider API
// events.
// When dispatching a chrome.printerProvider API event, its arguments will be
// massaged in custom bindings so a callback is added. The callback uses
// chrome.printerProviderInternal API to report the event results.
// In order to identify the event for which the callback is called, the event
// is internally dispatched having a requestId argument (which is removed from
// the argument list before the event actually reaches the event listeners). The
// requestId is forwarded to the chrome.printerProviderInternal API functions.
[implemented_in="extensions/browser/api/printer_provider/printer_provider_internal_api.h"]
namespace printerProviderInternal {
// Same as in printerProvider.PrintError enum API.
enum PrintError { OK, FAILED, INVALID_TICKET, INVALID_DATA };
// Callback carrying a blob.
callback BlobCallback = void([instanceOf=Blob] object blob);
interface Functions {
// Runs callback to printerProvider.onGetPrintersRequested event.
// |requestId|: Parameter identifying the event instance for which the
// callback is run.
// |printers|: List of printers reported by the extension.
void reportPrinters(long requestId,
optional printerProvider.PrinterInfo[] printers);
// Runs callback to printerProvider.onUsbAccessGranted event.
// |requestId|: Parameter identifying the event instance for which the
// callback is run.
// |printerInfo|: Printer information reported by the extension.
void reportUsbPrinterInfo(long requestId,
optional printerProvider.PrinterInfo printerInfo);
// Runs callback to printerProvider.onGetCapabilityRequested event.
// |requestId|: Parameter identifying the event instance for which the
// callback is run.
// |error|: The printer capability returned by the extension.
void reportPrinterCapability(long request_id, optional object capability);
// Runs callback to printerProvider.onPrintRequested event.
// |requestId|: Parameter identifying the event instance for which the
// callback is run.
// |error|: The requested print job result.
void reportPrintResult(long request_id, optional PrintError error);
// Gets information needed to create a print data blob for a print request.
// The blob will be dispatched to the extension via
// printerProvider.onPrintRequested event.
// |requestId|: The request id for the print request for which data is
// needed.
// |callback|: Callback called with a blob of print data.
[supportsPromises] void getPrintData(long requestId, BlobCallback callback);
};
};
@@ -0,0 +1,69 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Internal namespace for representing content scripts.
namespace scriptsInternal {
// The source of the user script. This will also determine certain
// capabilities of the script (such as whether it can use globs, raw strings
// for code, etc).
enum Source {
DYNAMIC_CONTENT_SCRIPT,
DYNAMIC_USER_SCRIPT,
MANIFEST_CONTENT_SCRIPT
};
// The source of the script to inject.
dictionary ScriptSource {
// A string containing the JavaScript code to inject. Exactly one of
// <code>file</code> or <code>code</code> must be specified.
DOMString? code;
// The path of the JavaScript file to inject relative to the extension's
// root directory. Exactly one of <code>file</code> or <code>code</code>
// must be specified.
DOMString? file;
};
// Describes a serialized script, intended for storage and persistence across
// browser sessions.
// Note: Though it is called "UserScript", this is used for scripts through
// the scripting API (dynamic content scripts), content scripts in the
// manifest (static content scripts), and user scripts through the userScripts
// API. "UserScript" was chosen because it matches the correspodning
// extenisons::UserScript object (the runtime representation of this) and
// because "Script" is ambiguous (e.g. background script, general JS script,
// etc).
dictionary SerializedUserScript {
// Whether the script will inject into all frames, regardless if it is not
// the top-most frame in the tab.
boolean? allFrames;
// The list of CSS files to be injected into matching pages. Note that,
// today, we only expect these to contain files. It is represented as a
// ScriptSource for compatibility and consistency with `js`.
ScriptSource[]? css;
// Excludes pages that this user script would otherwise be injected into.
DOMString[]? excludeMatches;
// Specifies wildcard patterns for pages this user script will NOT be
// injected into.
DOMString[]? excludeGlobs;
// The ID of the script.
DOMString id;
// Specifies wildcard patterns for pages this user script will be injected
// into.
DOMString[]? includeGlobs;
// The list of sources of javascript to be injected into matching pages.
ScriptSource[]? js;
// Specifies which pages this user script will be injected into.
DOMString[] matches;
// Whether the script should inject into any frames where the URL belongs to
// a scheme that would never match a specified Match Pattern, including
// about:, data:, blob:, and filesystem: schemes.
boolean? matchOriginAsFallback;
// Specifies when JavaScript files are injected into the web page.
extensionTypes.RunAt? runAt;
// The "source" of the user script.
Source source;
// The JavaScript "world" to run the script in.
extensionTypes.ExecutionWorld world;
};
};
+362
View File
@@ -0,0 +1,362 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.serial</code> API to read from and write to a device
// connected to a serial port.
namespace serial {
dictionary DeviceInfo {
// The device's system path. This should be passed as the <code>path</code>
// argument to <code>chrome.serial.connect</code> in order to connect to
// this device.
DOMString path;
// A PCI or USB vendor ID if one can be determined for the underlying
// device.
long? vendorId;
// A USB product ID if one can be determined for the underlying device.
long? productId;
// A human-readable display name for the underlying device if one can be
// queried from the host driver.
DOMString? displayName;
};
callback GetDevicesCallback = void (DeviceInfo[] ports);
enum DataBits { seven, eight };
enum ParityBit { no, odd, even };
enum StopBits { one, two };
dictionary ConnectionOptions {
// Flag indicating whether or not the connection should be left open when
// the application is suspended (see
// <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is "false." When the application is
// loaded, any serial connections previously opened with persistent=true
// can be fetched with <code>getConnections</code>.
boolean? persistent;
// An application-defined string to associate with the connection.
DOMString? name;
// The size of the buffer used to receive data. The default value is 4096.
long? bufferSize;
// The requested bitrate of the connection to be opened. For compatibility
// with the widest range of hardware, this number should match one of
// commonly-available bitrates, such as 110, 300, 1200, 2400, 4800, 9600,
// 14400, 19200, 38400, 57600, 115200. There is no guarantee, of course,
// that the device connected to the serial port will support the requested
// bitrate, even if the port itself supports that bitrate. <code>9600</code>
// will be passed by default.
long? bitrate;
// <code>"eight"</code> will be passed by default.
DataBits? dataBits;
// <code>"no"</code> will be passed by default.
ParityBit? parityBit;
// <code>"one"</code> will be passed by default.
StopBits? stopBits;
// Flag indicating whether or not to enable RTS/CTS hardware flow control.
// Defaults to false.
boolean? ctsFlowControl;
// The maximum amount of time (in milliseconds) to wait for new data before
// raising an <code>onReceiveError</code> event with a "timeout" error.
// If zero, receive timeout errors will not be raised for the connection.
// Defaults to 0.
long? receiveTimeout;
// The maximum amount of time (in milliseconds) to wait for a
// <code>send</code> operation to complete before calling the callback with
// a "timeout" error. If zero, send timeout errors will not be triggered.
// Defaults to 0.
long? sendTimeout;
};
// Result of the <code>getInfo</code> method.
dictionary ConnectionInfo {
// The id of the serial port connection.
long connectionId;
// Flag indicating whether the connection is blocked from firing onReceive
// events.
boolean paused;
// See <code>ConnectionOptions.persistent</code>
boolean persistent;
// See <code>ConnectionOptions.name</code>
DOMString name;
// See <code>ConnectionOptions.bufferSize</code>
long bufferSize;
// See <code>ConnectionOptions.receiveTimeout</code>
long receiveTimeout;
// See <code>ConnectionOptions.sendTimeout</code>
long sendTimeout;
// See <code>ConnectionOptions.bitrate</code>. This field may be omitted
// or inaccurate if a non-standard bitrate is in use, or if an error
// occurred while querying the underlying device.
long? bitrate;
// See <code>ConnectionOptions.dataBits</code>. This field may be omitted
// if an error occurred while querying the underlying device.
DataBits? dataBits;
// See <code>ConnectionOptions.parityBit</code>. This field may be omitted
// if an error occurred while querying the underlying device.
ParityBit? parityBit;
// See <code>ConnectionOptions.stopBits</code>. This field may be omitted
// if an error occurred while querying the underlying device.
StopBits? stopBits;
// See <code>ConnectionOptions.ctsFlowControl</code>. This field may be
// omitted if an error occurred while querying the underlying device.
boolean? ctsFlowControl;
};
// Callback from the <code>connect</code> method;
callback ConnectCallback = void (ConnectionInfo connectionInfo);
// Callback from the <code>update</code> method.
callback UpdateCallback = void (boolean result);
// Callback from the <code>disconnect</code> method. Returns true if the
// operation was successful.
callback DisconnectCallback = void (boolean result);
// Callback from the <code>setPaused</code> method.
callback SetPausedCallback = void ();
// Callback from the <code>getInfo</code> method.
callback GetInfoCallback = void (ConnectionInfo connectionInfo);
// Callback from the <code>getConnections</code> method.
callback GetConnectionsCallback = void (ConnectionInfo[] connectionInfos);
enum SendError {
// The connection was disconnected.
disconnected,
// A send was already pending.
pending,
// The send timed out.
timeout,
// A system error occurred and the connection may be unrecoverable.
system_error
};
dictionary SendInfo {
// The number of bytes sent.
long bytesSent;
// An error code if an error occurred.
SendError? error;
};
callback SendCallback = void (SendInfo sendInfo);
callback FlushCallback = void (boolean result);
callback SetBreakCallback = void (boolean result);
callback ClearBreakCallback = void (boolean result);
// The set of control signals which may be sent to a connected serial device
// using <code>setControlSignals</code>. Note that support for these signals
// is device-dependent.
dictionary HostControlSignals {
// DTR (Data Terminal Ready).
boolean? dtr;
// RTS (Request To Send).
boolean? rts;
};
// The set of control signals which may be set by a connected serial device.
// These can be queried using <code>getControlSignals</code>. Note that
// support for these signals is device-dependent.
dictionary DeviceControlSignals {
// DCD (Data Carrier Detect) or RLSD (Receive Line Signal/ Detect).
boolean dcd;
// CTS (Clear To Send).
boolean cts;
// RI (Ring Indicator).
boolean ri;
// DSR (Data Set Ready).
boolean dsr;
};
// Returns a snapshot of current control signals.
callback GetControlSignalsCallback = void (DeviceControlSignals signals);
// Returns true if operation was successful.
callback SetControlSignalsCallback = void (boolean result);
// Data from an <code>onReceive</code> event.
dictionary ReceiveInfo {
// The connection identifier.
long connectionId;
// The data received.
ArrayBuffer data;
};
enum ReceiveError {
// The connection was disconnected.
disconnected,
// No data has been received for <code>receiveTimeout</code> milliseconds.
timeout,
// The device was most likely disconnected from the host.
device_lost,
// The device detected a break condition.
break,
// The device detected a framing error.
frame_error,
// A character-buffer overrun has occurred. The next character is lost.
overrun,
// An input buffer overflow has occurred. There is either no room in the
// input buffer, or a character was received after the end-of-file (EOF)
// character.
buffer_overflow,
// The device detected a parity error.
parity_error,
// A system error occurred and the connection may be unrecoverable.
system_error
};
// Data from an <code>onReceiveError</code> event.
dictionary ReceiveErrorInfo {
// The connection identifier.
long connectionId;
// An error code indicating what went wrong.
ReceiveError error;
};
interface Functions {
// Returns information about available serial devices on the system.
// The list is regenerated each time this method is called.
// |callback| : Called with the list of <code>DeviceInfo</code> objects.
[supportsPromises] static void getDevices(GetDevicesCallback callback);
// Connects to a given serial port.
// |path| : The system path of the serial port to open.
// |options| : Port configuration options.
// |callback| : Called when the connection has been opened.
[supportsPromises] static void connect(DOMString path,
optional ConnectionOptions options,
ConnectCallback callback);
// Update the option settings on an open serial port connection.
// |connectionId| : The id of the opened connection.
// |options| : Port configuration options.
// |callback| : Called when the configuation has completed.
[supportsPromises] static void update(long connectionId,
ConnectionOptions options,
UpdateCallback callback);
// Disconnects from a serial port.
// |connectionId| : The id of the opened connection.
// |callback| : Called when the connection has been closed.
[supportsPromises] static void disconnect(long connectionId,
DisconnectCallback callback);
// Pauses or unpauses an open connection.
// |connectionId| : The id of the opened connection.
// |paused| : Flag to indicate whether to pause or unpause.
// |callback| : Called when the connection has been successfully paused or
// unpaused.
[supportsPromises] static void setPaused(long connectionId,
boolean paused,
SetPausedCallback callback);
// Retrieves the state of a given connection.
// |connectionId| : The id of the opened connection.
// |callback| : Called with connection state information when available.
[supportsPromises] static void getInfo(long connectionId,
GetInfoCallback callback);
// Retrieves the list of currently opened serial port connections owned by
// the application.
// |callback| : Called with the list of connections when available.
[supportsPromises] static void getConnections(
GetConnectionsCallback callback);
// Writes data to the given connection.
// |connectionId| : The id of the connection.
// |data| : The data to send.
// |callback| : Called when the operation has completed.
[supportsPromises] static void send(long connectionId,
ArrayBuffer data,
SendCallback callback);
// Flushes all bytes in the given connection's input and output buffers.
[supportsPromises] static void flush(long connectionId,
FlushCallback callback);
// Retrieves the state of control signals on a given connection.
// |connectionId| : The id of the connection.
// |callback| : Called when the control signals are available.
[supportsPromises] static void getControlSignals(
long connectionId,
GetControlSignalsCallback callback);
// Sets the state of control signals on a given connection.
// |connectionId| : The id of the connection.
// |signals| : The set of signal changes to send to the device.
// |callback| : Called once the control signals have been set.
[supportsPromises] static void setControlSignals(
long connectionId,
HostControlSignals signals,
SetControlSignalsCallback callback);
// Suspends character transmission on a given connection and places the
// transmission line in a break state until the clearBreak is called.
// |connectionId| : The id of the connection.
[supportsPromises] static void setBreak(long connectionId,
SetBreakCallback callback);
// Restore character transmission on a given connection and place the
// transmission line in a nonbreak state.
// |connectionId| : The id of the connection.
[supportsPromises] static void clearBreak(long connectionId,
ClearBreakCallback callback);
};
interface Events {
// Event raised when data has been read from the connection.
// |info| : Event data.
static void onReceive(ReceiveInfo info);
// Event raised when an error occurred while the runtime was waiting for
// data on the serial port. Once this event is raised, the connection may be
// set to <code>paused</code>. A <code>"timeout"</code> error does not pause
// the connection.
static void onReceiveError(ReceiveErrorInfo info);
};
};
@@ -0,0 +1,32 @@
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for the "import" and "export" manifest keys.
[generate_error_messages]
namespace sharedModule {
dictionary Import {
// Extension ID of the shared module this extension or app depends on.
DOMString id;
// Minimum supported version of the shared module.
DOMString? minimum_version;
};
dictionary Export {
// Optional list of extension IDs explicitly allowed to import this Shared
// Module's resources. If no allowlist is given, all extensions are allowed
// to import it.
DOMString[]? allowlist;
};
dictionary ManifestKeys {
// The import field is used by extensions and apps to declare that they
// depend on the resources from particular Shared Modules.
Import[]? import;
// The export field indicates an extension is a Shared Module that exports
// its resources.
Export? export;
};
};
+397
View File
@@ -0,0 +1,397 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.socket</code> API to send and receive data over the
// network using TCP and UDP connections. <b>Note:</b> Starting with Chrome 33,
// this API is deprecated in favor of the $(ref:sockets.udp), $(ref:sockets.tcp) and
// $(ref:sockets.tcpServer) APIs.
namespace socket {
enum SocketType {
tcp,
udp
};
// The socket options.
dictionary CreateOptions {
};
dictionary CreateInfo {
// The id of the newly created socket.
long socketId;
};
callback CreateCallback = void (CreateInfo createInfo);
callback ConnectCallback = void (long result);
callback BindCallback = void (long result);
callback ListenCallback = void (long result);
callback SecureCallback = void (long result);
dictionary AcceptInfo {
long resultCode;
// The id of the accepted socket.
long? socketId;
};
callback AcceptCallback = void (AcceptInfo acceptInfo);
dictionary ReadInfo {
// The resultCode returned from the underlying read() call.
long resultCode;
ArrayBuffer data;
};
callback ReadCallback = void (ReadInfo readInfo);
dictionary WriteInfo {
// The number of bytes sent, or a negative error code.
long bytesWritten;
};
callback WriteCallback = void (WriteInfo writeInfo);
dictionary RecvFromInfo {
// The resultCode returned from the underlying recvfrom() call.
long resultCode;
ArrayBuffer data;
// The address of the remote machine.
DOMString address;
long port;
};
dictionary SocketInfo {
// The type of the passed socket. This will be <code>tcp</code> or
// <code>udp</code>.
SocketType socketType;
// Whether or not the underlying socket is connected.
//
// For <code>tcp</code> sockets, this will remain true even if the remote
// peer has disconnected. Reading or writing to the socket may then result
// in an error, hinting that this socket should be disconnected via
// <code>disconnect()</code>.
//
// For <code>udp</code> sockets, this just represents whether a default
// remote address has been specified for reading and writing packets.
boolean connected;
// If the underlying socket is connected, contains the IPv4/6 address of
// the peer.
DOMString? peerAddress;
// If the underlying socket is connected, contains the port of the
// connected peer.
long? peerPort;
// If the underlying socket is bound or connected, contains its local
// IPv4/6 address.
DOMString? localAddress;
// If the underlying socket is bound or connected, contains its local port.
long? localPort;
};
dictionary NetworkInterface {
// The underlying name of the adapter. On *nix, this will typically be
// "eth0", "lo", etc.
DOMString name;
// The available IPv4/6 address.
DOMString address;
// The prefix length
long prefixLength;
};
dictionary TLSVersionConstraints {
// The minimum and maximum acceptable versions of TLS. Supported values are
// <code>tls1.2</code> or <code>tls1.3</code>.
//
// The values <code>tls1</code> and <code>tls1.1</code> are no longer
// supported. If |min| is set to one of these values, it will be silently
// clamped to <code>tls1.2</code>. If |max| is set to one of those values,
// or any other unrecognized value, it will be silently ignored.
DOMString? min;
DOMString? max;
};
dictionary SecureOptions {
TLSVersionConstraints? tlsVersion;
};
callback RecvFromCallback = void (RecvFromInfo recvFromInfo);
callback SendToCallback = void (WriteInfo writeInfo);
callback SetKeepAliveCallback = void (boolean result);
callback SetNoDelayCallback = void (boolean result);
callback GetInfoCallback = void (SocketInfo result);
callback GetNetworkCallback = void (NetworkInterface[] result);
callback JoinGroupCallback = void (long result);
callback LeaveGroupCallback = void (long result);
callback SetMulticastTimeToLiveCallback = void (long result);
callback SetMulticastLoopbackModeCallback = void (long result);
callback GetJoinedGroupsCallback = void (DOMString[] groups);
interface Functions {
// Creates a socket of the specified type that will connect to the specified
// remote machine.
// |type| : The type of socket to create. Must be <code>tcp</code> or
// <code>udp</code>.
// |options| : The socket options.
// |callback| : Called when the socket has been created.
static void create(SocketType type,
optional CreateOptions options,
CreateCallback callback);
// Destroys the socket. Each socket created should be destroyed after use.
// |socketId| : The socketId.
static void destroy(long socketId);
// Connects the socket to the remote machine (for a <code>tcp</code>
// socket). For a <code>udp</code> socket, this sets the default address
// which packets are sent to and read from for <code>read()</code>
// and <code>write()</code> calls.
// |socketId| : The socketId.
// |hostname| : The hostname or IP address of the remote machine.
// |port| : The port of the remote machine.
// |callback| : Called when the connection attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void connect(long socketId,
DOMString hostname,
long port,
ConnectCallback callback);
// Binds the local address for socket. Currently, it does not support
// TCP socket.
// |socketId| : The socketId.
// |address| : The address of the local machine.
// |port| : The port of the local machine.
// |callback| : Called when the bind attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void bind(long socketId,
DOMString address,
long port,
BindCallback callback);
// Disconnects the socket. For UDP sockets, <code>disconnect</code> is a
// non-operation but is safe to call.
// |socketId| : The socketId.
static void disconnect(long socketId);
// Reads data from the given connected socket.
// |socketId| : The socketId.
// |bufferSize| : The read buffer size.
// |callback| : Delivers data that was available to be read without
// blocking.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void read(long socketId,
optional long bufferSize,
ReadCallback callback);
// Writes data on the given connected socket.
// |socketId| : The socketId.
// |data| : The data to write.
// |callback| : Called when the write operation completes without blocking
// or an error occurs.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void write(long socketId,
ArrayBuffer data,
WriteCallback callback);
// Receives data from the given UDP socket.
// |socketId| : The socketId.
// |bufferSize| : The receive buffer size.
// |callback| : Returns result of the recvFrom operation.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void recvFrom(long socketId,
optional long bufferSize,
RecvFromCallback callback);
// Sends data on the given UDP socket to the given address and port.
// |socketId| : The socketId.
// |data| : The data to write.
// |address| : The address of the remote machine.
// |port| : The port of the remote machine.
// |callback| : Called when the send operation completes without blocking
// or an error occurs.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void sendTo(long socketId,
ArrayBuffer data,
DOMString address,
long port,
SendToCallback callback);
// This method applies to TCP sockets only.
// Listens for connections on the specified port and address. This
// effectively makes this a server socket, and client socket
// functions (connect, read, write) can no longer be used on this socket.
// |socketId| : The socketId.
// |address| : The address of the local machine.
// |port| : The port of the local machine.
// |backlog| : Length of the socket's listen queue.
// |callback| : Called when listen operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void listen(long socketId,
DOMString address,
long port,
optional long backlog,
ListenCallback callback);
// This method applies to TCP sockets only.
// Registers a callback function to be called when a connection is
// accepted on this listening server socket. Listen must be called first.
// If there is already an active accept callback, this callback will be
// invoked immediately with an error as the resultCode.
// |socketId| : The socketId.
// |callback| : The callback is invoked when a new socket is accepted.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void accept(long socketId,
AcceptCallback callback);
// Enables or disables the keep-alive functionality for a TCP connection.
// |socketId| : The socketId.
// |enable| : If true, enable keep-alive functionality.
// |delay| : Set the delay seconds between the last data packet received
// and the first keepalive probe. Default is 0.
// |callback| : Called when the setKeepAlive attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setKeepAlive(long socketId,
boolean enable,
optional long delay,
SetKeepAliveCallback callback);
// Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
// algorithm will be disabled when <code>TCP_NODELAY</code> is set.
// |socketId| : The socketId.
// |noDelay| : If true, disables Nagle's algorithm.
// |callback| : Called when the setNoDelay attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setNoDelay(long socketId,
boolean noDelay,
SetNoDelayCallback callback);
// Retrieves the state of the given socket.
// |socketId| : The socketId.
// |callback| : Called when the state is available.
static void getInfo(long socketId,
GetInfoCallback callback);
// Retrieves information about local adapters on this system.
// |callback| : Called when local adapter information is available.
static void getNetworkList(GetNetworkCallback callback);
// Join the multicast group and start to receive packets from that group.
// The socket must be of UDP type and must be bound to a local port
// before calling this method.
// |socketId| : The socketId.
// |address| : The group address to join. Domain names are not supported.
// |callback| : Called when the join group operation is done with an
// integer parameter indicating the platform-independent error code.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void joinGroup(long socketId,
DOMString address,
JoinGroupCallback callback);
// Leave the multicast group previously joined using <code>joinGroup</code>.
// It's not necessary to leave the multicast group before destroying the
// socket or exiting. This is automatically called by the OS.
//
// Leaving the group will prevent the router from sending multicast
// datagrams to the local host, presuming no other process on the host is
// still joined to the group.
//
// |socketId| : The socketId.
// |address| : The group address to leave. Domain names are not supported.
// |callback| : Called when the leave group operation is done with an
// integer parameter indicating the platform-independent error code.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void leaveGroup(long socketId, DOMString address,
LeaveGroupCallback callback);
// Set the time-to-live of multicast packets sent to the multicast group.
//
// Calling this method does not require multicast permissions.
//
// |socketId| : The socketId.
// |ttl| : The time-to-live value.
// |callback| : Called when the configuration operation is done.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setMulticastTimeToLive(
long socketId,
long ttl,
SetMulticastTimeToLiveCallback callback);
// Set whether multicast packets sent from the host to the multicast
// group will be looped back to the host.
//
// Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly
// different between Windows and Unix-like systems. The inconsistency
// happens only when there is more than one application on the same host
// joined to the same multicast group while having different settings on
// multicast loopback mode. On Windows, the applications with loopback off
// will not RECEIVE the loopback packets; while on Unix-like systems, the
// applications with loopback off will not SEND the loopback packets to
// other applications on the same host. See MSDN: http://goo.gl/6vqbj
//
// Calling this method does not require multicast permissions.
//
// |socketId| : The socketId.
// |enabled| : Indicate whether to enable loopback mode.
// |callback| : Called when the configuration operation is done.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setMulticastLoopbackMode(
long socketId,
boolean enabled,
SetMulticastLoopbackModeCallback callback);
// Get the multicast group addresses the socket is currently joined to.
// |socketId| : The socketId.
// |callback| : Called with an array of strings of the result.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void getJoinedGroups(long socketId,
GetJoinedGroupsCallback callback);
// Start a TLS client connection over a connected TCP client socket.
// |socketId| : The connected socket to use.
// |options| : Constraints and parameters for the TLS connection.
// |callback| : Called when the TLS connection attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void secure(long socketId,
optional SecureOptions options,
SecureCallback callback);
};
};
@@ -0,0 +1,295 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.sockets.tcp</code> API to send and receive data over the
// network using TCP connections. This API supersedes the TCP functionality
// previously found in the <code>chrome.socket</code> API.
namespace sockets.tcp {
// The socket properties specified in the <code>create</code> or
// <code>update</code> function. Each property is optional. If a property
// value is not specified, a default value is used when calling
// <code>create</code>, or the existing value if preserved when calling
// <code>update</code>.
dictionary SocketProperties {
// Flag indicating if the socket is left open when the event page of
// the application is unloaded (see
// <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is "false." When the application is
// loaded, any sockets previously opened with persistent=true can be fetched
// with <code>getSockets</code>.
boolean? persistent;
// An application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. The default value is 4096.
long? bufferSize;
};
// Result of <code>create</code> call.
dictionary CreateInfo {
// The ID of the newly created socket. Note that socket IDs created from
// this API are not compatible with socket IDs created from other APIs, such
// as the deprecated <code>$(ref:socket)</code> API.
long socketId;
};
// Callback from the <code>create</code> method.
// |createInfo| : The result of the socket creation.
callback CreateCallback = void (CreateInfo createInfo);
// DNS resolution preferences. The default is <code>any</code> and uses the
// current OS config which may return IPv4 or IPv6. <code>ipv4</code> forces
// IPv4, and <code>ipv6</code> forces IPv6.
enum DnsQueryType { any, ipv4, ipv6 };
// Callback from the <code>connect</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback ConnectCallback = void (long result);
// Callback from the <code>disconnect</code> method.
callback DisconnectCallback = void ();
// Result of the <code>send</code> method.
dictionary SendInfo {
// The result code returned from the underlying network call.
// A negative value indicates an error.
long resultCode;
// The number of bytes sent (if result == 0)
long? bytesSent;
};
// Callback from the <code>send</code> method.
// |sendInfo| : Result of the <code>send</code> method.
callback SendCallback = void (SendInfo sendInfo);
// Callback from the <code>close</code> method.
callback CloseCallback = void ();
// Callback from the <code>update</code> method.
callback UpdateCallback = void ();
// Callback from the <code>setPaused</code> method.
callback SetPausedCallback = void ();
// Callback from the <code>setKeepAliveCallback</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback SetKeepAliveCallback = void (long result);
// Callback from the <code>setNodeDelay</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback SetNoDelayCallback = void (long result);
dictionary TLSVersionConstraints {
// The minimum and maximum acceptable versions of TLS. Supported values are
// <code>tls1.2</code> or <code>tls1.3</code>.
//
// The values <code>tls1</code> and <code>tls1.1</code> are no longer
// supported. If |min| is set to one of these values, it will be silently
// clamped to <code>tls1.2</code>. If |max| is set to one of those values,
// or any other unrecognized value, it will be silently ignored.
DOMString? min;
DOMString? max;
};
dictionary SecureOptions {
TLSVersionConstraints? tlsVersion;
};
callback SecureCallback = void (long result);
// Result of the <code>getInfo</code> method.
dictionary SocketInfo {
// The socket identifier.
long socketId;
// Flag indicating whether the socket is left open when the application is
// suspended (see <code>SocketProperties.persistent</code>).
boolean persistent;
// Application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. If no buffer size has been
// specified explictly, the value is not provided.
long? bufferSize;
// Flag indicating whether a connected socket blocks its peer from sending
// more data (see <code>setPaused</code>).
boolean paused;
// Flag indicating whether the socket is connected to a remote peer.
boolean connected;
// If the underlying socket is connected, contains its local IPv4/6 address.
DOMString? localAddress;
// If the underlying socket is connected, contains its local port.
long? localPort;
// If the underlying socket is connected, contains the peer/ IPv4/6 address.
DOMString? peerAddress;
// If the underlying socket is connected, contains the peer port.
long? peerPort;
};
// Callback from the <code>getInfo</code> method.
// |socketInfo| : Object containing the socket information.
callback GetInfoCallback = void (SocketInfo socketInfo);
// Callback from the <code>getSockets</code> method.
// |socketInfos| : Array of object containing socket information.
callback GetSocketsCallback = void (SocketInfo[] socketInfos);
// Data from an <code>onReceive</code> event.
dictionary ReceiveInfo {
// The socket identifier.
long socketId;
// The data received, with a maxium size of <code>bufferSize</code>.
ArrayBuffer data;
};
// Data from an <code>onReceiveError</code> event.
dictionary ReceiveErrorInfo {
// The socket identifier.
long socketId;
// The result code returned from the underlying network call.
long resultCode;
};
interface Functions {
// Creates a TCP socket.
// |properties| : The socket properties (optional).
// |callback| : Called when the socket has been created.
static void create(optional SocketProperties properties,
CreateCallback callback);
// Updates the socket properties.
// |socketId| : The socket identifier.
// |properties| : The properties to update.
// |callback| : Called when the properties are updated.
static void update(long socketId,
SocketProperties properties,
optional UpdateCallback callback);
// Enables or disables the application from receiving messages from its
// peer. The default value is "false". Pausing a socket is typically used
// by an application to throttle data sent by its peer. When a socket is
// paused, no <code>onReceive</code> event is raised. When a socket is
// connected and un-paused, <code>onReceive</code> events are raised again
// when messages are received.
static void setPaused(long socketId,
boolean paused,
optional SetPausedCallback callback);
// Enables or disables the keep-alive functionality for a TCP connection.
// |socketId| : The socket identifier.
// |enable| : If true, enable keep-alive functionality.
// |delay| : Set the delay seconds between the last data packet received
// and the first keepalive probe. Default is 0.
// |callback| : Called when the setKeepAlive attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setKeepAlive(long socketId,
boolean enable,
optional long delay,
SetKeepAliveCallback callback);
// Sets or clears <code>TCP_NODELAY</code> for a TCP connection. Nagle's
// algorithm will be disabled when <code>TCP_NODELAY</code> is set.
// |socketId| : The socket identifier.
// |noDelay| : If true, disables Nagle's algorithm.
// |callback| : Called when the setNoDelay attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setNoDelay(long socketId,
boolean noDelay,
SetNoDelayCallback callback);
// Connects the socket to a remote machine. When the <code>connect</code>
// operation completes successfully, <code>onReceive</code> events are
// raised when data is received from the peer. If a network error occurs
// while the runtime is receiving packets, a <code>onReceiveError</code>
// event is raised, at which point no more <code>onReceive</code> event will
// be raised for this socket until the <code>resume</code> method is called.
// |socketId| : The socket identifier.
// |peerAddress| : The address of the remote machine. DNS name, IPv4 and
// IPv6 formats are supported.
// |peerPort| : The port of the remote machine.
// |dnsQueryType| : The address resolution preference.
// |callback| : Called when the connect attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void connect(long socketId,
DOMString peerAddress,
long peerPort,
optional DnsQueryType dnsQueryType,
ConnectCallback callback);
// Disconnects the socket.
// |socketId| : The socket identifier.
// |callback| : Called when the disconnect attempt is complete.
static void disconnect(long socketId,
optional DisconnectCallback callback);
// Start a TLS client connection over the connected TCP client socket.
// |socketId| : The existing, connected socket to use.
// |options| : Constraints and parameters for the TLS connection.
// |callback| : Called when the connection attempt is complete.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void secure(long socketId,
optional SecureOptions options,
SecureCallback callback);
// Sends data on the given TCP socket.
// |socketId| : The socket identifier.
// |data| : The data to send.
// |callback| : Called when the <code>send</code> operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void send(long socketId,
ArrayBuffer data,
SendCallback callback);
// Closes the socket and releases the address/port the socket is bound to.
// Each socket created should be closed after use. The socket id is no
// no longer valid as soon at the function is called. However, the socket is
// guaranteed to be closed only when the callback is invoked.
// |socketId| : The socket identifier.
// |callback| : Called when the <code>close</code> operation completes.
static void close(long socketId,
optional CloseCallback callback);
// Retrieves the state of the given socket.
// |socketId| : The socket identifier.
// |callback| : Called when the socket state is available.
static void getInfo(long socketId,
GetInfoCallback callback);
// Retrieves the list of currently opened sockets owned by the application.
// |callback| : Called when the list of sockets is available.
static void getSockets(GetSocketsCallback callback);
};
interface Events {
// Event raised when data has been received for a given socket.
// |info| : The event data.
static void onReceive(ReceiveInfo info);
// Event raised when a network error occured while the runtime was waiting
// for data on the socket address and port. Once this event is raised, the
// socket is set to <code>paused</code> and no more <code>onReceive</code>
// events are raised for this socket.
// |info| : The event data.
static void onReceiveError(ReceiveErrorInfo info);
};
};
@@ -0,0 +1,197 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.sockets.tcpServer</code> API to create server
// applications using TCP connections. This API supersedes the TCP functionality
// previously found in the <code>chrome.socket</code> API.
namespace sockets.tcpServer {
// The socket properties specified in the <code>create</code> or
// <code>update</code> function. Each property is optional. If a property
// value is not specified, a default value is used when calling
// <code>create</code>, or the existing value if preserved when calling
// <code>update</code>.
dictionary SocketProperties {
// Flag indicating if the socket remains open when the event page of the
// application is unloaded (see
// <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is "false." When the application is
// loaded, any sockets previously opened with persistent=true can be fetched
// with <code>getSockets</code>.
boolean? persistent;
// An application-defined string associated with the socket.
DOMString? name;
};
// Result of <code>create</code> call.
dictionary CreateInfo {
// The ID of the newly created server socket. Note that socket IDs created
// from this API are not compatible with socket IDs created from other APIs,
// such as the deprecated <code>$(ref:socket)</code> API.
long socketId;
};
// Callback from the <code>create</code> method.
// |createInfo| : The result of the socket creation.
callback CreateCallback = void (CreateInfo createInfo);
// Callback from the <code>listen</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback ListenCallback = void (long result);
// Callback from the <code>disconnect</code> method.
callback DisconnectCallback = void ();
// Callback from the <code>close</code> method.
callback CloseCallback = void ();
// Callback from the <code>update</code> method.
callback UpdateCallback = void ();
// Callback from the <code>setPaused</code> method.
callback SetPausedCallback = void ();
// Result of the <code>getInfo</code> method.
dictionary SocketInfo {
// The socket identifier.
long socketId;
// Flag indicating if the socket remains open when the event page of the
// application is unloaded (see <code>SocketProperties.persistent</code>).
// The default value is "false".
boolean persistent;
// Application-defined string associated with the socket.
DOMString? name;
// Flag indicating whether connection requests on a listening socket are
// dispatched through the <code>onAccept</code> event or queued up in the
// listen queue backlog.
// See <code>setPaused</code>. The default value is "false".
boolean paused;
// If the socket is listening, contains its local IPv4/6 address.
DOMString? localAddress;
// If the socket is listening, contains its local port.
long? localPort;
};
// Callback from the <code>getInfo</code> method.
// |socketInfo| : Object containing the socket information.
callback GetInfoCallback = void (SocketInfo socketInfo);
// Callback from the <code>getSockets</code> method.
// |socketInfos| : Array of object containing socket information.
callback GetSocketsCallback = void (SocketInfo[] socketInfos);
// Data from an <code>onAccept</code> event.
dictionary AcceptInfo {
// The server socket identifier.
long socketId;
// The client socket identifier, i.e. the socket identifier of the newly
// established connection. This socket identifier should be used only with
// functions from the <code>chrome.sockets.tcp</code> namespace. Note the
// client socket is initially paused and must be explictly un-paused by the
// application to start receiving data.
long clientSocketId;
};
// Data from an <code>onAcceptError</code> event.
dictionary AcceptErrorInfo {
// The server socket identifier.
long socketId;
// The result code returned from the underlying network call.
long resultCode;
};
interface Functions {
// Creates a TCP server socket.
// |properties| : The socket properties (optional).
// |callback| : Called when the socket has been created.
static void create(optional SocketProperties properties,
CreateCallback callback);
// Updates the socket properties.
// |socketId| : The socket identifier.
// |properties| : The properties to update.
// |callback| : Called when the properties are updated.
static void update(long socketId,
SocketProperties properties,
optional UpdateCallback callback);
// Enables or disables a listening socket from accepting new connections.
// When paused, a listening socket accepts new connections until its backlog
// (see <code>listen</code> function) is full then refuses additional
// connection requests. <code>onAccept</code> events are raised only when
// the socket is un-paused.
static void setPaused(long socketId,
boolean paused,
optional SetPausedCallback callback);
// Listens for connections on the specified port and address.
// If the port/address is in use, the callback indicates a failure.
// |socketId| : The socket identifier.
// |address| : The address of the local machine.
// |port| : The port of the local machine. When set to <code>0</code>, a
// free port is chosen dynamically. The dynamically allocated port can be
// found by calling <code>getInfo</code>.
// |backlog| : Length of the socket's listen queue. The default value
// depends on the Operating System (SOMAXCONN), which ensures a reasonable
// queue length for most applications.
// |callback| : Called when listen operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void listen(long socketId,
DOMString address,
long port,
optional long backlog,
ListenCallback callback);
// Disconnects the listening socket, i.e. stops accepting new connections
// and releases the address/port the socket is bound to. The socket
// identifier remains valid, e.g. it can be used with <code>listen</code> to
// accept connections on a new port and address.
// |socketId| : The socket identifier.
// |callback| : Called when the disconnect attempt is complete.
static void disconnect(long socketId,
optional DisconnectCallback callback);
// Disconnects and destroys the socket. Each socket created should be
// closed after use. The socket id is no longer valid as soon at the
// function is called. However, the socket is guaranteed to be closed only
// when the callback is invoked.
// |socketId| : The socket identifier.
// |callback| : Called when the <code>close</code> operation completes.
static void close(long socketId,
optional CloseCallback callback);
// Retrieves the state of the given socket.
// |socketId| : The socket identifier.
// |callback| : Called when the socket state is available.
static void getInfo(long socketId,
GetInfoCallback callback);
// Retrieves the list of currently opened sockets owned by the application.
// |callback| : Called when the list of sockets is available.
static void getSockets(GetSocketsCallback callback);
};
interface Events {
// Event raised when a connection has been made to the server socket.
// |info| : The event data.
static void onAccept(AcceptInfo info);
// Event raised when a network error occured while the runtime was waiting
// for new connections on the socket address and port. Once this event is
// raised, the socket is set to <code>paused</code> and no more
// <code>onAccept</code> events are raised for this socket until the socket
// is resumed.
// |info| : The event data.
static void onAcceptError(AcceptErrorInfo info);
};
};
@@ -0,0 +1,342 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.sockets.udp</code> API to send and receive data over the
// network using UDP connections. This API supersedes the UDP functionality
// previously found in the "socket" API.
namespace sockets.udp {
// The socket properties specified in the <code>create</code> or
// <code>update</code> function. Each property is optional. If a property
// value is not specified, a default value is used when calling
// <code>create</code>, or the existing value if preserved when calling
// <code>update</code>.
dictionary SocketProperties {
// Flag indicating if the socket is left open when the event page of the
// application is unloaded (see
// <a href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
// Lifecycle</a>). The default value is "false." When the application is
// loaded, any sockets previously opened with persistent=true can be fetched
// with <code>getSockets</code>.
boolean? persistent;
// An application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. If the buffer is too small
// to receive the UDP packet, data is lost. The default value is 4096.
long? bufferSize;
};
// Result of <code>create</code> call.
dictionary CreateInfo {
// The ID of the newly created socket. Note that socket IDs created from
// this API are not compatible with socket IDs created from other APIs, such
// as the deprecated <code>$(ref:socket)</code> API.
long socketId;
};
// Callback from the <code>create</code> method.
// |createInfo| : The result of the socket creation.
callback CreateCallback = void (CreateInfo createInfo);
// Callback from the <code>bind</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback BindCallback = void (long result);
// DNS resolution preferences. The default is <code>any</code> and uses the
// current OS config which may return IPv4 or IPv6. <code>ipv4</code> forces
// IPv4, and <code>ipv6</code> forces IPv6.
enum DnsQueryType { any, ipv4, ipv6 };
// Result of the <code>send</code> method.
dictionary SendInfo {
// The result code returned from the underlying network call.
// A negative value indicates an error.
long resultCode;
// The number of bytes sent (if result == 0)
long? bytesSent;
};
// Callback from the <code>send</code> method.
// |sendInfo| : Result of the <code>send</code> method.
callback SendCallback = void (SendInfo sendInfo);
// Callback from the <code>close</code> method.
callback CloseCallback = void ();
// Callback from the <code>update</code> method.
callback UpdateCallback = void ();
// Callback from the <code>setPaused</code> method.
callback SetPausedCallback = void ();
// Result of the <code>getInfo</code> method.
dictionary SocketInfo {
// The socket identifier.
long socketId;
// Flag indicating whether the socket is left open when the application is
// suspended (see <code>SocketProperties.persistent</code>).
boolean persistent;
// Application-defined string associated with the socket.
DOMString? name;
// The size of the buffer used to receive data. If no buffer size has been
// specified explictly, the value is not provided.
long? bufferSize;
// Flag indicating whether the socket is blocked from firing onReceive
// events.
boolean paused;
// If the underlying socket is bound, contains its local
// IPv4/6 address.
DOMString? localAddress;
// If the underlying socket is bound, contains its local port.
long? localPort;
};
// Callback from the <code>getInfo</code> method.
// |socketInfo| : Object containing the socket information.
callback GetInfoCallback = void (SocketInfo socketInfo);
// Callback from the <code>getSockets</code> method.
// |socketInfos| : Array of object containing socket information.
callback GetSocketsCallback = void (SocketInfo[] socketInfos);
// Callback from the <code>joinGroup</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback JoinGroupCallback = void (long result);
// Callback from the <code>leaveGroup</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback LeaveGroupCallback = void (long result);
// Callback from the <code>setMulticastTimeToLive</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback SetMulticastTimeToLiveCallback = void (long result);
// Callback from the <code>setMulticastLoopbackMode</code> method.
// |result| : The result code returned from the underlying network call.
// A negative value indicates an error.
callback SetMulticastLoopbackModeCallback = void (long result);
// Callback from the <code>getJoinedGroupsCallback</code> method.
// |groups| : Array of groups the socket joined.
callback GetJoinedGroupsCallback = void (DOMString[] groups);
// Callback from the <code>setBroadcast</code> method.
// |result| : The result code returned from the underlying network call.
callback SetBroadcastCallback = void (long result);
// Data from an <code>onReceive</code> event.
dictionary ReceiveInfo {
// The socket ID.
long socketId;
// The UDP packet content (truncated to the current buffer size).
ArrayBuffer data;
// The address of the host the packet comes from.
DOMString remoteAddress;
// The port of the host the packet comes from.
long remotePort;
};
// Data from an <code>onReceiveError</code> event.
dictionary ReceiveErrorInfo {
// The socket ID.
long socketId;
// The result code returned from the underlying recvfrom() call.
long resultCode;
};
interface Functions {
// Creates a UDP socket with the given properties.
// |properties| : The socket properties (optional).
// |callback| : Called when the socket has been created.
static void create(optional SocketProperties properties,
CreateCallback callback);
// Updates the socket properties.
// |socketId| : The socket ID.
// |properties| : The properties to update.
// |callback| : Called when the properties are updated.
static void update(long socketId,
SocketProperties properties,
optional UpdateCallback callback);
// Pauses or unpauses a socket. A paused socket is blocked from firing
// <code>onReceive</code> events.
// |connectionId| : The socket ID.
// |paused| : Flag to indicate whether to pause or unpause.
// |callback| : Called when the socket has been successfully paused or
// unpaused.
static void setPaused(long socketId,
boolean paused,
optional SetPausedCallback callback);
// Binds the local address and port for the socket. For a client socket, it
// is recommended to use port 0 to let the platform pick a free port.
//
// Once the <code>bind</code> operation completes successfully,
// <code>onReceive</code> events are raised when UDP packets arrive on the
// address/port specified -- unless the socket is paused.
//
// |socketId| : The socket ID.
// |address| : The address of the local machine. DNS name, IPv4 and IPv6
// formats are supported. Use "0.0.0.0" to accept packets from all local
// available network interfaces.
// |port| : The port of the local machine. Use "0" to bind to a free port.
// |callback| : Called when the <code>bind</code> operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void bind(long socketId,
DOMString address,
long port,
BindCallback callback);
// Sends data on the given socket to the given address and port. The socket
// must be bound to a local port before calling this method.
// |socketId| : The socket ID.
// |data| : The data to send.
// |address| : The address of the remote machine.
// |port| : The port of the remote machine.
// |dnsQueryType| : The address resolution preference.
// |callback| : Called when the <code>send</code> operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void send(long socketId,
ArrayBuffer data,
DOMString address,
long port,
optional DnsQueryType dnsQueryType,
SendCallback callback);
// Closes the socket and releases the address/port the socket is bound to.
// Each socket created should be closed after use. The socket id is no
// longer valid as soon at the function is called. However, the socket is
// guaranteed to be closed only when the callback is invoked.
// |socketId| : The socket ID.
// |callback| : Called when the <code>close</code> operation completes.
static void close(long socketId,
optional CloseCallback callback);
// Retrieves the state of the given socket.
// |socketId| : The socket ID.
// |callback| : Called when the socket state is available.
static void getInfo(long socketId,
GetInfoCallback callback);
// Retrieves the list of currently opened sockets owned by the application.
// |callback| : Called when the list of sockets is available.
static void getSockets(GetSocketsCallback callback);
// Joins the multicast group and starts to receive packets from that group.
// The socket must be bound to a local port before calling this method.
// |socketId| : The socket ID.
// |address| : The group address to join. Domain names are not supported.
// |callback| : Called when the <code>joinGroup</code> operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void joinGroup(long socketId,
DOMString address,
JoinGroupCallback callback);
// Leaves the multicast group previously joined using
// <code>joinGroup</code>. This is only necessary to call if you plan to
// keep using the socketafterwards, since it will be done automatically by
// the OS when the socket is closed.
//
// Leaving the group will prevent the router from sending multicast
// datagrams to the local host, presuming no other process on the host is
// still joined to the group.
//
// |socketId| : The socket ID.
// |address| : The group address to leave. Domain names are not supported.
// |callback| : Called when the <code>leaveGroup</code> operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void leaveGroup(long socketId,
DOMString address,
LeaveGroupCallback callback);
// Sets the time-to-live of multicast packets sent to the multicast group.
//
// Calling this method does not require multicast permissions.
//
// |socketId| : The socket ID.
// |ttl| : The time-to-live value.
// |callback| : Called when the configuration operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setMulticastTimeToLive(
long socketId,
long ttl,
SetMulticastTimeToLiveCallback callback);
// Sets whether multicast packets sent from the host to the multicast group
// will be looped back to the host.
//
// Note: the behavior of <code>setMulticastLoopbackMode</code> is slightly
// different between Windows and Unix-like systems. The inconsistency
// happens only when there is more than one application on the same host
// joined to the same multicast group while having different settings on
// multicast loopback mode. On Windows, the applications with loopback off
// will not RECEIVE the loopback packets; while on Unix-like systems, the
// applications with loopback off will not SEND the loopback packets to
// other applications on the same host. See MSDN: http://goo.gl/6vqbj
//
// Calling this method does not require multicast permissions.
//
// |socketId| : The socket ID.
// |enabled| : Indicate whether to enable loopback mode.
// |callback| : Called when the configuration operation completes.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setMulticastLoopbackMode(
long socketId,
boolean enabled,
SetMulticastLoopbackModeCallback callback);
// Gets the multicast group addresses the socket is currently joined to.
// |socketId| : The socket ID.
// |callback| : Called with an array of strings of the result.
static void getJoinedGroups(long socketId,
GetJoinedGroupsCallback callback);
// Enables or disables broadcast packets on this socket.
//
// |socketId| : The socket ID.
// |enabled| : <code>true</code> to enable broadcast packets,
// <code>false</code> to disable them.
[doesNotSupportPromises=
"Sets error along with callback arguments crbug.com/1504372"]
static void setBroadcast(long socketId,
boolean enabled,
SetBroadcastCallback callback);
};
interface Events {
// Event raised when a UDP packet has been received for the given socket.
// |info| : The event data.
static void onReceive(ReceiveInfo info);
// Event raised when a network error occured while the runtime was waiting
// for data on the socket address and port. Once this event is raised, the
// socket is paused and no more <code>onReceive</code> events will be raised
// for this socket until the socket is resumed.
// |info| : The event data.
static void onReceiveError(ReceiveErrorInfo info);
};
};
@@ -0,0 +1,61 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>system.cpu</code> API to query CPU metadata.
namespace system.cpu {
// Counters for assessing CPU utilization. Each field is monotonically
// increasing while the processor is powered on. Values are in milliseconds.
dictionary CpuTime {
// The cumulative time used by userspace programs on this processor.
double user;
// The cumulative time used by kernel programs on this processor.
double kernel;
// The cumulative time spent idle by this processor.
double idle;
// The total cumulative time for this processor. This value is equal to
// user + kernel + idle.
double total;
};
dictionary ProcessorInfo {
// Cumulative usage info for this logical processor.
CpuTime usage;
};
dictionary CpuInfo {
// The number of logical processors.
long numOfProcessors;
// The architecture name of the processors.
DOMString archName;
// The model name of the processors.
DOMString modelName;
// A set of feature codes indicating some of the processor's capabilities.
// The currently supported codes are "mmx", "sse", "sse2", "sse3", "ssse3",
// "sse4_1", "sse4_2", and "avx".
DOMString[] features;
// Information about each logical processor.
ProcessorInfo[] processors;
// List of CPU temperature readings from each thermal zone of the CPU.
// Temperatures are in degrees Celsius.
//
// <b>Currently supported on Chrome OS only.</b>
double[] temperatures;
};
callback CpuInfoCallback = void (CpuInfo info);
interface Functions {
// Queries basic CPU information of the system.
[supportsPromises] static void getInfo(CpuInfoCallback callback);
};
};
@@ -0,0 +1,456 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>system.display</code> API to query display metadata.
namespace system.display {
dictionary Bounds {
// The x-coordinate of the upper-left corner.
long left;
// The y-coordinate of the upper-left corner.
long top;
// The width of the display in pixels.
long width;
// The height of the display in pixels.
long height;
};
dictionary Insets {
// The x-axis distance from the left bound.
long left;
// The y-axis distance from the top bound.
long top;
// The x-axis distance from the right bound.
long right;
// The y-axis distance from the bottom bound.
long bottom;
};
dictionary Point {
// The x-coordinate of the point.
long x;
// The y-coordinate of the point.
long y;
};
dictionary TouchCalibrationPair {
// The coordinates of the display point.
Point displayPoint;
// The coordinates of the touch point corresponding to the display point.
Point touchPoint;
};
dictionary TouchCalibrationPairQuad {
// First pair of touch and display point required for touch calibration.
TouchCalibrationPair pair1;
// Second pair of touch and display point required for touch calibration.
TouchCalibrationPair pair2;
// Third pair of touch and display point required for touch calibration.
TouchCalibrationPair pair3;
// Fourth pair of touch and display point required for touch calibration.
TouchCalibrationPair pair4;
};
dictionary DisplayMode {
// The display mode width in device independent (user visible) pixels.
long width;
// The display mode height in device independent (user visible) pixels.
long height;
// The display mode width in native pixels.
long widthInNativePixels;
// The display mode height in native pixels.
long heightInNativePixels;
// The display mode UI scale factor.
[deprecated="Use $(ref: displayZoomFactor)"] double? uiScale;
// The display mode device scale factor.
double deviceScaleFactor;
// The display mode refresh rate in hertz.
double refreshRate;
// True if the mode is the display's native mode.
boolean isNative;
// True if the display mode is currently selected.
boolean isSelected;
// True if this mode is interlaced, false if not provided.
boolean? isInterlaced;
};
// Layout position, i.e. edge of parent that the display is attached to.
enum LayoutPosition { top, right, bottom, left };
dictionary DisplayLayout {
// The unique identifier of the display.
DOMString id;
// The unique identifier of the parent display. Empty if this is the root.
DOMString parentId;
// The layout position of this display relative to the parent. This will
// be ignored for the root.
LayoutPosition position;
// The offset of the display along the connected edge. 0 indicates that
// the topmost or leftmost corners are aligned.
long offset;
};
// EDID extracted parameters. Field description refers to "VESA ENHANCED
// EXTENDED DISPLAY IDENTIFICATION DATA STANDARD (Defines EDID Structure
// Version 1, Revision 4)" Release A, Revision 2 September 25, 2006.
// https://www.vesa.org/vesa-standards
dictionary Edid {
// 3 character manufacturer code. See Sec. 3.4.1 page 21. Required in v1.4.
DOMString manufacturerId;
// 2 byte manufacturer-assigned code, Sec. 3.4.2 page 21. Required in v1.4.
DOMString productId;
// Year of manufacturer, Sec. 3.4.4 page 22. Required in v1.4.
long yearOfManufacture;
};
// An enum to tell if the display is detected and used by the
// system. The display is considered 'inactive', if it is not
// detected by the system (maybe disconnected, or considered
// disconnected due to sleep mode, etc). This state is used to keep
// existing display when the all displays are disconnected, for
// example.
enum ActiveState { active, inactive };
dictionary DisplayUnitInfo {
// The unique identifier of the display.
DOMString id;
// The user-friendly name (e.g. "HP LCD monitor").
DOMString name;
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
Edid? edid;
// Chrome OS only. Identifier of the display that is being mirrored if
// mirroring is enabled, otherwise empty. This will be set for all displays
// (including the display being mirrored).
DOMString mirroringSourceId;
// Chrome OS only. Identifiers of the displays to which the source display
// is being mirrored. Empty if no displays are being mirrored. This will be
// set to the same value for all displays. This must not include
// |mirroringSourceId|.
DOMString[] mirroringDestinationIds;
// True if this is the primary display.
boolean isPrimary;
// True if this is an internal display.
boolean isInternal;
// True if this display is enabled.
boolean isEnabled;
// Active if the display is detected and used by the system.
ActiveState activeState;
// True for all displays when in unified desktop mode. See documentation
// for $(ref:enableUnifiedDesktop).
boolean isUnified;
// True when the auto-rotation is allowed. It happens when the device is in
// a tablet physical state or kSupportsClamshellAutoRotation is set.
// Provided for ChromeOS Settings UI only. TODO(stevenjb): Remove when
// Settings switches to a mojo API.
[nodoc] boolean? isAutoRotationAllowed;
// The number of pixels per inch along the x-axis.
double dpiX;
// The number of pixels per inch along the y-axis.
double dpiY;
// The display's clockwise rotation in degrees relative to the vertical
// position.
// Currently exposed only on ChromeOS. Will be set to 0 on other platforms.
// A value of -1 will be interpreted as auto-rotate when the device is in
// a physical tablet state.
long rotation;
// The display's logical bounds.
Bounds bounds;
// The display's insets within its screen's bounds.
// Currently exposed only on ChromeOS. Will be set to empty insets on
// other platforms.
Insets overscan;
// The usable work area of the display within the display bounds. The work
// area excludes areas of the display reserved for OS, for example taskbar
// and launcher.
Bounds workArea;
// The list of available display modes. The current mode will have
// isSelected=true. Only available on Chrome OS. Will be set to an empty
// array on other platforms.
DisplayMode[] modes;
// True if this display has a touch input device associated with it.
boolean hasTouchSupport;
// True if this display has an accelerometer associated with it.
// Provided for ChromeOS Settings UI only. TODO(stevenjb): Remove when
// Settings switches to a mojo API. NOTE: The name of this may change.
[nodoc] boolean hasAccelerometerSupport;
// A list of zoom factor values that can be set for the display.
double[] availableDisplayZoomFactors;
// The ratio between the display's current and default zoom.
// For example, value 1 is equivalent to 100% zoom, and value 1.5 is
// equivalent to 150% zoom.
double displayZoomFactor;
};
dictionary DisplayProperties {
// Chrome OS only. If set to true, changes the display mode to unified
// desktop (see $(ref:enableUnifiedDesktop) for details). If set to false,
// unified desktop mode will be disabled. This is only valid for the
// primary display. If provided, mirroringSourceId must not be provided and
// other properties will be ignored. This is has no effect if not provided.
boolean? isUnified;
// Chrome OS only. If set and not empty, enables mirroring for this display
// only. Otherwise disables mirroring for all displays. This value should
// indicate the id of the source display to mirror, which must not be the
// same as the id passed to setDisplayProperties. If set, no other property
// may be set.
[deprecated="Use $(ref:setMirrorMode)."] DOMString? mirroringSourceId;
// If set to true, makes the display primary. No-op if set to false.
// Note: If set, the display is considered primary for all other properties
// (i.e. $(ref:isUnified) may be set and bounds origin may not).
boolean? isPrimary;
// If set, sets the display's overscan insets to the provided values. Note
// that overscan values may not be negative or larger than a half of the
// screen's size. Overscan cannot be changed on the internal monitor.
Insets? overscan;
// If set, updates the display's rotation.
// Legal values are [0, 90, 180, 270]. The rotation is set clockwise,
// relative to the display's vertical position.
long? rotation;
// If set, updates the display's logical bounds origin along the x-axis.
// Applied together with $(ref:boundsOriginY). Defaults to the current value
// if not set and $(ref:boundsOriginY) is set. Note that when updating the
// display origin, some constraints will be applied, so the final bounds
// origin may be different than the one set. The final bounds can be
// retrieved using $(ref:getInfo). The bounds origin cannot be changed on
// the primary display.
long? boundsOriginX;
// If set, updates the display's logical bounds origin along the y-axis.
// See documentation for $(ref:boundsOriginX) parameter.
long? boundsOriginY;
// If set, updates the display mode to the mode matching this value.
// If other parameters are invalid, this will not be applied. If the
// display mode is invalid, it will not be applied and an error will be
// set, but other properties will still be applied.
DisplayMode? displayMode;
// If set, updates the zoom associated with the display. This zoom performs
// re-layout and repaint thus resulting in a better quality zoom than just
// performing a pixel by pixel stretch enlargement.
double? displayZoomFactor;
};
dictionary GetInfoFlags {
// If set to true, only a single $(ref:DisplayUnitInfo) will be returned
// by $(ref:getInfo) when in unified desktop mode (see
// $(ref:enableUnifiedDesktop)). Defaults to false.
boolean? singleUnified;
};
// Mirror mode, i.e. different ways of how a display is mirrored to other
// displays.
enum MirrorMode {
// Specifies the default mode (extended or unified desktop).
off,
// Specifies that the default source display will be mirrored to all other
// displays.
normal,
// Specifies that the specified source display will be mirrored to the
// provided destination displays. All other connected displays will be
// extended.
mixed
};
dictionary MirrorModeInfo {
// The mirror mode that should be set.
MirrorMode mode;
// The id of the mirroring source display. This is only valid for 'mixed'.
DOMString? mirroringSourceId;
// The ids of the mirroring destination displays. This is only valid for
// 'mixed'.
DOMString[]? mirroringDestinationIds;
};
callback DisplayInfoCallback = void (DisplayUnitInfo[] displayInfo);
callback DisplayLayoutCallback = void (DisplayLayout[] layouts);
callback SetDisplayUnitInfoCallback = void();
callback SetDisplayLayoutCallback = void();
callback NativeTouchCalibrationCallback = void(boolean success);
callback SetMirrorModeCallback = void();
interface Functions {
// Requests the information for all attached display devices.
// |flags|: Options affecting how the information is returned.
// |callback|: The callback to invoke with the results.
[supportsPromises] static void getInfo(optional GetInfoFlags flags,
DisplayInfoCallback callback);
// Requests the layout info for all displays.
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |callback|: The callback to invoke with the results.
[supportsPromises] static void getDisplayLayout(
DisplayLayoutCallback callback);
// Updates the properties for the display specified by |id|, according to
// the information provided in |info|. On failure, $(ref:runtime.lastError)
// will be set.
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |id|: The display's unique identifier.
// |info|: The information about display properties that should be changed.
// A property will be changed only if a new value for it is specified in
// |info|.
// |callback|: Empty function called when the function finishes. To find out
// whether the function succeeded, $(ref:runtime.lastError) should be
// queried.
[supportsPromises] static void setDisplayProperties(
DOMString id,
DisplayProperties info,
optional SetDisplayUnitInfoCallback callback);
// Set the layout for all displays. Any display not included will use the
// default layout. If a layout would overlap or be otherwise invalid it
// will be adjusted to a valid layout. After layout is resolved, an
// onDisplayChanged event will be triggered.
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |layouts|: The layout information, required for all displays except
// the primary display.
// |callback|: Empty function called when the function finishes. To find out
// whether the function succeeded, $(ref:runtime.lastError) should be
// queried.
[supportsPromises] static void setDisplayLayout(
DisplayLayout[] layouts,
optional SetDisplayLayoutCallback callback);
// Enables/disables the unified desktop feature. If enabled while mirroring
// is active, the desktop mode will not change until mirroring is turned
// off. Otherwise, the desktop mode will switch to unified immediately.
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |enabled|: True if unified desktop should be enabled.
static void enableUnifiedDesktop(boolean enabled);
// Starts overscan calibration for a display. This will show an overlay
// on the screen indicating the current overscan insets. If overscan
// calibration for display |id| is in progress this will reset calibration.
// |id|: The display's unique identifier.
static void overscanCalibrationStart(DOMString id);
// Adjusts the current overscan insets for a display. Typically this should
// either move the display along an axis (e.g. left+right have the same
// value) or scale it along an axis (e.g. top+bottom have opposite values).
// Each Adjust call is cumulative with previous calls since Start.
// |id|: The display's unique identifier.
// |delta|: The amount to change the overscan insets.
static void overscanCalibrationAdjust(DOMString id, Insets delta);
// Resets the overscan insets for a display to the last saved value (i.e
// before Start was called).
// |id|: The display's unique identifier.
static void overscanCalibrationReset(DOMString id);
// Complete overscan adjustments for a display by saving the current values
// and hiding the overlay.
// |id|: The display's unique identifier.
static void overscanCalibrationComplete(DOMString id);
// Displays the native touch calibration UX for the display with |id| as
// display id. This will show an overlay on the screen with required
// instructions on how to proceed. The callback will be invoked in case of
// successful calibration only. If the calibration fails, this will throw an
// error.
// |id|: The display's unique identifier.
// |callback|: Optional callback to inform the caller that the touch
// calibration has ended. The argument of the callback informs if the
// calibration was a success or not.
[supportsPromises] static void showNativeTouchCalibration(
DOMString id,
optional NativeTouchCalibrationCallback callback);
// Starts custom touch calibration for a display. This should be called when
// using a custom UX for collecting calibration data. If another touch
// calibration is already in progress this will throw an error.
// |id|: The display's unique identifier.
static void startCustomTouchCalibration(DOMString id);
// Sets the touch calibration pairs for a display. These |pairs| would be
// used to calibrate the touch screen for display with |id| called in
// startCustomTouchCalibration(). Always call |startCustomTouchCalibration|
// before calling this method. If another touch calibration is already in
// progress this will throw an error.
// |pairs|: The pairs of point used to calibrate the display.
// |bounds|: Bounds of the display when the touch calibration was performed.
// |bounds.left| and |bounds.top| values are ignored.
static void completeCustomTouchCalibration(TouchCalibrationPairQuad pairs,
Bounds bounds);
// Resets the touch calibration for the display and brings it back to its
// default state by clearing any touch calibration data associated with the
// display.
// |id|: The display's unique identifier.
static void clearTouchCalibration(DOMString id);
// Sets the display mode to the specified mirror mode. Each call resets the
// state from previous calls. Calling setDisplayProperties() will fail for
// the mirroring destination displays.
// NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
// |info|: The information of the mirror mode that should be applied to the
// display mode.
// |callback|: Empty function called when the function finishes. To find out
// whether the function succeeded, $(ref:runtime.lastError) should be
// queried.
[supportsPromises] static void setMirrorMode(
MirrorModeInfo info,
optional SetMirrorModeCallback callback);
};
interface Events {
// Fired when anything changes to the display configuration.
static void onDisplayChanged();
};
};
@@ -0,0 +1,21 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.system.memory</code> API.
namespace system.memory {
dictionary MemoryInfo {
// The total amount of physical memory capacity, in bytes.
double capacity;
// The amount of available capacity, in bytes.
double availableCapacity;
};
callback MemoryInfoCallback = void (MemoryInfo info);
interface Functions {
// Get physical memory information.
[supportsPromises] static void getInfo(MemoryInfoCallback callback);
};
};
@@ -0,0 +1,31 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.system.network</code> API.
namespace system.network {
dictionary NetworkInterface {
// The underlying name of the adapter. On *nix, this will typically be
// "eth0", "wlan0", etc.
DOMString name;
// The available IPv4/6 address.
DOMString address;
// The prefix length
long prefixLength;
};
// Callback from the <code>getNetworkInterfaces</code> method.
// |networkInterfaces| : Array of object containing network interfaces
// information.
callback GetNetworkInterfacesCallback =
void (NetworkInterface[] networkInterfaces);
interface Functions {
// Retrieves information about local adapters on this system.
// |callback| : Called when local adapter information is available.
[supportsPromises] static void getNetworkInterfaces(
GetNetworkInterfacesCallback callback);
};
};
@@ -0,0 +1,85 @@
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.system.storage</code> API to query storage device
// information and be notified when a removable storage device is attached and
// detached.
namespace system.storage {
enum StorageUnitType {
// The storage has fixed media, e.g. hard disk or SSD.
fixed,
// The storage is removable, e.g. USB flash drive.
removable,
// The storage type is unknown.
unknown
};
dictionary StorageUnitInfo {
// The transient ID that uniquely identifies the storage device.
// This ID will be persistent within the same run of a single application.
// It will not be a persistent identifier between different runs of an
// application, or between different applications.
DOMString id;
// The name of the storage unit.
DOMString name;
// The media type of the storage unit.
StorageUnitType type;
// The total amount of the storage space, in bytes.
double capacity;
};
dictionary StorageAvailableCapacityInfo {
// A copied |id| of getAvailableCapacity function parameter |id|.
DOMString id;
// The available capacity of the storage device, in bytes.
double availableCapacity;
};
[inline_doc] enum EjectDeviceResultCode {
// The ejection command is successful -- the application can prompt the user
// to remove the device.
success,
// The device is in use by another application. The ejection did not
// succeed; the user should not remove the device until the other
// application is done with the device.
in_use,
// There is no such device known.
no_such_device,
// The ejection command failed.
failure
};
callback EjectDeviceCallback = void (EjectDeviceResultCode result);
callback StorageInfoCallback = void (StorageUnitInfo[] info);
callback GetAvailableCapacityCallback = void (
StorageAvailableCapacityInfo info);
interface Functions {
// Get the storage information from the system. The argument passed to the
// callback is an array of StorageUnitInfo objects.
[supportsPromises] static void getInfo(StorageInfoCallback callback);
// Ejects a removable storage device.
[supportsPromises] static void ejectDevice(DOMString id,
EjectDeviceCallback callback);
// Get the available capacity of a specified |id| storage device.
// The |id| is the transient device ID from StorageUnitInfo.
[supportsPromises] static void getAvailableCapacity(
DOMString id,
GetAvailableCapacityCallback callback);
};
interface Events {
// Fired when a new removable storage is attached to the system.
static void onAttached(StorageUnitInfo info);
// Fired when a removable storage is detached from the system.
static void onDetached(DOMString id);
};
};
+417
View File
@@ -0,0 +1,417 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>chrome.usb</code> API to interact with connected USB
// devices. This API provides access to USB operations from within the context
// of an app. Using this API, apps can function as drivers for hardware devices.
//
// Errors generated by this API are reported by setting
// $(ref:runtime.lastError) and executing the function's regular callback. The
// callback's regular parameters will be undefined in this case.
namespace usb {
// Direction, Recipient, RequestType, and TransferType all map to their
// namesakes within the USB specification.
enum Direction {in, out};
enum Recipient {device, _interface, endpoint, other};
enum RequestType {standard, class, vendor, reserved};
enum TransferType {control, interrupt, isochronous, bulk};
// For interrupt and isochronous modes, SynchronizationType and UsageType map
// to their namesakes within the USB specification.
enum SynchronizationType {asynchronous, adaptive, synchronous};
enum UsageType {data, feedback, explicitFeedback, periodic, notification};
dictionary Device {
// An opaque ID for the USB device. It remains unchanged until the device is
// unplugged.
long device;
// The device vendor ID.
long vendorId;
// The product ID.
long productId;
// The device version (bcdDevice field).
long version;
// The iProduct string read from the device, if available.
DOMString productName;
// The iManufacturer string read from the device, if available.
DOMString manufacturerName;
// The iSerialNumber string read from the device, if available.
DOMString serialNumber;
};
dictionary ConnectionHandle {
// An opaque handle representing this connection to the USB device and all
// associated claimed interfaces and pending transfers. A new handle is
// created each time the device is opened. The connection handle is
// different from $(ref:Device.device).
long handle;
// The device vendor ID.
long vendorId;
// The product ID.
long productId;
};
[noinline_doc] dictionary EndpointDescriptor {
// Endpoint address.
long address;
// Transfer type.
TransferType type;
// Transfer direction.
Direction direction;
// Maximum packet size.
long maximumPacketSize;
// Transfer synchronization mode (isochronous only).
SynchronizationType? synchronization;
// Endpoint usage hint.
UsageType? usage;
// Polling interval (interrupt and isochronous only).
long? pollingInterval;
// Extra descriptor data associated with this endpoint.
ArrayBuffer extra_data;
};
[noinline_doc] dictionary InterfaceDescriptor {
// The interface number.
long interfaceNumber;
// The interface alternate setting number (defaults to <code>0</code).
long alternateSetting;
// The USB interface class.
long interfaceClass;
// The USB interface sub-class.
long interfaceSubclass;
// The USB interface protocol.
long interfaceProtocol;
// Description of the interface.
DOMString? description;
// Available endpoints.
EndpointDescriptor[] endpoints;
// Extra descriptor data associated with this interface.
ArrayBuffer extra_data;
};
[noinline_doc] dictionary ConfigDescriptor {
// Is this the active configuration?
boolean active;
// The configuration number.
long configurationValue;
// Description of the configuration.
DOMString? description;
// The device is self-powered.
boolean selfPowered;
// The device supports remote wakeup.
boolean remoteWakeup;
// The maximum power needed by this device in milliamps (mA).
long maxPower;
// Available interfaces.
InterfaceDescriptor[] interfaces;
// Extra descriptor data associated with this configuration.
ArrayBuffer extra_data;
};
dictionary ControlTransferInfo {
// The transfer direction (<code>"in"</code> or <code>"out"</code>).
Direction direction;
// The transfer target. The target given by <code>index</code> must be
// claimed if <code>"interface"</code> or <code>"endpoint"</code>.
Recipient recipient;
// The request type.
RequestType requestType;
// The <code>bRequest</code> field, see <i>Universal Serial Bus
// Specification Revision 1.1</i> &sect; 9.3.
long request;
// The <code>wValue</code> field, see <i>Ibid</i>.
long value;
// The <code>wIndex</code> field, see <i>Ibid</i>.
long index;
// The maximum number of bytes to receive (required only by input
// transfers).
long? length;
// The data to transmit (required only by output transfers).
ArrayBuffer? data;
// Request timeout (in milliseconds). The default value <code>0</code>
// indicates no timeout.
long? timeout;
};
dictionary GenericTransferInfo {
// The transfer direction (<code>"in"</code> or <code>"out"</code>).
Direction direction;
// The target endpoint address. The interface containing this endpoint must
// be claimed.
long endpoint;
// The maximum number of bytes to receive (required only by input
// transfers).
long? length;
// The data to transmit (required only by output transfers).
ArrayBuffer? data;
// Request timeout (in milliseconds). The default value <code>0</code>
// indicates no timeout.
long? timeout;
};
dictionary IsochronousTransferInfo {
// Transfer parameters. The transfer length or data buffer specified in this
// parameter block is split along <code>packetLength</code> boundaries to
// form the individual packets of the transfer.
GenericTransferInfo transferInfo;
// The total number of packets in this transfer.
long packets;
// The length of each of the packets in this transfer.
long packetLength;
};
dictionary TransferResultInfo {
// A value of <code>0</code> indicates that the transfer was a success.
// Other values indicate failure.
long? resultCode;
// The data returned by an input transfer. <code>undefined</code> for output
// transfers.
ArrayBuffer? data;
};
[noinline_doc] dictionary DeviceFilter {
// Device vendor ID.
long? vendorId;
// Device product ID, checked only if the vendor ID matches.
long? productId;
// USB interface class, matches any interface on the device.
long? interfaceClass;
// USB interface sub-class, checked only if the interface class matches.
long? interfaceSubclass;
// USB interface protocol, checked only if the interface sub-class matches.
long? interfaceProtocol;
};
dictionary EnumerateDevicesOptions {
[deprecated="Equivalent to setting $(ref:DeviceFilter.vendorId)."]
long? vendorId;
[deprecated="Equivalent to setting $(ref:DeviceFilter.productId)."]
long? productId;
// A device matching any given filter will be returned. An empty filter list
// will return all devices the app has permission for.
DeviceFilter[]? filters;
};
dictionary EnumerateDevicesAndRequestAccessOptions {
// The device vendor ID.
long vendorId;
// The product ID.
long productId;
// The interface ID to request access to.
// Only available on Chrome OS. It has no effect on other platforms.
long? interfaceId;
};
dictionary DevicePromptOptions {
// Allow the user to select multiple devices.
boolean? multiple;
// Filter the list of devices presented to the user. If multiple filters are
// provided devices matching any filter will be displayed.
DeviceFilter[]? filters;
};
callback VoidCallback = void ();
callback GetDevicesCallback = void (Device[] devices);
callback GetConfigurationsCallback = void (ConfigDescriptor[] configs);
callback RequestAccessCallback = void (boolean success);
callback OpenDeviceCallback = void (ConnectionHandle handle);
callback FindDevicesCallback = void (ConnectionHandle[] handles);
callback GetConfigurationCallback = void (ConfigDescriptor config);
callback ListInterfacesCallback = void (InterfaceDescriptor[] descriptors);
callback CloseDeviceCallback = void ();
callback TransferCallback = void (TransferResultInfo info);
callback ResetDeviceCallback = void(boolean success);
interface Functions {
// Enumerates connected USB devices.
// |options|: The properties to search for on target devices.
[supportsPromises] static void getDevices(EnumerateDevicesOptions options,
GetDevicesCallback callback);
// Presents a device picker to the user and returns the $(ref:Device)s
// selected.
// If the user cancels the picker devices will be empty. A user gesture
// is required for the dialog to display. Without a user gesture, the
// callback will run as though the user cancelled.
// |options|: Configuration of the device picker dialog box.
// |callback|: Invoked with a list of chosen $(ref:Device)s.
[supportsPromises] static void getUserSelectedDevices(
DevicePromptOptions options,
GetDevicesCallback callback);
// Returns the full set of device configuration descriptors.
// |device|: The $(ref:Device) to fetch descriptors from.
[supportsPromises] static void getConfigurations(
Device device,
GetConfigurationsCallback callback);
// Requests access from the permission broker to a device claimed by
// Chrome OS if the given interface on the device is not claimed.
//
// |device|: The $(ref:Device) to request access to.
// |interfaceId|: The particular interface requested.
[deprecated="This function was Chrome OS specific and calling it on other
platforms would fail. This operation is now implicitly performed as part of
$(ref:openDevice) and this function will return <code>true</code> on all
platforms.", supportsPromises]
static void requestAccess(Device device,
long interfaceId,
RequestAccessCallback callback);
// Opens a USB device returned by $(ref:getDevices).
// |device|: The $(ref:Device) to open.
[supportsPromises] static void openDevice(Device device,
OpenDeviceCallback callback);
// Finds USB devices specified by the vendor, product and (optionally)
// interface IDs and if permissions allow opens them for use.
//
// If the access request is rejected or the device fails to be opened a
// connection handle will not be created or returned.
//
// Calling this method is equivalent to calling $(ref:getDevices) followed
// by $(ref:openDevice) for each device.
//
// |options|: The properties to search for on target devices.
[supportsPromises] static void findDevices(
EnumerateDevicesAndRequestAccessOptions options,
FindDevicesCallback callback);
// Closes a connection handle. Invoking operations on a handle after it
// has been closed is a safe operation but causes no action to be taken.
// |handle|: The $(ref:ConnectionHandle) to close.
[supportsPromises] static void closeDevice(
ConnectionHandle handle,
optional CloseDeviceCallback callback);
// Select a device configuration.
//
// This function effectively resets the device by selecting one of the
// device's available configurations. Only configuration values greater
// than <code>0</code> are valid however some buggy devices have a working
// configuration <code>0</code> and so this value is allowed.
// |handle|: An open connection to the device.
[supportsPromises] static void setConfiguration(ConnectionHandle handle,
long configurationValue,
VoidCallback callback);
// Gets the configuration descriptor for the currently selected
// configuration.
// |handle|: An open connection to the device.
[supportsPromises] static void getConfiguration(
ConnectionHandle handle,
GetConfigurationCallback callback);
// Lists all interfaces on a USB device.
// |handle|: An open connection to the device.
[supportsPromises] static void listInterfaces(
ConnectionHandle handle,
ListInterfacesCallback callback);
// Claims an interface on a USB device.
// Before data can be transfered to an interface or associated endpoints the
// interface must be claimed. Only one connection handle can claim an
// interface at any given time. If the interface is already claimed, this
// call will fail.
//
// $(ref:releaseInterface) should be called when the interface is no longer
// needed.
//
// |handle|: An open connection to the device.
// |interfaceNumber|: The interface to be claimed.
[supportsPromises] static void claimInterface(ConnectionHandle handle,
long interfaceNumber,
VoidCallback callback);
// Releases a claimed interface.
// |handle|: An open connection to the device.
// |interfaceNumber|: The interface to be released.
[supportsPromises] static void releaseInterface(ConnectionHandle handle,
long interfaceNumber,
VoidCallback callback);
// Selects an alternate setting on a previously claimed interface.
// |handle|: An open connection to the device where this interface has been
// claimed.
// |interfaceNumber|: The interface to configure.
// |alternateSetting|: The alternate setting to configure.
[supportsPromises] static void setInterfaceAlternateSetting(
ConnectionHandle handle,
long interfaceNumber,
long alternateSetting,
VoidCallback callback);
// Performs a control transfer on the specified device.
//
// Control transfers refer to either the device, an interface or an
// endpoint. Transfers to an interface or endpoint require the interface to
// be claimed.
//
// |handle|: An open connection to the device.
[supportsPromises] static void controlTransfer(
ConnectionHandle handle,
ControlTransferInfo transferInfo,
TransferCallback callback);
// Performs a bulk transfer on the specified device.
// |handle|: An open connection to the device.
// |transferInfo|: The transfer parameters.
[supportsPromises] static void bulkTransfer(
ConnectionHandle handle,
GenericTransferInfo transferInfo,
TransferCallback callback);
// Performs an interrupt transfer on the specified device.
// |handle|: An open connection to the device.
// |transferInfo|: The transfer parameters.
[supportsPromises] static void interruptTransfer(
ConnectionHandle handle,
GenericTransferInfo transferInfo,
TransferCallback callback);
// Performs an isochronous transfer on the specific device.
// |handle|: An open connection to the device.
[supportsPromises] static void isochronousTransfer(
ConnectionHandle handle,
IsochronousTransferInfo transferInfo,
TransferCallback callback);
// Tries to reset the USB device.
// If the reset fails, the given connection handle will be closed and the
// USB device will appear to be disconnected then reconnected.
// In this case $(ref:getDevices) or $(ref:findDevices) must be called again
// to acquire the device.
//
// |handle|: A connection handle to reset.
[supportsPromises] static void resetDevice(ConnectionHandle handle,
ResetDeviceCallback callback);
};
interface Events {
// Event generated when a device is added to the system. Events are only
// broadcast to apps and extensions that have permission to access the
// device. Permission may have been granted at install time, when the user
// accepted an optional permission (see $(ref:permissions.request)), or
// through $(ref:getUserSelectedDevices).
static void onDeviceAdded(Device device);
// Event generated when a device is removed from the system. See
// $(ref:onDeviceAdded) for which events are delivered.
static void onDeviceRemoved(Device device);
};
};
@@ -0,0 +1,144 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Use the <code>userScripts</code> API to execute user scripts in the User
// Scripts context.
namespace userScripts {
// The JavaScript world for a user script to execute within.
enum ExecutionWorld {
// Specifies the execution environment of the DOM, which is the execution
// environment shared with the host page's JavaScript.
MAIN,
// Specifies the execution enviroment that is specific to user scripts and
// is exempt from the page's CSP.
USER_SCRIPT
};
// The source of the script to inject.
dictionary ScriptSource {
// A string containing the JavaScript code to inject. Exactly one of
// <code>file</code> or <code>code</code> must be specified.
DOMString? code;
// The path of the JavaScript file to inject relative to the extension's
// root directory. Exactly one of <code>file</code> or <code>code</code>
// must be specified.
DOMString? file;
};
// Describes a user script to be injected into a web page registered through
// this API. The script is injected into a page if its URL matches any of
// "matches" or "include_globs" patterns, and the URL doesn't match
// "exclude_matches" and "exclude_globs" patterns.
dictionary RegisteredUserScript {
// If true, it will inject into all frames, even if the frame is not the
// top-most frame in the tab. Each frame is checked independently for URL
// requirements; it will not inject into child frames if the URL
// requirements are not met. Defaults to false, meaning that only the top
// frame is matched.
boolean? allFrames;
// Excludes pages that this user script would otherwise be injected into.
// See <a href="develop/concepts/match-patterns">Match Patterns</a> for more details on
// the syntax of these strings.
DOMString[]? excludeMatches;
// The ID of the user script specified in the API call. This property must
// not start with a '_' as it's reserved as a prefix for generated script
// IDs.
DOMString id;
// Specifies wildcard patterns for pages this user script will be injected
// into.
DOMString[]? includeGlobs;
// Specifies wildcard patterns for pages this user script will NOT be
// injected into.
DOMString[]? excludeGlobs;
// The list of ScriptSource objects defining sources of scripts to be
// injected into matching pages.
ScriptSource[] js;
// Specifies which pages this user script will be injected into. See
// <a href="develop/concepts/match-patterns">Match Patterns</a> for more details on the
// syntax of these strings. This property must be specified for
// ${ref:register}.
DOMString[]? matches;
// Specifies when JavaScript files are injected into the web page. The
// preferred and default value is <code>document_idle</code>.
extensionTypes.RunAt? runAt;
// The JavaScript execution environment to run the script in. The default is
// <code>`USER_SCRIPT`</code>.
ExecutionWorld? world;
};
// An object used to filter user scripts for ${ref:getScripts}.
dictionary UserScriptFilter {
// $(ref:getScripts) only returns scripts with the IDs specified in this
// list.
DOMString[]? ids;
};
// An object used to update the <code>`USER_SCRIPT`</code> world
// configuration. If a propertie is not specified, it will reset it to its
// default value.
dictionary WorldProperties{
// Specifies the world csp. The default is the <code>`ISOLATED`</code>
// world csp.
DOMString? csp;
// Specifies whether messaging APIs are exposed. The default is
// <code>false</code>.
boolean? messaging;
};
callback RegisterCallback = void();
callback GetScriptsCallback = void(RegisteredUserScript[] scripts);
callback UnregisterCallback = void();
callback UpdateCallback = void();
callback ConfigureWorldCallback = void();
interface Functions {
// Registers one or more user scripts for this extension.
// |scripts|: Contains a list of user scripts to be registered.
// |callback|: Called once scripts have been fully registered or if an error
// has ocurred.
[supportsPromises] static void register(RegisteredUserScript[] scripts,
optional RegisterCallback callback);
// Returns all dynamically-registered user scripts for this extension.
// |filter|: If specified, this method returns only the user scripts that
// match it.
// |callback|: Called once scripts have been fully registered or if an error
// occurs.
[supportsPromises] static void getScripts(
optional UserScriptFilter filter,
GetScriptsCallback callback);
// Unregisters all dynamically-registered user scripts for this extension.
// |filter|: If specified, this method unregisters only the user scripts
// that match it.
// |callback|: Called once scripts have been fully unregistered or if an
// error ocurs
[supportsPromises] static void unregister(
optional UserScriptFilter filter,
UnregisterCallback callback);
// Updates one or more user scripts for this extension.
// |scripts|: Contains a list of user scripts to be updated. A property is
// only updated for the existing script if it is specified in this object.
// If there are errors during script parsing/file validation, or if the IDs
// specified do not correspond to a fully registered script, then no scripts
// are updated.
// |callback|: Called once scripts have been fully updated or if an error
// occurs.
[supportsPromises] static void update(
RegisteredUserScript[] scripts,
optional UpdateCallback callback);
// Configures the <code>`USER_SCRIPT`</code> execution environment.
// |properties|: Contains the user script world configuration.
// |callback|: Called once world hase been configured.
[supportsPromises] static void configureWorld(
WorldProperties properties,
optional ConfigureWorldCallback callback);
};
};
@@ -0,0 +1,39 @@
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// The <code>chrome.virtualKeyboard</code> API is a kiosk only API used to
// configure virtual keyboard layout and behavior in kiosk sessions.
[platforms=("chromeos", "lacros")]
namespace virtualKeyboard {
// <p>Determines whether advanced virtual keyboard features should be enabled
// or not. They are enabled by default.</p>
// <p>On <b>Chrome 58</b> all properties are expected to have the same value.
// </p>
// <p>From <b>Chrome 63</b> the properties can be distinct and are optional.
// If omitted, the current value is preserved.</p>
dictionary FeatureRestrictions {
// Whether virtual keyboards can provide auto-complete.
boolean? autoCompleteEnabled;
// Whether virtual keyboards can provide auto-correct.
boolean? autoCorrectEnabled;
// Whether virtual keyboards can provide input via handwriting recognition.
boolean? handwritingEnabled;
// Whether virtual keyboards can provide spell-check.
boolean? spellCheckEnabled;
// Whether virtual keyboards can provide voice input.
boolean? voiceInputEnabled;
};
callback RestrictFeaturesCallback = void(FeatureRestrictions update);
interface Functions {
// Sets restrictions on features provided by the virtual keyboard.
// |restrictions|: the preferences to enabled/disabled virtual keyboard
// features.
// |callback|: Invoked with the values which were updated.
[supportsPromises] void restrictFeatures(
FeatureRestrictions restrictions,
optional RestrictFeaturesCallback callback);
};
};
@@ -0,0 +1,33 @@
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for the "web_accessible_resources" manifest key.
[generate_error_messages] namespace webAccessibleResources {
dictionary WebAccessibleResource {
// Relative paths within the extension package representing web accessible
// resources.
DOMString[] resources;
// List of <a
// href="https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns">
// match patterns</a> to which "resources" are accessible. These patterns should
// have an effective path of "*". Each match will be checked against the
// initiating origin.
DOMString[]? matches;
// List of extension IDs the "resources" are accessible to. A wildcard can
// be used, denoted by "*".
DOMString[]? extension_ids;
// If true, the web accessible resources will only be accessible through a
// dynamic ID. This is an identifier that uniquely identifies the extension
// and is generated each session. The corresponding dynamic extension URL
// is available through $(ref:runtime.getURL).
boolean? use_dynamic_url;
};
dictionary ManifestKeys {
WebAccessibleResource[] web_accessible_resources;
};
};
@@ -0,0 +1,12 @@
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Stub namespace for the "web_accessible_resources" manifest key.
[generate_error_messages] namespace webAccessibleResourcesMv2 {
dictionary ManifestKeys {
// Relative paths within the extension package representing web accessible
// resources.
DOMString[] web_accessible_resources;
};
};
@@ -0,0 +1,99 @@
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Webcam Private API.
namespace webcamPrivate {
enum PanDirection { stop, right, left };
enum TiltDirection { stop, up, down };
enum Protocol { visca };
enum AutofocusState { on, off };
dictionary ProtocolConfiguration {
Protocol? protocol;
};
dictionary WebcamConfiguration {
double? pan;
double? panSpeed;
PanDirection? panDirection;
double? tilt;
double? tiltSpeed;
TiltDirection? tiltDirection;
double? zoom;
AutofocusState? autofocusState;
double? focus;
};
dictionary Range { double min; double max; };
dictionary WebcamCurrentConfiguration {
double pan;
double tilt;
double zoom;
double focus;
// Supported range of pan, tilt and zoom values.
Range? panRange;
Range? tiltRange;
Range? zoomRange;
Range? focusRange;
};
callback WebcamIdCallback = void(DOMString webcamId);
callback WebcamConfigurationCallback =
void(WebcamCurrentConfiguration configuration);
interface Functions {
// Open a serial port that controls a webcam.
[supportsPromises] static void openSerialWebcam(
DOMString path,
ProtocolConfiguration protocol,
WebcamIdCallback callback);
// Close a serial port connection to a webcam.
static void closeWebcam(DOMString webcamId);
// Retrieve webcam parameters. Will respond with a config holding the
// requested values that are available, or default values for those that
// aren't. If none of the requests succeed, will respond with an error.
[supportsPromises] static void get(
DOMString webcamId,
WebcamConfigurationCallback callback);
// A callback is included here which is invoked when the function responds.
// No configuration is returned through it.
[supportsPromises] static void set(DOMString webcamId,
WebcamConfiguration config,
WebcamConfigurationCallback callback);
// Reset a webcam. Note: the value of the parameter have no effect, it's the
// presence of the parameter that matters. E.g.: reset(webcamId, {pan: 0,
// tilt: 1}); will reset pan & tilt, but not zoom.
// A callback is included here which is invoked when the function responds.
// No configuration is returned through it.
[supportsPromises] static void reset(DOMString webcamId,
WebcamConfiguration config,
WebcamConfigurationCallback callback);
// Set home preset for a webcam. A callback is included here which is
// invoked when the function responds.
[supportsPromises] static void setHome(
DOMString webcamId,
WebcamConfigurationCallback callback);
// Restore the camera's position to that of the specified preset. A callback
// is included here which is invoked when the function responds.
[supportsPromises] static void restoreCameraPreset(
DOMString webcamId,
double presetNumber,
WebcamConfigurationCallback callback);
// Set the current camera's position to be stored for the specified preset.
// A callback is included here which is invoked when the function responds.
[supportsPromises] static void setCameraPreset(
DOMString webcamId,
double presetNumber,
WebcamConfigurationCallback callback);
};
};