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 if (0 !== tabCaptureNatives.RequestDeviceMedia( |
| 25 response.deviceId, response.options, successFunc, errorFunc)) |
| 26 errorFunc(); |
| 27 } |
| 28 request.callback = null; |
| 29 }); |
| 30 }); |
OLD | NEW |