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 binding for the fileBrowserPrivate API. |
| 6 |
| 7 var binding = require('binding').Binding.create('fileBrowserPrivate'); |
6 | 8 |
7 var fileBrowserPrivateNatives = requireNative('file_browser_private'); | 9 var fileBrowserPrivateNatives = requireNative('file_browser_private'); |
8 var GetLocalFileSystem = fileBrowserPrivateNatives.GetLocalFileSystem; | 10 var GetLocalFileSystem = fileBrowserPrivateNatives.GetLocalFileSystem; |
9 | 11 |
10 var fileBrowserNatives = requireNative('file_browser_handler'); | 12 var fileBrowserNatives = requireNative('file_browser_handler'); |
11 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry; | 13 var GetExternalFileEntry = fileBrowserNatives.GetExternalFileEntry; |
12 | 14 |
13 var chromeHidden = requireNative('chrome_hidden').GetChromeHidden(); | 15 binding.registerCustomHook(function(bindingsAPI) { |
14 | |
15 chromeHidden.registerCustomHook('fileBrowserPrivate', function(bindingsAPI) { | |
16 var apiFunctions = bindingsAPI.apiFunctions; | 16 var apiFunctions = bindingsAPI.apiFunctions; |
17 | 17 |
18 apiFunctions.setCustomCallback('requestLocalFileSystem', | 18 apiFunctions.setCustomCallback('requestLocalFileSystem', |
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 = GetLocalFileSystem(response.name, response.path); | 22 fs = GetLocalFileSystem(response.name, response.path); |
23 if (request.callback) | 23 if (request.callback) |
24 request.callback(fs); | 24 request.callback(fs); |
25 request.callback = null; | 25 request.callback = null; |
(...skipping 28 matching lines...) Expand all Loading... |
54 | 54 |
55 // So |request.callback| doesn't break if response is not defined. | 55 // So |request.callback| doesn't break if response is not defined. |
56 if (!response) | 56 if (!response) |
57 response = {}; | 57 response = {}; |
58 | 58 |
59 if (request.callback) | 59 if (request.callback) |
60 request.callback(response); | 60 request.callback(response); |
61 request.callback = null; | 61 request.callback = null; |
62 }); | 62 }); |
63 }); | 63 }); |
| 64 |
| 65 exports.binding = binding.generate(); |
OLD | NEW |