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