Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / common / extensions / api / tab_capture.idl
blobc6489d6f6980c167c3b898864692979588bec2d5
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Use the <code>chrome.tabCapture</code> API to interact with tab media
6 // streams.
7 namespace tabCapture {
9 enum TabCaptureState {
10 pending,
11 active,
12 stopped,
13 error
16 dictionary CaptureInfo {
17 // The id of the tab whose status changed.
18 long tabId;
20 // The new capture status of the tab.
21 TabCaptureState status;
23 // Whether an element in the tab being captured is in fullscreen mode.
24 boolean fullscreen;
27 // MediaTrackConstraints for the media streams that will be passed to WebRTC.
28 // See section on MediaTrackConstraints:
29 // http://dev.w3.org/2011/webrtc/editor/getusermedia.html
30 dictionary MediaStreamConstraint {
31 object mandatory;
32 object? _optional;
35 // Whether we are requesting tab video and/or audio and the
36 // MediaTrackConstraints that should be set for these streams.
37 dictionary CaptureOptions {
38 boolean? audio;
39 boolean? video;
40 MediaStreamConstraint? audioConstraints;
41 MediaStreamConstraint? videoConstraints;
44 callback GetTabMediaCallback =
45 void ([instanceOf=LocalMediaStream] object stream);
47 callback GetCapturedTabsCallback = void (CaptureInfo[] result);
49 interface Functions {
50 // Captures the visible area of the currently active tab. Capture can
51 // only be started on the currently active tab after the extension has been
52 // <em>invoked</em>. Capture is maintained across page navigations within
53 // the tab, and stops when the tab is closed, or the media stream is closed
54 // by the extension.
56 // |options| : Configures the returned media stream.
57 // |callback| : Callback with either the tab capture stream or
58 // <code>null</code>.
59 static void capture(CaptureOptions options,
60 GetTabMediaCallback callback);
62 // Returns a list of tabs that have requested capture or are being
63 // captured, i.e. status != stopped and status != error.
64 // This allows extensions to inform the user that there is an existing
65 // tab capture that would prevent a new tab capture from succeeding (or
66 // to prevent redundant requests for the same tab).
67 // |callback| : Callback invoked with CaptureInfo[] for captured tabs.
68 static void getCapturedTabs(GetCapturedTabsCallback callback);
71 interface Events {
72 // Event fired when the capture status of a tab changes.
73 // This allows extension authors to keep track of the capture status of
74 // tabs to keep UI elements like page actions in sync.
75 // |info| : CaptureInfo with new capture status for the tab.
76 static void onStatusChanged(CaptureInfo info);