diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 06:19:02 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-25 06:19:02 +0000 |
commit | 3976e5dfe1b2c23bb8e573f34d1da1a05403e41f (patch) | |
tree | 858230a49fceabe22c886a1a70c3a771f3708560 /chrome/browser/resources/file_manager/js | |
parent | 434da4e43076f7cdb7faf899c2841b6829c01541 (diff) | |
download | chromium_src-3976e5dfe1b2c23bb8e573f34d1da1a05403e41f.zip chromium_src-3976e5dfe1b2c23bb8e573f34d1da1a05403e41f.tar.gz chromium_src-3976e5dfe1b2c23bb8e573f34d1da1a05403e41f.tar.bz2 |
Revert 93838 - Merged already reviewed CLs for r/o zip support in ChromeOS file browser:
Re-landing http://codereview.chromium.org/7457001:
Adding support for mount point different from removable
devices to MountLibrary
(work in progress..have to add GetMountPoints support)
tested on ChromeOS with these three patches:
http://gerrit.chromium.org/gerrit/#change,4447
http://gerrit.chromium.org/gerrit/#change,4449
http://gerrit.chromium.org/gerrit/#change,4544
http://codereview.chromium.org/7471039/:
UI for mounting/unmounting archive files.
BUG=chromium-os:17673, chromium-os:17783
TEST=Made sure mounting devices still works and that MountCompleted event gets through to file_browser_event_router (checking ui and chrome logs for mount completed entries)
TBR=tbarzic, dgozman
Review URL: http://codereview.chromium.org/7488044
TBR=zelidrag@chromium.org
Review URL: http://codereview.chromium.org/7495024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@93849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/resources/file_manager/js')
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 143 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/main.js | 2 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/mock_chrome.js | 84 |
3 files changed, 17 insertions, 212 deletions
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index c079ffe..42814da 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -105,18 +105,6 @@ function FileManager(dialogDom, rootEntries, params) { this.addEventListener('selection-summarized', this.onSelectionSummarized_.bind(this)); - // The list of archives requested to mount. We will show contents once - // archive is mounted, but only for mounts from within this filebrowser tab. - this.mountRequests_ = []; - chrome.fileBrowserPrivate.onMountCompleted.addListener( - this.onMountCompleted_.bind(this)); - - var self = this; - // The list of active mount points to distinct them from other directories. - chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { - self.mountPoints_ = mountPoints; - }); - chrome.fileBrowserHandler.onExecute.addListener( this.onFileTaskExecute_.bind(this)); @@ -156,16 +144,10 @@ FileManager.prototype = { const RIGHT_TRIANGLE = '\u25b8'; /** - * The DirectoryEntry.fullPath value of the directory containing externally - * mounted removable storage volumes. + * The DirectoryEntry.fullPath value of the directory containing external + * storage volumes. */ - const REMOVABLE_DIRECTORY = 'removable'; - - /** - * The DirectoryEntry.fullPath value of the directory containing externally - * mounted archive file volumes. - */ - const ARCHIVE_DIRECTORY = 'archive'; + const MEDIA_DIRECTORY = '/media'; /** * Mnemonics for the second parameter of the changeDirectory method. @@ -658,10 +640,8 @@ FileManager.prototype = { !this.renameInput_.currentEntry && // Not in root directory. this.currentDirEntry_.fullPath != '/' && - // Not in media/archive directory. - this.currentDirEntry_.fullPath != ARCHIVE_DIRECTORY && - // Not in media/removable directory. - this.currentDirEntry_.fullPath != REMOVABLE_DIRECTORY && + // Not in media directory. + this.currentDirEntry_.fullPath != MEDIA_DIRECTORY && // Only one file selected. this.selection.totalCount == 1); }; @@ -677,10 +657,8 @@ FileManager.prototype = { !this.renameInput_.currentEntry && // Not in root directory. this.currentDirEntry_.fullPath != '/' && - // Not in media/removable directory. - this.currentDirEntry_.fullPath != REMOVABLE_DIRECTORY && - // Not in media/archive directory. - this.currentDirEntry_.fullPath != ARCHIVE_DIRECTORY); + // Not in media directory. + this.currentDirEntry_.fullPath != MEDIA_DIRECTORY); }; FileManager.prototype.setListType = function(type) { @@ -1100,11 +1078,8 @@ FileManager.prototype = { if (path == 'Downloads') return str('DOWNLOADS_DIRECTORY_LABEL'); - if (path == 'archive') - return str('ARCHIVE_DIRECTORY_LABEL'); - - if (path == 'removable') - return str('REMOVABLE_DIRECTORY_LABEL'); + if (path == 'media') + return str('MEDIA_DIRECTORY_LABEL'); return path || str('ROOT_DIRECTORY_LABEL'); }; @@ -1169,8 +1144,8 @@ FileManager.prototype = { var self = this; cacheEntryDate(entry, function(entry) { - if (self.currentDirEntry_.fullPath == ARCHIVE_DIRECTORY || - self.currentDirEntry_.fullPath == REMOVABLE_DIRECTORY) { + if (self.currentDirEntry_.fullPath == MEDIA_DIRECTORY && + entry.cachedMtime_.getTime() == 0) { // Mount points for FAT volumes have this time associated with them. // We'd rather display nothing than this bogus date. div.textContent = '---'; @@ -1273,12 +1248,8 @@ FileManager.prototype = { }; if (this.dialogType_ == FileManager.DialogType.FULL_PAGE) { - // Since unmount task cannot be defined in terms of file patterns, - // we manually include it here, if all selected items are mount points. - chrome.fileBrowserPrivate.getFileTasks( - selection.urls, - this.onTasksFound_.bind(this, - this.shouldShowUnmount_(selection.urls))); + chrome.fileBrowserPrivate.getFileTasks(selection.urls, + this.onTasksFound_.bind(this)); } cacheNextFile(); @@ -1331,20 +1302,7 @@ FileManager.prototype = { this[methodName].apply(this, data.arguments); }; - /** - * Callback called when tasks for selected files are determined. - * @param {boolean} unmount Whether unmount task should be included. - * @param {Array.<Task>} tasksList The tasks list. - */ - FileManager.prototype.onTasksFound_ = function(unmount, tasksList) { - if (unmount) { - tasksList.push({ - taskId: this.getExtensionId_() + '|unmount-archive', - iconUrl: '', - title: '' - }); - } - + FileManager.prototype.onTasksFound_ = function(tasksList) { this.taskButtons_.innerHTML = ''; for (var i = 0; i < tasksList.length; i++) { var task = tasksList[i]; @@ -1371,14 +1329,6 @@ FileManager.prototype = { task.iconUrl = chrome.extension.getURL('images/icon_add_to_queue_16x16.png'); task.title = str('ENQUEUE'); - } else if (task_parts[1] == 'mount-archive') { - task.iconUrl = - chrome.extension.getURL('images/icon_mount_archive_16x16.png'); - task.title = str('MOUNT_ARCHIVE'); - } else if (task_parts[1] == 'unmount-archive') { - task.iconUrl = - chrome.extension.getURL('images/icon_unmount_archive_16x16.png'); - task.title = str('UNMOUNT_ARCHIVE'); } } @@ -1406,41 +1356,6 @@ FileManager.prototype = { this.selection.urls); }; - /** - * Event handler called when some volume was mounted or unmouted. - */ - FileManager.prototype.onMountCompleted_ = function(event) { - var self = this; - chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { - self.mountPoints_ = mountPoints; - if (event.eventType == 'mount') { - for (var index = 0; index < self.mountRequests_.length; ++index) { - if (self.mountRequests_[index] == event.sourceUrl) { - self.mountRequests_.splice(index, 1); - if (event.status == 'success') { - self.changeDirectory(event.mountPath); - } else { - // Report mount error. - if (event.mountType == 'file') { - var fileName = event.sourceUrl.substr( - event.sourceUrl.lastIndexOf('/') + 1); - window.alert(strf('ARCHIVE_MOUNT_FAILED', fileName, - event.status)); - } - } - return; - } - } - } - // TODO(dgozman): rescan directory, only if it contains mounted points, - // when mounts location will be decided. - this.rescanDirectory_(); - }); - }; - - /** - * Event handler called when some internal task should be executed. - */ FileManager.prototype.onFileTaskExecute_ = function(id, details) { var urls = details.entries.map(function(entry) { return entry.toURL(); @@ -1457,31 +1372,7 @@ FileManager.prototype = { this.imageEditor_.getBuffer().load(urls[0]); } else if (id == 'play' || id == 'enqueue') { chrome.fileBrowserPrivate.viewFiles(urls, id); - } else if (id == 'mount-archive') { - for (var index = 0; index < urls.length; ++index) { - this.mountRequests_.push(urls[index]); - chrome.fileBrowserPrivate.addMount(urls[index], 'file', {}); - } - } else if (id == 'unmount-archive') { - for (var index = 0; index < urls.length; ++index) { - chrome.fileBrowserPrivate.removeMount(urls[index]); - } - } - }; - - /** - * Determines whether unmount task should present for selected files. - */ - FileManager.prototype.shouldShowUnmount_ = function(urls) { - for (var index = 0; index < urls.length; ++index) { - // Each url should be a mount point. - var path = urls[index]; - if (!this.mountPoints_.hasOwnProperty(path) || - this.mountPoints_[path].type != 'file') { - return false; - } } - return true; }; FileManager.prototype.onImageEditorSave = function(canvas) { @@ -1945,8 +1836,7 @@ FileManager.prototype = { this.selection.fileCount >= 1); } else if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { if (this.currentDirEntry_.fullPath == '/' || - this.currentDirEntry_.fullPath == ARCHIVE_DIRECTORY || - this.currentDirEntry_.fullPath == REMOVABLE_DIRECTORY) { + this.currentDirEntry_.fullPath == MEDIA_DIRECTORY) { // Nothing can be saved in to the root or media/ directories. selectable = false; } else { @@ -2004,8 +1894,7 @@ FileManager.prototype = { // New folder should never be enabled in the root or media/ directories. this.newFolderButton_.disabled = (this.currentDirEntry_.fullPath == '/' || - this.currentDirEntry_.fullPath == ARCHIVE_DIRECTORY || - this.currentDirEntry_.fullPath == REMOVABLE_DIRECTORY); + this.currentDirEntry_.fullPath == MEDIA_DIRECTORY); this.document_.title = this.currentDirEntry_.fullPath; diff --git a/chrome/browser/resources/file_manager/js/main.js b/chrome/browser/resources/file_manager/js/main.js index 1a278c9..7181285 100644 --- a/chrome/browser/resources/file_manager/js/main.js +++ b/chrome/browser/resources/file_manager/js/main.js @@ -15,7 +15,7 @@ var fileManager; function init() { var params; - var rootPaths = ['Downloads', 'removable', 'archive']; + var rootPaths = ['Downloads', 'media']; if (document.location.search) { var json = decodeURIComponent(document.location.search.substr(1)); diff --git a/chrome/browser/resources/file_manager/js/mock_chrome.js b/chrome/browser/resources/file_manager/js/mock_chrome.js index ded229c..82bc0c8 100644 --- a/chrome/browser/resources/file_manager/js/mock_chrome.js +++ b/chrome/browser/resources/file_manager/js/mock_chrome.js @@ -58,9 +58,6 @@ chrome.fileBrowserPrivate = { addListener: function(cb) { this.callbacks.push(cb) } }, - /** - * Returns common tasks for a given list of files. - */ getFileTasks: function(urlList, callback) { if (urlList.length == 0) return callback([]); @@ -79,11 +76,6 @@ chrome.fileBrowserPrivate = { regexp: /\.(jpe?g|png|cr2?|tiff)$/i, iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sEEBcOAw9XftIAAADFSURBVCjPrZKxCsIwEIa/FHFwsvYxROjSQXAoqLiIL+xgBtvZ91A6uOnQc2hT0zRqkR4c3P25+/PfJTCwLU6wEpgBWkDXuInDPSwF5r7mJIeNQFTnIiCeONpVdYlLoK9wEUhNg8+B9FDVaZcgCKAovjTXfvPJFwGZtKW60pt8bOGBzfLouemnFY/MAs8wDeEI4NzaybewBu4AysKVgrK0gfe5iB9vjdAUqQ/S1Y/R3IX9Zc1zxc7zxe2/0Iskt7AsG0hhx14W8XV43FgV4gAAAABJRU5ErkJggg==', }, - { taskId: 'mount-archive', - title: 'Mount', - regexp: /\.(zip)$/i, - iconUrl: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAOCAYAAAAmL5yKAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sEEBcOAw9XftIAAADFSURBVCjPrZKxCsIwEIa/FHFwsvYxROjSQXAoqLiIL+xgBtvZ91A6uOnQc2hT0zRqkR4c3P25+/PfJTCwLU6wEpgBWkDXuInDPSwF5r7mJIeNQFTnIiCeONpVdYlLoK9wEUhNg8+B9FDVaZcgCKAovjTXfvPJFwGZtKW60pt8bOGBzfLouemnFY/MAs8wDeEI4NzaybewBu4AysKVgrK0gfe5iB9vjdAUqQ/S1Y/R3IX9Zc1zxc7zxe2/0Iskt7AsG0hhx14W8XV43FgV4gAAAABJRU5ErkJggg==', - }, ]; // Copy all tasks, then remove the ones that don't match. @@ -106,72 +98,8 @@ chrome.fileBrowserPrivate = { callback(candidateTasks); }, - /** - * Executes a task. - */ executeTask: function(taskId, urlList) { console.log('executing task: ' + taskId + ': ' + urlList.length + ' urls'); - var parts = taskId.split('|'); - taskId = parts[parts.length - 1]; - function createEntry(url) { - return { - toURL: function() { return url; } - }; - } - var details = {entries: urlList.map(createEntry)}; - var listeners = chrome.fileBrowserHandler.onExecute.listeners_; - for (var listener, index = 0; listener = listeners[index]; ++index) { - listener(taskId, details); - } - }, - - /** - * Event fired on mount and unmount operations. - */ - onDiskChanged: { - listeners_: [], - addListener: function(listener) { - chrome.fileBrowserPrivate.onDiskChanged.listeners_.push(listener); - } - }, - - addMount: function(source, type, options) { - var event = { - eventType: 'added', - volumeInfo: { - devicePath: source, - type: type, - mountPath: '/' - } - }; - var listeners = chrome.fileBrowserPrivate.onDiskChanged.listeners_; - for (var listener, index = 0; listener = listeners[index]; ++index) { - listener(event); - } - }, - - getMountPoints: function() { - // This will work in harness. - var path = 'filesystem:file:///persistent/media'; - var result = {}; - result[path] = {mountPath: path, type: 'file'}; - return result; - }, - - removeMount: function(mountPoint) { - console.log('unmounted: ' + mountPoint); - var event = { - eventType: 'removed', - volumeInfo: { - devicePath: '', - type: '', - mountPath: mountPoint - } - }; - var listeners = chrome.fileBrowserPrivate.onDiskChanged.listeners_; - for (var listener, index = 0; listener = listeners[index]; ++index) { - listener(event); - } }, /** @@ -215,9 +143,6 @@ chrome.fileBrowserPrivate = { VOLUME_LABEL: 'Volume Label', READ_ONLY: 'Read Only', - MOUNT_ARCHIVE: 'Open archive', - UNMOUNT_ARCHIVE: 'Close archive', - CONFIRM_OVERWRITE_FILE: 'A file named "$1" already exists. Do you want to replace it?', FILE_ALREADY_EXISTS: 'The file named "$1" already exists. Please choose a different name.', DIRECTORY_ALREADY_EXISTS: 'The directory named "$1" already exists. Please choose a different name.', @@ -278,12 +203,3 @@ chrome.test = { console.log('chrome.test.sendMessage: ' + msg); } }; - -chrome.fileBrowserHandler = { - onExecute: { - listeners_: [], - addListener: function(listener) { - chrome.fileBrowserHandler.onExecute.listeners_.push(listener); - } - } -}; |