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 Media Gallery API. | 5 // Custom binding for the Media Gallery API. |
6 | 6 |
7 var binding = require('binding').Binding.create('mediaGalleries'); | 7 var binding = require('binding').Binding.create('mediaGalleries'); |
8 var blobNatives = requireNative('blob_natives'); | 8 var blobNatives = requireNative('blob_natives'); |
9 var mediaGalleriesNatives = requireNative('mediaGalleries'); | 9 var mediaGalleriesNatives = requireNative('mediaGalleries'); |
10 | 10 |
(...skipping 12 matching lines...) Expand all Loading... |
23 delete metadata.fsid; | 23 delete metadata.fsid; |
24 mediaGalleriesMetadata[filesystem.name] = metadata; | 24 mediaGalleriesMetadata[filesystem.name] = metadata; |
25 } | 25 } |
26 } | 26 } |
27 return result; | 27 return result; |
28 } | 28 } |
29 | 29 |
30 binding.registerCustomHook(function(bindingsAPI, extensionId) { | 30 binding.registerCustomHook(function(bindingsAPI, extensionId) { |
31 var apiFunctions = bindingsAPI.apiFunctions; | 31 var apiFunctions = bindingsAPI.apiFunctions; |
32 | 32 |
33 // getMediaFileSystems, addUserSelectedFolder, and addScanResults use a | 33 // getMediaFileSystems and addUserSelectedFolder use a custom callback so that |
34 // custom callback so that they can instantiate and return an array of file | 34 // they can instantiate and return an array of file system objects. |
35 // system objects. | |
36 apiFunctions.setCustomCallback('getMediaFileSystems', | 35 apiFunctions.setCustomCallback('getMediaFileSystems', |
37 function(name, request, callback, response) { | 36 function(name, request, callback, response) { |
38 var result = createFileSystemObjectsAndUpdateMetadata(response); | 37 var result = createFileSystemObjectsAndUpdateMetadata(response); |
39 if (callback) | 38 if (callback) |
40 callback(result); | 39 callback(result); |
41 }); | 40 }); |
42 | 41 |
43 apiFunctions.setCustomCallback('addScanResults', | |
44 function(name, request, callback, response) { | |
45 var result = createFileSystemObjectsAndUpdateMetadata(response); | |
46 if (callback) | |
47 callback(result); | |
48 }); | |
49 | |
50 apiFunctions.setCustomCallback('addUserSelectedFolder', | 42 apiFunctions.setCustomCallback('addUserSelectedFolder', |
51 function(name, request, callback, response) { | 43 function(name, request, callback, response) { |
52 var fileSystems = []; | 44 var fileSystems = []; |
53 var selectedFileSystemName = ""; | 45 var selectedFileSystemName = ""; |
54 if (response && 'mediaFileSystems' in response && | 46 if (response && 'mediaFileSystems' in response && |
55 'selectedFileSystemIndex' in response) { | 47 'selectedFileSystemIndex' in response) { |
56 fileSystems = createFileSystemObjectsAndUpdateMetadata( | 48 fileSystems = createFileSystemObjectsAndUpdateMetadata( |
57 response['mediaFileSystems']); | 49 response['mediaFileSystems']); |
58 var selectedFileSystemIndex = response['selectedFileSystemIndex']; | 50 var selectedFileSystemIndex = response['selectedFileSystemIndex']; |
59 if (selectedFileSystemIndex >= 0) { | 51 if (selectedFileSystemIndex >= 0) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 callback(response ? response.metadata : null); | 112 callback(response ? response.metadata : null); |
121 | 113 |
122 // The UUID was in position 0 in the setUpdateArgumentsPostValidate | 114 // The UUID was in position 0 in the setUpdateArgumentsPostValidate |
123 // function. | 115 // function. |
124 var uuid = request.args[0]; | 116 var uuid = request.args[0]; |
125 delete blobsAwaitingMetadata[uuid]; | 117 delete blobsAwaitingMetadata[uuid]; |
126 }); | 118 }); |
127 }); | 119 }); |
128 | 120 |
129 exports.binding = binding.generate(); | 121 exports.binding = binding.generate(); |
OLD | NEW |