Commit 2a488cfd authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Chromium LUCI CQ

Files SWA: Change Background page fakes to comply with the interface

This is a follow up to the changes in the interfaces: CL:2613848.

Remove launcher from BackgroundWindow and add launchFileManager() to
FileBrowserBackgroundFUll.

Move registerDialog() from BackgroundWindow to
FileBrowserBackgroundFUll.

Removed the class FileBrowserBackground and merged its content in
FileBrowserBackgroundFull.  This distinction it's only relevant for
other apps (Gallery, Audio and Video Players).  For Files app only the
"full" version is relevant.

NOTE: This file isn't checked by Closure compiler, so there is no
automatic check if these implementations adhere to the interface.

Test: Checked manually that loading the SWA doesn't produce any JS error
in the console.

Bug: 1113981
Change-Id: Ie0b792e7c88db908c2939723df14c7b713eddfe5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2617407
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Auto-Submit: Luciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843272}
parent 8b728444
......@@ -77,73 +77,30 @@ window.chrome.storage = {
window.BackgroundWindowSWA = class {
constructor() {
/**
* @type {!FileBrowserBackground|!FileBrowserBackgroundFull}
* @type {!FileBrowserBackgroundFull}
*/
this.background = new FileBrowserBackgroundFull();
/**
* @type {!Object}
*/
this.launcher = {
/** @param {Object=} appState App state. */
launchFileManager(appState) {
window.fileManagerLaunchNewWindow(appState);
},
};
/**
* @type {!DriveSyncHandler}
*/
this.driveSyncHandler = new DriveSyncHandler();
}
/**
* @param {Window} window
*/
registerDialog(window) {}
}
window.FileBrowserBackground = class {
window.FileBrowserBackgroundFull = class {
constructor() {
/**
* Dialogs
* @type {!Object<!Window>}
*/
this.dialogs;
this.dialogs = {};
/**
* String assets. Notable difference here: files app extern defines
* this string object on FileBrowserBackgroundFull.
* String assets (translation strings and flag states).
* @type {Object<string>}
*/
this.stringData;
}
/**
* @param {function()} callback Ready callback.
*/
ready(callback) {
const script = document.createElement('script');
script.onload = () => {
this.stringData = window.loadTimeData.data_;
window.loadTimeData.data_ = null;
callback();
};
document.head.append(script);
script.src = 'strings.js';
}
}
window.FileBrowserBackgroundFull = class extends FileBrowserBackground {
constructor() {
super();
this.stringData = {};
/**
* @type {!DriveSyncHandler}
*/
this.driveSyncHandler;
this.driveSyncHandler = new DriveSyncHandler();
/**
* @type {!ProgressCenter}
......@@ -181,6 +138,29 @@ window.FileBrowserBackgroundFull = class extends FileBrowserBackground {
this.volumeManagerInstance_;
}
/**
* @param {!Window} window
*/
registerDialog(window) {
console.error('registerDialog() not implemented for SWA yet');
}
/**
* @param {function()} callback Ready callback.
*/
ready(callback) {
const script = document.createElement('script');
script.onload = () => {
this.stringData = window.loadTimeData.data_;
window.loadTimeData.data_ = null;
callback();
};
document.head.append(script);
script.src = 'strings.js';
}
/**
* Returns VolumeManager instance.
* @public
......@@ -193,6 +173,17 @@ window.FileBrowserBackgroundFull = class extends FileBrowserBackground {
return this.volumeManagerInstance_;
}
/**
* Launches a new File Manager window.
*
* @param {Object=} opt_appState App state.
* @return {!Promise<chrome.app.window.AppWindow|string>} Resolved with the
* App ID.
*/
async launchFileManager(opt_appState) {
console.error('launchFileManager() not implemented for SWA yet');
}
}
window.VolumeManager = class {
......
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