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 1fda67a1cae3d1bbb3a59ed95ef67cda1811f359..a05e02912486abf8b5a19ea4c16718b5cfe8a910 100644 |
--- a/chrome/browser/resources/file_manager/js/directory_model.js |
+++ b/chrome/browser/resources/file_manager/js/directory_model.js |
@@ -520,10 +520,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); |
@@ -552,8 +568,8 @@ DirectoryModel.prototype = { |
this.changeDirectoryEntry_(baseDirEntry, |
function() { |
this.selectEntry(leafEntry.name); |
- if (opt_fileSelectCallback) |
- opt_fileSelectCallback(); |
+ if (opt_loadedCallback) |
Vladislav Kaznacheev
2012/02/29 21:04:48
opt_loadedCallback has different semantic from the
Rick Byers
2012/03/02 00:19:46
Thanks. So you want to handle the case where the
|
+ opt_loadedCallback(); |
}.bind(this), |
false /*HACK*/); |
// TODO(kaznacheev): Fix history.replaceState for the File Browser and |
@@ -575,11 +591,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); |
@@ -608,8 +624,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) { |
@@ -754,7 +772,7 @@ DirectoryModel.prototype = { |
onGData, onGDataError); |
}, |
- updateRoots: function(opt_changeDirectoryTo) { |
+ updateRoots: function(opt_callback) { |
var self = this; |
this.resolveRoots_(function(rootEntries) { |
var dm = self.rootsList_; |
@@ -762,9 +780,8 @@ DirectoryModel.prototype = { |
dm.splice.apply(dm, args); |
self.updateRootsListSelection_(); |
- |
- if (opt_changeDirectoryTo) |
- self.changeDirectory(opt_changeDirectoryTo); |
+ if (opt_callback) |
+ opt_callback(); |
}); |
}, |