Chromium Code Reviews| Index: chrome/browser/resources/file_manager/foreground/js/file_manager.js |
| diff --git a/chrome/browser/resources/file_manager/foreground/js/file_manager.js b/chrome/browser/resources/file_manager/foreground/js/file_manager.js |
| index e39955e48ae4e87eeb5b68642fc5ffc9f7cbb46a..54889307362a312873156096ed16ac6e8d772135 100644 |
| --- a/chrome/browser/resources/file_manager/foreground/js/file_manager.js |
| +++ b/chrome/browser/resources/file_manager/foreground/js/file_manager.js |
| @@ -44,6 +44,13 @@ function FileManager() { |
| * @private |
| */ |
| this.currentVolumeInfo_ = null; |
| + |
| + /** |
| + * Whether to show dot files in the non-Drive folder. Default: false. |
| + * @type {boolean} |
| + * @private |
| + */ |
| + this.dotFilesHidden_ = false; |
| } |
| FileManager.prototype = { |
| @@ -907,9 +914,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| this.dialogType == DialogType.SELECT_UPLOAD_FOLDER || |
| this.dialogType == DialogType.SELECT_SAVEAS_FILE; |
| - this.fileFilter_ = new FileFilter( |
| - this.metadataCache_, |
| - false /* Don't show dot files by default. */); |
| + this.fileFilter_ = new FileFilter(this.metadataCache_); |
| this.fileWatcher_ = new FileWatcher(this.metadataCache_); |
| this.fileWatcher_.addEventListener( |
| @@ -1313,6 +1318,32 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| }; |
| /** |
| + * Filters dot files if the setting is enabled and the current directory is |
| + * '/Downloads'. |
| + * |
| + * @return {boolean} True if the filter is enabled, false otherwise. |
| + * @private |
| + */ |
| + FileManager.prototype.updateDotFilesFilter_ = function() { |
| + var enabled = |
| + this.dotFilesHidden_ && |
| + this.currentVolumeInfo_ && |
| + this.currentVolumeInfo_.volumeType !== util.VolumeType.DRIVE; |
| + |
| + if (enabled) { |
| + this.fileFilter_.addFilter( |
| + 'dot-file-hidden', |
| + function(entry) { |
| + return (entry.name.substr(0, 1) !== '.'); |
|
hirono
2014/01/30 08:07:01
nit: entry.name[0] or entry.name.charAt(0) ?
|
| + }); |
| + } else { |
| + this.fileFilter_.removeFilter('dot-file-hidden'); |
| + } |
| + |
| + return enabled; |
| + }; |
| + |
| + /** |
| * Resize details and thumb views to fit the new window size. |
| * @private |
| */ |
| @@ -2308,6 +2339,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| '' /* selectionPath */, |
| '' /* opt_param */); |
| + this.updateDotFilesFilter_(); |
| + |
| if (this.commandHandler) |
| this.commandHandler.updateAvailability(); |
| @@ -2841,9 +2874,8 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| switch (util.getKeyModifiers(event) + event.keyCode) { |
| case 'Ctrl-190': // Ctrl-. => Toggle filter files. |
| - this.fileFilter_.setFilterHidden( |
| - !this.fileFilter_.isFilterHiddenOn()); |
| - event.preventDefault(); |
| + this.dotFilesHidden_ = !this.dotFilesHidden_; |
| + this.updateDotFilesFilter_(); |
| return; |
| case '27': // Escape => Cancel dialog. |
| @@ -3310,7 +3342,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; |
| msg = str('ERROR_WHITESPACE_NAME'); |
| } else if (/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name)) { |
| msg = str('ERROR_RESERVED_NAME'); |
| - } else if (this.fileFilter_.isFilterHiddenOn() && name[0] == '.') { |
| + } else if (this.updateDotFilesFilter_() && name[0] == '.') { |
| msg = str('ERROR_HIDDEN_NAME'); |
| } |