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

Unified Diff: ui/file_manager/file_manager/foreground/js/ui/directory_tree.js

Issue 1137383002: Show the eject button only for removabled and file handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments + fixed tests. Created 5 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
Index: ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
diff --git a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
index 109d481be913ae54845aa3b3fe5704ba56dd3c08..c38e6e35db0046e62e2737074a0d3ef1a637d4eb 100644
--- a/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
+++ b/ui/file_manager/file_manager/foreground/js/ui/directory_tree.js
@@ -433,10 +433,13 @@ function VolumeItem(modelItem, tree) {
item.modelItem_ = modelItem;
item.volumeInfo_ = modelItem.volumeInfo;
-
- // Sets up icons of the item.
item.setupIcon_(item.querySelector('.icon'), item.volumeInfo_);
- item.setupEjectButton_(item.rowElement);
+
+ // Attach the "eject" icon if the volume is ejectable.
+ if (modelItem.volumeInfo_.source === VolumeManagerCommon.Source.DEVICE ||
+ modelItem.volumeInfo_.source === VolumeManagerCommon.Source.FILE) {
+ item.setupEjectButton_(item.rowElement);
+ }
// Sets up context menu of the item.
if (tree.contextMenuForRootItems)
@@ -479,8 +482,7 @@ VolumeItem.prototype = {
* @param {!cr.ui.Menu} menu Menu to be set.
*/
VolumeItem.prototype.setContextMenu = function(menu) {
hirono 2015/05/15 08:27:45 Can we make it private?
mtomasz 2015/05/15 09:32:37 Good idea. Done.
- if (this.isRemovable_())
- cr.ui.contextMenuHandler.setContextMenu(this, menu);
+ cr.ui.contextMenuHandler.setContextMenu(this, menu);
};
/**
@@ -509,17 +511,6 @@ VolumeItem.prototype.activate = function() {
};
/**
- * @return {boolean} True if this volume can be removed by user operation.
- * @private
- */
-VolumeItem.prototype.isRemovable_ = function() {
- var volumeType = this.volumeInfo_.volumeType;
- return volumeType === VolumeManagerCommon.VolumeType.ARCHIVE ||
- volumeType === VolumeManagerCommon.VolumeType.REMOVABLE ||
- volumeType === VolumeManagerCommon.VolumeType.PROVIDED;
-};
-
-/**
* Set up icon of this volume item.
* @param {Element} icon Icon element to be setup.
* @param {VolumeInfo} volumeInfo VolumeInfo determines the icon type.
@@ -548,31 +539,29 @@ VolumeItem.prototype.setupIcon_ = function(icon, volumeInfo) {
* @private
*/
VolumeItem.prototype.setupEjectButton_ = function(rowElement) {
- if (this.isRemovable_()) {
- var ejectButton = cr.doc.createElement('div');
- // Block other mouse handlers.
- ejectButton.addEventListener(
- 'mouseup', function(event) { event.stopPropagation() });
- ejectButton.addEventListener(
- 'mousedown', function(event) { event.stopPropagation() });
- ejectButton.className = 'root-eject';
- ejectButton.setAttribute('aria-label', str('UNMOUNT_DEVICE_BUTTON_LABEL'));
- ejectButton.addEventListener('click', function(event) {
- event.stopPropagation();
- var unmountCommand = cr.doc.querySelector('command#unmount');
- // Let's make sure 'canExecute' state of the command is properly set for
- // the root before executing it.
- unmountCommand.canExecuteChange(this);
- unmountCommand.execute(this);
- }.bind(this));
- rowElement.appendChild(ejectButton);
+ var ejectButton = cr.doc.createElement('div');
+ // Block other mouse handlers.
+ ejectButton.addEventListener(
+ 'mouseup', function(event) { event.stopPropagation() });
+ ejectButton.addEventListener(
+ 'mousedown', function(event) { event.stopPropagation() });
+ ejectButton.className = 'root-eject';
+ ejectButton.setAttribute('aria-label', str('UNMOUNT_DEVICE_BUTTON_LABEL'));
+ ejectButton.addEventListener('click', function(event) {
+ event.stopPropagation();
+ var unmountCommand = cr.doc.querySelector('command#unmount');
+ // Let's make sure 'canExecute' state of the command is properly set for
+ // the root before executing it.
+ unmountCommand.canExecuteChange(this);
+ unmountCommand.execute(this);
+ }.bind(this));
+ rowElement.appendChild(ejectButton);
- // Add paper-ripple effect on the eject button.
- var ripple = cr.doc.createElement('paper-ripple');
- ripple.setAttribute('fit', '');
- ripple.className = 'circle recenteringTouch';
- ejectButton.appendChild(ripple);
- }
+ // Add paper-ripple effect on the eject button.
+ var ripple = cr.doc.createElement('paper-ripple');
+ ripple.setAttribute('fit', '');
+ ripple.className = 'circle recenteringTouch';
+ ejectButton.appendChild(ripple);
};

Powered by Google App Engine
This is Rietveld 408576698