Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Side by Side Diff: extensions/renderer/resources/display_source_custom_bindings.js

Issue 1471243002: chrome.displaySource custom bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 // Custom binding for the Display Source API.
6
7 var binding = require('binding').Binding.create('displaySource');
8 var chrome = requireNative('chrome').GetChrome();
9 var lastError = require('lastError');
10 var natives = requireNative('display_source');
11
12 binding.registerCustomHook(function(bindingsAPI, extensionId) {
13 var apiFunctions = bindingsAPI.apiFunctions;
14 apiFunctions.setHandleRequest('startSession',
15 function(sessionInfo, callback) {
16 try {
17 natives.StartSession(sessionInfo);
18 } catch (e) {
19 lastError.set('displaySource.startSession', e.message, null, chrome);
20 } finally {
21 if (callback !== undefined)
22 callback();
23 lastError.clear(chrome);
24 }
25 });
26 apiFunctions.setHandleRequest('terminateSession',
27 function(sink_id, callback) {
28 try {
29 natives.TerminateSession(sink_id);
30 } catch (e) {
31 lastError.set(
32 'displaySource.terminateSession', e.message, null, chrome);
33 } finally {
34 if (callback !== undefined)
35 callback();
36 lastError.clear(chrome);
37 }
38 });
39 });
40
41 exports.$set('binding', binding.generate());
OLDNEW
« no previous file with comments | « extensions/renderer/display_source_custom_bindings.cc ('k') | extensions/renderer/resources/extensions_renderer_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698