Chromium Code Reviews| 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..fc5159990e8888b5eff09e5d2648dbf7002a3796 100644 |
| --- a/chrome/browser/resources/file_manager/js/file_selection.js |
| +++ b/chrome/browser/resources/file_manager/js/file_selection.js |
| @@ -476,37 +476,50 @@ 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() { |
|
yoshiki
2013/05/28 02:26:48
Why moved to here? The logic doesn't seem changed.
hirono
2013/05/28 04:08:44
If a callback function is assigned to a variable,
yoshiki
2013/05/28 04:20:33
Got it. Thanks for explanation.
|
| + if (this.selection != selection) return; |
|
yoshiki
2013/05/28 02:26:48
nit: New line after condition.
hirono
2013/05/28 04:08:44
Done.
|
| + 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 = null; |
| + if (util.platform.newUI() && selection.totalCount == 0) { |
| + thumbnailEntries = [ |
| + this.fileManager_.getCurrentDirectoryEntry() |
| + ]; |
| + } else { |
| + thumbnailEntries = selection.entries; |
| + selection.computeBytes(function() { |
|
yoshiki
2013/05/28 02:26:48
if selection.totalCount == 1, we don't need to com
hirono
2013/05/28 04:08:44
Done.
|
| + if (this.selection != selection) return; |
|
yoshiki
2013/05/28 02:26:48
nit: New line after condition.
hirono
2013/05/28 04:08:44
Done.
|
| + 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. |
| + updateTarget = selection.entries[0].fullPath; |
| + } else if (selection.totalCount == 0 && !PathUtil.isRootPath(path)) { |
| + // Hides the breadcrumbs list on the root path. |
|
yoshiki
2013/05/28 02:26:48
Does this comment appropriate for this block?
May
hirono
2013/05/28 04:08:44
Done.
|
| + 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); |
| @@ -517,39 +530,11 @@ FileSelectionHandler.prototype.updateFileSelectionAsync = function(selection) { |
| 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_(); |
| - } |
| - } |
| + // 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); |
| }; |
| /** |