OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 var GalleryUtil = {}; | 5 var GalleryUtil = {}; |
6 | 6 |
7 /** | 7 /** |
8 * Obtains the entry set from the entries passed from onLaunched events. | 8 * Obtains the entry set from the entries passed from onLaunched events. |
9 * If an single entry is specified, the function returns all entries in the same | 9 * If an single entry is specified, the function returns all entries in the same |
10 * directory. Otherwise the function returns the passed entries. | 10 * directory. Otherwise the function returns the passed entries. |
(...skipping 27 matching lines...) Expand all Loading... |
38 return originalEntries[0].toURL() === entry.toURL() || | 38 return originalEntries[0].toURL() === entry.toURL() || |
39 entry.name[0] !== '.'; | 39 entry.name[0] !== '.'; |
40 }); | 40 }); |
41 }); | 41 }); |
42 } else { | 42 } else { |
43 entriesPromise = Promise.resolve(originalEntries); | 43 entriesPromise = Promise.resolve(originalEntries); |
44 } | 44 } |
45 | 45 |
46 return entriesPromise.then(function(entries) { | 46 return entriesPromise.then(function(entries) { |
47 return entries.filter(function(entry) { | 47 return entries.filter(function(entry) { |
| 48 // Currently the gallery doesn't support mime types, so checking by |
| 49 // file extensions is enough. |
48 return FileType.isImage(entry) || FileType.isRaw(entry); | 50 return FileType.isImage(entry) || FileType.isRaw(entry); |
49 }).sort(function(a, b) { | 51 }).sort(function(a, b) { |
50 return a.name.localeCompare(b.name); | 52 return a.name.localeCompare(b.name); |
51 }); | 53 }); |
52 }); | 54 }); |
53 }; | 55 }; |
54 | 56 |
55 /** | 57 /** |
56 * Returns true if entry is on MTP volume. | 58 * Returns true if entry is on MTP volume. |
57 * @param {!Entry} entry An entry. | 59 * @param {!Entry} entry An entry. |
58 * @param {!VolumeManagerWrapper} volumeManager Volume manager. | 60 * @param {!VolumeManagerWrapper} volumeManager Volume manager. |
59 * @return True if entry is on MTP volume. | 61 * @return True if entry is on MTP volume. |
60 */ | 62 */ |
61 GalleryUtil.isOnMTPVolume = function(entry, volumeManager) { | 63 GalleryUtil.isOnMTPVolume = function(entry, volumeManager) { |
62 var volumeInfo = volumeManager.getVolumeInfo(entry); | 64 var volumeInfo = volumeManager.getVolumeInfo(entry); |
63 return volumeInfo && | 65 return volumeInfo && |
64 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP; | 66 volumeInfo.volumeType === VolumeManagerCommon.VolumeType.MTP; |
65 } | 67 } |
OLD | NEW |