blob: 13e81670a05ec1f7e25ee0a7618bb06b95069f41 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Custom binding for the Display Source API.
var binding = require('binding').Binding.create('displaySource');
var chrome = requireNative('chrome').GetChrome();
var lastError = require('lastError');
var natives = requireNative('display_source');
binding.registerCustomHook(function(bindingsAPI, extensionId) {
var apiFunctions = bindingsAPI.apiFunctions;
apiFunctions.setHandleRequest('startSession',
function(sessionInfo, callback) {
try {
natives.StartSession(sessionInfo);
} catch (e) {
lastError.set('displaySource.startSession', e.message, null, chrome);
} finally {
if (callback !== undefined)
callback();
lastError.clear(chrome);
}
});
apiFunctions.setHandleRequest('terminateSession',
function(sink_id, callback) {
try {
natives.TerminateSession(sink_id);
} catch (e) {
lastError.set(
'displaySource.terminateSession', e.message, null, chrome);
} finally {
if (callback !== undefined)
callback();
lastError.clear(chrome);
}
});
});
exports.$set('binding', binding.generate());
|