diff options
author | sidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-27 04:56:20 +0000 |
---|---|---|
committer | sidor@chromium.org <sidor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-27 04:56:20 +0000 |
commit | bb04179fb837602c0d3e494179c15fed0bd75b0e (patch) | |
tree | b2651bd79de349bbde0ad4eeb13f80034f161a96 /chrome | |
parent | 141adb47cecd5b550ac02bd7e34f71d0d898e1ab (diff) | |
download | chromium_src-bb04179fb837602c0d3e494179c15fed0bd75b0e.zip chromium_src-bb04179fb837602c0d3e494179c15fed0bd75b0e.tar.gz chromium_src-bb04179fb837602c0d3e494179c15fed0bd75b0e.tar.bz2 |
This is UI side unreadable device support.
Mostly format manager code, that diplays and handles unreadalbe device. There's option to format them. One cannot access them.
Icons were added as well.
Depends on the following change in ChromeOS: http://gerrit.chromium.org/gerrit/#change,6406
BUG=19506
TEST=None.
Review URL: http://codereview.chromium.org/7706028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98548 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
11 files changed, 249 insertions, 121 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 78b6dc7..56c85c5 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -9216,6 +9216,12 @@ Keep your key file in a safe place. You will need it to create new versions of y Are you sure you want to delete $1 items? </message> + <message name="IDS_FILE_BROWSER_UNKNOWN_FILESYSTEM_WARNING" desc="Displayed when device contents cannot be read because filesystem is unknown."> + This device cannot be opened because its filesystem was not recognized. + </message> + <message name="IDS_FILE_BROWSER_UNSUPPORTED_FILESYSTEM_WARNING" desc="Displayed when device contents cannot be read because filesystem is unsupported."> + This device cannot be opened because its filesystem is not supported. + </message> <message name="IDS_FILE_BROWSER_FORMATTING_WARNING" desc="Displayed when you attempt to format device."> Formatting the removable media is going to erase all data. Do you wish to continue? </message> diff --git a/chrome/browser/chromeos/cros/mount_library.cc b/chrome/browser/chromeos/cros/mount_library.cc index 952f1dd..12f969b 100644 --- a/chrome/browser/chromeos/cros/mount_library.cc +++ b/chrome/browser/chromeos/cros/mount_library.cc @@ -34,6 +34,20 @@ std::string MountLibrary::MountTypeToString(MountType type) { return ""; } +std::string MountLibrary::MountConditionToString(MountCondition condition) { + switch (condition) { + case MOUNT_CONDITION_NONE: + return ""; + case MOUNT_CONDITION_UNKNOWN_FILESYSTEM: + return "unknown_filesystem"; + case MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM: + return "unsupported_filesystem"; + default: + NOTREACHED(); + } + return ""; +} + // static MountType MountLibrary::MountTypeFromString( const std::string& type_str) { @@ -173,7 +187,10 @@ class MountLibraryImpl : public MountLibrary { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); if (!CrosLibrary::Get()->EnsureLoaded()) { OnMountCompleted(MOUNT_ERROR_LIBRARY_NOT_LOADED, - MountPointInfo(source_path, NULL, type)); + MountPointInfo(source_path, + NULL, + type, + MOUNT_CONDITION_NONE)); return; } libcros_proxy_->CallMountPath(source_path, type, options, @@ -330,9 +347,20 @@ class MountLibraryImpl : public MountLibrary { MountType type, const char* mount_path) { DCHECK(object); + MountCondition mount_condition = MOUNT_CONDITION_NONE; + if (type == MOUNT_TYPE_DEVICE) { + if (error_code == MOUNT_ERROR_UNKNOWN_FILESYSTEM) + mount_condition = MOUNT_CONDITION_UNKNOWN_FILESYSTEM; + if (error_code == MOUNT_ERROR_UNSUPORTED_FILESYSTEM) + mount_condition = MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; + } + MountLibraryImpl* self = static_cast<MountLibraryImpl*>(object); self->OnMountCompleted(static_cast<MountError>(error_code), - MountPointInfo(source_path, mount_path, type)); + MountPointInfo(source_path, + mount_path, + type, + mount_condition)); } // Callback for UnmountRemovableDevice method. @@ -437,20 +465,14 @@ class MountLibraryImpl : public MountLibrary { // If the device is corrupted but it's still possible to format it, it will // be fake mounted. - // TODO(sidor): Write more general condition when it will possible. - bool mount_corrupted_device = - (error_code == MOUNT_ERROR_UNKNOWN_FILESYSTEM || - error_code == MOUNT_ERROR_UNSUPORTED_FILESYSTEM) && - mount_info.mount_type == MOUNT_TYPE_DEVICE; - - if ((error_code == MOUNT_ERROR_NONE || mount_corrupted_device) && + if ((error_code == MOUNT_ERROR_NONE || mount_info.mount_condition) && mount_points_.find(mount_info.mount_path) == mount_points_.end()) { mount_points_.insert(MountPointMap::value_type( mount_info.mount_path.c_str(), mount_info)); } - if ((error_code == MOUNT_ERROR_NONE || mount_corrupted_device) && + if ((error_code == MOUNT_ERROR_NONE || mount_info.mount_condition) && mount_info.mount_type == MOUNT_TYPE_DEVICE && !mount_info.source_path.empty() && !mount_info.mount_path.empty()) { @@ -480,7 +502,8 @@ class MountLibraryImpl : public MountLibrary { MOUNT_ERROR_NONE, MountPointInfo(mount_points_it->second.source_path.c_str(), mount_points_it->second.mount_path.c_str(), - mount_points_it->second.mount_type)); + mount_points_it->second.mount_type, + mount_points_it->second.mount_condition)); std::string path(mount_points_it->second.source_path); mount_points_.erase(mount_points_it); DiskMap::iterator iter = disks_.find(path); diff --git a/chrome/browser/chromeos/cros/mount_library.h b/chrome/browser/chromeos/cros/mount_library.h index 688c8b1..8108f44 100644 --- a/chrome/browser/chromeos/cros/mount_library.h +++ b/chrome/browser/chromeos/cros/mount_library.h @@ -29,6 +29,12 @@ typedef enum MountLibraryEventType { MOUNT_FORMATTING_FINISHED } MountLibraryEventType; +typedef enum MountCondition { + MOUNT_CONDITION_NONE, + MOUNT_CONDITION_UNKNOWN_FILESYSTEM, + MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM +} MountCondition; + class MountLibcrosProxy { public: virtual ~MountLibcrosProxy() {} @@ -135,11 +141,14 @@ class MountLibrary { std::string source_path; std::string mount_path; MountType mount_type; + MountCondition mount_condition; - MountPointInfo(const char* source, const char* mount, const MountType type) + MountPointInfo(const char* source, const char* mount, const MountType type, + MountCondition condition) : source_path(source ? source : ""), mount_path(mount ? mount : ""), - mount_type(type) { + mount_type(type), + mount_condition(condition) { } }; @@ -155,7 +164,7 @@ class MountLibrary { virtual void DiskChanged(MountLibraryEventType event, const Disk* disk) = 0; virtual void DeviceChanged(MountLibraryEventType event, - const std::string& device_path ) = 0; + const std::string& device_path) = 0; virtual void MountCompleted(MountEvent event_type, MountError error_code, const MountPointInfo& mount_info) = 0; @@ -189,6 +198,7 @@ class MountLibrary { // Helper functions for parameter conversions. static std::string MountTypeToString(MountType type); static MountType MountTypeFromString(const std::string& type_str); + static std::string MountConditionToString(MountCondition type); // Used in testing. Enables mocking libcros. virtual void SetLibcrosProxy(MountLibcrosProxy* proxy) {} diff --git a/chrome/browser/chromeos/extensions/file_browser_event_router.cc b/chrome/browser/chromeos/extensions/file_browser_event_router.cc index 5c0fc99..aa01068 100644 --- a/chrome/browser/chromeos/extensions/file_browser_event_router.cc +++ b/chrome/browser/chromeos/extensions/file_browser_event_router.cc @@ -344,16 +344,10 @@ void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( FilePath relative_mount_path; bool relative_mount_path_set = false; - // If the device is corrupted but it's still possible to format it, it will - // be fake mounted. - // TODO(sidor): Write more general condition when it will possible. - bool mount_corrupted_device = - (error_code == chromeos::MOUNT_ERROR_UNKNOWN_FILESYSTEM || - error_code == chromeos::MOUNT_ERROR_UNSUPORTED_FILESYSTEM) && - mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE; - - // If there were no error, add mountPath to the event. - if (error_code == chromeos::MOUNT_ERROR_NONE || mount_corrupted_device) { + // If there were no error or some special conditions occured, add mountPath + // to the event. + if (error_code == chromeos::MOUNT_ERROR_NONE || + mount_info.mount_condition) { // Convert mount point path to relative path with the external file system // exposed within File API. if (FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, @@ -373,7 +367,7 @@ void ExtensionFileBrowserEventRouter::DispatchMountCompletedEvent( if (relative_mount_path_set && mount_info.mount_type == chromeos::MOUNT_TYPE_DEVICE && - !mount_corrupted_device && // User should not be bothered by that. + !mount_info.mount_condition && event == chromeos::MountLibrary::MOUNTING) { FileManagerUtil::ShowFullTabUrl(profile_, FilePath(mount_info.mount_path)); } diff --git a/chrome/browser/extensions/extension_file_browser_private_api.cc b/chrome/browser/extensions/extension_file_browser_private_api.cc index 0a6be00..2cd65da 100644 --- a/chrome/browser/extensions/extension_file_browser_private_api.cc +++ b/chrome/browser/extensions/extension_file_browser_private_api.cc @@ -268,6 +268,10 @@ base::DictionaryValue* MountPointToValue(Profile* profile, mount_info->SetString("mountPath", relative_mount_path.value()); } + mount_info->SetString("mountCondition", + chromeos::MountLibrary::MountConditionToString( + mount_point_info.mount_condition)); + return mount_info; } #endif @@ -1346,12 +1350,15 @@ bool GetVolumeMetadataFunction::RunImpl() { DictionaryValue* volume_info = new DictionaryValue(); result_.reset(volume_info); // Localising mount path. - FilePath relative_mount_path; - FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, - FilePath(volume->mount_path()), &relative_mount_path); - + std::string mount_path; + if (!volume->mount_path().empty()) { + FilePath relative_mount_path; + FileManagerUtil::ConvertFileToRelativeFileSystemPath(profile_, + FilePath(volume->mount_path()), &relative_mount_path); + mount_path = relative_mount_path.value(); + } volume_info->SetString("devicePath", volume->device_path()); - volume_info->SetString("mountPath", relative_mount_path.value()); + volume_info->SetString("mountPath", mount_path); volume_info->SetString("systemPath", volume->system_path()); volume_info->SetString("filePath", volume->file_path()); volume_info->SetString("deviceLabel", volume->device_label()); @@ -1477,6 +1484,8 @@ bool FileDialogStringsFunction::RunImpl() { SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_ONE); SET_STRING(IDS_FILE_BROWSER, CONFIRM_DELETE_SOME); + SET_STRING(IDS_FILE_BROWSER, UNKNOWN_FILESYSTEM_WARNING); + SET_STRING(IDS_FILE_BROWSER, UNSUPPORTED_FILESYSTEM_WARNING); SET_STRING(IDS_FILE_BROWSER, FORMATTING_WARNING); SET_STRING(IDS_FILE_BROWSER, SELECT_FOLDER_TITLE); diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd index 718348b..90b7b12 100644 --- a/chrome/browser/resources/component_extension_resources.grd +++ b/chrome/browser/resources/component_extension_resources.grd @@ -46,6 +46,7 @@ <include name="IDR_FILE_MANAGER_ARCHIVE_UNMOUNT_ICON" file="file_manager/images/icon_unmount_archive_16x16.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_AUDIO" file="file_manager/images/filetype_audio.png" type="BINDATA" /> + <include name="IDR_FILE_MANAGER_IMG_FILETYPE_DEVICE" file="file_manager/images/filetype_device.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_DOC" file="file_manager/images/filetype_doc.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_FOLDER" file="file_manager/images/filetype_folder.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_GENERIC" file="file_manager/images/filetype_generic.png" type="BINDATA" /> @@ -54,6 +55,7 @@ <include name="IDR_FILE_MANAGER_IMG_FILETYPE_PDF" file="file_manager/images/filetype_pdf.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_PRESENTATION" file="file_manager/images/filetype_presentation.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_SPREADSHEET" file="file_manager/images/filetype_spreadsheet.png" type="BINDATA" /> + <include name="IDR_FILE_MANAGER_IMG_FILETYPE_UNREADABLE_DEVICE" file="file_manager/images/filetype_unreadable_device.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_TEXT" file="file_manager/images/filetype_text.png" type="BINDATA" /> <include name="IDR_FILE_MANAGER_IMG_FILETYPE_VIDEO" file="file_manager/images/filetype_video.png" type="BINDATA" /> diff --git a/chrome/browser/resources/file_manager/css/file_manager.css b/chrome/browser/resources/file_manager/css/file_manager.css index 16316e3..1071a31 100644 --- a/chrome/browser/resources/file_manager/css/file_manager.css +++ b/chrome/browser/resources/file_manager/css/file_manager.css @@ -325,6 +325,10 @@ li.thumbnail-item[selected] .file-checkbox { background-image: url(../images/filetype_audio.png); } +.detail-icon[iconType="device"] { + background-image: url(../images/filetype_device.png); +} + .detail-icon[iconType="doc"] { background-image: url(../images/filetype_doc.png); } @@ -357,6 +361,10 @@ li.thumbnail-item[selected] .file-checkbox { background-image: url(../images/filetype_text.png); } +.detail-icon[iconType="unreadable"] { + background-image: url(../images/filetype_unreadable_device.png); +} + .detail-icon[iconType="video"] { background-image: url(../images/filetype_video.png); } diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index a9f05c4..df39eef 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -208,10 +208,10 @@ FileManager.prototype = { var localStrings; /** - * Map of icon types to regular expressions. + * Map of icon types to regular expressions and functions * - * The first regexp to match the file name determines the icon type - * assigned to dom elements for a file. Order of evaluation is not + * The first regexp/function to match the entry name determines the icon type + * assigned to dom elements for a file. Order of evaluation is not * defined, so don't depend on it. */ const iconTypes = { @@ -220,13 +220,33 @@ FileManager.prototype = { 'image': /\.(bmp|gif|jpe?g|ico|png|webp)$/i, 'pdf' : /\.(pdf)$/i, 'text': /\.(pod|rst|txt|log)$/i, - 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i + 'video': /\.(3gp|avi|mov|mp4|m4v|mpe?g4?|ogm|ogv|ogx|webm)$/i, + 'device': function(self, entry) { + var deviceNumber = self.getDeviceNumber(entry); + if (deviceNumber != undefined) + return (self.mountPoints_[deviceNumber].mountCondition == ''); + return false; + }, + 'unreadable': function(self, entry) { + var deviceNumber = self.getDeviceNumber(entry); + if (deviceNumber != undefined) { + return self.mountPoints_[deviceNumber].mountCondition == + 'unknown_filesystem' || + self.mountPoints_[deviceNumber].mountCondition == + 'unsupported_filesystem'; + } + return false; + } }; const previewArt = { 'audio': 'images/filetype_large_audio.png', + // TODO(sidor): Find better icon here. + 'device': 'images/filetype_large_folder.png', 'folder': 'images/filetype_large_folder.png', 'unknown': 'images/filetype_large_generic.png', + // TODO(sidor): Find better icon here. + 'unreadable': 'images/filetype_large_folder.png', 'video': 'images/filetype_large_video.png' }; @@ -294,50 +314,19 @@ FileManager.prototype = { return parent; } - /** - * Get the icon type for a given Entry. - * - * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry). - * @return {string} One of the keys from FileManager.iconTypes, or - * 'unknown'. - */ - function getIconType(entry) { - if (entry.cachedIconType_) - return entry.cachedIconType_; - - var rv = 'unknown'; - - if (entry.isDirectory) { - rv = 'folder'; - } else { - for (var name in iconTypes) { - var value = iconTypes[name]; - - if (value instanceof RegExp) { - if (value.test(entry.name)) { - rv = name; - break; - } - } else if (typeof value == 'function') { - try { - if (value(entry)) { - rv = name; - break; - } - } catch (ex) { - console.error('Caught exception while evaluating iconType: ' + - name, ex); - } - } else { - console.log('Unexpected value in iconTypes[' + name + ']: ' + value); - } - } - } - - entry.cachedIconType_ = rv; - return rv; + /** + * Normalizes path not to start with / + * + * @param {string} path The file path. + */ + function normalizeAbsolutePath(x) { + if (x[0] == '/') + return x.slice(1); + else + return x; } + /** * Call an asynchronous method on dirEntry, batching multiple callers. * @@ -479,27 +468,6 @@ FileManager.prototype = { } } - /** - * Get the icon type of a file, caching the result. - * - * When this method completes, the fileEntry object will get a - * 'cachedIconType_' property (if it doesn't already have one) containing the - * icon type of the file as a string. - * - * The successCallback is always invoked synchronously, since this does not - * actually require an async call. You should not depend on this, as it may - * change if we were to start reading magic numbers (for example). - * - * @param {Entry} entry An HTML5 Entry object. - * @param {function(Entry)} successCallback The function to invoke once the - * icon type is known. - */ - function cacheEntryIconType(entry, successCallback) { - getIconType(entry); - if (successCallback) - setTimeout(function() { successCallback(entry) }, 0); - } - function isSystemDirEntry(dirEntry) { return dirEntry.fullPath == '/' || dirEntry.fullPath == REMOVABLE_DIRECTORY || @@ -659,6 +627,68 @@ FileManager.prototype = { }; /** + * Get the icon type for a given Entry. + * + * @param {Entry} entry An Entry subclass (FileEntry or DirectoryEntry). + * @return {string} One of the keys from FileManager.iconTypes, or + * 'unknown'. + */ + FileManager.prototype.getIconType = function(entry) { + if (entry.cachedIconType_) + return entry.cachedIconType_; + + var rv = 'unknown'; + if (entry.isDirectory) + rv = 'folder'; + for (var name in iconTypes) { + var value = iconTypes[name]; + + if (value instanceof RegExp) { + if (value.test(entry.name)) { + rv = name; + break; + } + } else if (typeof value == 'function') { + try { + if (value(this,entry)) { + rv = name; + break; + } + } catch (ex) { + console.error('Caught exception while evaluating iconType: ' + + name, ex); + } + } else { + console.log('Unexpected value in iconTypes[' + name + ']: ' + value); + } + } + entry.cachedIconType_ = rv; + return rv; + }; + + + /** + * Get the icon type of a file, caching the result. + * + * When this method completes, the fileEntry object will get a + * 'cachedIconType_' property (if it doesn't already have one) containing the + * icon type of the file as a string. + * + * The successCallback is always invoked synchronously, since this does not + * actually require an async call. You should not depend on this, as it may + * change if we were to start reading magic numbers (for example). + * + * @param {Entry} entry An HTML5 Entry object. + * @param {function(Entry)} successCallback The function to invoke once the + * icon type is known. + */ + FileManager.prototype.cacheEntryIconType = function(entry, successCallback) { + this.getIconType(entry); + if (successCallback) + setTimeout(function() { successCallback(entry) }, 0); + } + + /** * Compare by mtime first, then by name. */ FileManager.prototype.compareMtime_ = function(a, b) { @@ -1244,7 +1274,7 @@ FileManager.prototype = { } else if (field == 'cachedSize_') { cacheFunction = cacheEntrySize; } else if (field == 'cachedIconType_') { - cacheFunction = cacheEntryIconType; + cacheFunction = this.cacheEntryIconType.bind(this); } else { callback(); return; @@ -1351,7 +1381,7 @@ FileManager.prototype = { var icon = this.document_.createElement('div'); icon.className = 'detail-icon'; - entry.cachedIconType_ = getIconType(entry); + entry.cachedIconType_ = this.getIconType(entry); icon.setAttribute('iconType', entry.cachedIconType_); div.appendChild(icon); @@ -1486,9 +1516,9 @@ FileManager.prototype = { selection.urls.push(entry.toURL()); if (selection.iconType == null) { - selection.iconType = getIconType(entry); + selection.iconType = this.getIconType(entry); } else if (selection.iconType != 'unknown') { - var iconType = getIconType(entry); + var iconType = this.getIconType(entry); if (selection.iconType != iconType) selection.iconType = 'unknown'; } @@ -1719,19 +1749,11 @@ FileManager.prototype = { var self = this; function onMountPointsFound(mountPoints) { self.mountPoints_ = mountPoints; - - function normalize(x) { - if (x[0] == '/') - return x.slice(1); - else - return x; - } - function onVolumeMetadataFound(volumeMetadata) { if (volumeMetadata.deviceType == "flash") { - if (selection.entries.length != 1 || - normalize(selection.entries[0].fullPath) != - normalize(volumeMetadata.mountPath)) { + if (self.selection.entries.length != 1 || + normalizeAbsolutePath(self.selection.entries[0].fullPath) != + normalizeAbsolutePath(volumeMetadata.mountPath)) { return; } var task = { @@ -1748,7 +1770,8 @@ FileManager.prototype = { var selectedPath = selection.entries[0].fullPath; for (var i = 0; i < mountPoints.length; i++) { if (mountPoints[i].mountType == "device" && - normalize(mountPoints[i].mountPath) == normalize(selectedPath)) { + normalizeAbsolutePath(mountPoints[i].mountPath) == + normalizeAbsolutePath(selectedPath)) { chrome.fileBrowserPrivate.getVolumeMetadata(mountPoints[i].sourceUrl, onVolumeMetadataFound); return; @@ -1802,11 +1825,16 @@ FileManager.prototype = { return; } + var rescanDirectoryNeeded = (event.status == 'success'); + for (var i = 0; i < mountPoints.length; i++) { + if (event.sourceUrl == mountPoints[i].sourceUrl && + mountPoints[i].mountCondition != '') { + rescanDirectoryNeeded = true; + } + } // TODO(dgozman): rescan directory, only if it contains mounted points, // when mounts location will be decided. - if (event.status == 'success' || - event.status == 'error_unknown_filesystem' || - event.status == 'error_unsuported_filesystem') + if (rescanDirectoryNeeded) self.rescanDirectory_(null, 300); }); }; @@ -1841,6 +1869,17 @@ FileManager.prototype = { } }; + FileManager.prototype.getDeviceNumber = function(entry) { + if (!entry.isDirectory) return false; + for (var i = 0; i < this.mountPoints_.length; i++) { + if (normalizeAbsolutePath(entry.fullPath) == + normalizeAbsolutePath(this.mountPoints_[i].mountPath)) { + return i; + } + } + return undefined; + } + FileManager.prototype.openImageEditor_ = function(entry) { var self = this; @@ -1945,7 +1984,7 @@ FileManager.prototype = { this.previewFilename_.textContent = previewName; - var iconType = getIconType(this.selection.leadEntry); + var iconType = this.getIconType(this.selection.leadEntry); if (iconType == 'image') { if (fileManager.selection.totalCount > 1) this.previewImage_.classList.add('multiple-selected'); @@ -2102,7 +2141,7 @@ FileManager.prototype = { if (!entry) return; - var iconType = getIconType(entry); + var iconType = this.getIconType(entry); this.cacheMetadata_(entry, function (metadata) { var url = metadata.thumbnailURL; @@ -2502,14 +2541,30 @@ FileManager.prototype = { return; } - if (entry.isDirectory) - return this.changeDirectory(entry.fullPath); + if (entry.isDirectory) { + return this.onDirectoryAction(entry); + } if (!this.okButton_.disabled) this.onOk_(); }; + FileManager.prototype.onDirectoryAction = function(entry) { + var deviceNumber = this.getDeviceNumber(entry); + if (deviceNumber != undefined && + this.mountPoints_[deviceNumber].mountCondition == + 'unknown_filesystem') { + return this.showButter(str('UNKNOWN_FILESYSTEM_WARNING')); + } else if (deviceNumber != undefined && + this.mountPoints_[deviceNumber].mountCondition == + 'unsupported_filesystem') { + return this.showButter(str('UNSUPPORTED_FILESYSTEM_WARNING')); + } else { + return this.changeDirectory(entry.fullPath); + } + } + /** * Update the UI when the current directory changes. * @@ -2972,7 +3027,7 @@ FileManager.prototype = { this.selection.leadEntry.isDirectory && this.dialogType_ != FileManager.SELECT_FOLDER) { event.preventDefault(); - this.changeDirectory(this.selection.leadEntry.fullPath); + this.onDirectoryAction(this.selection.leadEntry); } else if (!this.okButton_.disabled) { event.preventDefault(); this.onOk_(); diff --git a/chrome/browser/resources/file_manager/js/mock_chrome.js b/chrome/browser/resources/file_manager/js/mock_chrome.js index 70bb972..298accd 100644 --- a/chrome/browser/resources/file_manager/js/mock_chrome.js +++ b/chrome/browser/resources/file_manager/js/mock_chrome.js @@ -281,6 +281,13 @@ chrome.fileBrowserPrivate = { CONFIRM_DELETE_ONE: 'Are you sure you want to delete "$1"?', CONFIRM_DELETE_SOME: 'Are you sure you want to delete $1 items?', + UNKNOWN_FILESYSTEM_WARNING:'This device cannot be opened because its' + + ' filesystem was not recognized.', + UNSUPPORTED_FILESYSTEM_WARNING: 'This device cannot be opened because' + + ' its filesystem is not supported.', + FORMATTING_WARNING: 'Formatting the removable media is going to erase' + + ' all data. Do you wish to continue?', + ID3_ALBUM: 'Album', // TALB ID3_BPM: 'BPM ', // TBPM ID3_COMPOSER: 'Composer', // TCOM diff --git a/chrome/browser/ui/webui/fileicon_source_cros.cc b/chrome/browser/ui/webui/fileicon_source_cros.cc index 3540acb..aa17e9b 100644 --- a/chrome/browser/ui/webui/fileicon_source_cros.cc +++ b/chrome/browser/ui/webui/fileicon_source_cros.cc @@ -52,6 +52,11 @@ const IdrBySize kAudioIdrs = { IDR_FILE_MANAGER_IMG_FILETYPE_LARGE_AUDIO, IDR_FILE_MANAGER_IMG_FILETYPE_LARGE_AUDIO }; +const IdrBySize kDeviceIdrs = { + IDR_FILE_MANAGER_IMG_FILETYPE_DEVICE, + IDR_FILE_MANAGER_IMG_FILETYPE_DEVICE, + IDR_FILE_MANAGER_IMG_FILETYPE_DEVICE +}; const IdrBySize kDocIdrs = { IDR_FILE_MANAGER_IMG_FILETYPE_DOC, IDR_FILE_MANAGER_IMG_FILETYPE_DOC, @@ -92,6 +97,11 @@ const IdrBySize kSpreadsheetIdrs = { IDR_FILE_MANAGER_IMG_FILETYPE_SPREADSHEET, IDR_FILE_MANAGER_IMG_FILETYPE_SPREADSHEET }; +const IdrBySize kUnreadableDeviceIdrs = { + IDR_FILE_MANAGER_IMG_FILETYPE_UNREADABLE_DEVICE, + IDR_FILE_MANAGER_IMG_FILETYPE_UNREADABLE_DEVICE, + IDR_FILE_MANAGER_IMG_FILETYPE_UNREADABLE_DEVICE +}; const IdrBySize kTextIdrs = { IDR_FILE_MANAGER_IMG_FILETYPE_TEXT, IDR_FILE_MANAGER_IMG_FILETYPE_TEXT, diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 9777066..1326a40 100644 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -6627,6 +6627,10 @@ "type": "string", "enum": ["device", "file", "network"], "description": "Type of the mount." + }, + "mountCondition": { + "type": "string", + "description": "Additional data about mount, for example, that the filesystem is not supported." } } }, |