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

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

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

Powered by Google App Engine
This is Rietveld 408576698