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) { ...@@ -476,80 +476,74 @@ FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) {
if (this.selection != selection) return; if (this.selection != selection) return;
// Update the file tasks. // 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 && if (this.fileManager_.dialogType == DialogType.FULL_PAGE &&
selection.directoryCount == 0 && selection.fileCount > 0) { 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 { } else {
this.taskItems_.hidden = true; this.taskItems_.hidden = true;
} }
// Update the UI. // Update preview panels.
var wasVisible = this.isPreviewPanelVisibile_(); 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.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(); var path = this.fileManager_.getCurrentDirectory();
// Hides the breadcrumbs list on the root path. if (selection.totalCount == 1) {
if (PathUtil.isRootPath(path)) // Shows the breadcrumb list when a file is selected.
this.updatePreviewPanelBreadcrumbs_(null); updateTarget = selection.entries[0].fullPath;
else } else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) {
this.updatePreviewPanelBreadcrumbs_(path); // Shows the breadcrumb list when no file is selected and the current
var entry = this.fileManager_.getCurrentDirectoryEntry(); // directory is non-root path.
this.showPreviewThumbnails_([entry]); updateTarget = path;
this.updatePreviewPanelText_(); }
return;
} }
this.updatePreviewPanelBreadcrumbs_(updateTarget);
this.fileManager_.updateContextMenuActionItems(null, false); // Scroll to item
if (!wasVisible && this.selection.totalCount == 1) { if (!wasVisible && this.selection.totalCount == 1) {
var list = this.fileManager_.getCurrentList(); var list = this.fileManager_.getCurrentList();
list.scrollIndexIntoView(list.selectionModel.selectedIndex); list.scrollIndexIntoView(list.selectionModel.selectedIndex);
} }
// Sync the commands availability. // Sync the commands availability.
var commands = this.fileManager_.dialogDom_.querySelectorAll('command'); if (selection.totalCount != 0) {
for (var i = 0; i < commands.length; i++) var commands = this.fileManager_.dialogDom_.querySelectorAll('command');
commands[i].canExecuteChange(); 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_();
}
} }
// Inform tests it's OK to click buttons now. // Update context menu.
chrome.test.sendMessage('selection-change-complete'); this.fileManager_.updateContextMenuActionItems(null, false);
// Show thumbnails. // Inform tests it's OK to click buttons now.
this.showPreviewThumbnails_(selection.entries); 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