diff options
author | mikhail.pozdnyakov <mikhail.pozdnyakov@intel.com> | 2015-12-09 04:09:40 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 12:10:32 +0000 |
commit | 79486f1c04861a577489fa63b1f82342aaee095b (patch) | |
tree | 824933762da51d3ad91d77ec8639d6c96b299bf5 /extensions/renderer/resources | |
parent | aae35e589d9df6d5111cf658e69a82faa1ebed3e (diff) | |
download | chromium_src-79486f1c04861a577489fa63b1f82342aaee095b.zip chromium_src-79486f1c04861a577489fa63b1f82342aaee095b.tar.gz chromium_src-79486f1c04861a577489fa63b1f82342aaee095b.tar.bz2 |
chrome.displaySource custom bindings
This patch introduces custom bindings for 'chrome.displaySource' API.
These are bindings for 'startSession', 'terminateSession' methods
and for the 'onSessionStarted', 'onSessionTerminated',
'onSessionErrorOccured' events.
The bindings should belong to render process (i.e. be custom) as:
1) they accept dom objects arguments (MediaStreamTrack)
2) for security reasons: to keep all protocols handling within sandbox
The abstract 'DisplaySourceSession' class is added to be implemented
by the 'chrome.displaySource' API backends.
BUG=242107
Review URL: https://codereview.chromium.org/1471243002
Cr-Commit-Position: refs/heads/master@{#364045}
Diffstat (limited to 'extensions/renderer/resources')
-rw-r--r-- | extensions/renderer/resources/display_source_custom_bindings.js | 41 | ||||
-rw-r--r-- | extensions/renderer/resources/extensions_renderer_resources.grd | 1 |
2 files changed, 42 insertions, 0 deletions
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 0000000..13e8167 --- /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()); diff --git a/extensions/renderer/resources/extensions_renderer_resources.grd b/extensions/renderer/resources/extensions_renderer_resources.grd index 8a08705..bad8e29 100644 --- a/extensions/renderer/resources/extensions_renderer_resources.grd +++ b/extensions/renderer/resources/extensions_renderer_resources.grd @@ -72,6 +72,7 @@ <include name="IDR_CONTEXT_MENUS_CUSTOM_BINDINGS_JS" file="context_menus_custom_bindings.js" type="BINDATA" /> <include name="IDR_CONTEXT_MENUS_HANDLERS_JS" file="context_menus_handlers.js" type="BINDATA" /> <include name="IDR_DECLARATIVE_WEBREQUEST_CUSTOM_BINDINGS_JS" file="declarative_webrequest_custom_bindings.js" type="BINDATA" /> + <include name="IDR_DISPLAY_SOURCE_CUSTOM_BINDINGS_JS" file="display_source_custom_bindings.js" type="BINDATA" /> <include name="IDR_EXTENSION_CUSTOM_BINDINGS_JS" file="extension_custom_bindings.js" type="BINDATA" /> <include name="IDR_GREASEMONKEY_API_JS" file="greasemonkey_api.js" type="BINDATA" /> <include name="IDR_I18N_CUSTOM_BINDINGS_JS" file="i18n_custom_bindings.js" type="BINDATA" /> |