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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 'isMediaDevice': false, | 96 'isMediaDevice': false, |
97 'isAvailable': false, | 97 'isAvailable': false, |
98 }; | 98 }; |
99 }); | 99 }); |
100 | 100 |
101 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', | 101 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', |
102 function(mediaFile, options, callback) { | 102 function(mediaFile, options, callback) { |
103 var blobUuid = blobNatives.GetBlobUuid(mediaFile) | 103 var blobUuid = blobNatives.GetBlobUuid(mediaFile) |
104 return [blobUuid, options, callback]; | 104 return [blobUuid, options, callback]; |
105 }); | 105 }); |
| 106 |
| 107 apiFunctions.setCustomCallback('getMetadata', |
| 108 function(name, request, response) { |
| 109 var metadata = response[0]; |
| 110 var attachedPicturesBytes = response[1]; |
| 111 var attachedPicturesTypes = response[2]; |
| 112 for (var i = 0; i < attachedPicturesBytes.length; i++) { |
| 113 var dataView = new DataView(attachedPicturesBytes[i]); |
| 114 var blob = new Blob([dataView], {type : attachedPicturesTypes[i]}); |
| 115 metadata.attachedPictures.push(blob); |
| 116 } |
| 117 |
| 118 if (request.callback) |
| 119 request.callback(metadata); |
| 120 request.callback = null; |
| 121 }); |
106 }); | 122 }); |
107 | 123 |
108 exports.binding = binding.generate(); | 124 exports.binding = binding.generate(); |
OLD | NEW |