Commit 1f657186 authored by Tatsuhisa Yamaguchi's avatar Tatsuhisa Yamaguchi Committed by Commit Bot

Serve "Get Info" command from the toolbar menu button.

TEST=manually tested get-info command enabled for single selection and disabled for multiple selection
TEST=manually tested chrome://histograms records the new way to open QuickView as #2.

Bug: 740842
Change-Id: I3c9d58f7d3877e7b059bb386a56cdc8d4e54a43b
Reviewed-on: https://chromium-review.googlesource.com/571380
Commit-Queue: Tatsuhisa Yamaguchi <yamaguchi@chromium.org>
Reviewed-by: default avatarNaoki Fukino <fukino@chromium.org>
Cr-Commit-Position: refs/heads/master@{#486732}
parent ae912960
......@@ -16636,6 +16636,7 @@ uploading your change for review. These are checked by presubmit scripts.
<enum name="FileManagerQuickViewWayToOpen">
<int value="0" label="Context menu"/>
<int value="1" label="Space key"/>
<int value="2" label="Selection menu"/>
</enum>
<enum name="FileManagerRootType">
......@@ -590,10 +590,10 @@ FileManager.prototype = /** @struct */ {
this.metadataModel_, this.quickViewModel_, this.fileMetadataFormatter_);
this.quickViewController_ = new QuickViewController(
assert(this.metadataModel_), assert(this.selectionHandler_),
assert(this.ui_.listContainer), assert(this.quickViewModel_),
assert(this.taskController_), fileListSelectionModel,
assert(this.quickViewUma_), metadataBoxController, this.dialogType,
assert(this.volumeManager_));
assert(this.ui_.listContainer), assert(this.ui_.selectionMenuButton),
assert(this.quickViewModel_), assert(this.taskController_),
fileListSelectionModel, assert(this.quickViewUma_),
metadataBoxController, this.dialogType, assert(this.volumeManager_));
if (this.dialogType === DialogType.FULL_PAGE) {
importer.importEnabled().then(
......
......@@ -1080,7 +1080,8 @@ CommandHandler.COMMANDS_['get-info'] = /** @type {Command} */ ({
* @param {!CommandHandlerDeps} fileManager CommandHandlerDeps to use.
*/
canExecute: function(event, fileManager) {
var entries = CommandUtil.getCommandEntries(event.target);
// QuickViewModel refers the file selection instead of event target.
var entries = fileManager.getSelection().entries;
if (entries.length === 0) {
event.canExecute = false;
event.command.setHidden(true);
......
......@@ -9,6 +9,7 @@
* @param {!MetadataModel} metadataModel File system metadata.
* @param {!FileSelectionHandler} selectionHandler
* @param {!ListContainer} listContainer
* @param {!cr.ui.MenuButton} selectionMenuButton
* @param {!QuickViewModel} quickViewModel
* @param {!TaskController} taskController
* @param {!cr.ui.ListSelectionModel} fileListSelectionModel
......@@ -20,8 +21,8 @@
* @constructor
*/
function QuickViewController(
metadataModel, selectionHandler, listContainer, quickViewModel,
taskController, fileListSelectionModel, quickViewUma,
metadataModel, selectionHandler, listContainer, selectionMenuButton,
quickViewModel, taskController, fileListSelectionModel, quickViewUma,
metadataBoxController, dialogType, volumeManager) {
/**
* @type {FilesQuickView}
......@@ -103,9 +104,13 @@ function QuickViewController(
this.listContainer_.element.addEventListener(
'keydown', this.onKeyDownToOpen_.bind(this));
this.listContainer_.element.addEventListener('command', function(event) {
if(event.command.id === 'get-info')
if (event.command.id === 'get-info')
this.display_(QuickViewUma.WayToOpen.CONTEXT_MENU);
}.bind(this));
selectionMenuButton.addEventListener('command', function(event) {
if (event.command.id === 'get-info')
this.display_(QuickViewUma.WayToOpen.SELECTION_MENU);
}.bind(this));
}
/**
......
......@@ -32,6 +32,7 @@ function QuickViewUma(volumeManager, dialogType) {
QuickViewUma.WayToOpen = {
CONTEXT_MENU: 'contextMenu',
SPACE_KEY: 'spaceKey',
SELECTION_MENU: 'selectionMenu',
};
/**
......@@ -43,6 +44,7 @@ QuickViewUma.WayToOpen = {
QuickViewUma.WayToOpenValues_ = [
QuickViewUma.WayToOpen.CONTEXT_MENU,
QuickViewUma.WayToOpen.SPACE_KEY,
QuickViewUma.WayToOpen.SELECTION_MENU,
];
/**
......
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