OLD | NEW |
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 fileBrowserPrivate API. | 5 // Custom binding for the fileBrowserPrivate API. |
6 | 6 |
7 var binding = require('binding').Binding.create('fileBrowserPrivate'); | 7 var binding = require('binding').Binding.create('fileBrowserPrivate'); |
8 | 8 |
9 var fileBrowserPrivateNatives = requireNative('file_browser_private'); | 9 var fileBrowserPrivateNatives = requireNative('file_browser_private'); |
10 var GetFileSystem = fileBrowserPrivateNatives.GetFileSystem; | 10 var GetFileSystem = fileBrowserPrivateNatives.GetFileSystem; |
11 | 11 |
12 var fileBrowserNatives = requireNative('file_browser_handler'); | 12 var fileBrowserNatives = requireNative('file_browser_handler'); |
13 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry; | 13 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry; |
14 | 14 |
15 binding.registerCustomHook(function(bindingsAPI) { | 15 binding.registerCustomHook(function(bindingsAPI) { |
16 var apiFunctions = bindingsAPI.apiFunctions; | 16 var apiFunctions = bindingsAPI.apiFunctions; |
17 | 17 |
18 apiFunctions.setCustomCallback('requestFileSystem', | 18 apiFunctions.setCustomCallback('requestFileSystem', |
19 function(name, request, response) { | 19 function(name, request, response) { |
20 var fs = null; | 20 var fs = null; |
21 if (response && !response.error) | 21 if (response && !response.error) |
22 fs = GetFileSystem(response.name, response.path); | 22 fs = GetFileSystem(response.name, response.root_url); |
23 if (request.callback) | 23 if (request.callback) |
24 request.callback(fs); | 24 request.callback(fs); |
25 request.callback = null; | 25 request.callback = null; |
26 }); | 26 }); |
27 | 27 |
28 apiFunctions.setCustomCallback('searchDrive', | 28 apiFunctions.setCustomCallback('searchDrive', |
29 function(name, request, response) { | 29 function(name, request, response) { |
30 if (response && !response.error && response.entries) { | 30 if (response && !response.error && response.entries) { |
31 response.entries = response.entries.map(function(entry) { | 31 response.entries = response.entries.map(function(entry) { |
32 return GetExternalFileEntry(entry); | 32 return GetExternalFileEntry(entry); |
(...skipping 22 matching lines...) Expand all Loading... |
55 if (!response) | 55 if (!response) |
56 response = {}; | 56 response = {}; |
57 | 57 |
58 if (request.callback) | 58 if (request.callback) |
59 request.callback(response); | 59 request.callback(response); |
60 request.callback = null; | 60 request.callback = null; |
61 }); | 61 }); |
62 }); | 62 }); |
63 | 63 |
64 exports.binding = binding.generate(); | 64 exports.binding = binding.generate(); |
OLD | NEW |