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 /** | 5 /** |
6 * Namespace object for file type utility functions. | 6 * Namespace object for file type utility functions. |
7 */ | 7 */ |
8 var FileType = {}; | 8 var FileType = {}; |
9 | 9 |
10 FileType.types = { | 10 FileType.types = { |
(...skipping 30 matching lines...) Expand all Loading... |
41 'wav': {type: 'audio', name: 'AUDIO_FILE_TYPE', subtype: 'WAV'}, | 41 'wav': {type: 'audio', name: 'AUDIO_FILE_TYPE', subtype: 'WAV'}, |
42 | 42 |
43 // Text | 43 // Text |
44 'pod': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'POD'}, | 44 'pod': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'POD'}, |
45 'rst': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'RST'}, | 45 'rst': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'RST'}, |
46 'txt': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'TXT'}, | 46 'txt': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'TXT'}, |
47 'log': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'LOG'}, | 47 'log': {type: 'text', name: 'PLAIN_TEXT_FILE_TYPE', subtype: 'LOG'}, |
48 | 48 |
49 // Others | 49 // Others |
50 'zip': {type: 'archive', name: 'ZIP_ARCHIVE_FILE_TYPE'}, | 50 'zip': {type: 'archive', name: 'ZIP_ARCHIVE_FILE_TYPE'}, |
| 51 'rar': {type: 'archive', name: 'RAR_ARCHIVE_FILE_TYPE'}, |
| 52 'tar': {type: 'archive', name: 'TAR_ARCHIVE_FILE_TYPE'}, |
| 53 'tar.bz2': {type: 'archive', name: 'TAR_BZIP2_ARCHIVE_FILE_TYPE'}, |
| 54 'tbz': {type: 'archive', name: 'TAR_BZIP2_ARCHIVE_FILE_TYPE'}, |
| 55 'tbz2': {type: 'archive', name: 'TAR_BZIP2_ARCHIVE_FILE_TYPE'}, |
| 56 'tar.gz': {type: 'archive', name: 'TAR_GZIP_ARCHIVE_FILE_TYPE'}, |
| 57 'tgz': {type: 'archive', name: 'TAR_GZIP_ARCHIVE_FILE_TYPE'}, |
51 | 58 |
52 'pdf': {type: 'text', icon: 'pdf', name: 'PDF_DOCUMENT_FILE_TYPE', | 59 'pdf': {type: 'text', icon: 'pdf', name: 'PDF_DOCUMENT_FILE_TYPE', |
53 subtype: 'PDF'}, | 60 subtype: 'PDF'}, |
54 'html': {type: 'text', icon: 'html', name: 'HTML_DOCUMENT_FILE_TYPE', | 61 'html': {type: 'text', icon: 'html', name: 'HTML_DOCUMENT_FILE_TYPE', |
55 subtype: 'HTML'}, | 62 subtype: 'HTML'}, |
56 'htm': {type: 'text', icon: 'html', name: 'HTML_DOCUMENT_FILE_TYPE', | 63 'htm': {type: 'text', icon: 'html', name: 'HTML_DOCUMENT_FILE_TYPE', |
57 subtype: 'HTML'} | 64 subtype: 'HTML'} |
58 }; | 65 }; |
59 | 66 |
60 FileType.previewArt = { | 67 FileType.previewArt = { |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 * @param {number} opt_size The file size to be used if the metadata does not | 125 * @param {number} opt_size The file size to be used if the metadata does not |
119 * contain fileSize. | 126 * contain fileSize. |
120 * @return {boolean} Whether it is OK to use the image url for a preview. | 127 * @return {boolean} Whether it is OK to use the image url for a preview. |
121 */ | 128 */ |
122 FileType.canUseImageUrlForPreview = function(metadata, opt_size) { | 129 FileType.canUseImageUrlForPreview = function(metadata, opt_size) { |
123 var fileSize = metadata.fileSize || opt_size; | 130 var fileSize = metadata.fileSize || opt_size; |
124 return ((fileSize && fileSize <= FileType.MAX_PREVIEW_FILE_SIZE) || | 131 return ((fileSize && fileSize <= FileType.MAX_PREVIEW_FILE_SIZE) || |
125 (metadata.width && metadata.height && | 132 (metadata.width && metadata.height && |
126 (metadata.width * metadata.height <= FileType.MAX_PREVIEW_PIXEL_COUNT))); | 133 (metadata.width * metadata.height <= FileType.MAX_PREVIEW_PIXEL_COUNT))); |
127 }; | 134 }; |
OLD | NEW |