Skip to content

Commit

Permalink
[M90] Files SWA: Simplify loadTimeData loading
Browse files Browse the repository at this point in the history
We special cased loadTimeData for SWA File Manager in the background
code. This had the side effect of including 'strings.js' twice in the
elements at run time.

Remove the special casing in the background code.

(cherry picked from commit 95badd6)

Bug: 1113981
Change-Id: I5777dbbd8107c52cd880d1d8ad663d46dccf2d97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2719784
Reviewed-by: Bo Majewski <majewski@chromium.org>
Commit-Queue: Alex Danilo <adanilo@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#858040}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2737875
Auto-Submit: Alex Danilo <adanilo@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/branch-heads/4430@{#144}
Cr-Branched-From: e5ce7dc-refs/heads/master@{#857950}
  • Loading branch information
adanilo authored and Chromium LUCI CQ committed Mar 5, 2021
1 parent 26d484e commit a22f941
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions ui/file_manager/file_manager/background/js/background_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,16 @@
this.dialogs = {};

// Initializes the strings. This needs for the volume manager.
if (!window.isSWA) {
this.initializationPromise_ = new Promise((fulfill, reject) => {
chrome.fileManagerPrivate.getStrings(stringData => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
return;
}
loadTimeData.data = assert(stringData);
fulfill(stringData);
});
});
} else {
this.initializationPromise_ = new Promise((fulfill, reject) => {
const script = document.createElement('script');

script.onload = () => {
// window.loadTimeData.data_ = null; // Gambiarra!
fulfill(window.loadTimeData.data_);
};

document.head.append(script);
script.src = 'strings.js';
this.initializationPromise_ = new Promise((fulfill, reject) => {
chrome.fileManagerPrivate.getStrings(stringData => {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
return;
}
loadTimeData.data = assert(stringData);
fulfill(stringData);
});
}
});

/** @private {?LaunchHandler} */
this.launchHandler_ = null;
Expand Down

0 comments on commit a22f941

Please sign in to comment.