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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 var selectedFileSystemIndex = response['selectedFileSystemIndex']; | 59 var selectedFileSystemIndex = response['selectedFileSystemIndex']; |
60 if (selectedFileSystemIndex >= 0) { | 60 if (selectedFileSystemIndex >= 0) { |
61 selectedFileSystemName = fileSystems[selectedFileSystemIndex].name; | 61 selectedFileSystemName = fileSystems[selectedFileSystemIndex].name; |
62 } | 62 } |
63 } | 63 } |
64 if (request.callback) | 64 if (request.callback) |
65 request.callback(fileSystems, selectedFileSystemName); | 65 request.callback(fileSystems, selectedFileSystemName); |
66 request.callback = null; | 66 request.callback = null; |
67 }); | 67 }); |
68 | 68 |
| 69 apiFunctions.setCustomCallback('dropPermissionForMediaFileSystem', |
| 70 function(name, request, response) { |
| 71 var galleryId = response[0]; |
| 72 var result = response[1]; |
| 73 |
| 74 if (galleryId && result) { |
| 75 for (var key in mediaGalleriesMetadata) { |
| 76 if (mediaGalleriesMetadata[key].galleryId == galleryId) { |
| 77 delete mediaGalleriesMetadata[key]; |
| 78 break; |
| 79 } |
| 80 } |
| 81 } |
| 82 if (request.callback) |
| 83 request.callback(result); |
| 84 request.callback = null; |
| 85 }); |
| 86 |
69 apiFunctions.setHandleRequest('getMediaFileSystemMetadata', | 87 apiFunctions.setHandleRequest('getMediaFileSystemMetadata', |
70 function(filesystem) { | 88 function(filesystem) { |
71 if (filesystem && filesystem.name && | 89 if (filesystem && filesystem.name && |
72 mediaGalleriesMetadata[filesystem.name]) { | 90 filesystem.name in mediaGalleriesMetadata) { |
73 return mediaGalleriesMetadata[filesystem.name]; | 91 return mediaGalleriesMetadata[filesystem.name]; |
74 } | 92 } |
75 return {}; | 93 return { |
| 94 'name': '', |
| 95 'galleryId': '', |
| 96 'isRemovable': false, |
| 97 'isMediaDevice': false, |
| 98 'isAvailable': false, |
| 99 }; |
76 }); | 100 }); |
77 | 101 |
78 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', | 102 apiFunctions.setUpdateArgumentsPostValidate('getMetadata', |
79 function(mediaFile, options, callback) { | 103 function(mediaFile, options, callback) { |
80 var blobUuid = blobNatives.GetBlobUuid(mediaFile) | 104 var blobUuid = blobNatives.GetBlobUuid(mediaFile) |
81 return [blobUuid, options, callback]; | 105 return [blobUuid, options, callback]; |
82 }); | 106 }); |
83 }); | 107 }); |
84 | 108 |
85 exports.binding = binding.generate(); | 109 exports.binding = binding.generate(); |
OLD | NEW |