Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2270)

Unified Diff: chrome/browser/resources/file_manager/js/file_selection.js

Issue 15808007: Reland r202508: Made the open menu item in the context menu updated when the context menu is open. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/file_manager/js/file_selection.js
diff --git a/chrome/browser/resources/file_manager/js/file_selection.js b/chrome/browser/resources/file_manager/js/file_selection.js
index 88c5c15ea925060dd9538b63763b61d29dbb2493..f6169f20af59522317fb64695e75cc870d5fd1c7 100644
--- a/chrome/browser/resources/file_manager/js/file_selection.js
+++ b/chrome/browser/resources/file_manager/js/file_selection.js
@@ -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');
+ }
};
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698