Commit 5cd9674d authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[filesapp] Change startInitBackgroundPage_ for files app SWA case

Initialize this.backgroundPage_ with new BackgroundWindowSWA() fake if
Files app is running in the SWA container.

window.BackgroundWindowSWA || null is used to pass Closure compile for
current Files app (there are no extern defines for the SWA fakes).

No change in Files app behavior.

Test: browser_tests --gtest_filter="*launchFilesAppSwa*"
Bug: 1113981
Change-Id: Ia079ea266583afd5a2ea67412758a77939327c8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2542931Reviewed-by: default avatarLuciano Pacheco <lucmult@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Commit-Queue: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828068}
parent 9d32e890
......@@ -847,12 +847,17 @@ class FileManager extends cr.EventTarget {
async startInitBackgroundPage_() {
metrics.startInterval('Load.InitBackgroundPage');
/** @type {!Window} */
const backgroundPage =
await new Promise(resolve => chrome.runtime.getBackgroundPage(resolve));
assert(backgroundPage);
this.backgroundPage_ =
/** @type {!BackgroundWindow} */ (backgroundPage);
/** @type {!BackgroundWindow} */
this.backgroundPage_ = await new Promise(resolve => {
if (window.isSWA) {
const backgroundWindowSWA = window.BackgroundWindowSWA || null;
resolve(new backgroundWindowSWA());
} else {
chrome.runtime.getBackgroundPage(resolve);
}
});
assert(this.backgroundPage_);
this.fileBrowserBackground_ =
/** @type {!FileBrowserBackgroundFull} */ (
this.backgroundPage_.background);
......@@ -868,6 +873,7 @@ class FileManager extends cr.EventTarget {
this.mediaScanner_ = this.fileBrowserBackground_.mediaScanner;
this.historyLoader_ = this.fileBrowserBackground_.historyLoader;
this.crostini_ = this.fileBrowserBackground_.crostini;
metrics.recordInterval('Load.InitBackgroundPage');
}
......
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