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

Unified 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 side-by-side diff with in-line comments
Download patch
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..13e81670a05ec1f7e25ee0a7618bb06b95069f41
--- /dev/null
+++ b/extensions/renderer/resources/display_source_custom_bindings.js
@@ -0,0 +1,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());
« 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