Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: chrome/browser/resources/file_manager/js/directory_model.js

Issue 10212005: Revert 133666 - Do not auto-select the first file on entering a folder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/directory_model.js
===================================================================
--- chrome/browser/resources/file_manager/js/directory_model.js (revision 133744)
+++ chrome/browser/resources/file_manager/js/directory_model.js (working copy)
@@ -37,6 +37,7 @@
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();
@@ -195,6 +196,13 @@
};
/**
+ * @param {number} value New auto select index.
+ */
+DirectoryModel.prototype.setAutoSelectIndex = function(value) {
+ this.autoSelectIndex_ = value;
+};
+
+/**
* @private
* @return {Array.<string>} Names of selected files.
*/
@@ -645,7 +653,10 @@
* @param {function} opt_OnError Called if failed.
*/
DirectoryModel.prototype.changeDirectory = function(path, opt_OnError) {
- var onDirectoryResolved = this.changeDirectoryEntry_.bind(this, false);
+ var onDirectoryResolved = function(dirEntry) {
+ var autoSelect = this.selectIndex.bind(this, this.autoSelectIndex_);
+ this.changeDirectoryEntry_(dirEntry, autoSelect, false);
+ }.bind(this);
if (this.unmountedGDataEntry_ &&
DirectoryModel.getRootType(path) == DirectoryModel.RootType.GDATA) {
@@ -680,14 +691,19 @@
* 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 A new directory entry.
*/
-DirectoryModel.prototype.changeDirectoryEntry_ = function(initial, dirEntry) {
+DirectoryModel.prototype.changeDirectoryEntry_ = function(dirEntry, action,
+ initial) {
var previous = this.currentDirEntry_;
this.currentDirEntry_ = dirEntry;
function onRescanComplete() {
+ action();
// For tests that open the dialog to empty directories, everything
// is loaded at this point.
chrome.test.sendMessage('directory-change-complete');
@@ -733,10 +749,10 @@
opt_pathResolveCallback(baseName, leafName, exists && !overridden);
}.bind(this);
- var changeDirectoryEntry = function(entry, initial, exists) {
+ var changeDirectoryEntry = function(entry, callback, initial, exists) {
resolveCallback(exists);
if (!overridden)
- this.changeDirectoryEntry_(initial, entry);
+ this.changeDirectoryEntry_(entry, callback, initial);
}.bind(this);
var INITIAL = true;
@@ -744,10 +760,15 @@
// 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_, INITIAL, !EXISTS);
+ changeDirectoryEntry(this.root_, autoSelect, INITIAL, !EXISTS);
return;
}
@@ -758,7 +779,7 @@
if (leafEntry.isDirectory) {
baseName = path;
leafName = '';
- changeDirectoryEntry(leafEntry, INITIAL, EXISTS);
+ changeDirectoryEntry(leafEntry, autoSelect, INITIAL, EXISTS);
return;
}
@@ -780,7 +801,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, INITIAL, !EXISTS);
+ changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS);
}
var onBaseError = function(err) {
@@ -801,7 +822,7 @@
var onBaseFound = function(baseDirEntry) {
if (!leafName) {
// Default path is just a directory, cd to it and we're done.
- changeDirectoryEntry(baseDirEntry, INITIAL, !EXISTS);
+ changeDirectoryEntry(baseDirEntry, autoSelect, INITIAL, !EXISTS);
return;
}
Property changes on: chrome/browser/resources/file_manager/js/directory_model.js
___________________________________________________________________
Deleted: svn:mergeinfo
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698