From 6e7df01d4614df70ec2a1418a6b36717e21c85f3 Mon Sep 17 00:00:00 2001 From: fukino Date: Fri, 5 Sep 2014 01:25:01 -0700 Subject: [PATCH] Hide .crdownload files and prevent users from changing extension to it. BUG=409490 TEST=manually Review URL: https://codereview.chromium.org/528263002 Cr-Commit-Position: refs/heads/master@{#293477} --- ui/file_manager/file_manager/common/js/util.js | 2 ++ ui/file_manager/file_manager/foreground/js/directory_contents.js | 9 +++++++-- ui/file_manager/file_manager/foreground/js/file_manager.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ui/file_manager/file_manager/common/js/util.js b/ui/file_manager/file_manager/common/js/util.js index 25af53434638..757955f6e91f 100644 --- a/ui/file_manager/file_manager/common/js/util.js +++ b/ui/file_manager/file_manager/common/js/util.js @@ -1344,6 +1344,8 @@ util.validateFileName = function(parentEntry, name, filterHiddenOn) { return Promise.reject(str('ERROR_WHITESPACE_NAME')); else if (/^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i.test(name)) return Promise.reject(str('ERROR_RESERVED_NAME')); + else if (filterHiddenOn && /\.crdownload$/i.test(name)) + return Promise.reject(str('ERROR_RESERVED_NAME')); else if (filterHiddenOn && name[0] == '.') return Promise.reject(str('ERROR_HIDDEN_NAME')); diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js index a436f9459183..ca3f2e69e6c6 100644 --- a/ui/file_manager/file_manager/foreground/js/directory_contents.js +++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js @@ -319,7 +319,8 @@ DriveMetadataSearchContentScanner.prototype.scan = function( * When filters are changed, a 'changed' event is fired. * * @param {MetadataCache} metadataCache Metadata cache service. - * @param {boolean} showHidden If files starting with '.' are shown. + * @param {boolean} showHidden If files starting with '.' or ending with + * '.crdownlaod' are shown. * @constructor * @extends {cr.EventTarget} */ @@ -371,10 +372,14 @@ FileFilter.prototype.removeFilter = function(name) { * @param {boolean} value If do not show hidden files. */ FileFilter.prototype.setFilterHidden = function(value) { + var regexpCrdownloadExtension = /\.crdownload$/i; if (value) { this.addFilter( 'hidden', - function(entry) { return entry.name.substr(0, 1) !== '.'; } + function(entry) { + return entry.name.substr(0, 1) !== '.' && + !regexpCrdownloadExtension.test(entry.name); + } ); } else { this.removeFilter('hidden'); diff --git a/ui/file_manager/file_manager/foreground/js/file_manager.js b/ui/file_manager/file_manager/foreground/js/file_manager.js index 7ca5611b8c2b..c83cc47e47ee 100644 --- a/ui/file_manager/file_manager/foreground/js/file_manager.js +++ b/ui/file_manager/file_manager/foreground/js/file_manager.js @@ -932,7 +932,7 @@ var BOTTOM_MARGIN_FOR_PREVIEW_PANEL_PX = 52; this.fileFilter_ = new FileFilter( this.metadataCache_, - false /* Don't show dot files by default. */); + false /* Don't show dot files and *.crdownload by default. */); this.fileWatcher_ = new FileWatcher(this.metadataCache_); this.fileWatcher_.addEventListener( -- 2.11.4.GIT