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. ...@@ -16636,6 +16636,7 @@ uploading your change for review. These are checked by presubmit scripts.
<enum name="FileManagerQuickViewWayToOpen"> <enum name="FileManagerQuickViewWayToOpen">
<int value="0" label="Context menu"/> <int value="0" label="Context menu"/>
<int value="1" label="Space key"/> <int value="1" label="Space key"/>
<int value="2" label="Selection menu"/>
</enum> </enum>
<enum name="FileManagerRootType"> <enum name="FileManagerRootType">
...@@ -590,10 +590,10 @@ FileManager.prototype = /** @struct */ { ...@@ -590,10 +590,10 @@ FileManager.prototype = /** @struct */ {
this.metadataModel_, this.quickViewModel_, this.fileMetadataFormatter_); this.metadataModel_, this.quickViewModel_, this.fileMetadataFormatter_);
this.quickViewController_ = new QuickViewController( this.quickViewController_ = new QuickViewController(
assert(this.metadataModel_), assert(this.selectionHandler_), assert(this.metadataModel_), assert(this.selectionHandler_),
assert(this.ui_.listContainer), assert(this.quickViewModel_), assert(this.ui_.listContainer), assert(this.ui_.selectionMenuButton),
assert(this.taskController_), fileListSelectionModel, assert(this.quickViewModel_), assert(this.taskController_),
assert(this.quickViewUma_), metadataBoxController, this.dialogType, fileListSelectionModel, assert(this.quickViewUma_),
assert(this.volumeManager_)); metadataBoxController, this.dialogType, assert(this.volumeManager_));
if (this.dialogType === DialogType.FULL_PAGE) { if (this.dialogType === DialogType.FULL_PAGE) {
importer.importEnabled().then( importer.importEnabled().then(
......
...@@ -1080,7 +1080,8 @@ CommandHandler.COMMANDS_['get-info'] = /** @type {Command} */ ({ ...@@ -1080,7 +1080,8 @@ CommandHandler.COMMANDS_['get-info'] = /** @type {Command} */ ({
* @param {!CommandHandlerDeps} fileManager CommandHandlerDeps to use. * @param {!CommandHandlerDeps} fileManager CommandHandlerDeps to use.
*/ */
canExecute: function(event, fileManager) { 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) { if (entries.length === 0) {
event.canExecute = false; event.canExecute = false;
event.command.setHidden(true); event.command.setHidden(true);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* @param {!MetadataModel} metadataModel File system metadata. * @param {!MetadataModel} metadataModel File system metadata.
* @param {!FileSelectionHandler} selectionHandler * @param {!FileSelectionHandler} selectionHandler
* @param {!ListContainer} listContainer * @param {!ListContainer} listContainer
* @param {!cr.ui.MenuButton} selectionMenuButton
* @param {!QuickViewModel} quickViewModel * @param {!QuickViewModel} quickViewModel
* @param {!TaskController} taskController * @param {!TaskController} taskController
* @param {!cr.ui.ListSelectionModel} fileListSelectionModel * @param {!cr.ui.ListSelectionModel} fileListSelectionModel
...@@ -20,8 +21,8 @@ ...@@ -20,8 +21,8 @@
* @constructor * @constructor
*/ */
function QuickViewController( function QuickViewController(
metadataModel, selectionHandler, listContainer, quickViewModel, metadataModel, selectionHandler, listContainer, selectionMenuButton,
taskController, fileListSelectionModel, quickViewUma, quickViewModel, taskController, fileListSelectionModel, quickViewUma,
metadataBoxController, dialogType, volumeManager) { metadataBoxController, dialogType, volumeManager) {
/** /**
* @type {FilesQuickView} * @type {FilesQuickView}
...@@ -103,9 +104,13 @@ function QuickViewController( ...@@ -103,9 +104,13 @@ function QuickViewController(
this.listContainer_.element.addEventListener( this.listContainer_.element.addEventListener(
'keydown', this.onKeyDownToOpen_.bind(this)); 'keydown', this.onKeyDownToOpen_.bind(this));
this.listContainer_.element.addEventListener('command', function(event) { 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); this.display_(QuickViewUma.WayToOpen.CONTEXT_MENU);
}.bind(this)); }.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) { ...@@ -32,6 +32,7 @@ function QuickViewUma(volumeManager, dialogType) {
QuickViewUma.WayToOpen = { QuickViewUma.WayToOpen = {
CONTEXT_MENU: 'contextMenu', CONTEXT_MENU: 'contextMenu',
SPACE_KEY: 'spaceKey', SPACE_KEY: 'spaceKey',
SELECTION_MENU: 'selectionMenu',
}; };
/** /**
...@@ -43,6 +44,7 @@ QuickViewUma.WayToOpen = { ...@@ -43,6 +44,7 @@ QuickViewUma.WayToOpen = {
QuickViewUma.WayToOpenValues_ = [ QuickViewUma.WayToOpenValues_ = [
QuickViewUma.WayToOpen.CONTEXT_MENU, QuickViewUma.WayToOpen.CONTEXT_MENU,
QuickViewUma.WayToOpen.SPACE_KEY, 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