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

Side by Side Diff: chrome/renderer/resources/extensions/tab_capture_custom_bindings.js

Issue 1221483002: New tabCapture.captureOffscreenTab API, initially for Presentation API 1UA mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mostly revert to Patch Set 6, plus minor tweaks. [and REBASE] Created 5 years, 2 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Custom binding for the Tab Capture API. 5 // Custom binding for the Tab Capture API.
6 6
7 var binding = require('binding').Binding.create('tabCapture'); 7 var binding = require('binding').Binding.create('tabCapture');
8 8
9 binding.registerCustomHook(function(bindingsAPI, extensionId) { 9 binding.registerCustomHook(function(bindingsAPI, extensionId) {
10 var apiFunctions = bindingsAPI.apiFunctions; 10 var apiFunctions = bindingsAPI.apiFunctions;
11 11
12 apiFunctions.setCustomCallback('capture', 12 function proxyToGetUserMedia(name, request, callback, response) {
13 function(name, request, callback, response) {
14 if (!callback) 13 if (!callback)
15 return; 14 return;
16 15
16 // TODO(miu): Propagate exceptions and always provide a useful error when
17 // callback() is invoked with a null argument. http://crbug.com/463679
17 if (response) { 18 if (response) {
18 var options = {}; 19 var options = {};
19 if (response.audioConstraints) 20 if (response.audioConstraints)
20 options.audio = response.audioConstraints; 21 options.audio = response.audioConstraints;
21 if (response.videoConstraints) 22 if (response.videoConstraints)
22 options.video = response.videoConstraints; 23 options.video = response.videoConstraints;
23 24
24 try { 25 try {
25 navigator.webkitGetUserMedia(options, 26 navigator.webkitGetUserMedia(options,
26 function(stream) { callback(stream); }, 27 function(stream) { callback(stream); },
27 function() { callback(null); }); 28 function(exception) { callback(null); });
28 } catch (e) { 29 } catch (e) {
29 callback(null); 30 callback(null);
30 } 31 }
31 } else { 32 } else {
32 callback(null); 33 callback(null);
33 } 34 }
34 }); 35 }
36
37 apiFunctions.setCustomCallback('capture', proxyToGetUserMedia);
38 apiFunctions.setCustomCallback('captureOffscreenTab', proxyToGetUserMedia);
35 }); 39 });
36 40
37 exports.binding = binding.generate(); 41 exports.binding = binding.generate();
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/tab_capture.idl ('k') | chrome/test/data/extensions/api_test/tab_capture/api_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698