1 // Copyright 2015 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 webrtcDesktopCapturePrivate API.
7 var binding = require('binding').Binding.create('webrtcDesktopCapturePrivate');
8 var sendRequest = require('sendRequest').sendRequest;
9 var idGenerator = requireNative('id_generator');
11 binding.registerCustomHook(function(bindingsAPI) {
12 var apiFunctions = bindingsAPI.apiFunctions;
14 var pendingRequests = {};
16 function onRequestResult(id, result) {
17 if (id in pendingRequests) {
18 var callback = pendingRequests[id];
19 delete pendingRequests[id];
24 apiFunctions.setHandleRequest('chooseDesktopMedia',
25 function(sources, request, callback) {
26 var id = idGenerator.GetNextId();
27 pendingRequests[id] = callback;
28 sendRequest(this.name,
29 [id, sources, request, onRequestResult.bind(null, id)],
30 this.definition.parameters, {});
34 apiFunctions.setHandleRequest('cancelChooseDesktopMedia', function(id) {
35 if (id in pendingRequests) {
36 delete pendingRequests[id];
37 sendRequest(this.name, [id], this.definition.parameters, {});
42 exports.binding = binding.generate();