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

Reland r202508: Made the open menu item in the context menu updated when the context menu is open.

Original patch broke SelectFileAndOpen browser test. This is because Files.app
notify 'selection-change-complete' to the tests even if the selection is empty.
This CL is fixed the problem by adding a check of the number of selected items.

Previously reverted CL: crrev.com/15950003

BUG=243687
TEST=browser_tests

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@202798 0039d316-1c4b-4281-b951-d872f2087c98
parent 18fb3d13
......@@ -476,80 +476,74 @@ 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();
}
// Inform tests it's OK to click buttons now.
chrome.test.sendMessage('selection-change-complete');
// Update context menu.
this.fileManager_.updateContextMenuActionItems(null, false);
// Show thumbnails.
this.showPreviewThumbnails_(selection.entries);
// Inform tests it's OK to click buttons now.
if (selection.totalCount > 0) {
chrome.test.sendMessage('selection-change-complete');
}
};
/**
......
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