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

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

Issue 12313142: Revert 184837 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 binding for the fileBrowserHandler API. 5 // Custom bindings for the fileBrowserHandler API.
6
7 var binding = require('binding').Binding.create('fileBrowserHandler');
8 6
9 var fileBrowserNatives = requireNative('file_browser_handler'); 7 var fileBrowserNatives = requireNative('file_browser_handler');
10 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry; 8 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry;
11 9
12 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); 10 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden();
13 var fileBrowserHandlerInternal = require('binding').Binding.create(
14 'fileBrowserHandlerInternal').generate();
15 11
16 chromeHidden.Event.registerArgumentMassager('fileBrowserHandler.onExecute', 12 chromeHidden.Event.registerArgumentMassager('fileBrowserHandler.onExecute',
17 function(args, dispatch) { 13 function(args, dispatch) {
18 if (args.length < 2) { 14 if (args.length < 2) {
19 dispatch(args); 15 dispatch(args);
20 return; 16 return;
21 } 17 }
22 var fileList = args[1].entries; 18 var fileList = args[1].entries;
23 if (!fileList) { 19 if (!fileList) {
24 dispatch(args); 20 dispatch(args);
25 return; 21 return;
26 } 22 }
27 // The second parameter for this event's payload is file definition 23 // The second parameter for this event's payload is file definition
28 // dictionary that we used to reconstruct File API's Entry instance 24 // dictionary that we used to reconstruct File API's Entry instance
29 // here. 25 // here.
30 for (var i = 0; i < fileList.length; i++) 26 for (var i = 0; i < fileList.length; i++)
31 fileList[i] = GetExternalFileEntry(fileList[i]); 27 fileList[i] = GetExternalFileEntry(fileList[i]);
32 dispatch(args); 28 dispatch(args);
33 }); 29 });
34 30
35 binding.registerCustomHook(function(bindingsAPI) { 31 chromeHidden.registerCustomHook('fileBrowserHandler', function(bindingsAPI) {
36 var apiFunctions = bindingsAPI.apiFunctions; 32 var apiFunctions = bindingsAPI.apiFunctions;
37 33
38 apiFunctions.setHandleRequest('selectFile', 34 apiFunctions.setHandleRequest('selectFile',
39 function(selectionParams, callback) { 35 function(selectionParams, callback) {
40 function internalCallback(externalCallback, internalResult) { 36 function internalCallback(externalCallback, internalResult) {
41 if (!externalCallback) 37 if (!externalCallback)
42 return; 38 return;
43 var result = undefined; 39 var result = undefined;
44 if (internalResult) { 40 if (internalResult) {
45 result = { success: internalResult.success, entry: null }; 41 result = { success: internalResult.success, entry: null };
46 if (internalResult.success) 42 if (internalResult.success)
47 result.entry = GetExternalFileEntry(internalResult.entry); 43 result.entry = GetExternalFileEntry(internalResult.entry);
48 } 44 }
49 45
50 externalCallback(result); 46 externalCallback(result);
51 } 47 }
52 48
53 return fileBrowserHandlerInternal.selectFile( 49 return chromeHidden.internalAPIs.fileBrowserHandlerInternal.selectFile(
54 selectionParams, internalCallback.bind(null, callback)); 50 selectionParams, internalCallback.bind(null, callback));
55 }); 51 });
56 }); 52 });
57
58 exports.binding = binding.generate();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698