Commit 960adc17 authored by oleg@chromium.org's avatar oleg@chromium.org

Do not auto-select the first file on entering a folder.

BUG=chromium-os:26471
TEST=After entering the folder none of the files is selected.
Review URL: https://chromiumcodereview.appspot.com/10204015

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133666 0039d316-1c4b-4281-b951-d872f2087c98
parent 8909ccd4
...@@ -37,7 +37,6 @@ function DirectoryModel(root, singleSelection, showGData, metadataCache) { ...@@ -37,7 +37,6 @@ function DirectoryModel(root, singleSelection, showGData, metadataCache) {
this.currentDirEntry_ = root; this.currentDirEntry_ = root;
this.fileList_.prepareSort = this.prepareSort_.bind(this); this.fileList_.prepareSort = this.prepareSort_.bind(this);
this.autoSelectIndex_ = 0;
this.rootsList_ = new cr.ui.ArrayDataModel([]); this.rootsList_ = new cr.ui.ArrayDataModel([]);
this.rootsListSelection_ = new cr.ui.ListSingleSelectionModel(); this.rootsListSelection_ = new cr.ui.ListSingleSelectionModel();
...@@ -195,13 +194,6 @@ DirectoryModel.prototype.getCurrentDirEntry = function() { ...@@ -195,13 +194,6 @@ DirectoryModel.prototype.getCurrentDirEntry = function() {
return this.currentDirEntry_; return this.currentDirEntry_;
}; };
/**
* @param {number} value New auto select index.
*/
DirectoryModel.prototype.setAutoSelectIndex = function(value) {
this.autoSelectIndex_ = value;
};
/** /**
* @private * @private
* @return {Array.<string>} Names of selected files. * @return {Array.<string>} Names of selected files.
...@@ -653,10 +645,7 @@ DirectoryModel.prototype.createDirectory = function(name, successCallback, ...@@ -653,10 +645,7 @@ DirectoryModel.prototype.createDirectory = function(name, successCallback,
* @param {function} opt_OnError Called if failed. * @param {function} opt_OnError Called if failed.
*/ */
DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) { DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) {
var onDirectoryResolved = function(dirEntry) { var onDirectoryResolved = this.changeDirectoryEntry_.bind(this, false);
var autoSelect = this.selectIndex.bind(this, this.autoSelectIndex_);
this.changeDirectoryEntry_(dirEntry, autoSelect, false);
}.bind(this);
if (this.unmountedGDataEntry_ && if (this.unmountedGDataEntry_ &&
DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) { DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) {
...@@ -691,19 +680,14 @@ DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) { ...@@ -691,19 +680,14 @@ DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) {
* changed. * changed.
* *
* @private * @private
* @param {DirectoryEntry} dirEntry The absolute path to the new directory.
* @param {function} action Action executed if the directory loads
* successfully. By default selects the first item (unless it's a save
* dialog).
* @param {boolean} initial True if it comes from setupPath and * @param {boolean} initial True if it comes from setupPath and
* false if caused by an user action. * false if caused by an user action.
* @param {DirectoryEntry} dirEntry A new directory entry.
*/ */
DirectoryModel.prototype.changeDirectoryEntry_ = function(dirEntry, action, DirectoryModel.prototype.changeDirectoryEntry_ = function(initial, dirEntry) {
initial) {
var previous = this.currentDirEntry_; var previous = this.currentDirEntry_;
this.currentDirEntry_ = dirEntry; this.currentDirEntry_ = dirEntry;
function onRescanComplete() { function onRescanComplete() {
action();
// For tests that open the dialog to empty directories, everything // For tests that open the dialog to empty directories, everything
// is loaded at this point. // is loaded at this point.
chrome.test.sendMessage('directory-change-complete'); chrome.test.sendMessage('directory-change-complete');
...@@ -749,10 +733,10 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, ...@@ -749,10 +733,10 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback,
opt_pathResolveCallback(baseName, leafName, exists && !overridden); opt_pathResolveCallback(baseName, leafName, exists && !overridden);
}.bind(this); }.bind(this);
var changeDirectoryEntry = function(entry, callback, initial, exists) { var changeDirectoryEntry = function(entry, initial, exists) {
resolveCallback(exists); resolveCallback(exists);
if (!overridden) if (!overridden)
this.changeDirectoryEntry_(entry, callback, initial); this.changeDirectoryEntry_(initial, entry);
}.bind(this); }.bind(this);
var INITIAL = true; var INITIAL = true;
...@@ -760,15 +744,10 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, ...@@ -760,15 +744,10 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback,
// Split the dirname from the basename. // Split the dirname from the basename.
var ary = path.match(/^(?:(.*)\/)?([^\/]*)$/); var ary = path.match(/^(?:(.*)\/)?([^\/]*)$/);
var autoSelect = function() {
this.selectIndex(this.autoSelectIndex_);
if (opt_loadedCallback)
opt_loadedCallback();
}.bind(this);
if (!ary) { if (!ary) {
console.warn('Unable to split default path: ' + path); console.warn('Unable to split default path: ' + path);
changeDirectoryEntry(this.root_, autoSelect, INITIAL, !EXISTS); changeDirectoryEntry(this.root_, INITIAL, !EXISTS);
return; return;
} }
...@@ -779,7 +758,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, ...@@ -779,7 +758,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback,
if (leafEntry.isDirectory) { if (leafEntry.isDirectory) {
baseName = path; baseName = path;
leafName = ''; leafName = '';
changeDirectoryEntry(leafEntry, autoSelect, INITIAL, EXISTS); changeDirectoryEntry(leafEntry, INITIAL, EXISTS);
return; return;
} }
...@@ -801,7 +780,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, ...@@ -801,7 +780,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback,
// Usually, leaf does not exist, because it's just a suggested file name. // Usually, leaf does not exist, because it's just a suggested file name.
if (err.code != FileError.NOT_FOUND_ERR) if (err.code != FileError.NOT_FOUND_ERR)
console.log('Unexpected error resolving default leaf: ' + err); console.log('Unexpected error resolving default leaf: ' + err);
changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS); changeDirectoryEntry(baseDirEntry, INITIAL, !EXISTS);
} }
var onBaseError = function(err) { var onBaseError = function(err) {
...@@ -822,7 +801,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback, ...@@ -822,7 +801,7 @@ DirectoryModel.prototype.setupPath = function(path, opt_loadedCallback,
var onBaseFound = function(baseDirEntry) { var onBaseFound = function(baseDirEntry) {
if (!leafName) { if (!leafName) {
// Default path is just a directory, cd to it and we're done. // Default path is just a directory, cd to it and we're done.
changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS); changeDirectoryEntry(baseDirEntry, INITIAL, !EXISTS);
return; return;
} }
......
...@@ -743,9 +743,6 @@ FileManager.prototype = { ...@@ -743,9 +743,6 @@ FileManager.prototype = {
this.directoryModel_.getFileListSelection().addEventListener( this.directoryModel_.getFileListSelection().addEventListener(
'change', this.onSelectionChanged_.bind(this)); 'change', this.onSelectionChanged_.bind(this));
this.directoryModel_.setAutoSelectIndex(
this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE ? -1 : 0);
this.initTable_(); this.initTable_();
this.initGrid_(); this.initGrid_();
this.initRootsList_(); this.initRootsList_();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment