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

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

Issue 11571014: Lazy load chrome.* APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments/TODOs Created 7 years, 11 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 | Annotate | Revision Log
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 bindings for the Tab Capture API. 5 // Custom bindings for the Tab Capture API.
6 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
7 6
8 chromeHidden.registerCustomHook('tabCapture', 7 var bindings = new (require('schema_binding_generator').Bindings)('tabCapture');
9 function(bindingsAPI, extensionId) { 8
9 bindings.registerCustomHook(function(bindingsAPI, extensionId) {
10 var apiFunctions = bindingsAPI.apiFunctions; 10 var apiFunctions = bindingsAPI.apiFunctions;
11 11
12 apiFunctions.setCustomCallback('capture', 12 apiFunctions.setCustomCallback('capture',
13 function(name, request, response) { 13 function(name, request, response) {
14 if (response && request.callback) { 14 if (response && request.callback) {
15 var callback = request.callback; 15 var callback = request.callback;
16 var successFunc = function(stream) { 16 var successFunc = function(stream) {
17 callback(stream); 17 callback(stream);
18 }; 18 };
19 var errorFunc = function() { 19 var errorFunc = function() {
20 callback(null); 20 callback(null);
21 }; 21 };
22 22
23 var options = {}; 23 var options = {};
24 if (response.audioConstraints) 24 if (response.audioConstraints)
25 options.audio = response.audioConstraints; 25 options.audio = response.audioConstraints;
26 if (response.videoConstraints) 26 if (response.videoConstraints)
27 options.video = response.videoConstraints; 27 options.video = response.videoConstraints;
28 28
29 navigator.webkitGetUserMedia(options, successFunc, errorFunc); 29 navigator.webkitGetUserMedia(options, successFunc, errorFunc);
30 } else { 30 } else {
31 request.callback(); 31 request.callback();
32 } 32 }
33 request.callback = null; 33 request.callback = null;
34 }); 34 });
35 }); 35 });
36
37 exports.bindings = bindings.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698