| Index: chrome/browser/resources/file_manager/js/directory_model.js
|
| ===================================================================
|
| --- chrome/browser/resources/file_manager/js/directory_model.js (revision 134073)
|
| +++ chrome/browser/resources/file_manager/js/directory_model.js (working copy)
|
| @@ -37,7 +37,6 @@
|
| this.currentDirEntry_ = root;
|
|
|
| this.fileList_.prepareSort = this.prepareSort_.bind(this);
|
| - this.autoSelectIndex_ = 0;
|
|
|
| this.rootsList_ = new cr.ui.ArrayDataModel([]);
|
| this.rootsListSelection_ = new cr.ui.ListSingleSelectionModel();
|
| @@ -203,13 +202,6 @@
|
| };
|
|
|
| /**
|
| - * @param {number} value New auto select index.
|
| - */
|
| -DirectoryModel.prototype.setAutoSelectIndex = function(value) {
|
| - this.autoSelectIndex_ = value;
|
| -};
|
| -
|
| -/**
|
| * @private
|
| * @return {Array.<string>} Names of selected files.
|
| */
|
| @@ -660,10 +652,7 @@
|
| * @param {function} opt_OnError Called if failed.
|
| */
|
| DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) {
|
| - var onDirectoryResolved = function(dirEntry) {
|
| - var autoSelect = this.selectIndex.bind(this, this.autoSelectIndex_);
|
| - this.changeDirectoryEntry_(dirEntry, autoSelect, false);
|
| - }.bind(this);
|
| + var onDirectoryResolved = this.changeDirectoryEntry_.bind(this, false);
|
|
|
| if (this.unmountedGDataEntry_ &&
|
| DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) {
|
| @@ -698,19 +687,18 @@
|
| * changed.
|
| *
|
| * @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
|
| * false if caused by an user action.
|
| + * @param {DirectoryEntry} dirEntry The absolute path to the new directory.
|
| + * @param {function} opt_callback Executed if the directory loads successfully.
|
| */
|
| -DirectoryModel.prototype.changeDirectoryEntry_ = function(dirEntry, action,
|
| - initial) {
|
| +DirectoryModel.prototype.changeDirectoryEntry_ = function(initial, dirEntry,
|
| + opt_callback) {
|
| var previous = this.currentDirEntry_;
|
| this.currentDirEntry_ = dirEntry;
|
| function onRescanComplete() {
|
| - action();
|
| + if (opt_callback)
|
| + opt_callback();
|
| // For tests that open the dialog to empty directories, everything
|
| // is loaded at this point.
|
| chrome.test.sendMessage('directory-change-complete');
|
| @@ -754,10 +742,10 @@
|
| opt_pathResolveCallback(baseName, leafName, exists && !overridden);
|
| }.bind(this);
|
|
|
| - var changeDirectoryEntry = function(entry, callback, initial, exists) {
|
| + var changeDirectoryEntry = function(entry, initial, exists, opt_callback) {
|
| resolveCallback(exists);
|
| if (!overridden)
|
| - this.changeDirectoryEntry_(entry, callback, initial);
|
| + this.changeDirectoryEntry_(initial, entry, opt_callback);
|
| }.bind(this);
|
|
|
| var INITIAL = true;
|
| @@ -765,15 +753,10 @@
|
|
|
| // Split the dirname from the basename.
|
| var ary = path.match(/^(?:(.*)\/)?([^\/]*)$/);
|
| - var autoSelect = function() {
|
| - this.selectIndex(this.autoSelectIndex_);
|
| - if (opt_loadedCallback)
|
| - opt_loadedCallback();
|
| - }.bind(this);
|
|
|
| if (!ary) {
|
| console.warn('Unable to split default path: ' + path);
|
| - changeDirectoryEntry(this.root_, autoSelect, INITIAL, !EXISTS);
|
| + changeDirectoryEntry(this.root_, INITIAL, !EXISTS);
|
| return;
|
| }
|
|
|
| @@ -784,19 +767,19 @@
|
| if (leafEntry.isDirectory) {
|
| baseName = path;
|
| leafName = '';
|
| - changeDirectoryEntry(leafEntry, autoSelect, INITIAL, EXISTS);
|
| + changeDirectoryEntry(leafEntry, INITIAL, EXISTS);
|
| return;
|
| }
|
|
|
| // Leaf is an existing file, cd to its parent directory and select it.
|
| changeDirectoryEntry(baseDirEntry,
|
| + !INITIAL /*HACK*/,
|
| + EXISTS,
|
| function() {
|
| this.selectEntry(leafEntry.name);
|
| if (opt_loadedCallback)
|
| opt_loadedCallback();
|
| - }.bind(this),
|
| - !INITIAL /*HACK*/,
|
| - EXISTS);
|
| + }.bind(this));
|
| // TODO(kaznacheev): Fix history.replaceState for the File Browser and
|
| // change !INITIAL to INITIAL. Passing |false| makes things
|
| // less ugly for now.
|
| @@ -806,7 +789,7 @@
|
| // Usually, leaf does not exist, because it's just a suggested file name.
|
| if (err.code != FileError.NOT_FOUND_ERR)
|
| console.log('Unexpected error resolving default leaf: ' + err);
|
| - changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS);
|
| + changeDirectoryEntry(baseDirEntry, INITIAL, !EXISTS);
|
| }
|
|
|
| var onBaseError = function(err) {
|
| @@ -827,7 +810,7 @@
|
| var onBaseFound = function(baseDirEntry) {
|
| if (!leafName) {
|
| // Default path is just a directory, cd to it and we're done.
|
| - changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS);
|
| + changeDirectoryEntry(baseDirEntry, INITIAL, !EXISTS);
|
| return;
|
| }
|
|
|
|
|