Index: chrome/browser/resources/file_manager/js/directory_model.js |
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js |
index 8048f005972e50a024be7681ad97c1645022c040..207bc9552ac7f136971aa7197b64a44a4facd8a9 100644 |
--- a/chrome/browser/resources/file_manager/js/directory_model.js |
+++ b/chrome/browser/resources/file_manager/js/directory_model.js |
@@ -522,10 +522,26 @@ DirectoryModel.prototype = { |
this.dispatchEvent(e); |
}, |
- setupPath: function(path, opt_pathResolveCallback, opt_fileSelectCallback) { |
+ /** |
+ * Change the state of the model to reflect the specified path (either a |
+ * file or directory). |
+ * |
+ * @param {string} path The root path to use |
+ * @param {Function=} opt_loadedCallback Invoked when the entire directory |
+ * has been loaded and any default file selected. |
+ * @param {Function=} opt_pathResolveCallback Invoked as soon as the path has |
+ * been resolved, and called with the base and leaf portions of the path |
+ * name, and a flag indicating if the entry exists. |
+ */ |
+ setupPath: function(path, opt_loadedCallback, opt_pathResolveCallback) { |
// Split the dirname from the basename. |
var ary = path.match(/^(?:(.*)\/)?([^\/]*)$/); |
- var autoSelect = this.selectIndex.bind(this, this.autoSelectIndex_); |
+ var autoSelect = function() { |
+ this.selectIndex(this.autoSelectIndex_); |
+ if (opt_loadedCallback) |
+ opt_loadedCallback(); |
+ }.bind(this); |
+ |
if (!ary) { |
console.warn('Unable to split default path: ' + path); |
this.changeDirectoryEntry_(this.root_, autoSelect, true); |
@@ -554,8 +570,8 @@ DirectoryModel.prototype = { |
this.changeDirectoryEntry_(baseDirEntry, |
function() { |
this.selectEntry(leafEntry.name); |
- if (opt_fileSelectCallback) |
- opt_fileSelectCallback(); |
+ if (opt_loadedCallback) |
+ opt_loadedCallback(); |
}.bind(this), |
false /*HACK*/); |
// TODO(kaznacheev): Fix history.replaceState for the File Browser and |
@@ -577,11 +593,11 @@ DirectoryModel.prototype = { |
baseName + '": ' + err); |
if (path != '/' + DirectoryModel.DOWNLOADS_DIRECTORY) { |
// Can't find the provided path, let's go to default one instead. |
- this.setupDefaultPath(); |
+ this.setupDefaultPath(opt_loadedCallback); |
} 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); |
+ this.changeDirectory('/', opt_loadedCallback, true); |
} |
}.bind(this); |
@@ -610,8 +626,10 @@ DirectoryModel.prototype = { |
} |
}, |
- setupDefaultPath: function() { |
- this.getDefaultDirectory_(this.setupPath.bind(this)); |
+ setupDefaultPath: function(opt_callback) { |
+ this.getDefaultDirectory_(function(path) { |
+ this.setupPath(path, opt_callback); |
+ }.bind(this)); |
}, |
getDefaultDirectory_: function(callback) { |
@@ -756,7 +774,7 @@ DirectoryModel.prototype = { |
onGData, onGDataError); |
}, |
- updateRoots: function(opt_changeDirectoryTo) { |
+ updateRoots: function(opt_callback) { |
var self = this; |
this.resolveRoots_(function(rootEntries) { |
var dm = self.rootsList_; |
@@ -764,9 +782,8 @@ DirectoryModel.prototype = { |
dm.splice.apply(dm, args); |
self.updateRootsListSelection_(); |
- |
- if (opt_changeDirectoryTo) |
- self.changeDirectory(opt_changeDirectoryTo); |
+ if (opt_callback) |
+ opt_callback(); |
}); |
}, |