Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / renderer / resources / extensions / file_browser_handler_custom_bindings.js
blobb19c29a56ca0ba43b58779eb0d1ef46063f871e5
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
3 // found in the LICENSE file.
5 // Custom binding for the fileBrowserHandler API.
7 var binding = require('binding').Binding.create('fileBrowserHandler');
9 var eventBindings = require('event_bindings');
10 var fileBrowserNatives = requireNative('file_browser_handler');
11 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry;
12 var fileBrowserHandlerInternal = require('binding').Binding.create(
13 'fileBrowserHandlerInternal').generate();
15 eventBindings.registerArgumentMassager('fileBrowserHandler.onExecute',
16 function(args, dispatch) {
17 if (args.length < 2) {
18 dispatch(args);
19 return;
21 var fileList = args[1].entries;
22 if (!fileList) {
23 dispatch(args);
24 return;
26 // The second parameter for this event's payload is file definition
27 // dictionary that we used to reconstruct File API's Entry instance
28 // here.
29 for (var i = 0; i < fileList.length; i++)
30 fileList[i] = GetExternalFileEntry(fileList[i]);
31 dispatch(args);
32 });
34 binding.registerCustomHook(function(bindingsAPI) {
35 var apiFunctions = bindingsAPI.apiFunctions;
37 apiFunctions.setHandleRequest('selectFile',
38 function(selectionParams, callback) {
39 function internalCallback(externalCallback, internalResult) {
40 if (!externalCallback)
41 return;
42 var result = undefined;
43 if (internalResult) {
44 result = { success: internalResult.success, entry: null };
45 if (internalResult.success)
46 result.entry = GetExternalFileEntry(internalResult.entry);
49 externalCallback(result);
52 return fileBrowserHandlerInternal.selectFile(
53 selectionParams, $Function.bind(internalCallback, null, callback));
54 });
55 });
57 exports.binding = binding.generate();