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

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: merging conflict 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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 */ 201 */
202 const CP_RECURSE = true; 202 const CP_RECURSE = true;
203 const CP_NO_RECURSE = false; 203 const CP_NO_RECURSE = false;
204 204
205 /** 205 /**
206 * Translated strings. 206 * Translated strings.
207 */ 207 */
208 var localStrings; 208 var localStrings;
209 209
210 /** 210 /**
211 * Map of icon types to regular expressions. 211 * Map of icon types to regular expressions and functions
212 * 212 *
213 * The first regexp to match the file name determines the icon type 213 * The first regexp/function to match the entry name determines the icon type
214 * assigned to dom elements for a file. Order of evaluation is not 214 * assigned to dom elements for a file. Order of evaluation is not
215 * defined, so don't depend on it. 215 * defined, so don't depend on it.
216 */ 216 */
217 const iconTypes = { 217 const iconTypes = {
218 'audio': /\.(flac|mp3|m4a|oga|ogg|wav)$/i, 218 'audio': /\.(flac|mp3|m4a|oga|ogg|wav)$/i,
219 'html': /\.(html?)$/i, 219 'html': /\.(html?)$/i,
220 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i, 220 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i,
221 'pdf' : /\.(pdf)$/i, 221 'pdf' : /\.(pdf)$/i,
222 'text': /\.(pod|rst|txt|log)$/i, 222 'text': /\.(pod|rst|txt|log)$/i,
223 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i 223 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i,
224 'device': function(self, entry) {
225 var deviceNumber = self.getDeviceNumber(entry);
226 if (deviceNumber != undefined)
227 return (self.mountPoints_[deviceNumber].mountCondition == '');
228 return false;
229 },
230 'unreadable': function(self, entry) {
231 var deviceNumber = self.getDeviceNumber(entry);
232 if (deviceNumber != undefined) {
233 return self.mountPoints_[deviceNumber].mountCondition ==
234 'unknown_filesystem' ||
235 self.mountPoints_[deviceNumber].mountCondition ==
236 'unsupported_filesystem';
237 }
238 return false;
239 }
224 }; 240 };
225 241
226 const previewArt = { 242 const previewArt = {
227 'audio': 'images/filetype_large_audio.png', 243 'audio': 'images/filetype_large_audio.png',
244 // TODO(sidor): Find better icon here.
245 'device': 'images/filetype_large_folder.png',
228 'folder': 'images/filetype_large_folder.png', 246 'folder': 'images/filetype_large_folder.png',
229 'unknown': 'images/filetype_large_generic.png', 247 'unknown': 'images/filetype_large_generic.png',
248 // TODO(sidor): Find better icon here.
249 'unreadable': 'images/filetype_large_folder.png',
230 'video': 'images/filetype_large_video.png' 250 'video': 'images/filetype_large_video.png'
231 }; 251 };
232 252
233 /** 253 /**
234 * Regexp for archive files. Used to show mount-archive task. 254 * Regexp for archive files. Used to show mount-archive task.
235 */ 255 */
236 const ARCHIVES_REGEXP = /.zip$/; 256 const ARCHIVES_REGEXP = /.zip$/;
237 257
238 /** 258 /**
239 * Return a translated string. 259 * Return a translated string.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 * 307 *
288 * @param {string} path The file path. 308 * @param {string} path The file path.
289 */ 309 */
290 function getParentPath(path) { 310 function getParentPath(path) {
291 var parent = path.replace(/[\/]?[^\/]+[\/]?$/,''); 311 var parent = path.replace(/[\/]?[^\/]+[\/]?$/,'');
292 if (parent.length == 0) 312 if (parent.length == 0)
293 parent = '/'; 313 parent = '/';
294 return parent; 314 return parent;
295 } 315 }
296 316
297 /** 317 /**
298 * Get the icon type for a given Entry. 318 * Normalizes path not to start with /
299 * 319 *
300 * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry). 320 * @param {string} path The file path.
301 * @return {string} One of the keys from FileManager.iconTypes, or 321 */
302 * 'unknown'. 322 function normalizeAbsolutePath(x) {
303 */ 323 if (x[0] == '/')
304 function getIconType(entry) { 324 return x.slice(1);
305 if (entry.cachedIconType_) 325 else
306 return entry.cachedIconType_; 326 return x;
327 }
307 328
308 var rv = 'unknown';
309
310 if (entry.isDirectory) {
311 rv = 'folder';
312 } else {
313 for (var name in iconTypes) {
314 var value = iconTypes[name];
315
316 if (value instanceof RegExp) {
317 if (value.test(entry.name)) {
318 rv = name;
319 break;
320 }
321 } else if (typeof value == 'function') {
322 try {
323 if (value(entry)) {
324 rv = name;
325 break;
326 }
327 } catch (ex) {
328 console.error('Caught exception while evaluating iconType: ' +
329 name, ex);
330 }
331 } else {
332 console.log('Unexpected value in iconTypes[' + name + ']: ' + value);
333 }
334 }
335 }
336
337 entry.cachedIconType_ = rv;
338 return rv;
339 }
340 329
341 /** 330 /**
342 * Call an asynchronous method on dirEntry, batching multiple callers. 331 * Call an asynchronous method on dirEntry, batching multiple callers.
343 * 332 *
344 * This batches multiple callers into a single invocation, calling all 333 * This batches multiple callers into a single invocation, calling all
345 * interested parties back when the async call completes. 334 * interested parties back when the async call completes.
346 * 335 *
347 * The Entry method to be invoked should take two callbacks as parameters 336 * The Entry method to be invoked should take two callbacks as parameters
348 * (one for success and one for failure), and it should invoke those 337 * (one for success and one for failure), and it should invoke those
349 * callbacks with a single parameter representing the result of the call. 338 * callbacks with a single parameter representing the result of the call.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 }); 461 });
473 } else { 462 } else {
474 batchAsyncCall(entry, 'getMetadata', function(metadata) { 463 batchAsyncCall(entry, 'getMetadata', function(metadata) {
475 entry.cachedMtime_ = metadata.modificationTime; 464 entry.cachedMtime_ = metadata.modificationTime;
476 if (successCallback) 465 if (successCallback)
477 successCallback(entry); 466 successCallback(entry);
478 }, opt_errorCallback); 467 }, opt_errorCallback);
479 } 468 }
480 } 469 }
481 470
482 /**
483 * Get the icon type of a file, caching the result.
484 *
485 * When this method completes, the fileEntry object will get a
486 * 'cachedIconType_' property (if it doesn't already have one) containing the
487 * icon type of the file as a string.
488 *
489 * The successCallback is always invoked synchronously, since this does not
490 * actually require an async call. You should not depend on this, as it may
491 * change if we were to start reading magic numbers (for example).
492 *
493 * @param {Entry} entry An HTML5 Entry object.
494 * @param {function(Entry)} successCallback The function to invoke once the
495 * icon type is known.
496 */
497 function cacheEntryIconType(entry, successCallback) {
498 getIconType(entry);
499 if (successCallback)
500 setTimeout(function() { successCallback(entry) }, 0);
501 }
502
503 function isSystemDirEntry(dirEntry) { 471 function isSystemDirEntry(dirEntry) {
504 return dirEntry.fullPath == '/' || 472 return dirEntry.fullPath == '/' ||
505 dirEntry.fullPath == REMOVABLE_DIRECTORY || 473 dirEntry.fullPath == REMOVABLE_DIRECTORY ||
506 dirEntry.fullPath == ARCHIVE_DIRECTORY; 474 dirEntry.fullPath == ARCHIVE_DIRECTORY;
507 } 475 }
508 476
509 // Public statics. 477 // Public statics.
510 478
511 /** 479 /**
512 * List of dialog types. 480 * List of dialog types.
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 620
653 this.setListType(FileManager.ListType.DETAIL); 621 this.setListType(FileManager.ListType.DETAIL);
654 622
655 this.onResize_(); 623 this.onResize_();
656 this.dialogDom_.style.opacity = '1'; 624 this.dialogDom_.style.opacity = '1';
657 625
658 this.textSearchState_ = {text: '', date: new Date()}; 626 this.textSearchState_ = {text: '', date: new Date()};
659 }; 627 };
660 628
661 /** 629 /**
630 * Get the icon type for a given Entry.
631 *
632 * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry).
633 * @return {string} One of the keys from FileManager.iconTypes, or
634 * 'unknown'.
635 */
636 FileManager.prototype.getIconType = function(entry) {
637 if (entry.cachedIconType_)
638 return entry.cachedIconType_;
639
640 var rv = 'unknown';
641 if (entry.isDirectory)
642 rv = 'folder';
643 for (var name in iconTypes) {
644 var value = iconTypes[name];
645
646 if (value instanceof RegExp) {
647 if (value.test(entry.name)) {
648 rv = name;
649 break;
650 }
651 } else if (typeof value == 'function') {
652 try {
653 if (value(this,entry)) {
654 rv = name;
655 break;
656 }
657 } catch (ex) {
658 console.error('Caught exception while evaluating iconType: ' +
659 name, ex);
660 }
661 } else {
662 console.log('Unexpected value in iconTypes[' + name + ']: ' + value);
663 }
664 }
665 entry.cachedIconType_ = rv;
666 return rv;
667 };
668
669
670 /**
671 * Get the icon type of a file, caching the result.
672 *
673 * When this method completes, the fileEntry object will get a
674 * 'cachedIconType_' property (if it doesn't already have one) containing the
675 * icon type of the file as a string.
676 *
677 * The successCallback is always invoked synchronously, since this does not
678 * actually require an async call. You should not depend on this, as it may
679 * change if we were to start reading magic numbers (for example).
680 *
681 * @param {Entry} entry An HTML5 Entry object.
682 * @param {function(Entry)} successCallback The function to invoke once the
683 * icon type is known.
684 */
685 FileManager.prototype.cacheEntryIconType = function(entry, successCallback) {
686 this.getIconType(entry);
687 if (successCallback)
688 setTimeout(function() { successCallback(entry) }, 0);
689 }
690
691 /**
662 * Compare by mtime first, then by name. 692 * Compare by mtime first, then by name.
663 */ 693 */
664 FileManager.prototype.compareMtime_ = function(a, b) { 694 FileManager.prototype.compareMtime_ = function(a, b) {
665 if (a.cachedMtime_ > b.cachedMtime_) 695 if (a.cachedMtime_ > b.cachedMtime_)
666 return 1; 696 return 1;
667 697
668 if (a.cachedMtime_ < b.cachedMtime_) 698 if (a.cachedMtime_ < b.cachedMtime_)
669 return -1; 699 return -1;
670 700
671 return this.collator_.compare(a.name, b.name); 701 return this.collator_.compare(a.name, b.name);
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 FileManager.prototype.prepareSort_ = function(field, callback) { 1267 FileManager.prototype.prepareSort_ = function(field, callback) {
1238 var cacheFunction; 1268 var cacheFunction;
1239 1269
1240 if (field == 'name' || field == 'cachedMtime_') { 1270 if (field == 'name' || field == 'cachedMtime_') {
1241 // Mtime is the tie-breaker for a name sort, so we need to resolve 1271 // Mtime is the tie-breaker for a name sort, so we need to resolve
1242 // it for both mtime and name sorts. 1272 // it for both mtime and name sorts.
1243 cacheFunction = cacheEntryDate; 1273 cacheFunction = cacheEntryDate;
1244 } else if (field == 'cachedSize_') { 1274 } else if (field == 'cachedSize_') {
1245 cacheFunction = cacheEntrySize; 1275 cacheFunction = cacheEntrySize;
1246 } else if (field == 'cachedIconType_') { 1276 } else if (field == 'cachedIconType_') {
1247 cacheFunction = cacheEntryIconType; 1277 cacheFunction = this.cacheEntryIconType.bind(this);
1248 } else { 1278 } else {
1249 callback(); 1279 callback();
1250 return; 1280 return;
1251 } 1281 }
1252 1282
1253 function checkCount() { 1283 function checkCount() {
1254 if (uncachedCount == 0) { 1284 if (uncachedCount == 0) {
1255 // Callback via a setTimeout so the sync/async semantics don't change 1285 // Callback via a setTimeout so the sync/async semantics don't change
1256 // based on whether or not the value is cached. 1286 // based on whether or not the value is cached.
1257 setTimeout(callback, 0); 1287 setTimeout(callback, 0);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 */ 1374 */
1345 FileManager.prototype.renderIconType_ = function(entry, columnId, table) { 1375 FileManager.prototype.renderIconType_ = function(entry, columnId, table) {
1346 var div = this.document_.createElement('div'); 1376 var div = this.document_.createElement('div');
1347 div.className = 'detail-icon-container'; 1377 div.className = 'detail-icon-container';
1348 1378
1349 if (this.showCheckboxes_) 1379 if (this.showCheckboxes_)
1350 div.appendChild(this.renderCheckbox_(entry)); 1380 div.appendChild(this.renderCheckbox_(entry));
1351 1381
1352 var icon = this.document_.createElement('div'); 1382 var icon = this.document_.createElement('div');
1353 icon.className = 'detail-icon'; 1383 icon.className = 'detail-icon';
1354 entry.cachedIconType_ = getIconType(entry); 1384 entry.cachedIconType_ = this.getIconType(entry);
1355 icon.setAttribute('iconType', entry.cachedIconType_); 1385 icon.setAttribute('iconType', entry.cachedIconType_);
1356 div.appendChild(icon); 1386 div.appendChild(icon);
1357 1387
1358 return div; 1388 return div;
1359 }; 1389 };
1360 1390
1361 FileManager.prototype.getLabelForRootPath_ = function(path) { 1391 FileManager.prototype.getLabelForRootPath_ = function(path) {
1362 // This hack lets us localize the top level directories. 1392 // This hack lets us localize the top level directories.
1363 if (path == 'Downloads') 1393 if (path == 'Downloads')
1364 return str('DOWNLOADS_DIRECTORY_LABEL'); 1394 return str('DOWNLOADS_DIRECTORY_LABEL');
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 1509
1480 for (var i = 0; i < selection.indexes.length; i++) { 1510 for (var i = 0; i < selection.indexes.length; i++) {
1481 var entry = this.dataModel_.item(selection.indexes[i]); 1511 var entry = this.dataModel_.item(selection.indexes[i]);
1482 if (!entry) 1512 if (!entry)
1483 continue; 1513 continue;
1484 1514
1485 selection.entries.push(entry); 1515 selection.entries.push(entry);
1486 selection.urls.push(entry.toURL()); 1516 selection.urls.push(entry.toURL());
1487 1517
1488 if (selection.iconType == null) { 1518 if (selection.iconType == null) {
1489 selection.iconType = getIconType(entry); 1519 selection.iconType = this.getIconType(entry);
1490 } else if (selection.iconType != 'unknown') { 1520 } else if (selection.iconType != 'unknown') {
1491 var iconType = getIconType(entry); 1521 var iconType = this.getIconType(entry);
1492 if (selection.iconType != iconType) 1522 if (selection.iconType != iconType)
1493 selection.iconType = 'unknown'; 1523 selection.iconType = 'unknown';
1494 } 1524 }
1495 1525
1496 selection.totalCount++; 1526 selection.totalCount++;
1497 1527
1498 if (entry.isFile) { 1528 if (entry.isFile) {
1499 selection.fileCount += 1; 1529 selection.fileCount += 1;
1500 if (!('cachedSize_' in entry)) { 1530 if (!('cachedSize_' in entry)) {
1501 // Any file that hasn't been rendered may be missing its cachedSize_ 1531 // Any file that hasn't been rendered may be missing its cachedSize_
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 * @param {Object} selection Selected files object. 1742 * @param {Object} selection Selected files object.
1713 */ 1743 */
1714 FileManager.prototype.maybeRenderFormattingTask_ = function(selection) { 1744 FileManager.prototype.maybeRenderFormattingTask_ = function(selection) {
1715 // Not to make unnecessary getMountPoints() call we doublecheck if there is 1745 // Not to make unnecessary getMountPoints() call we doublecheck if there is
1716 // only one selected entry. 1746 // only one selected entry.
1717 if (selection.entries.length != 1) 1747 if (selection.entries.length != 1)
1718 return; 1748 return;
1719 var self = this; 1749 var self = this;
1720 function onMountPointsFound(mountPoints) { 1750 function onMountPointsFound(mountPoints) {
1721 self.mountPoints_ = mountPoints; 1751 self.mountPoints_ = mountPoints;
1722
1723 function normalize(x) {
1724 if (x[0] == '/')
1725 return x.slice(1);
1726 else
1727 return x;
1728 }
1729
1730 function onVolumeMetadataFound(volumeMetadata) { 1752 function onVolumeMetadataFound(volumeMetadata) {
1731 if (volumeMetadata.deviceType == "flash") { 1753 if (volumeMetadata.deviceType == "flash") {
1732 if (selection.entries.length != 1 || 1754 if (self.selection.entries.length != 1 ||
1733 normalize(selection.entries[0].fullPath) != 1755 normalizeAbsolutePath(self.selection.entries[0].fullPath) !=
1734 normalize(volumeMetadata.mountPath)) { 1756 normalizeAbsolutePath(volumeMetadata.mountPath)) {
1735 return; 1757 return;
1736 } 1758 }
1737 var task = { 1759 var task = {
1738 taskId: self.getExtensionId_() + '|format-device', 1760 taskId: self.getExtensionId_() + '|format-device',
1739 iconUrl: chrome.extension.getURL('images/filetype_generic.png'), 1761 iconUrl: chrome.extension.getURL('images/filetype_generic.png'),
1740 title: str('FORMAT_DEVICE') 1762 title: str('FORMAT_DEVICE')
1741 }; 1763 };
1742 self.renderTaskButton_(task); 1764 self.renderTaskButton_(task);
1743 } 1765 }
1744 } 1766 }
1745 1767
1746 if (selection.entries.length != 1) 1768 if (selection.entries.length != 1)
1747 return; 1769 return;
1748 var selectedPath = selection.entries[0].fullPath; 1770 var selectedPath = selection.entries[0].fullPath;
1749 for (var i = 0; i < mountPoints.length; i++) { 1771 for (var i = 0; i < mountPoints.length; i++) {
1750 if (mountPoints[i].mountType == "device" && 1772 if (mountPoints[i].mountType == "device" &&
1751 normalize(mountPoints[i].mountPath) == normalize(selectedPath)) { 1773 normalizeAbsolutePath(mountPoints[i].mountPath) ==
1774 normalizeAbsolutePath(selectedPath)) {
1752 chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl, 1775 chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl,
1753 onVolumeMetadataFound); 1776 onVolumeMetadataFound);
1754 return; 1777 return;
1755 } 1778 }
1756 } 1779 }
1757 } 1780 }
1758 1781
1759 chrome.fileBrowserPrivate.getMountPoints(onMountPointsFound); 1782 chrome.fileBrowserPrivate.getMountPoints(onMountPointsFound);
1760 }; 1783 };
1761 1784
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 } 1818 }
1796 } 1819 }
1797 1820
1798 if (event.eventType == 'unmount' && event.status == 'success' && 1821 if (event.eventType == 'unmount' && event.status == 'success' &&
1799 self.currentDirEntry_ && 1822 self.currentDirEntry_ &&
1800 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) { 1823 isParentPath(event.mountPath, self.currentDirEntry_.fullPath)) {
1801 self.changeDirectory(getParentPath(event.mountPath)); 1824 self.changeDirectory(getParentPath(event.mountPath));
1802 return; 1825 return;
1803 } 1826 }
1804 1827
1828 var rescanDirectoryNeeded = (event.status == 'success');
1829 for (var i = 0; i < mountPoints.length; i++) {
1830 if (event.sourceUrl == mountPoints[i].sourceUrl &&
1831 mountPoints[i].mountCondition != '') {
1832 rescanDirectoryNeeded = true;
1833 }
1834 }
1805 // TODO(dgozman): rescan directory, only if it contains mounted points, 1835 // TODO(dgozman): rescan directory, only if it contains mounted points,
1806 // when mounts location will be decided. 1836 // when mounts location will be decided.
1807 if (event.status == 'success' || 1837 if (rescanDirectoryNeeded)
1808 event.status == 'error_unknown_filesystem' ||
1809 event.status == 'error_unsuported_filesystem')
1810 self.rescanDirectory_(null, 300); 1838 self.rescanDirectory_(null, 300);
1811 }); 1839 });
1812 }; 1840 };
1813 1841
1814 /** 1842 /**
1815 * Event handler called when some internal task should be executed. 1843 * Event handler called when some internal task should be executed.
1816 */ 1844 */
1817 FileManager.prototype.onFileTaskExecute_ = function(id, details) { 1845 FileManager.prototype.onFileTaskExecute_ = function(id, details) {
1818 var urls = details.entries.map(function(entry) { 1846 var urls = details.entries.map(function(entry) {
1819 return entry.toURL(); 1847 return entry.toURL();
(...skipping 14 matching lines...) Expand all
1834 for (var index = 0; index < urls.length; ++index) { 1862 for (var index = 0; index < urls.length; ++index) {
1835 chrome.fileBrowserPrivate.removeMount(urls[index]); 1863 chrome.fileBrowserPrivate.removeMount(urls[index]);
1836 } 1864 }
1837 } else if (id == 'format-device') { 1865 } else if (id == 'format-device') {
1838 this.confirm.show(str('FORMATTING_WARNING'), function() { 1866 this.confirm.show(str('FORMATTING_WARNING'), function() {
1839 chrome.fileBrowserPrivate.formatDevice(urls[0]); 1867 chrome.fileBrowserPrivate.formatDevice(urls[0]);
1840 }); 1868 });
1841 } 1869 }
1842 }; 1870 };
1843 1871
1872 FileManager.prototype.getDeviceNumber = function(entry) {
1873 if (!entry.isDirectory) return false;
1874 for (var i = 0; i < this.mountPoints_.length; i++) {
1875 if (normalizeAbsolutePath(entry.fullPath) ==
1876 normalizeAbsolutePath(this.mountPoints_[i].mountPath)) {
1877 return i;
1878 }
1879 }
1880 return undefined;
1881 }
1882
1844 FileManager.prototype.openImageEditor_ = function(entry) { 1883 FileManager.prototype.openImageEditor_ = function(entry) {
1845 var self = this; 1884 var self = this;
1846 1885
1847 var editorFrame = this.document_.createElement('iframe'); 1886 var editorFrame = this.document_.createElement('iframe');
1848 editorFrame.className = 'overlay-pane'; 1887 editorFrame.className = 'overlay-pane';
1849 editorFrame.scrolling = 'no'; 1888 editorFrame.scrolling = 'no';
1850 1889
1851 editorFrame.onload = function() { 1890 editorFrame.onload = function() {
1852 self.cacheMetadata_(entry, function(metadata) { 1891 self.cacheMetadata_(entry, function(metadata) {
1853 editorFrame.contentWindow.ImageEditor.open( 1892 editorFrame.contentWindow.ImageEditor.open(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 this.previewFilename_.textContent = ''; 1977 this.previewFilename_.textContent = '';
1939 return; 1978 return;
1940 } 1979 }
1941 1980
1942 var previewName = this.selection.leadEntry.name; 1981 var previewName = this.selection.leadEntry.name;
1943 if (this.currentDirEntry_.name == '') 1982 if (this.currentDirEntry_.name == '')
1944 previewName = this.getLabelForRootPath_(previewName); 1983 previewName = this.getLabelForRootPath_(previewName);
1945 1984
1946 this.previewFilename_.textContent = previewName; 1985 this.previewFilename_.textContent = previewName;
1947 1986
1948 var iconType = getIconType(this.selection.leadEntry); 1987 var iconType = this.getIconType(this.selection.leadEntry);
1949 if (iconType == 'image') { 1988 if (iconType == 'image') {
1950 if (fileManager.selection.totalCount > 1) 1989 if (fileManager.selection.totalCount > 1)
1951 this.previewImage_.classList.add('multiple-selected'); 1990 this.previewImage_.classList.add('multiple-selected');
1952 } 1991 }
1953 1992
1954 var self = this; 1993 var self = this;
1955 var leadEntry = this.selection.leadEntry; 1994 var leadEntry = this.selection.leadEntry;
1956 1995
1957 this.getThumbnailURL(leadEntry, function(iconType, url) { 1996 this.getThumbnailURL(leadEntry, function(iconType, url) {
1958 if (self.selection.leadEntry != leadEntry) { 1997 if (self.selection.leadEntry != leadEntry) {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
2095 addProperty('DIMENSIONS_LABEL', 2134 addProperty('DIMENSIONS_LABEL',
2096 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value, 2135 strf('DIMENSIONS_FORMAT', exifDir[0xa002].value,
2097 exifDir[0xa003].value)); 2136 exifDir[0xa003].value));
2098 } 2137 }
2099 }; 2138 };
2100 2139
2101 FileManager.prototype.getThumbnailURL = function(entry, callback) { 2140 FileManager.prototype.getThumbnailURL = function(entry, callback) {
2102 if (!entry) 2141 if (!entry)
2103 return; 2142 return;
2104 2143
2105 var iconType = getIconType(entry); 2144 var iconType = this.getIconType(entry);
2106 2145
2107 this.cacheMetadata_(entry, function (metadata) { 2146 this.cacheMetadata_(entry, function (metadata) {
2108 var url = metadata.thumbnailURL; 2147 var url = metadata.thumbnailURL;
2109 if (!url) { 2148 if (!url) {
2110 if (iconType == 'image') { 2149 if (iconType == 'image') {
2111 url = entry.toURL(); 2150 url = entry.toURL();
2112 } else { 2151 } else {
2113 url = previewArt[iconType] || previewArt['unknown']; 2152 url = previewArt[iconType] || previewArt['unknown'];
2114 } 2153 }
2115 } 2154 }
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2495 // Don't pay attention to double clicks during a rename. 2534 // Don't pay attention to double clicks during a rename.
2496 return; 2535 return;
2497 } 2536 }
2498 2537
2499 var entry = this.selection.leadEntry; 2538 var entry = this.selection.leadEntry;
2500 if (!entry) { 2539 if (!entry) {
2501 console.log('Invalid selection'); 2540 console.log('Invalid selection');
2502 return; 2541 return;
2503 } 2542 }
2504 2543
2505 if (entry.isDirectory) 2544 if (entry.isDirectory) {
2506 return this.changeDirectory(entry.fullPath); 2545 return this.onDirectoryAction(entry);
2546 }
2507 2547
2508 if (!this.okButton_.disabled) 2548 if (!this.okButton_.disabled)
2509 this.onOk_(); 2549 this.onOk_();
2510 2550
2511 }; 2551 };
2512 2552
2553 FileManager.prototype.onDirectoryAction = function(entry) {
2554 var deviceNumber = this.getDeviceNumber(entry);
2555 if (deviceNumber != undefined &&
2556 this.mountPoints_[deviceNumber].mountCondition ==
2557 'unknown_filesystem') {
2558 return this.showButter(str('UNKNOWN_FILESYSTEM_WARNING'));
2559 } else if (deviceNumber != undefined &&
2560 this.mountPoints_[deviceNumber].mountCondition ==
2561 'unsupported_filesystem') {
2562 return this.showButter(str('UNSUPPORTED_FILESYSTEM_WARNING'));
2563 } else {
2564 return this.changeDirectory(entry.fullPath);
2565 }
2566 }
2567
2513 /** 2568 /**
2514 * Update the UI when the current directory changes. 2569 * Update the UI when the current directory changes.
2515 * 2570 *
2516 * @param {cr.Event} event The directory-changed event. 2571 * @param {cr.Event} event The directory-changed event.
2517 */ 2572 */
2518 FileManager.prototype.onDirectoryChanged_ = function(event) { 2573 FileManager.prototype.onDirectoryChanged_ = function(event) {
2519 this.updateCommands_(); 2574 this.updateCommands_();
2520 this.updateOkButton_(); 2575 this.updateOkButton_();
2521 2576
2522 // New folder should never be enabled in the root or media/ directories. 2577 // New folder should never be enabled in the root or media/ directories.
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
2965 var path = path.replace(/\/[^\/]+$/, ''); 3020 var path = path.replace(/\/[^\/]+$/, '');
2966 this.changeDirectory(path || '/'); 3021 this.changeDirectory(path || '/');
2967 } 3022 }
2968 break; 3023 break;
2969 3024
2970 case 13: // Enter => Change directory or complete dialog. 3025 case 13: // Enter => Change directory or complete dialog.
2971 if (this.selection.totalCount == 1 && 3026 if (this.selection.totalCount == 1 &&
2972 this.selection.leadEntry.isDirectory && 3027 this.selection.leadEntry.isDirectory &&
2973 this.dialogType_ != FileManager.SELECT_FOLDER) { 3028 this.dialogType_ != FileManager.SELECT_FOLDER) {
2974 event.preventDefault(); 3029 event.preventDefault();
2975 this.changeDirectory(this.selection.leadEntry.fullPath); 3030 this.onDirectoryAction(this.selection.leadEntry);
2976 } else if (!this.okButton_.disabled) { 3031 } else if (!this.okButton_.disabled) {
2977 event.preventDefault(); 3032 event.preventDefault();
2978 this.onOk_(); 3033 this.onOk_();
2979 } 3034 }
2980 break; 3035 break;
2981 3036
2982 case 32: // Ctrl-Space => New Folder. 3037 case 32: // Ctrl-Space => New Folder.
2983 if (this.newFolderButton_.style.display != 'none' && event.ctrlKey) { 3038 if (this.newFolderButton_.style.display != 'none' && event.ctrlKey) {
2984 event.preventDefault(); 3039 event.preventDefault();
2985 this.onNewFolderButtonClick_(); 3040 this.onNewFolderButtonClick_();
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
3211 3266
3212 if (msg) { 3267 if (msg) {
3213 console.log('no no no'); 3268 console.log('no no no');
3214 this.alert.show(msg, onAccept); 3269 this.alert.show(msg, onAccept);
3215 return false; 3270 return false;
3216 } 3271 }
3217 3272
3218 return true; 3273 return true;
3219 }; 3274 };
3220 })(); 3275 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/css/file_manager.css ('k') | chrome/browser/resources/file_manager/js/mock_chrome.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698