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