Chromium Code Reviews| Index: extensions/renderer/resources/display_source_custom_bindings.js |
| diff --git a/extensions/renderer/resources/display_source_custom_bindings.js b/extensions/renderer/resources/display_source_custom_bindings.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6258b938a7e418c9b93bfcbd060a98529c30654f |
| --- /dev/null |
| +++ b/extensions/renderer/resources/display_source_custom_bindings.js |
| @@ -0,0 +1,39 @@ |
| +// 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); |
|
asargent_no_longer_on_chrome
2015/12/07 21:47:49
Looks like you're missing a matching call to lastE
Mikhail
2015/12/08 07:44:44
Done.
|
| + } finally { |
| + if (callback !== undefined) |
| + callback(); |
| + } |
| + }); |
| + apiFunctions.setHandleRequest('terminateSession', |
| + function(sink_id, callback) { |
| + try { |
| + natives.TerminateSession(sink_id); |
| + } catch (e) { |
| + lastError.set( |
|
asargent_no_longer_on_chrome
2015/12/07 21:47:49
same thing here
Mikhail
2015/12/08 07:44:44
Done.
|
| + 'displaySource.terminateSession', e.message, null, chrome); |
| + } finally { |
| + if (callback !== undefined) |
| + callback(); |
| + } |
| + }); |
| +}); |
| + |
| +exports.$set('binding', binding.generate()); |