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

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: corrected strings + added mocks + style in js 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(self, entry) {
223 var deviceNumber = self.getDeviceNumber(entry);
224 if (deviceNumber != undefined)
225 return (self.mountPoints_[deviceNumber].specialData == '');
226 return false;
227 },
228 'unreadable': function(self, entry) {
229 var deviceNumber = self.getDeviceNumber(entry);
230 if (deviceNumber != undefined) {
231 return self.mountPoints_[deviceNumber].specialData ==
232 'unreadable_unknown_filesystem' ||
233 self.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 normalizeAbsolutePath(x) {
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 }); 459 });
471 } else { 460 } else {
472 batchAsyncCall(entry, 'getMetadata', function(metadata) { 461 batchAsyncCall(entry, 'getMetadata', function(metadata) {
473 entry.cachedMtime_ = metadata.modificationTime; 462 entry.cachedMtime_ = metadata.modificationTime;
474 if (successCallback) 463 if (successCallback)
475 successCallback(entry); 464 successCallback(entry);
476 }, opt_errorCallback); 465 }, opt_errorCallback);
477 } 466 }
478 } 467 }
479 468
480 /**
481 * Get the icon type of a file, caching the result.
482 *
483 * When this method completes, the fileEntry object will get a
484 * 'cachedIconType_' property (if it doesn't already have one) containing the
485 * icon type of the file as a string.
486 *
487 * 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
489 * change if we were to start reading magic numbers (for example).
490 *
491 * @param {Entry} entry An HTML5 Entry object.
492 * @param {function(Entry)} successCallback The function to invoke once the
493 * icon type is known.
494 */
495 function cacheEntryIconType(entry, successCallback) {
496 getIconType(entry);
497 if (successCallback)
498 setTimeout(function() { successCallback(entry) }, 0);
499 }
500
501 function isSystemDirEntry(dirEntry) { 469 function isSystemDirEntry(dirEntry) {
502 return dirEntry.fullPath == '/' || 470 return dirEntry.fullPath == '/' ||
503 dirEntry.fullPath == REMOVABLE_DIRECTORY || 471 dirEntry.fullPath == REMOVABLE_DIRECTORY ||
504 dirEntry.fullPath == ARCHIVE_DIRECTORY; 472 dirEntry.fullPath == ARCHIVE_DIRECTORY;
505 } 473 }
506 474
507 // Public statics. 475 // Public statics.
508 476
509 /** 477 /**
510 * List of dialog types. 478 * List of dialog types.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 619
652 this.setListType(FileManager.ListType.DETAIL); 620 this.setListType(FileManager.ListType.DETAIL);
653 621
654 this.onResize_(); 622 this.onResize_();
655 this.dialogDom_.style.opacity = '1'; 623 this.dialogDom_.style.opacity = '1';
656 624
657 this.textSearchState_ = {text: '', date: new Date()}; 625 this.textSearchState_ = {text: '', date: new Date()};
658 }; 626 };
659 627
660 /** 628 /**
629 * Get the icon type for a given Entry.
630 *
631 * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry).
632 * @return {string} One of the keys from FileManager.iconTypes, or
633 * 'unknown'.
634 */
635 FileManager.prototype.getIconType = function(entry) {
636 if (entry.cachedIconType_)
637 return entry.cachedIconType_;
638
639 var rv = 'unknown';
640 if (entry.isDirectory)
641 rv = 'folder';
642 for (var name in iconTypes) {
643 var value = iconTypes[name];
644
645 if (value instanceof RegExp) {
646 if (value.test(entry.name)) {
647 rv = name;
648 break;
649 }
650 } else if (typeof value == 'function') {
651 try {
652 if (value(this,entry)) {
653 rv = name;
654 break;
655 }
656 } catch (ex) {
657 console.error('Caught exception while evaluating iconType: ' +
658 name, ex);
659 }
660 } else {
661 console.log('Unexpected value in iconTypes[' + name + ']: ' + value);
662 }
663 }
664 entry.cachedIconType_ = rv;
665 return rv;
666 };
667
668
669 /**
670 * Get the icon type of a file, caching the result.
671 *
672 * When this method completes, the fileEntry object will get a
673 * 'cachedIconType_' property (if it doesn't already have one) containing the
674 * icon type of the file as a string.
675 *
676 * The successCallback is always invoked synchronously, since this does not
677 * actually require an async call. You should not depend on this, as it may
678 * change if we were to start reading magic numbers (for example).
679 *
680 * @param {Entry} entry An HTML5 Entry object.
681 * @param {function(Entry)} successCallback The function to invoke once the
682 * icon type is known.
683 */
684 FileManager.prototype.cacheEntryIconType = function(entry, successCallback) {
685 this.getIconType(entry);
686 if (successCallback)
687 setTimeout(function() { successCallback(entry) }, 0);
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 = this.cacheEntryIconType;
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 normalizeAbsolutePath(self.selection.entries[0].fullPath) !=
1721 normalize(volumeMetadata.mountPath)) { 1743 normalizeAbsolutePath(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 }
1731 } 1753 }
1732 1754
1733 if (selection.entries.length != 1) 1755 if (selection.entries.length != 1)
1734 return; 1756 return;
1735 var selectedPath = selection.entries[0].fullPath; 1757 var selectedPath = selection.entries[0].fullPath;
1736 for (var i = 0; i < mountPoints.length; i++) { 1758 for (var i = 0; i < mountPoints.length; i++) {
1737 if (mountPoints[i].mountType == "device" && 1759 if (mountPoints[i].mountType == "device" &&
1738 normalize(mountPoints[i].mountPath) == normalize(selectedPath)) { 1760 normalizeAbsolutePath(mountPoints[i].mountPath) ==
1761 normalizeAbsolutePath(selectedPath)) {
1739 chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl, 1762 chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl,
1740 onVolumeMetadataFound); 1763 onVolumeMetadataFound);
1741 return; 1764 return;
1742 } 1765 }
1743 } 1766 }
1744 } 1767 }
1745 1768
1746 chrome.fileBrowserPrivate.getMountPoints(onMountPointsFound); 1769 chrome.fileBrowserPrivate.getMountPoints(onMountPointsFound);
1747 }; 1770 };
1748 1771
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 } 1805 }
1783 } 1806 }
1784 1807
1785 if (event.eventType == 'unmount' && event.status == 'success' && 1808 if (event.eventType == 'unmount' && event.status == 'success' &&
1786 self.currentDirEntry_ && 1809 self.currentDirEntry_ &&
1787 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) { 1810 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) {
1788 self.changeDirectory(getParentPath(event.mountPath)); 1811 self.changeDirectory(getParentPath(event.mountPath));
1789 return; 1812 return;
1790 } 1813 }
1791 1814
1815 var rescanDirectory = (event.status == 'success');
tbarzic 2011/08/24 03:59:44 I think smth like rescanDirectoryNeeded would be c
sidor 2011/08/24 04:26:06 Will do this tommorrow.
1816 for (var i = 0; i < mountPoints.length; i++) {
1817 if (event.sourceUrl == mountPoints[i].sourceUrl &&
tbarzic 2011/08/24 03:59:44 why don't you just add specialData field to the ev
sidor 2011/08/24 04:26:06 Because I need to perform check later on double cl
tbarzic 2011/08/25 02:03:44 yeah, I know.. What I ment is you could avoid sear
1818 mountPoints[i].specialData != '') {
1819 rescanDirectory = true;
1820 }
1821 }
1792 // TODO(dgozman): rescan directory, only if it contains mounted points, 1822 // TODO(dgozman): rescan directory, only if it contains mounted points,
1793 // when mounts location will be decided. 1823 // when mounts location will be decided.
1794 if (event.status == 'success' || 1824 if (rescanDirectory)
1795 event.status == 'error_unknown_filesystem' ||
1796 event.status == 'error_unsuported_filesystem')
1797 self.rescanDirectory_(); 1825 self.rescanDirectory_();
1798 }); 1826 });
1799 }; 1827 };
1800 1828
1801 /** 1829 /**
1802 * Event handler called when some internal task should be executed. 1830 * Event handler called when some internal task should be executed.
1803 */ 1831 */
1804 FileManager.prototype.onFileTaskExecute_ = function(id, details) { 1832 FileManager.prototype.onFileTaskExecute_ = function(id, details) {
1805 var urls = details.entries.map(function(entry) { 1833 var urls = details.entries.map(function(entry) {
1806 return entry.toURL(); 1834 return entry.toURL();
(...skipping 14 matching lines...) Expand all
1821 for (var index = 0; index < urls.length; ++index) { 1849 for (var index = 0; index < urls.length; ++index) {
1822 chrome.fileBrowserPrivate.removeMount(urls[index]); 1850 chrome.fileBrowserPrivate.removeMount(urls[index]);
1823 } 1851 }
1824 } else if (id == 'format-device') { 1852 } else if (id == 'format-device') {
1825 this.confirm.show(str('FORMATTING_WARNING'), function() { 1853 this.confirm.show(str('FORMATTING_WARNING'), function() {
1826 chrome.fileBrowserPrivate.formatDevice(urls[0]); 1854 chrome.fileBrowserPrivate.formatDevice(urls[0]);
1827 }); 1855 });
1828 } 1856 }
1829 }; 1857 };
1830 1858
1859 FileManager.prototype.getDeviceNumber = function(entry) {
1860 if (!entry.isDirectory) return false;
1861 for (var i = 0; i < this.mountPoints_.length; i++) {
1862 if (normalizeAbsolutePath(entry.fullPath) ==
1863 normalizeAbsolutePath(this.mountPoints_[i].mountPath)) {
1864 return i;
1865 }
1866 }
1867 return undefined;
1868 }
1869
1831 FileManager.prototype.openImageEditor_ = function(entry) { 1870 FileManager.prototype.openImageEditor_ = function(entry) {
1832 var self = this; 1871 var self = this;
1833 1872
1834 var editorFrame = this.document_.createElement('iframe'); 1873 var editorFrame = this.document_.createElement('iframe');
1835 editorFrame.className = 'overlay-pane'; 1874 editorFrame.className = 'overlay-pane';
1836 editorFrame.scrolling = 'no'; 1875 editorFrame.scrolling = 'no';
1837 1876
1838 editorFrame.onload = function() { 1877 editorFrame.onload = function() {
1839 self.cacheMetadata_(entry, function(metadata) { 1878 self.cacheMetadata_(entry, function(metadata) {
1840 editorFrame.contentWindow.ImageEditor.open( 1879 editorFrame.contentWindow.ImageEditor.open(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 this.previewFilename_.textContent = ''; 1964 this.previewFilename_.textContent = '';
1926 return; 1965 return;
1927 } 1966 }
1928 1967
1929 var previewName = this.selection.leadEntry.name; 1968 var previewName = this.selection.leadEntry.name;
1930 if (this.currentDirEntry_.name == '') 1969 if (this.currentDirEntry_.name == '')
1931 previewName = this.getLabelForRootPath_(previewName); 1970 previewName = this.getLabelForRootPath_(previewName);
1932 1971
1933 this.previewFilename_.textContent = previewName; 1972 this.previewFilename_.textContent = previewName;
1934 1973
1935 var iconType = getIconType(this.selection.leadEntry); 1974 var iconType = this.getIconType(this.selection.leadEntry);
1936 if (iconType == 'image') { 1975 if (iconType == 'image') {
1937 if (fileManager.selection.totalCount > 1) 1976 if (fileManager.selection.totalCount > 1)
1938 this.previewImage_.classList.add('multiple-selected'); 1977 this.previewImage_.classList.add('multiple-selected');
1939 } 1978 }
1940 1979
1941 var self = this; 1980 var self = this;
1942 var leadEntry = this.selection.leadEntry; 1981 var leadEntry = this.selection.leadEntry;
1943 1982
1944 this.getThumbnailURL(leadEntry, function(iconType, url) { 1983 this.getThumbnailURL(leadEntry, function(iconType, url) {
1945 if (self.selection.leadEntry != leadEntry) { 1984 if (self.selection.leadEntry != leadEntry) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 addProperty('DIMENSIONS_LABEL', 2121 addProperty('DIMENSIONS_LABEL',
2083 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value, 2122 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value,
2084 exifDir[0xa003].value)); 2123 exifDir[0xa003].value));
2085 } 2124 }
2086 }; 2125 };
2087 2126
2088 FileManager.prototype.getThumbnailURL = function(entry, callback) { 2127 FileManager.prototype.getThumbnailURL = function(entry, callback) {
2089 if (!entry) 2128 if (!entry)
2090 return; 2129 return;
2091 2130
2092 var iconType = getIconType(entry); 2131 var iconType = this.getIconType(entry);
2093 2132
2094 this.cacheMetadata_(entry, function (metadata) { 2133 this.cacheMetadata_(entry, function (metadata) {
2095 var url = metadata.thumbnailURL; 2134 var url = metadata.thumbnailURL;
2096 if (!url) { 2135 if (!url) {
2097 if (iconType == 'image') { 2136 if (iconType == 'image') {
2098 url = entry.toURL(); 2137 url = entry.toURL();
2099 } else { 2138 } else {
2100 url = previewArt[iconType] || previewArt['unknown']; 2139 url = previewArt[iconType] || previewArt['unknown'];
2101 } 2140 }
2102 } 2141 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 // Don't pay attention to double clicks during a rename. 2521 // Don't pay attention to double clicks during a rename.
2483 return; 2522 return;
2484 } 2523 }
2485 2524
2486 var entry = this.selection.leadEntry; 2525 var entry = this.selection.leadEntry;
2487 if (!entry) { 2526 if (!entry) {
2488 console.log('Invalid selection'); 2527 console.log('Invalid selection');
2489 return; 2528 return;
2490 } 2529 }
2491 2530
2492 if (entry.isDirectory) 2531 if (entry.isDirectory) {
2493 return this.changeDirectory(entry.fullPath); 2532 var deviceNumber = this.getDeviceNumber(entry);
2494 2533
2534 if (deviceNumber != undefined &&
2535 this.mountPoints_[deviceNumber].specialData ==
2536 'unreadable_unknown_filesystem') {
2537 return this.showButter(str('UNKNOWN_FILESYSTEM_WARNING'));
tbarzic 2011/08/24 03:59:44 do we really need different error messages for unk
sidor 2011/08/24 04:26:06 In the future I will add a message suggesting form
tbarzic 2011/08/25 02:03:44 ok
2538 } else if (deviceNumber != undefined &&
2539 this.mountPoints_[deviceNumber].specialData ==
2540 'unreadable_unsupported_filesystem') {
2541 return this.showButter(str('UNSUPPORTED_FILESYSTEM_WARNING'));
2542 } else {
2543 return this.changeDirectory(entry.fullPath);
2544 }
2545 }
2495 if (!this.okButton_.disabled) 2546 if (!this.okButton_.disabled)
2496 this.onOk_(); 2547 this.onOk_();
2497 2548
2498 }; 2549 };
2499 2550
2500 /** 2551 /**
2501 * Update the UI when the current directory changes. 2552 * Update the UI when the current directory changes.
2502 * 2553 *
2503 * @param {cr.Event} event The directory-changed event. 2554 * @param {cr.Event} event The directory-changed event.
2504 */ 2555 */
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
3147 3198
3148 if (msg) { 3199 if (msg) {
3149 console.log('no no no'); 3200 console.log('no no no');
3150 this.alert.show(msg, onAccept); 3201 this.alert.show(msg, onAccept);
3151 return false; 3202 return false;
3152 } 3203 }
3153 3204
3154 return true; 3205 return true;
3155 }; 3206 };
3156 })(); 3207 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698