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

Gallery, Video, Audio Players: Change var to let/const as pointed by presubmit

Bug: 1067478
Change-Id: If02f41840491558f3a6c33a07b2e507b8378e184
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148919
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759513}
parent b888c915
......@@ -9,21 +9,21 @@
* @type {!string}
* @const
*/
var AUDIO_PLAYER_ICON = 'icons/audio-player-192.png';
const AUDIO_PLAYER_ICON = 'icons/audio-player-192.png';
/**
* HTML source of the audio player.
* @type {!string}
* @const
*/
var AUDIO_PLAYER_APP_URL = 'audio_player.html';
const AUDIO_PLAYER_APP_URL = 'audio_player.html';
/**
* Configuration of the audio player.
* @type {!Object}
* @const
*/
var audioPlayerCreateOptions = {
const audioPlayerCreateOptions = {
id: 'audio-player',
minHeight: 4 + 48 + 96, // 4px: border-top, 48px: track, 96px: controller
minWidth: 320,
......@@ -55,13 +55,14 @@ class AudioPlayerBackground extends BackgroundBase {
* Backgound object. This is necessary for AppWindowWrapper.
* @type {!AudioPlayerBackground}
*/
// eslint-disable-next-line no-var
var background = new AudioPlayerBackground();
/**
* Audio player app window wrapper.
* @type {!SingletonAppWindowWrapper}
*/
var audioPlayer = new SingletonAppWindowWrapper(
const audioPlayer = new SingletonAppWindowWrapper(
AUDIO_PLAYER_APP_URL, audioPlayerCreateOptions);
/**
......@@ -71,8 +72,8 @@ var audioPlayer = new SingletonAppWindowWrapper(
* @return {!Promise} Promise to be fulfilled on success, or rejected on error.
*/
function open(urls) {
var position = 0;
var startUrl = (position < urls.length) ? urls[position] : '';
let position = 0;
const startUrl = (position < urls.length) ? urls[position] : '';
return new Promise(function(fulfill, reject) {
if (urls.length === 0) {
......@@ -83,12 +84,12 @@ function open(urls) {
// Gets the current list of the children of the parent.
window.webkitResolveLocalFileSystemURL(urls[0], function(fileEntry) {
fileEntry.getParent(function(parentEntry) {
var dirReader = parentEntry.createReader();
var entries = [];
const dirReader = parentEntry.createReader();
let entries = [];
// Call the reader.readEntries() until no more results are
// returned.
var readEntries = function() {
const readEntries = function() {
dirReader.readEntries(function(results) {
if (!results.length) {
fulfill(entries.sort(util.compareName));
......@@ -107,17 +108,18 @@ function open(urls) {
})
.then(function(entries) {
// Omits non-audio files.
var audioEntries = entries.filter(FileType.isAudio);
const audioEntries = entries.filter(FileType.isAudio);
// Adjusts the position to start playing.
var maybePosition = util.entriesToURLs(audioEntries).indexOf(startUrl);
const maybePosition =
util.entriesToURLs(audioEntries).indexOf(startUrl);
if (maybePosition !== -1) {
position = maybePosition;
}
// Opens the audio player.
return new Promise(function(fulfill, reject) {
var urls = util.entriesToURLs(audioEntries);
const urls = util.entriesToURLs(audioEntries);
audioPlayer.launch(
{items: urls, position: position}, false,
fulfill.bind(null, null));
......
......@@ -7,14 +7,14 @@
* @type {!Object}
* @const
*/
var windowCreateOptions = {
const windowCreateOptions = {
id: 'gallery',
outerBounds: {
minWidth: 860,
minHeight: 554
minHeight: 554,
},
frame: {
color: '#1E2023'
color: '#1E2023',
},
hidden: true
};
......@@ -23,13 +23,14 @@ var windowCreateOptions = {
* Backgound object. This is necessary for AppWindowWrapper.
* @type {!BackgroundBase}
*/
// eslint-disable-next-line no-var
var background = new BackgroundBase();
/**
* Gallery app window wrapper.
* @type {!SingletonAppWindowWrapper}
*/
var galleryWrapper =
const galleryWrapper =
new SingletonAppWindowWrapper('gallery.html', windowCreateOptions);
/**
......@@ -56,7 +57,7 @@ function openGalleryWindow(urls) {
{urls: urls}, false, fulfill.bind(null, galleryWrapper));
})
.then(function(galleryWrapper) {
var galleryWrapperDocument =
const galleryWrapperDocument =
galleryWrapper.rawAppWindow.contentWindow.document;
if (galleryWrapperDocument.readyState == 'complete') {
return galleryWrapper;
......
......@@ -8,25 +8,26 @@
* @type {!string}
* @const
*/
var ICON_IMAGE = 'images/icon/video-player-192.png';
const ICON_IMAGE = 'images/icon/video-player-192.png';
/**
* Configuration of the video player panel.
* @type {!Object}
* @const
*/
var windowCreateOptions = {
const windowCreateOptions = {
frame: {
color: '#fafafa'
color: '#fafafa',
},
minWidth: 480,
minHeight: 270
minHeight: 270,
};
/**
* Backgound object.
* @type {!BackgroundBase}
*/
// eslint-disable-next-line no-var
var background = new BackgroundBase();
/**
......@@ -34,8 +35,8 @@ var background = new BackgroundBase();
* used to create the string. The first call returns "VIDEO_PLAYER_APP_0".
* @return {string} windowId The windowId string.
*/
var generateWindowId = (function() {
var seq = 0;
const generateWindowId = (function() {
let seq = 0;
return function() {
return 'VIDEO_PLAYER_APP_' + seq++;
}.wrap();
......@@ -48,9 +49,9 @@ var generateWindowId = (function() {
* @return {!Promise} Promise to be fulfilled on success, or rejected on error.
*/
function openVideoPlayerWindow(urls) {
var position = 0;
var startUrl = (position < urls.length) ? urls[position] : '';
var windowId = null;
let position = 0;
const startUrl = (position < urls.length) ? urls[position] : '';
let windowId = null;
return new Promise(function(fulfill, reject) {
util.URLsToEntries(urls)
......@@ -65,7 +66,7 @@ function openVideoPlayerWindow(urls) {
}
// Adjusts the position to start playing.
var maybePosition = util.entriesToURLs(entries).indexOf(startUrl);
const maybePosition = util.entriesToURLs(entries).indexOf(startUrl);
if (maybePosition !== -1) {
position = maybePosition;
}
......@@ -74,8 +75,8 @@ function openVideoPlayerWindow(urls) {
// Opens the video player window.
return new Promise(function(fulfill, reject) {
var urls = util.entriesToURLs(entries);
var videoPlayer = new AppWindowWrapper(
const urls = util.entriesToURLs(entries);
const videoPlayer = new AppWindowWrapper(
'video_player.html', assert(windowId), windowCreateOptions);
videoPlayer.launch(
......@@ -84,7 +85,7 @@ function openVideoPlayerWindow(urls) {
}.wrap());
}.wrap())
.then(function(videoPlayer) {
var appWindow = videoPlayer.rawAppWindow;
const appWindow = videoPlayer.rawAppWindow;
appWindow.onClosed.addListener(function() {
chrome.power.releaseKeepAwake();
......
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