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 bindings for the fileBrowserPrivate API. | 5 // Custom bindings for the fileBrowserPrivate API. |
6 | 6 |
7 (function() { | 7 var GetChromeHidden = natives.GetChromeHidden; |
8 | 8 var GetLocalFileSystem = natives.GetLocalFileSystem; |
9 native function GetChromeHidden(); | |
10 native function GetLocalFileSystem(name, path); | |
11 | 9 |
12 var chromeHidden = GetChromeHidden(); | 10 var chromeHidden = GetChromeHidden(); |
13 | 11 |
14 chromeHidden.registerCustomHook('fileBrowserPrivate', function(bindingsAPI) { | 12 chromeHidden.registerCustomHook('fileBrowserPrivate', function(bindingsAPI) { |
15 var apiFunctions = bindingsAPI.apiFunctions; | 13 var apiFunctions = bindingsAPI.apiFunctions; |
16 | 14 |
17 apiFunctions.setCustomCallback( | 15 apiFunctions.setCustomCallback( |
18 "fileBrowserPrivate.requestLocalFileSystem", | 16 "fileBrowserPrivate.requestLocalFileSystem", |
19 function(name, request, response) { | 17 function(name, request, response) { |
20 var resp = response ? [chromeHidden.JSON.parse(response)] : []; | 18 var resp = response ? [chromeHidden.JSON.parse(response)] : []; |
21 var fs = null; | 19 var fs = null; |
22 if (!resp[0].error) | 20 if (!resp[0].error) |
23 fs = GetLocalFileSystem(resp[0].name, resp[0].path); | 21 fs = GetLocalFileSystem(resp[0].name, resp[0].path); |
24 if (request.callback) | 22 if (request.callback) |
25 request.callback(fs); | 23 request.callback(fs); |
26 request.callback = null; | 24 request.callback = null; |
27 }); | 25 }); |
28 }); | 26 }); |
29 | |
30 })(); | |
OLD | NEW |