Give names to all utility processes.
[chromium-blink-merge.git] / chrome / renderer / resources / extensions / tab_capture_custom_bindings.js
blob93a60549e3743d366c47fabe14f7d8c63bff316d
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 // Custom binding for the Tab Capture API.
7 var binding = require('binding').Binding.create('tabCapture');
9 binding.registerCustomHook(function(bindingsAPI, extensionId) {
10 var apiFunctions = bindingsAPI.apiFunctions;
12 apiFunctions.setCustomCallback('capture',
13 function(name, request, callback, response) {
14 if (!callback)
15 return;
17 if (response) {
18 var options = {};
19 if (response.audioConstraints)
20 options.audio = response.audioConstraints;
21 if (response.videoConstraints)
22 options.video = response.videoConstraints;
24 try {
25 navigator.webkitGetUserMedia(options,
26 function(stream) { callback(stream); },
27 function() { callback(null); });
28 } catch (e) {
29 callback(null);
31 } else {
32 callback(null);
34 });
35 });
37 exports.binding = binding.generate();