Commit 0709f3d4 authored by Julian Watson's avatar Julian Watson Committed by Commit Bot

file_manager: fix linting errors

Bug: 778674
Test: autoninja -C out/Release ui/file_manager:closure_compile
Test: autoninja -C out/Release browser_tests && out/Release/browser_tests --gtest_filter=*/FilesApp*
Change-Id: I1a9e532afc0122a78328eae857e0dbf34971fcbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212015
Commit-Queue: Julian Watson <juwa@google.com>
Auto-Submit: Julian Watson <juwa@google.com>
Reviewed-by: default avatarFrançois Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771492}
parent bc5da8c9
......@@ -59,26 +59,23 @@ function AudioPlayer(container) {
// Restore the saved state from local storage, and update the local storage
// if the states are changed.
var STORAGE_PREFIX = 'audioplayer-';
var KEYS_TO_SAVE_STATES =
['shuffle',
'repeat-mode',
'volume',
'playlist-expanded',
'track-info-expanded'];
var storageKeys = KEYS_TO_SAVE_STATES.map(a => STORAGE_PREFIX + a);
const STORAGE_PREFIX = 'audioplayer-';
const KEYS_TO_SAVE_STATES = [
'shuffle', 'repeat-mode', 'volume', 'playlist-expanded',
'track-info-expanded'
];
const storageKeys = KEYS_TO_SAVE_STATES.map(a => STORAGE_PREFIX + a);
chrome.storage.local.get(storageKeys, function(results) {
// Update the UI by loaded state.
for (var storageKey in results) {
var key = storageKey.substr(STORAGE_PREFIX.length);
for (const storageKey in results) {
const key = storageKey.substr(STORAGE_PREFIX.length);
this.player_[Polymer.CaseMap.dashToCamelCase(key)] = results[storageKey];
}
// Start listening to UI changes to write back the states to local storage.
for (var i = 0; i < KEYS_TO_SAVE_STATES.length; i++) {
for (let i = 0; i < KEYS_TO_SAVE_STATES.length; i++) {
this.player_.addEventListener(
KEYS_TO_SAVE_STATES[i] + '-changed',
function(storageKey, event) {
var objectToBeSaved = {};
KEYS_TO_SAVE_STATES[i] + '-changed', function(storageKey, event) {
const objectToBeSaved = {};
objectToBeSaved[storageKey] = event.detail.value;
chrome.storage.local.set(objectToBeSaved);
}.bind(this, storageKeys[i]));
......@@ -134,7 +131,7 @@ function AudioPlayer(container) {
document.addEventListener('keydown', this.onKeyDown_.bind(this));
// Show the window after DOM is processed.
var currentWindow = chrome.app.window.current();
const currentWindow = chrome.app.window.current();
if (currentWindow) {
setTimeout(currentWindow.show.bind(currentWindow), 0);
}
......@@ -193,19 +190,18 @@ AudioPlayer.prototype.load = function(playlist) {
util.URLsToEntries(playlist.items || [], function(entries) {
this.entries_ = entries;
var position = playlist.position || 0;
var time = playlist.time || 0;
const position = playlist.position || 0;
if (this.entries_.length == 0) {
return;
}
var newTracks = [];
var currentTracks = this.player_.tracks;
var unchanged = (currentTracks.length === this.entries_.length);
const newTracks = [];
const currentTracks = this.player_.tracks;
let unchanged = (currentTracks.length === this.entries_.length);
for (var i = 0; i != this.entries_.length; i++) {
var entry = this.entries_[i];
for (let i = 0; i != this.entries_.length; i++) {
const entry = this.entries_[i];
newTracks.push(new AudioPlayer.TrackInfo(entry));
if (unchanged && entry.toURL() !== currentTracks[i].url) {
......@@ -224,7 +220,7 @@ AudioPlayer.prototype.load = function(playlist) {
// Load the selected track metadata first, then load the rest.
this.loadMetadata_(position);
for (i = 0; i != this.entries_.length; i++) {
for (let i = 0; i != this.entries_.length; i++) {
if (i != position) {
this.loadMetadata_(i);
}
......@@ -311,7 +307,7 @@ AudioPlayer.prototype.select_ = function(newTrack) {
window.appState.time = 0;
appUtil.saveAppState();
var entry = this.entries_[this.currentTrackIndex_];
const entry = this.entries_[this.currentTrackIndex_];
this.fetchMetadata_(entry, function(metadata) {
if (this.currentTrackIndex_ != newTrack) {
......@@ -345,18 +341,17 @@ AudioPlayer.prototype.fetchMetadata_ = function(entry, callback) {
* @private
*/
AudioPlayer.prototype.onError_ = function() {
var track = this.currentTrackIndex_;
const track = this.currentTrackIndex_;
this.invalidTracks_[track] = true;
this.fetchMetadata_(
this.entries_[track],
function(metadata) {
var error = (!navigator.onLine && !metadata.present) ?
this.offlineString_ : this.errorString_;
this.displayMetadata_(track, metadata, error);
this.player_.onAudioError();
}.bind(this));
this.fetchMetadata_(this.entries_[track], function(metadata) {
const error = (!navigator.onLine && !metadata.present) ?
this.offlineString_ :
this.errorString_;
this.displayMetadata_(track, metadata, error);
this.player_.onAudioError();
}.bind(this));
};
/**
......@@ -366,8 +361,8 @@ AudioPlayer.prototype.onError_ = function() {
* @private
*/
AudioPlayer.prototype.onResize_ = function(event) {
var trackListHeight =
(/** @type {{trackList:TrackListElement}} */ (this.player_.$))
const trackListHeight =
(/** @type {{trackList:TrackListElement}} */ (this.player_.$))
.trackList.clientHeight;
if (trackListHeight > AudioPlayer.TOP_PADDING_HEIGHT) {
this.isPlaylistExpanded_ = true;
......@@ -393,16 +388,20 @@ AudioPlayer.prototype.onKeyDown_ = function(event) {
// Handle debug shortcut keys.
case 'Ctrl-Shift-I': // Ctrl+Shift+I
chrome.fileManagerPrivate.openInspector('normal');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.NORMAL);
break;
case 'Ctrl-Shift-J': // Ctrl+Shift+J
chrome.fileManagerPrivate.openInspector('console');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.CONSOLE);
break;
case 'Ctrl-Shift-C': // Ctrl+Shift+C
chrome.fileManagerPrivate.openInspector('element');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.ELEMENT);
break;
case 'Ctrl-Shift-B': // Ctrl+Shift+B
chrome.fileManagerPrivate.openInspector('background');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.BACKGROUND);
break;
case ' ': // Space
......@@ -416,16 +415,16 @@ AudioPlayer.prototype.onKeyDown_ = function(event) {
case 'ArrowDown':
this.player_.dispatchEvent(new Event('small-backword-skip-event'));
break;
case 'ArrowRight':
var eventName = this.isRtl_ ? 'small-backword-skip-event' :
'small-forward-skip-event';
case 'ArrowRight': {
const eventName = this.isRtl_ ? 'small-backword-skip-event' :
'small-forward-skip-event';
this.player_.dispatchEvent(new Event(eventName));
break;
case 'ArrowLeft':
var eventName = this.isRtl_ ? 'small-forward-skip-event' :
'small-backword-skip-event';
} break;
case 'ArrowLeft': {
const eventName = this.isRtl_ ? 'small-forward-skip-event' :
'small-backword-skip-event';
this.player_.dispatchEvent(new Event(eventName));
break;
} break;
case 'l':
this.player_.dispatchEvent(new Event('big-forward-skip-event'));
break;
......@@ -571,8 +570,8 @@ AudioPlayer.prototype.onTrackInfoExpandedChanged_ = function(newValue) {
if (this.isTrackInfoExpanded_ !== newValue) {
this.isTrackInfoExpanded_ = newValue;
var state = chrome.app.window.current();
var newHeight = window.outerHeight;
const state = chrome.app.window.current();
let newHeight = window.outerHeight;
if (newValue) {
state.innerBounds.minHeight = AudioPlayer.EXPANDED_MODE_MIN_HEIGHT;
newHeight += AudioPlayer.EXPANDED_MODE_MIN_HEIGHT -
......@@ -594,15 +593,15 @@ AudioPlayer.prototype.onTrackInfoExpandedChanged_ = function(newValue) {
* @private
*/
AudioPlayer.prototype.syncHeightForPlaylist_ = function() {
var targetInnerHeight;
let targetInnerHeight;
if (this.player_.playlistExpanded) {
// playllist expanded.
if (!this.lastExpandedInnerHeight_ ||
this.lastExpandedInnerHeight_ < AudioPlayer.EXPANDED_MODE_MIN_HEIGHT) {
var expandedListHeight =
const expandedListHeight =
Math.min(this.entries_.length, AudioPlayer.DEFAULT_EXPANDED_ITEMS) *
AudioPlayer.TRACK_HEIGHT;
AudioPlayer.TRACK_HEIGHT;
if (this.player_.trackInfoExpanded) {
targetInnerHeight = AudioPlayer.TOP_PADDING_HEIGHT +
AudioPlayer.EXPANDED_ARTWORK_HEIGHT +
......@@ -653,9 +652,11 @@ AudioPlayer.TrackInfo = function(entry) {
* @return {string} Default track title (file name extracted from the url).
*/
AudioPlayer.TrackInfo.prototype.getDefaultTitle = function() {
var title = this.url.split('/').pop();
var dotIndex = title.lastIndexOf('.');
if (dotIndex >= 0) title = title.substr(0, dotIndex);
let title = this.url.split('/').pop();
const dotIndex = title.lastIndexOf('.');
if (dotIndex >= 0) {
title = title.substr(0, dotIndex);
}
title = decodeURIComponent(title);
return title;
};
......
......@@ -107,7 +107,7 @@ class CrostiniImpl {
// Record UMA.
const root = this.getRoot_(entry);
let suffix = CrostiniImpl.VALID_ROOT_TYPES_FOR_SHARE.get(root) ||
const suffix = CrostiniImpl.VALID_ROOT_TYPES_FOR_SHARE.get(root) ||
CrostiniImpl.UMA_ROOT_TYPE_OTHER;
metrics.recordSmallCount(
'CrostiniSharedPaths.Depth.' + suffix,
......@@ -143,7 +143,7 @@ class CrostiniImpl {
/**
* Handles events for enable/disable, share/unshare.
* @param {chrome.fileManagerPrivate.CrostiniEvent} event
* @param {!chrome.fileManagerPrivate.CrostiniEvent} event
* @private
*/
onCrostiniChanged_(event) {
......@@ -156,12 +156,12 @@ class CrostiniImpl {
break;
case chrome.fileManagerPrivate.CrostiniEventType.SHARE:
for (const entry of event.entries) {
this.registerSharedPath(event.vmName, entry);
this.registerSharedPath(event.vmName, assert(entry));
}
break;
case chrome.fileManagerPrivate.CrostiniEventType.UNSHARE:
for (const entry of event.entries) {
this.unregisterSharedPath(event.vmName, entry);
this.unregisterSharedPath(event.vmName, assert(entry));
}
break;
}
......
......@@ -3,7 +3,7 @@
// found in the LICENSE file.
// Namespace
var importer = importer || {};
window.importer = window.importer || {};
/**
* A duplicate finder for Google Drive.
......@@ -138,7 +138,6 @@ importer.DriveDuplicateFinder = class DriveDuplicateFinder {
volumeId, [hash],
/**
* @param {!Object<string, !Array<string>>|undefined} urls
* @this {importer.DriveDuplicateFinder}
*/
urls => {
const elapsedTime = new Date().getTime() - startTime;
......
......@@ -247,8 +247,8 @@ Object.freeze(DriveMetadataSearchContentScanner.SearchType);
class RecentContentScanner extends ContentScanner {
/**
* @param {string} query Search query.
* @param {string=} opt_sourceRestriction
* @param {string=} opt_recentFileType
* @param {chrome.fileManagerPrivate.SourceRestriction=} opt_sourceRestriction
* @param {chrome.fileManagerPrivate.RecentFileType=} opt_recentFileType
*/
constructor(query, opt_sourceRestriction, opt_recentFileType) {
super();
......@@ -259,13 +259,13 @@ class RecentContentScanner extends ContentScanner {
this.query_ = query.toLowerCase();
/**
* @private {string}
* @private {chrome.fileManagerPrivate.SourceRestriction}
*/
this.sourceRestriction_ = opt_sourceRestriction ||
chrome.fileManagerPrivate.SourceRestriction.ANY_SOURCE;
/**
* @private {string}
* @private {chrome.fileManagerPrivate.RecentFileType}
*/
this.recentFileType_ =
opt_recentFileType || chrome.fileManagerPrivate.RecentFileType.ALL;
......
......@@ -1187,7 +1187,7 @@ class FileManager extends cr.EventTarget {
(entries, firstForSession) => {
showToast = showToast || firstForSession;
for (const entry of entries) {
this.crostini_.registerSharedPath(vmName, entry);
this.crostini_.registerSharedPath(vmName, assert(entry));
}
resolve(entries.length);
});
......
......@@ -2263,7 +2263,8 @@ CommandHandler.COMMANDS_['unpin-folder'] = new class extends Command {
*/
CommandHandler.COMMANDS_['zoom-in'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.zoom('in');
chrome.fileManagerPrivate.zoom(
chrome.fileManagerPrivate.ZoomOperationType.IN);
}
};
......@@ -2272,7 +2273,8 @@ CommandHandler.COMMANDS_['zoom-in'] = new class extends Command {
*/
CommandHandler.COMMANDS_['zoom-out'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.zoom('out');
chrome.fileManagerPrivate.zoom(
chrome.fileManagerPrivate.ZoomOperationType.OUT);
}
};
......@@ -2281,7 +2283,8 @@ CommandHandler.COMMANDS_['zoom-out'] = new class extends Command {
*/
CommandHandler.COMMANDS_['zoom-reset'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.zoom('reset');
chrome.fileManagerPrivate.zoom(
chrome.fileManagerPrivate.ZoomOperationType.RESET);
}
};
......@@ -2342,7 +2345,8 @@ CommandHandler.COMMANDS_['sort-by-date'] = new class extends Command {
*/
CommandHandler.COMMANDS_['inspect-normal'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.openInspector('normal');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.NORMAL);
}
};
......@@ -2351,7 +2355,8 @@ CommandHandler.COMMANDS_['inspect-normal'] = new class extends Command {
*/
CommandHandler.COMMANDS_['inspect-console'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.openInspector('console');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.CONSOLE);
}
};
......@@ -2360,7 +2365,8 @@ CommandHandler.COMMANDS_['inspect-console'] = new class extends Command {
*/
CommandHandler.COMMANDS_['inspect-element'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.openInspector('element');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.ELEMENT);
}
};
......@@ -2369,7 +2375,8 @@ CommandHandler.COMMANDS_['inspect-element'] = new class extends Command {
*/
CommandHandler.COMMANDS_['inspect-background'] = new class extends Command {
execute(event, fileManager) {
chrome.fileManagerPrivate.openInspector('background');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.BACKGROUND);
}
};
......
......@@ -274,6 +274,18 @@ class TaskController {
this.ui_.fileContextMenu.defaultTaskMenuItem.taskId),
title: /** @type {string} */ (
this.ui_.fileContextMenu.defaultTaskMenuItem.label),
get iconUrl() {
assert(false);
return '';
},
get isDefault() {
assert(false);
return false;
},
get isGenericFileHandler() {
assert(false);
return false;
},
};
tasks.execute(task);
})
......
......@@ -27,7 +27,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
const oldGetLinuxPackageInfo = chrome.fileManagerPrivate.getLinuxPackageInfo;
let packageInfoCallback = null;
chrome.fileManagerPrivate.getLinuxPackageInfo = (entry, callback) => {
packageInfoCallback = callback;
packageInfoCallback = /** @type{function():void} */ (callback);
};
await test.setupAndWaitUntilReady([], [], [test.ENTRIES.debPackage]);
......@@ -53,7 +53,7 @@ crostiniTasks.testErrorLoadingLinuxPackageInfo = async (done) => {
// Call the callback with an error.
chrome.runtime.lastError = {message: 'error message'};
packageInfoCallback(undefined);
packageInfoCallback();
delete chrome.runtime.lastError;
assertEquals(
'Details\nFailed to retrieve app info.',
......
This diff is collapsed.
......@@ -285,7 +285,8 @@ ImageRequest.prototype.downloadOriginal_ = function(onSuccess, onFailure) {
drivefsUrlMatches[1],
entry => {
chrome.fileManagerPrivate.getThumbnail(
entry, !!this.request_.crop, thumbnail => {
/** @type {FileEntry} */ (entry), !!this.request_.crop,
thumbnail => {
if (!thumbnail) {
onFailure();
return;
......
......@@ -108,16 +108,20 @@ class NativeControlsVideoPlayer {
switch (key) {
// Handle debug shortcut keys.
case 'Ctrl+Shift+I':
chrome.fileManagerPrivate.openInspector('normal');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.NORMAL);
break;
case 'Ctrl+Shift+J':
chrome.fileManagerPrivate.openInspector('console');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.CONSOLE);
break;
case 'Ctrl+Shift+C':
chrome.fileManagerPrivate.openInspector('element');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.ELEMENT);
break;
case 'Ctrl+Shift+B':
chrome.fileManagerPrivate.openInspector('background');
chrome.fileManagerPrivate.openInspector(
chrome.fileManagerPrivate.InspectionType.BACKGROUND);
break;
case 'k':
......@@ -262,7 +266,7 @@ class NativeControlsVideoPlayer {
oldTop = window.screen.availHeight / 2;
}
let appWindow = chrome.app.window.current();
const appWindow = chrome.app.window.current();
appWindow.innerBounds.width = Math.round(newWidth);
appWindow.innerBounds.height = Math.round(newHeight);
appWindow.outerBounds.left =
......
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