Commit b0685e16 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Files app: ES6 class empty_folder_controller.js, navigation_uma.js and launch_param.js

Bug: 778674
Change-Id: Iab56d84cf26975f9c476680d74037a9088ec1c78
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760837
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688487}
parent 20c58415
...@@ -4,13 +4,14 @@ ...@@ -4,13 +4,14 @@
/** /**
* Empty folder controller. * Empty folder controller.
*/
class EmptyFolderController {
/**
* @param {!EmptyFolder} emptyFolder Empty folder ui. * @param {!EmptyFolder} emptyFolder Empty folder ui.
* @param {!DirectoryModel} directoryModel Directory model. * @param {!DirectoryModel} directoryModel Directory model.
* @param {!FilesAlertDialog} alertDialog Alert dialog. * @param {!FilesAlertDialog} alertDialog Alert dialog.
* @constructor
* @struct
*/ */
function EmptyFolderController(emptyFolder, directoryModel, alertDialog) { constructor(emptyFolder, directoryModel, alertDialog) {
/** /**
* @private {!EmptyFolder} * @private {!EmptyFolder}
*/ */
...@@ -48,32 +49,32 @@ function EmptyFolderController(emptyFolder, directoryModel, alertDialog) { ...@@ -48,32 +49,32 @@ function EmptyFolderController(emptyFolder, directoryModel, alertDialog) {
'rescan-completed', this.onScanFinished_.bind(this)); 'rescan-completed', this.onScanFinished_.bind(this));
this.dataModel_.addEventListener('splice', this.onSplice_.bind(this)); this.dataModel_.addEventListener('splice', this.onSplice_.bind(this));
} }
/** /**
* Handles splice event. * Handles splice event.
* @private * @private
*/ */
EmptyFolderController.prototype.onSplice_ = function() { onSplice_() {
this.update_(); this.update_();
}; }
/** /**
* Handles scan start. * Handles scan start.
* @private * @private
*/ */
EmptyFolderController.prototype.onScanStarted_ = function() { onScanStarted_() {
this.isScanning_ = true; this.isScanning_ = true;
this.update_(); this.update_();
}; }
/** /**
* Handles scan fail. * Handles scan fail.
* @param {Event} event Event may contain error field containing DOMError for * @param {Event} event Event may contain error field containing DOMError for
* alert. * alert.
* @private * @private
*/ */
EmptyFolderController.prototype.onScanFailed_ = function(event) { onScanFailed_(event) {
this.isScanning_ = false; this.isScanning_ = false;
// Show alert for crostini connection error. // Show alert for crostini connection error.
if (event.error.name == DirectoryModel.CROSTINI_CONNECT_ERR) { if (event.error.name == DirectoryModel.CROSTINI_CONNECT_ERR) {
...@@ -81,22 +82,22 @@ EmptyFolderController.prototype.onScanFailed_ = function(event) { ...@@ -81,22 +82,22 @@ EmptyFolderController.prototype.onScanFailed_ = function(event) {
str('ERROR_LINUX_FILES_CONNECTION'), event.error.message); str('ERROR_LINUX_FILES_CONNECTION'), event.error.message);
} }
this.update_(); this.update_();
}; }
/** /**
* Handles scan finish. * Handles scan finish.
* @private * @private
*/ */
EmptyFolderController.prototype.onScanFinished_ = function() { onScanFinished_() {
this.isScanning_ = false; this.isScanning_ = false;
this.update_(); this.update_();
}; }
/** /**
* Updates visibility of empty folder UI. * Updates visibility of empty folder UI.
* @private * @private
*/ */
EmptyFolderController.prototype.update_ = function() { update_() {
if (!this.isScanning_ && this.dataModel_.length === 0) { if (!this.isScanning_ && this.dataModel_.length === 0) {
const query = this.directoryModel_.getLastSearchQuery(); const query = this.directoryModel_.getLastSearchQuery();
let html = ''; let html = '';
...@@ -111,4 +112,5 @@ EmptyFolderController.prototype.update_ = function() { ...@@ -111,4 +112,5 @@ EmptyFolderController.prototype.update_ = function() {
} else { } else {
this.emptyFolder_.hide(); this.emptyFolder_.hide();
} }
}; }
}
...@@ -10,12 +10,11 @@ ...@@ -10,12 +10,11 @@
*/ */
let SuggestAppDialogState; let SuggestAppDialogState;
/** class LaunchParam {
/**
* @param {!Object} unformatted Unformatted option. * @param {!Object} unformatted Unformatted option.
* @constructor
* @struct
*/ */
function LaunchParam(unformatted) { constructor(unformatted) {
/** /**
* @type {DialogType} * @type {DialogType}
* @const * @const
...@@ -47,7 +46,8 @@ function LaunchParam(unformatted) { ...@@ -47,7 +46,8 @@ function LaunchParam(unformatted) {
* @type {string} * @type {string}
* @const * @const
*/ */
this.targetName = unformatted['targetName'] ? unformatted['targetName'] : ''; this.targetName =
unformatted['targetName'] ? unformatted['targetName'] : '';
/** /**
* @type {!Array<!Object>} * @type {!Array<!Object>}
...@@ -85,4 +85,5 @@ function LaunchParam(unformatted) { ...@@ -85,4 +85,5 @@ function LaunchParam(unformatted) {
* @const * @const
*/ */
this.showAndroidPickerApps = !!unformatted['showAndroidPickerApps']; this.showAndroidPickerApps = !!unformatted['showAndroidPickerApps'];
}
} }
...@@ -5,19 +5,21 @@ ...@@ -5,19 +5,21 @@
/** /**
* UMA exporter for navigation in the Files app. * UMA exporter for navigation in the Files app.
* *
*/
class NavigationUma {
/**
* @param {!VolumeManager} volumeManager * @param {!VolumeManager} volumeManager
* *
* @constructor
*/ */
function NavigationUma(volumeManager) { constructor(volumeManager) {
/** /**
* @type {!VolumeManager} * @type {!VolumeManager}
* @private * @private
*/ */
this.volumeManager_ = volumeManager; this.volumeManager_ = volumeManager;
} }
/** /**
* Exports file type metric with the given |name|. * Exports file type metric with the given |name|.
* *
* @param {!FileEntry} entry * @param {!FileEntry} entry
...@@ -25,19 +27,20 @@ function NavigationUma(volumeManager) { ...@@ -25,19 +27,20 @@ function NavigationUma(volumeManager) {
* *
* @private * @private
*/ */
NavigationUma.prototype.exportRootType_ = function(entry, name) { exportRootType_(entry, name) {
const locationInfo = this.volumeManager_.getLocationInfo(entry); const locationInfo = this.volumeManager_.getLocationInfo(entry);
if (locationInfo) { if (locationInfo) {
metrics.recordEnum( metrics.recordEnum(
name, locationInfo.rootType, VolumeManagerCommon.RootTypesForUMA); name, locationInfo.rootType, VolumeManagerCommon.RootTypesForUMA);
} }
}; }
/** /**
* Exports UMA based on the entry that has became new current directory. * Exports UMA based on the entry that has became new current directory.
* *
* @param {!FileEntry} entry the new directory * @param {!FileEntry} entry the new directory
*/ */
NavigationUma.prototype.onDirectoryChanged = function(entry) { onDirectoryChanged(entry) {
this.exportRootType_(entry, 'ChangeDirectory.RootType'); this.exportRootType_(entry, 'ChangeDirectory.RootType');
}; }
}
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