OLD | NEW |
---|---|
(Empty) | |
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. | |
4 | |
5 // Custom bindings for the Tab Capture API. | |
6 | |
7 var tabCaptureNatives = requireNative('experimental_tabCapture'); | |
8 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | |
9 | |
10 chromeHidden.registerCustomHook('experimental.tabCapture', | |
11 function(bindingsAPI, extensionId) { | |
12 var apiFunctions = bindingsAPI.apiFunctions; | |
13 | |
14 apiFunctions.setCustomCallback('getTabMedia', | |
15 function(name, request, response) { | |
16 if (response && request.callback) { | |
17 var callback = request.callback; | |
18 var successFunc = function(stream) { | |
19 callback(stream); | |
20 }; | |
21 var errorFunc = function() { | |
22 callback(null); | |
23 }; | |
24 var videoConstraints = false; | |
25 var audioConstraints = false; | |
26 | |
27 // TODO(justinlin): Merge with other constraints when they land. | |
28 if (response.options.video) { | |
29 videoConstraints = { | |
30 mandatory: { | |
31 chromeMediaSource: 'tab', | |
32 chromeMediaSourceId: response.deviceId | |
33 } | |
34 }; | |
35 } | |
36 | |
37 if (response.options.audio) { | |
38 audioConstraints = { | |
39 mandatory: { | |
40 chromeMediaSource: 'tab', | |
41 chromeMediaSourceId: response.deviceId | |
42 } | |
43 }; | |
44 } | |
45 | |
46 var options = {}; | |
47 options.video = videoConstraints; | |
48 options.audio = audioConstraints; | |
49 | |
50 navigator.webkitGetUserMedia(options, successFunc, errorFunc); | |
Aaron Boodman
2012/10/04 07:21:43
What prevents bad extensions from just calling thi
justinlin
2012/10/08 09:58:31
Do you mean what prevents any normal page calling
| |
51 } | |
52 request.callback = null; | |
53 }); | |
54 }); | |
OLD | NEW |