diff options
author | dgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 11:09:14 +0000 |
---|---|---|
committer | dgozman@chromium.org <dgozman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-19 11:09:14 +0000 |
commit | 8d8b239819e5ec32212ed53de34b528492a0c281 (patch) | |
tree | 42e1df9fdbb44adee36837168144a0640a257a84 | |
parent | b0a28ee99b0d3b7c237f449824ad695a61bec37b (diff) | |
download | chromium_src-8d8b239819e5ec32212ed53de34b528492a0c281.zip chromium_src-8d8b239819e5ec32212ed53de34b528492a0c281.tar.gz chromium_src-8d8b239819e5ec32212ed53de34b528492a0c281.tar.bz2 |
[filebrowser] No moving above the roots, persisting list type, show file name for single selection.
- Prohibited moving above the roots;
- Persisting list type (list/grid) between launches for modal dialogs;
- Show file name and size for single file selected;
- User cannot type the wrong path in the URL and see the strange contents - instead we go to default path.
BUG=chromium-os:22505,chromium-os:24803,chromium-os:24635
TEST=See bugs.
Review URL: https://chromiumcodereview.appspot.com/9251011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118285 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 39 insertions, 19 deletions
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js index 56247f7..3979a68 100644 --- a/chrome/browser/resources/file_manager/js/directory_model.js +++ b/chrome/browser/resources/file_manager/js/directory_model.js @@ -474,20 +474,24 @@ DirectoryModel.prototype = { function onLeafError(baseDirEntry, err) { callBack(); - if (err = FileError.NOT_FOUND_ERR) { - // Leaf does not exist, it's just a suggested file name. - this.changeDirectoryEntry_(baseDirEntry, autoSelect); - } else { + // Usually, leaf does not exist, because it's just a suggested file name. + if (err != FileError.NOT_FOUND_ERR) console.log('Unexpected error resolving default leaf: ' + err); - this.changeDirectoryEntry_(this.root_, autoSelect, true); - } + this.changeDirectoryEntry_(baseDirEntry, autoSelect, true); } var onBaseError = function(err) { callBack(); console.log('Unexpected error resolving default base "' + baseName + '": ' + err); - this.changeDirectory('/', undefined, true); + if (path != '/' + DirectoryModel.DOWNLOADS_DIRECTORY) { + // Can't find the provided path, let's go to default one instead. + this.setupDefaultPath(); + } else { + // Well, we can't find the downloads dir. Let's just show something, + // or we will get an infinite recursion. + this.changeDirectory('/', undefined, true); + } }.bind(this); var onBaseFound = function(baseDirEntry) { @@ -713,3 +717,8 @@ DirectoryModel.getRootType = function(path) { return ''; }; +DirectoryModel.isRootPath = function(path) { + if (path[path.length - 1] == '/') + path = path.substring(0, path.length - 1); + return DirectoryModel.getRootPath(path) == path; +}; diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index 2f44872..395c85e 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -440,6 +440,13 @@ FileManager.prototype = { FULL_PAGE: 'full-page' }; + FileManager.DialogType.isModal = function(type) { + return type == FileManager.DialogType.SELECT_FOLDER || + type == FileManager.DialogType.SELECT_SAVEAS_FILE || + type == FileManager.DialogType.SELECT_OPEN_FILE || + type == FileManager.DialogType.SELECT_OPEN_MULTI_FILE; + }; + FileManager.ListType = { DETAIL: 'detail', THUMBNAIL: 'thumb' @@ -731,12 +738,15 @@ FileManager.prototype = { this.directoryModel_.cacheEntryIconType = this.cacheEntryIconType.bind(this); - this.initTable_(); this.initGrid_(); this.initRootsList_(); - this.setListType(FileManager.ListType.DETAIL); + var listType = FileManager.ListType.DETAIL; + if (FileManager.DialogType.isModal(this.dialogType_)) + listType = window.localStorage['listType-' + this.dialogType_] || + FileManager.ListType.DETAIL; + this.setListType(listType); this.textSearchState_ = {text: '', date: new Date()}; }; @@ -1102,6 +1112,9 @@ FileManager.prototype = { if (type && type == this.listType_) return; + if (FileManager.DialogType.isModal(this.dialogType_)) + window.localStorage['listType-' + this.dialogType_] = type; + this.table_.list.startBatchUpdates(); this.grid_.startBatchUpdates(); @@ -2594,9 +2607,9 @@ FileManager.prototype = { if (selection.totalCount == 0) { text = str('NOTHING_SELECTED'); } else if (selection.fileCount == 1 && selection.directoryCount == 0) { - text = strf('ONE_FILE_SELECTED', bytes); + text = selection.entries[0].name + ', ' + bytes; } else if (selection.fileCount == 0 && selection.directoryCount == 1) { - text = str('ONE_DIRECTORY_SELECTED'); + text = selection.entries[0].name; } else if (selection.directoryCount == 0) { text = strf('MANY_FILES_SELECTED', selection.fileCount, bytes); } else if (selection.fileCount == 0) { @@ -3193,15 +3206,13 @@ FileManager.prototype = { return; } - //console.log(event.keyCode); - switch (event.keyCode) { case 8: // Backspace => Up one directory. event.preventDefault(); var path = this.getCurrentDirectory(); - if (path && path != '/') { + if (path && !DirectoryModel.isRootPath(path)) { var path = path.replace(/\/[^\/]+$/, ''); - this.directoryModel_.changeDirectory(path || '/'); + this.directoryModel_.changeDirectory(path); } break; diff --git a/chrome/browser/resources/file_manager/js/mock_chrome.js b/chrome/browser/resources/file_manager/js/mock_chrome.js index cbe010a..33c1aa1 100644 --- a/chrome/browser/resources/file_manager/js/mock_chrome.js +++ b/chrome/browser/resources/file_manager/js/mock_chrome.js @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -401,4 +401,4 @@ chrome.metricsPrivate = { recordTime: function() {}, recordUserAction: function() {}, recordValue: function() {} -};
\ No newline at end of file +}; diff --git a/chrome/browser/resources/file_manager/js/util.js b/chrome/browser/resources/file_manager/js/util.js index 04d3413..7cccc00 100644 --- a/chrome/browser/resources/file_manager/js/util.js +++ b/chrome/browser/resources/file_manager/js/util.js @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -345,7 +345,7 @@ var util = { var rounded = Math.round(bytes / s * 10) / 10; // TODO(rginda): Switch to v8Locale's number formatter when it's // available. - return rounded.toLocaleString() + u; + return rounded.toLocaleString() + ' ' + u; } // This loop index is used outside the loop if it turns out |bytes| |