OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Use the <code>chrome.tabCapture</code> API to interact with tab media | 5 // Use the <code>chrome.tabCapture</code> API to interact with tab media |
6 // streams. | 6 // streams. |
7 namespace tabCapture { | 7 namespace tabCapture { |
8 | 8 |
9 enum TabCaptureState { | 9 enum TabCaptureState { |
10 pending, | 10 pending, |
(...skipping 21 matching lines...) Expand all Loading... |
32 object? _optional; | 32 object? _optional; |
33 }; | 33 }; |
34 | 34 |
35 // Whether we are requesting tab video and/or audio and the | 35 // Whether we are requesting tab video and/or audio and the |
36 // MediaTrackConstraints that should be set for these streams. | 36 // MediaTrackConstraints that should be set for these streams. |
37 dictionary CaptureOptions { | 37 dictionary CaptureOptions { |
38 boolean? audio; | 38 boolean? audio; |
39 boolean? video; | 39 boolean? video; |
40 MediaStreamConstraint? audioConstraints; | 40 MediaStreamConstraint? audioConstraints; |
41 MediaStreamConstraint? videoConstraints; | 41 MediaStreamConstraint? videoConstraints; |
| 42 [nodoc] DOMString? presentationId; |
42 }; | 43 }; |
43 | 44 |
44 callback GetTabMediaCallback = | 45 callback GetTabMediaCallback = |
45 void ([instanceOf=LocalMediaStream] object stream); | 46 void ([instanceOf=LocalMediaStream] object stream); |
46 | 47 |
47 callback GetCapturedTabsCallback = void (CaptureInfo[] result); | 48 callback GetCapturedTabsCallback = void (CaptureInfo[] result); |
48 | 49 |
49 interface Functions { | 50 interface Functions { |
50 // Captures the visible area of the currently active tab. Capture can | 51 // 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 // 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 // <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 // the tab, and stops when the tab is closed, or the media stream is closed |
54 // by the extension. | 55 // by the extension. |
55 // | 56 // |
56 // |options| : Configures the returned media stream. | 57 // |options| : Configures the returned media stream. |
57 // |callback| : Callback with either the tab capture stream or | 58 // |callback| : Callback with either the tab capture stream or |
58 // <code>null</code>. | 59 // <code>null</code>. |
59 static void capture(CaptureOptions options, | 60 static void capture(CaptureOptions options, |
60 GetTabMediaCallback callback); | 61 GetTabMediaCallback callback); |
61 | 62 |
62 // Returns a list of tabs that have requested capture or are being | 63 // Returns a list of tabs that have requested capture or are being |
63 // captured, i.e. status != stopped and status != error. | 64 // captured, i.e. status != stopped and status != error. |
64 // This allows extensions to inform the user that there is an existing | 65 // 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 // tab capture that would prevent a new tab capture from succeeding (or |
66 // to prevent redundant requests for the same tab). | 67 // to prevent redundant requests for the same tab). |
67 // |callback| : Callback invoked with CaptureInfo[] for captured tabs. | 68 // |callback| : Callback invoked with CaptureInfo[] for captured tabs. |
68 static void getCapturedTabs(GetCapturedTabsCallback callback); | 69 static void getCapturedTabs(GetCapturedTabsCallback callback); |
| 70 |
| 71 // Creates an off-screen tab and navigates it to the given |startUrl|. |
| 72 // Then, capture is started and a MediaStream is returned via |callback|. |
| 73 // |
| 74 // Off-screen tabs are isolated from the user's normal browser experience. |
| 75 // They do not show up in the browser window or tab strip, nor are they |
| 76 // visible to extensions (e.g., via the chrome.tabs.* APIs). |
| 77 // |
| 78 // An off-screen tab remains alive until one of three events occurs: 1. All |
| 79 // MediaStreams providing its captured content are closed; 2. the page |
| 80 // self-closes (e.g., via window.close()); 3. the extension that called |
| 81 // captureOffscreenTab() is unloaded. |
| 82 // |
| 83 // Sandboxing: The off-screen tab does not have any access whatsoever to the |
| 84 // local user profile (including cookies, HTTP auth, etc.). Instead, it is |
| 85 // provided its own sandboxed profile. Also, it cannot access any |
| 86 // interactive resources such as keyboard/mouse input, media recording |
| 87 // devices (e.g., web cams), copy/paste to/from the system clipboard, etc. |
| 88 // |
| 89 // Note: This is a new API, currently only available in Canary/Dev channel, |
| 90 // and may change without notice. |
| 91 // |
| 92 // |options| : Constraints for the capture and returned MediaStream. |
| 93 // |callback| : <code>null</code> on error. |
| 94 static void captureOffscreenTab(DOMString startUrl, |
| 95 CaptureOptions options, |
| 96 GetTabMediaCallback callback); |
69 }; | 97 }; |
70 | 98 |
71 interface Events { | 99 interface Events { |
72 // Event fired when the capture status of a tab changes. | 100 // Event fired when the capture status of a tab changes. |
73 // This allows extension authors to keep track of the capture status of | 101 // This allows extension authors to keep track of the capture status of |
74 // tabs to keep UI elements like page actions in sync. | 102 // tabs to keep UI elements like page actions in sync. |
75 // |info| : CaptureInfo with new capture status for the tab. | 103 // |info| : CaptureInfo with new capture status for the tab. |
76 static void onStatusChanged(CaptureInfo info); | 104 static void onStatusChanged(CaptureInfo info); |
77 }; | 105 }; |
78 | 106 |
79 }; | 107 }; |
OLD | NEW |