Commit d533188a authored by hirono@chromium.org's avatar hirono@chromium.org

Made the open menu item in the context menu updated when the context menu is open.

Originally, FileSelectionHandler#updateFileSelectionAsync have the complex
conditional statements. And when util.platform.newUI() is true and
selection.totalCount is zero, updateContextMenuActionItems that updates the open
menu item is not called.

This CL arranged the statements by the target of update and added some comments.

BUG=243687
TEST=manually

Review URL: https://chromiumcodereview.appspot.com/15950003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202508 0039d316-1c4b-4281-b951-d872f2087c98
parent 7df9fe9d
......@@ -476,80 +476,72 @@ FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) {
if (this.selection != selection) return;
// Update the file tasks.
var onTasks = function() {
if (this.selection != selection) return;
selection.tasks.display(this.taskItems_);
selection.tasks.updateMenuItem();
}.bind(this);
if (this.fileManager_.dialogType == DialogType.FULL_PAGE &&
selection.directoryCount == 0 && selection.fileCount > 0) {
selection.createTasks(onTasks);
selection.createTasks(function() {
if (this.selection != selection)
return;
selection.tasks.display(this.taskItems_);
selection.tasks.updateMenuItem();
}.bind(this));
} else {
this.taskItems_.hidden = true;
}
// Update the UI.
// Update preview panels.
var wasVisible = this.isPreviewPanelVisibile_();
var thumbnailEntries;
if (util.platform.newUI() && selection.totalCount == 0) {
thumbnailEntries = [
this.fileManager_.getCurrentDirectoryEntry()
];
} else {
thumbnailEntries = selection.entries;
if (selection.totalCount != 1) {
selection.computeBytes(function() {
if (this.selection != selection)
return;
this.updatePreviewPanelText_();
}.bind(this));
}
}
this.updatePreviewPanelVisibility_();
this.updatePreviewPanelText_();
this.showPreviewThumbnails_(thumbnailEntries);
if (util.platform.newUI() && selection.totalCount == 0) {
// Update breadcrums.
var updateTarget = null;
if (util.platform.newUI()) {
var path = this.fileManager_.getCurrentDirectory();
// Hides the breadcrumbs list on the root path.
if (PathUtil.isRootPath(path))
this.updatePreviewPanelBreadcrumbs_(null);
else
this.updatePreviewPanelBreadcrumbs_(path);
var entry = this.fileManager_.getCurrentDirectoryEntry();
this.showPreviewThumbnails_([entry]);
this.updatePreviewPanelText_();
return;
if (selection.totalCount == 1) {
// Shows the breadcrumb list when a file is selected.
updateTarget = selection.entries[0].fullPath;
} else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) {
// Shows the breadcrumb list when no file is selected and the current
// directory is non-root path.
updateTarget = path;
}
}
this.updatePreviewPanelBreadcrumbs_(updateTarget);
this.fileManager_.updateContextMenuActionItems(null, false);
// Scroll to item
if (!wasVisible && this.selection.totalCount == 1) {
var list = this.fileManager_.getCurrentList();
list.scrollIndexIntoView(list.selectionModel.selectedIndex);
}
// Sync the commands availability.
var commands = this.fileManager_.dialogDom_.querySelectorAll('command');
for (var i = 0; i < commands.length; i++)
commands[i].canExecuteChange();
if (!util.platform.newUI()) {
this.updateSearchBreadcrumbs_();
// Update the summary information.
var onBytes = function() {
if (this.selection != selection) return;
this.updatePreviewPanelText_();
}.bind(this);
selection.computeBytes(onBytes);
this.updatePreviewPanelText_();
} else {
if (selection.totalCount == 1) {
// Shows the breadcrumb list.
var firstEntry = selection.entries[0];
this.updatePreviewPanelBreadcrumbs_(firstEntry.fullPath);
this.updatePreviewPanelText_();
} else {
this.updatePreviewPanelBreadcrumbs_(null);
// Update the summary information.
var onBytes = function() {
if (this.selection != selection) return;
this.updatePreviewPanelText_();
}.bind(this);
selection.computeBytes(onBytes);
this.updatePreviewPanelText_();
}
if (selection.totalCount != 0) {
var commands = this.fileManager_.dialogDom_.querySelectorAll('command');
for (var i = 0; i < commands.length; i++)
commands[i].canExecuteChange();
}
// Update context menu.
this.fileManager_.updateContextMenuActionItems(null, false);
// Inform tests it's OK to click buttons now.
chrome.test.sendMessage('selection-change-complete');
// Show thumbnails.
this.showPreviewThumbnails_(selection.entries);
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment