Index: chrome/browser/resources/file_manager/js/file_manager.js |
diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js |
index eb1f9b7c4224e52dd0dae6f41ebf573689308d1f..2bbd14db34c4020a73743a7eb45d452b8b9f3bf2 100644 |
--- a/chrome/browser/resources/file_manager/js/file_manager.js |
+++ b/chrome/browser/resources/file_manager/js/file_manager.js |
@@ -482,7 +482,7 @@ FileManager.prototype = { |
(this.dialogType_ == FileManager.DialogType.FULL_PAGE || |
this.dialogType_ == FileManager.DialogType.SELECT_OPEN_MULTI_FILE); |
- this.table_.list.startBatchUpdates(); |
+ this.table_.startBatchUpdates(); |
this.grid_.startBatchUpdates(); |
this.initFileList_(); |
@@ -550,7 +550,7 @@ FileManager.prototype = { |
this.createMetadataProvider_(); |
- this.table_.list.endBatchUpdates(); |
+ this.table_.endBatchUpdates(); |
this.grid_.endBatchUpdates(); |
metrics.recordInterval('Load.DOM'); |
@@ -761,7 +761,9 @@ FileManager.prototype = { |
// TODO(dgozman): add "Add a drive" item. |
this.rootsList_.dataModel = this.directoryModel_.rootsList; |
- this.directoryModel_.updateRoots(); |
+ this.directoryModel_.updateRoots(function() { |
+ self.rootsList_.endBatchUpdates(); |
+ }); |
}; |
FileManager.prototype.initGData_ = function() { |
@@ -1397,6 +1399,11 @@ FileManager.prototype = { |
* window has neither. |
*/ |
FileManager.prototype.setupCurrentDirectory_ = function() { |
+ // Avoid a bunch of intermediate list redraws while the data model is |
+ // cleared and updated. |
+ this.table_.startBatchUpdates(); |
+ var onLoaded = this.table_.endBatchUpdates.bind(this.table_); |
+ |
if (location.hash) { |
// Location hash has the highest priority. |
var path = decodeURI(location.hash.substr(1)); |
@@ -1424,32 +1431,34 @@ FileManager.prototype = { |
// until the selection is done. |
var self = this; |
function onFileSelected() { |
+ onLoaded(); |
self.dispatchDefaultTask_(); |
setTimeout(removeShade, 1000); |
} |
- this.directoryModel_.setupPath(path, onResolve, onFileSelected); |
+ this.directoryModel_.setupPath(path, onFileSelected, onResolve); |
return; |
} |
- this.directoryModel_.setupPath(path); |
+ this.directoryModel_.setupPath(path, onLoaded); |
return; |
} |
if (this.params_.defaultPath) { |
var path = this.params_.defaultPath; |
if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) { |
- this.directoryModel_.setupPath(path, function(basePath, leafName) { |
- this.filenameInput_.value = leafName; |
- this.selectDefaultPathInFilenameInput_(); |
- }.bind(this)); |
+ this.directoryModel_.setupPath(path, onLoaded, |
+ function(basePath, leafName) { |
+ this.filenameInput_.value = leafName; |
+ this.selectDefaultPathInFilenameInput_(); |
+ }.bind(this)); |
return; |
} |
- this.directoryModel_.setupPath(path); |
+ this.directoryModel_.setupPath(path, onLoaded); |
return; |
} |
- this.directoryModel_.setupDefaultPath(); |
+ this.directoryModel_.setupDefaultPath(onLoaded); |
}; |
/** |
@@ -2348,7 +2357,7 @@ FileManager.prototype = { |
chrome.fileBrowserPrivate.getMountPoints(function(mountPoints) { |
self.setMountPoints_(mountPoints); |
- var changeDirectoryTo = null; |
+ var changeDirectoryCallback = null; |
if (event.eventType == 'mount') { |
// Mount request finished - remove it. |
@@ -2392,13 +2401,16 @@ FileManager.prototype = { |
return; |
} |
// Current durectory just unmounted. Move to the 'Downloads'. |
- changeDirectoryTo = '/' + DirectoryModel.DOWNLOADS_DIRECTORY; |
+ changeDirectoryCallback = function() { |
+ self.directoryModel_.changeDirectory( |
+ '/' + DirectoryModel.DOWNLOADS_DIRECTORY); |
+ }; |
} |
// Even if something failed root list should be rescanned. |
// Failed mounts can "give" us new devices which might be formatted, |
// so we have to refresh root list then. |
- self.directoryModel_.updateRoots(changeDirectoryTo); |
+ self.directoryModel_.updateRoots(changeDirectoryCallback); |
}); |
}; |