Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: chrome/browser/resources/file_manager/js/file_manager.js

Issue 7706028: This is UI side unreadable device support. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Setting the src of an img to an empty string can crash the browser, so we 5 // Setting the src of an img to an empty string can crash the browser, so we
6 // use an empty 1x1 gif instead. 6 // use an empty 1x1 gif instead.
7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,' 7 const EMPTY_IMAGE_URI = 'data:image/gif;base64,'
8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D'; 8 + 'R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw%3D%3D';
9 9
10 var g_slideshow_data = null; 10 var g_slideshow_data = null;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 */ 199 */
200 const CP_RECURSE = true; 200 const CP_RECURSE = true;
201 const CP_NO_RECURSE = false; 201 const CP_NO_RECURSE = false;
202 202
203 /** 203 /**
204 * Translated strings. 204 * Translated strings.
205 */ 205 */
206 var localStrings; 206 var localStrings;
207 207
208 /** 208 /**
209 * Map of icon types to regular expressions. 209 * Map of icon types to regular expressions and functions
210 * 210 *
211 * The first regexp to match the file name determines the icon type 211 * The first regexp/function to match the entry name determines the icon type
212 * assigned to dom elements for a file. Order of evaluation is not 212 * assigned to dom elements for a file. Order of evaluation is not
213 * defined, so don't depend on it. 213 * defined, so don't depend on it.
214 */ 214 */
215 const iconTypes = { 215 const iconTypes = {
216 'audio': /\.(flac|mp3|m4a|oga|ogg|wav)$/i, 216 'audio': /\.(flac|mp3|m4a|oga|ogg|wav)$/i,
217 'html': /\.(html?)$/i, 217 'html': /\.(html?)$/i,
218 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i, 218 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i,
219 'pdf' : /\.(pdf)$/i, 219 'pdf' : /\.(pdf)$/i,
220 'text': /\.(pod|rst|txt|log)$/i, 220 'text': /\.(pod|rst|txt|log)$/i,
221 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i 221 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i,
222 'device': function(entry) {
223 var deviceNumber = this.getDeviceNumber(entry);
224 if (deviceNumber != undefined)
225 return (this.mountPoints_[deviceNumber].specialData == '');
226 return false;
227 },
228 'unreadable': function(entry) {
229 var deviceNumber = this.getDeviceNumber(entry);
230 if (deviceNumber != undefined) {
231 return this.mountPoints_[deviceNumber].specialData ==
232 'unreadable_unknown_filesystem' ||
233 this.mountPoints_[deviceNumber].specialData ==
234 'unreadable_unsupported_filesystem';
235 }
236 return false;
237 }
222 }; 238 };
223 239
224 const previewArt = { 240 const previewArt = {
225 'audio': 'images/filetype_large_audio.png', 241 'audio': 'images/filetype_large_audio.png',
242 // TODO(sidor): Find better icon here.
243 'device': 'images/filetype_large_folder.png',
226 'folder': 'images/filetype_large_folder.png', 244 'folder': 'images/filetype_large_folder.png',
227 'unknown': 'images/filetype_large_generic.png', 245 'unknown': 'images/filetype_large_generic.png',
246 // TODO(sidor): Find better icon here.
247 'unreadable': 'images/filetype_large_folder.png',
228 'video': 'images/filetype_large_video.png' 248 'video': 'images/filetype_large_video.png'
229 }; 249 };
230 250
231 /** 251 /**
232 * Regexp for archive files. Used to show mount-archive task. 252 * Regexp for archive files. Used to show mount-archive task.
233 */ 253 */
234 const ARCHIVES_REGEXP = /.zip$/; 254 const ARCHIVES_REGEXP = /.zip$/;
235 255
236 /** 256 /**
237 * Return a translated string. 257 * Return a translated string.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 * 305 *
286 * @param {string} path The file path. 306 * @param {string} path The file path.
287 */ 307 */
288 function getParentPath(path) { 308 function getParentPath(path) {
289 var parent = path.replace(/[\/]?[^\/]+[\/]?$/,''); 309 var parent = path.replace(/[\/]?[^\/]+[\/]?$/,'');
290 if (parent.length == 0) 310 if (parent.length == 0)
291 parent = '/'; 311 parent = '/';
292 return parent; 312 return parent;
293 } 313 }
294 314
295 /** 315 /**
296 * Get the icon type for a given Entry. 316 * Normalizes path not to start with /
297 * 317 *
298 * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry). 318 * @param {string} path The file path.
299 * @return {string} One of the keys from FileManager.iconTypes, or 319 */
300 * 'unknown'. 320 function normalize(x) {
rginda 2011/08/23 20:23:30 normalizePath please.
rginda 2011/08/23 20:25:12 Actually, it would probably be cleaner to call thi
sidor 2011/08/23 23:18:47 So according to Toni, this should be removing / at
sidor 2011/08/23 23:18:47 Path name changed.
301 */ 321 if (x[0] == '/')
302 function getIconType(entry) { 322 return x.slice(1);
303 if (entry.cachedIconType_) 323 else
304 return entry.cachedIconType_; 324 return x;
325 }
305 326
306 var rv = 'unknown';
307
308 if (entry.isDirectory) {
309 rv = 'folder';
310 } else {
311 for (var name in iconTypes) {
312 var value = iconTypes[name];
313
314 if (value instanceof RegExp) {
315 if (value.test(entry.name)) {
316 rv = name;
317 break;
318 }
319 } else if (typeof value == 'function') {
320 try {
321 if (value(entry)) {
322 rv = name;
323 break;
324 }
325 } catch (ex) {
326 console.error('Caught exception while evaluating iconType: ' +
327 name, ex);
328 }
329 } else {
330 console.log('Unexpected value in iconTypes[' + name + ']: ' + value);
331 }
332 }
333 }
334
335 entry.cachedIconType_ = rv;
336 return rv;
337 }
338 327
339 /** 328 /**
340 * Call an asynchronous method on dirEntry, batching multiple callers. 329 * Call an asynchronous method on dirEntry, batching multiple callers.
341 * 330 *
342 * This batches multiple callers into a single invocation, calling all 331 * This batches multiple callers into a single invocation, calling all
343 * interested parties back when the async call completes. 332 * interested parties back when the async call completes.
344 * 333 *
345 * The Entry method to be invoked should take two callbacks as parameters 334 * The Entry method to be invoked should take two callbacks as parameters
346 * (one for success and one for failure), and it should invoke those 335 * (one for success and one for failure), and it should invoke those
347 * callbacks with a single parameter representing the result of the call. 336 * callbacks with a single parameter representing the result of the call.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 * icon type of the file as a string. 474 * icon type of the file as a string.
486 * 475 *
487 * The successCallback is always invoked synchronously, since this does not 476 * The successCallback is always invoked synchronously, since this does not
488 * actually require an async call. You should not depend on this, as it may 477 * actually require an async call. You should not depend on this, as it may
489 * change if we were to start reading magic numbers (for example). 478 * change if we were to start reading magic numbers (for example).
490 * 479 *
491 * @param {Entry} entry An HTML5 Entry object. 480 * @param {Entry} entry An HTML5 Entry object.
492 * @param {function(Entry)} successCallback The function to invoke once the 481 * @param {function(Entry)} successCallback The function to invoke once the
493 * icon type is known. 482 * icon type is known.
494 */ 483 */
495 function cacheEntryIconType(entry, successCallback) { 484 function cacheEntryIconType(entry, successCallback) {
rginda 2011/08/23 20:23:30 If this is going to be invoked as a method, it sho
sidor 2011/08/23 23:18:47 Done.
496 getIconType(entry); 485 this.getIconType(entry);
497 if (successCallback) 486 if (successCallback)
498 setTimeout(function() { successCallback(entry) }, 0); 487 setTimeout(function() { successCallback(entry) }, 0);
499 } 488 }
500 489
501 function isSystemDirEntry(dirEntry) { 490 function isSystemDirEntry(dirEntry) {
502 return dirEntry.fullPath == '/' || 491 return dirEntry.fullPath == '/' ||
503 dirEntry.fullPath == REMOVABLE_DIRECTORY || 492 dirEntry.fullPath == REMOVABLE_DIRECTORY ||
504 dirEntry.fullPath == ARCHIVE_DIRECTORY; 493 dirEntry.fullPath == ARCHIVE_DIRECTORY;
505 } 494 }
506 495
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 640
652 this.setListType(FileManager.ListType.DETAIL); 641 this.setListType(FileManager.ListType.DETAIL);
653 642
654 this.onResize_(); 643 this.onResize_();
655 this.dialogDom_.style.opacity = '1'; 644 this.dialogDom_.style.opacity = '1';
656 645
657 this.textSearchState_ = {text: '', date: new Date()}; 646 this.textSearchState_ = {text: '', date: new Date()};
658 }; 647 };
659 648
660 /** 649 /**
650 * Get the icon type for a given Entry.
651 *
652 * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry).
653 * @return {string} One of the keys from FileManager.iconTypes, or
654 * 'unknown'.
655 */
656 FileManager.prototype.getIconType = function(entry) {
657 if (entry.cachedIconType_)
658 return entry.cachedIconType_;
659
660 var rv = 'unknown';
661 if (entry.isDirectory)
662 rv = 'folder';
663 for (var name in iconTypes) {
664 var value = iconTypes[name];
665
666 if (value instanceof RegExp) {
667 if (value.test(entry.name)) {
668 rv = name;
669 break;
670 }
671 } else if (typeof value == 'function') {
672 try {
673 var isThisIconForThatEntry = value.bind(this);
rginda 2011/08/23 20:23:30 Please just pass in the FileManager instance as a
sidor 2011/08/23 23:18:47 Done.
674 if (isThisIconForThatEntry(entry)) {
675 rv = name;
676 break;
677 }
678 } catch (ex) {
679 console.error('Caught exception while evaluating iconType: ' +
680 name, ex);
681 }
682 } else {
683 console.log('Unexpected value in iconTypes[' + name + ']: ' + value);
684 }
685 }
686 entry.cachedIconType_ = rv;
687 return rv;
688 };
689
690 /**
661 * Compare by mtime first, then by name. 691 * Compare by mtime first, then by name.
662 */ 692 */
663 FileManager.prototype.compareMtime_ = function(a, b) { 693 FileManager.prototype.compareMtime_ = function(a, b) {
664 if (a.cachedMtime_ > b.cachedMtime) 694 if (a.cachedMtime_ > b.cachedMtime)
665 return 1; 695 return 1;
666 696
667 if (a.cachedMtime_ < b.cachedMtime) 697 if (a.cachedMtime_ < b.cachedMtime)
668 return -1; 698 return -1;
669 699
670 return this.collator_.compare(a.name, b.name); 700 return this.collator_.compare(a.name, b.name);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 FileManager.prototype.prepareSort_ = function(field, callback) { 1266 FileManager.prototype.prepareSort_ = function(field, callback) {
1237 var cacheFunction; 1267 var cacheFunction;
1238 1268
1239 if (field == 'name' || field == 'cachedMtime_') { 1269 if (field == 'name' || field == 'cachedMtime_') {
1240 // Mtime is the tie-breaker for a name sort, so we need to resolve 1270 // Mtime is the tie-breaker for a name sort, so we need to resolve
1241 // it for both mtime and name sorts. 1271 // it for both mtime and name sorts.
1242 cacheFunction = cacheEntryDate; 1272 cacheFunction = cacheEntryDate;
1243 } else if (field == 'cachedSize_') { 1273 } else if (field == 'cachedSize_') {
1244 cacheFunction = cacheEntrySize; 1274 cacheFunction = cacheEntrySize;
1245 } else if (field == 'cachedIconType_') { 1275 } else if (field == 'cachedIconType_') {
1246 cacheFunction = cacheEntryIconType; 1276 cacheFunction = cacheEntryIconType.bind(this);
1247 } else { 1277 } else {
1248 callback(); 1278 callback();
1249 return; 1279 return;
1250 } 1280 }
1251 1281
1252 function checkCount() { 1282 function checkCount() {
1253 if (uncachedCount == 0) { 1283 if (uncachedCount == 0) {
1254 // Callback via a setTimeout so the sync/async semantics don't change 1284 // Callback via a setTimeout so the sync/async semantics don't change
1255 // based on whether or not the value is cached. 1285 // based on whether or not the value is cached.
1256 setTimeout(callback, 0); 1286 setTimeout(callback, 0);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 */ 1373 */
1344 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { 1374 FileManager.prototype.renderIconType_ = function(entry, columnId, table) {
1345 var div = this.document_.createElement('div'); 1375 var div = this.document_.createElement('div');
1346 div.className = 'detail-icon-container'; 1376 div.className = 'detail-icon-container';
1347 1377
1348 if (this.showCheckboxes_) 1378 if (this.showCheckboxes_)
1349 div.appendChild(this.renderCheckbox_(entry)); 1379 div.appendChild(this.renderCheckbox_(entry));
1350 1380
1351 var icon = this.document_.createElement('div'); 1381 var icon = this.document_.createElement('div');
1352 icon.className = 'detail-icon'; 1382 icon.className = 'detail-icon';
1353 entry.cachedIconType_ = getIconType(entry); 1383 entry.cachedIconType_ = this.getIconType(entry);
1354 icon.setAttribute('iconType', entry.cachedIconType_); 1384 icon.setAttribute('iconType', entry.cachedIconType_);
1355 div.appendChild(icon); 1385 div.appendChild(icon);
1356 1386
1357 return div; 1387 return div;
1358 }; 1388 };
1359 1389
1360 FileManager.prototype.getLabelForRootPath_ = function(path) { 1390 FileManager.prototype.getLabelForRootPath_ = function(path) {
1361 // This hack lets us localize the top level directories. 1391 // This hack lets us localize the top level directories.
1362 if (path == 'Downloads') 1392 if (path == 'Downloads')
1363 return str('DOWNLOADS_DIRECTORY_LABEL'); 1393 return str('DOWNLOADS_DIRECTORY_LABEL');
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 1508
1479 for (var i = 0; i < selection.indexes.length; i++) { 1509 for (var i = 0; i < selection.indexes.length; i++) {
1480 var entry = this.dataModel_.item(selection.indexes[i]); 1510 var entry = this.dataModel_.item(selection.indexes[i]);
1481 if (!entry) 1511 if (!entry)
1482 continue; 1512 continue;
1483 1513
1484 selection.entries.push(entry); 1514 selection.entries.push(entry);
1485 selection.urls.push(entry.toURL()); 1515 selection.urls.push(entry.toURL());
1486 1516
1487 if (selection.iconType == null) { 1517 if (selection.iconType == null) {
1488 selection.iconType = getIconType(entry); 1518 selection.iconType = this.getIconType(entry);
1489 } else if (selection.iconType != 'unknown') { 1519 } else if (selection.iconType != 'unknown') {
1490 var iconType = getIconType(entry); 1520 var iconType = this.getIconType(entry);
1491 if (selection.iconType != iconType) 1521 if (selection.iconType != iconType)
1492 selection.iconType = 'unknown'; 1522 selection.iconType = 'unknown';
1493 } 1523 }
1494 1524
1495 selection.totalCount++; 1525 selection.totalCount++;
1496 1526
1497 if (entry.isFile) { 1527 if (entry.isFile) {
1498 selection.fileCount += 1; 1528 selection.fileCount += 1;
1499 if (!('cachedSize_' in entry)) { 1529 if (!('cachedSize_' in entry)) {
1500 // Any file that hasn't been rendered may be missing its cachedSize_ 1530 // Any file that hasn't been rendered may be missing its cachedSize_
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 * @param {Object} selection Selected files object. 1729 * @param {Object} selection Selected files object.
1700 */ 1730 */
1701 FileManager.prototype.maybeRenderFormattingTask_ = function(selection) { 1731 FileManager.prototype.maybeRenderFormattingTask_ = function(selection) {
1702 // Not to make unnecessary getMountPoints() call we doublecheck if there is 1732 // Not to make unnecessary getMountPoints() call we doublecheck if there is
1703 // only one selected entry. 1733 // only one selected entry.
1704 if (selection.entries.length != 1) 1734 if (selection.entries.length != 1)
1705 return; 1735 return;
1706 var self = this; 1736 var self = this;
1707 function onMountPointsFound(mountPoints) { 1737 function onMountPointsFound(mountPoints) {
1708 self.mountPoints_ = mountPoints; 1738 self.mountPoints_ = mountPoints;
1709
1710 function normalize(x) {
1711 if (x[0] == '/')
1712 return x.slice(1);
1713 else
1714 return x;
1715 }
1716
1717 function onVolumeMetadataFound(volumeMetadata) { 1739 function onVolumeMetadataFound(volumeMetadata) {
1718 if (volumeMetadata.deviceType == "flash") { 1740 if (volumeMetadata.deviceType == "flash") {
1719 if (selection.entries.length != 1 || 1741 if (self.selection.entries.length != 1 ||
1720 normalize(selection.entries[0].fullPath) != 1742 normalize(self.selection.entries[0].fullPath) !=
1721 normalize(volumeMetadata.mountPath)) { 1743 normalize(volumeMetadata.mountPath)) {
1722 return; 1744 return;
1723 } 1745 }
1724 var task = { 1746 var task = {
1725 taskId: self.getExtensionId_() + '|format-device', 1747 taskId: self.getExtensionId_() + '|format-device',
1726 iconUrl: chrome.extension.getURL('images/filetype_generic.png'), 1748 iconUrl: chrome.extension.getURL('images/filetype_generic.png'),
1727 title: str('FORMAT_DEVICE') 1749 title: str('FORMAT_DEVICE')
1728 }; 1750 };
1729 self.renderTaskButton_(task); 1751 self.renderTaskButton_(task);
1730 } 1752 }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 } 1804 }
1783 } 1805 }
1784 1806
1785 if (event.eventType == 'unmount' && event.status == 'success' && 1807 if (event.eventType == 'unmount' && event.status == 'success' &&
1786 self.currentDirEntry_ && 1808 self.currentDirEntry_ &&
1787 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) { 1809 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) {
1788 self.changeDirectory(getParentPath(event.mountPath)); 1810 self.changeDirectory(getParentPath(event.mountPath));
1789 return; 1811 return;
1790 } 1812 }
1791 1813
1814 var rescanDirectory = (event.status == 'success');
1815 for (var i = 0; i < mountPoints.length; i++) {
1816 if (event.sourceUrl == mountPoints[i].sourceUrl &&
1817 mountPoints[i].specialData != '') {
1818 rescanDirectory = true;
1819 }
1820 }
1792 // TODO(dgozman): rescan directory, only if it contains mounted points, 1821 // TODO(dgozman): rescan directory, only if it contains mounted points,
1793 // when mounts location will be decided. 1822 // when mounts location will be decided.
1794 if (event.status == 'success') 1823 if (rescanDirectory)
1795 self.rescanDirectory_(); 1824 self.rescanDirectory_();
1796 }); 1825 });
1797 }; 1826 };
1798 1827
1799 /** 1828 /**
1800 * Event handler called when some internal task should be executed. 1829 * Event handler called when some internal task should be executed.
1801 */ 1830 */
1802 FileManager.prototype.onFileTaskExecute_ = function(id, details) { 1831 FileManager.prototype.onFileTaskExecute_ = function(id, details) {
1803 var urls = details.entries.map(function(entry) { 1832 var urls = details.entries.map(function(entry) {
1804 return entry.toURL(); 1833 return entry.toURL();
(...skipping 14 matching lines...) Expand all
1819 for (var index = 0; index < urls.length; ++index) { 1848 for (var index = 0; index < urls.length; ++index) {
1820 chrome.fileBrowserPrivate.removeMount(urls[index]); 1849 chrome.fileBrowserPrivate.removeMount(urls[index]);
1821 } 1850 }
1822 } else if (id == 'format-device') { 1851 } else if (id == 'format-device') {
1823 this.confirm.show(str('FORMATTING_WARNING'), function() { 1852 this.confirm.show(str('FORMATTING_WARNING'), function() {
1824 chrome.fileBrowserPrivate.formatDevice(urls[0]); 1853 chrome.fileBrowserPrivate.formatDevice(urls[0]);
1825 }); 1854 });
1826 } 1855 }
1827 }; 1856 };
1828 1857
1858 FileManager.prototype.getDeviceNumber = function(entry) {
1859 if (!entry.isDirectory) return false;
1860 for (var i = 0; i < this.mountPoints_.length; i++) {
1861 if (normalize(entry.fullPath) ==
1862 normalize(this.mountPoints_[i].mountPath)) {
1863 return i;
1864 }
1865 }
1866 return undefined;
1867 }
1868
1829 FileManager.prototype.openImageEditor_ = function(entry) { 1869 FileManager.prototype.openImageEditor_ = function(entry) {
1830 var self = this; 1870 var self = this;
1831 1871
1832 var editorFrame = this.document_.createElement('iframe'); 1872 var editorFrame = this.document_.createElement('iframe');
1833 editorFrame.className = 'overlay-pane'; 1873 editorFrame.className = 'overlay-pane';
1834 editorFrame.scrolling = 'no'; 1874 editorFrame.scrolling = 'no';
1835 1875
1836 editorFrame.onload = function() { 1876 editorFrame.onload = function() {
1837 self.cacheMetadata_(entry, function(metadata) { 1877 self.cacheMetadata_(entry, function(metadata) {
1838 editorFrame.contentWindow.ImageEditor.open( 1878 editorFrame.contentWindow.ImageEditor.open(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 this.previewFilename_.textContent = ''; 1963 this.previewFilename_.textContent = '';
1924 return; 1964 return;
1925 } 1965 }
1926 1966
1927 var previewName = this.selection.leadEntry.name; 1967 var previewName = this.selection.leadEntry.name;
1928 if (this.currentDirEntry_.name == '') 1968 if (this.currentDirEntry_.name == '')
1929 previewName = this.getLabelForRootPath_(previewName); 1969 previewName = this.getLabelForRootPath_(previewName);
1930 1970
1931 this.previewFilename_.textContent = previewName; 1971 this.previewFilename_.textContent = previewName;
1932 1972
1933 var iconType = getIconType(this.selection.leadEntry); 1973 var iconType = this.getIconType(this.selection.leadEntry);
1934 if (iconType == 'image') { 1974 if (iconType == 'image') {
1935 if (fileManager.selection.totalCount > 1) 1975 if (fileManager.selection.totalCount > 1)
1936 this.previewImage_.classList.add('multiple-selected'); 1976 this.previewImage_.classList.add('multiple-selected');
1937 } 1977 }
1938 1978
1939 var self = this; 1979 var self = this;
1940 var leadEntry = this.selection.leadEntry; 1980 var leadEntry = this.selection.leadEntry;
1941 1981
1942 this.getThumbnailURL(leadEntry, function(iconType, url) { 1982 this.getThumbnailURL(leadEntry, function(iconType, url) {
1943 if (self.selection.leadEntry != leadEntry) { 1983 if (self.selection.leadEntry != leadEntry) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2080 addProperty('DIMENSIONS_LABEL', 2120 addProperty('DIMENSIONS_LABEL',
2081 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value, 2121 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value,
2082 exifDir[0xa003].value)); 2122 exifDir[0xa003].value));
2083 } 2123 }
2084 }; 2124 };
2085 2125
2086 FileManager.prototype.getThumbnailURL = function(entry, callback) { 2126 FileManager.prototype.getThumbnailURL = function(entry, callback) {
2087 if (!entry) 2127 if (!entry)
2088 return; 2128 return;
2089 2129
2090 var iconType = getIconType(entry); 2130 var iconType = this.getIconType(entry);
2091 2131
2092 this.cacheMetadata_(entry, function (metadata) { 2132 this.cacheMetadata_(entry, function (metadata) {
2093 var url = metadata.thumbnailURL; 2133 var url = metadata.thumbnailURL;
2094 if (!url) { 2134 if (!url) {
2095 if (iconType == 'image') { 2135 if (iconType == 'image') {
2096 url = entry.toURL(); 2136 url = entry.toURL();
2097 } else { 2137 } else {
2098 url = previewArt[iconType] || previewArt['unknown']; 2138 url = previewArt[iconType] || previewArt['unknown'];
2099 } 2139 }
2100 } 2140 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2480 // Don't pay attention to double clicks during a rename. 2520 // Don't pay attention to double clicks during a rename.
2481 return; 2521 return;
2482 } 2522 }
2483 2523
2484 var entry = this.selection.leadEntry; 2524 var entry = this.selection.leadEntry;
2485 if (!entry) { 2525 if (!entry) {
2486 console.log('Invalid selection'); 2526 console.log('Invalid selection');
2487 return; 2527 return;
2488 } 2528 }
2489 2529
2490 if (entry.isDirectory) 2530 if (entry.isDirectory) {
2491 return this.changeDirectory(entry.fullPath); 2531 var deviceNumber = this.getDeviceNumber(entry);
2492 2532
2533 if (deviceNumber != undefined &&
2534 this.mountPoints_[deviceNumber].specialData ==
2535 'unreadable_unknown_filesystem') {
2536 return this.showButter(str('UNKNOWN_FILESYSTEM_WARNING'));
2537 } else if (deviceNumber != undefined &&
2538 this.mountPoints_[deviceNumber].specialData ==
2539 'unreadable_unsupported_filesystem') {
2540 return this.showButter(str('UNSUPPORTED_FILESYSTEM_WARNING'));
2541 } else {
2542 return this.changeDirectory(entry.fullPath);
2543 }
2544 }
2493 if (!this.okButton_.disabled) 2545 if (!this.okButton_.disabled)
2494 this.onOk_(); 2546 this.onOk_();
2495 2547
2496 }; 2548 };
2497 2549
2498 /** 2550 /**
2499 * Update the UI when the current directory changes. 2551 * Update the UI when the current directory changes.
2500 * 2552 *
2501 * @param {cr.Event} event The directory-changed event. 2553 * @param {cr.Event} event The directory-changed event.
2502 */ 2554 */
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
3145 3197
3146 if (msg) { 3198 if (msg) {
3147 console.log('no no no'); 3199 console.log('no no no');
3148 this.alert.show(msg, onAccept); 3200 this.alert.show(msg, onAccept);
3149 return false; 3201 return false;
3150 } 3202 }
3151 3203
3152 return true; 3204 return true;
3153 }; 3205 };
3154 })(); 3206 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698