mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1036117 - Make WebappRT users wait for the configuration to be loaded. r=myk
This commit is contained in:
parent
13f5af8688
commit
2583fd1340
@ -103,7 +103,7 @@ this.startup = function(window) {
|
||||
appUpdated = yield WebappRT.applyUpdate();
|
||||
}
|
||||
|
||||
yield WebappRT.loadConfig();
|
||||
yield WebappRT.configPromise;
|
||||
|
||||
let appData = WebappRT.config.app;
|
||||
|
||||
|
@ -10,6 +10,7 @@ const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
Cu.import("resource://gre/modules/AppsUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
||||
@ -29,6 +30,21 @@ XPCOMUtils.defineLazyServiceGetter(this, "appsService",
|
||||
"nsIAppsService");
|
||||
|
||||
this.WebappRT = {
|
||||
_configPromise: null,
|
||||
|
||||
get configPromise() {
|
||||
if (!this._configPromise) {
|
||||
this._configPromise = Task.spawn(function*() {
|
||||
let webappJson = OS.Path.join(Services.dirsvc.get("AppRegD", Ci.nsIFile).path,
|
||||
"webapp.json");
|
||||
|
||||
WebappRT.config = yield AppsUtils.loadJSONAsync(webappJson);
|
||||
});
|
||||
}
|
||||
|
||||
return this._configPromise;
|
||||
},
|
||||
|
||||
get launchURI() {
|
||||
return this.localeManifest.fullLaunchPath();
|
||||
},
|
||||
@ -39,7 +55,7 @@ this.WebappRT = {
|
||||
},
|
||||
|
||||
get appID() {
|
||||
let manifestURL = WebappRT.config.app.manifestURL;
|
||||
let manifestURL = this.config.app.manifestURL;
|
||||
if (!manifestURL) {
|
||||
return Ci.nsIScriptSecurityManager.NO_APP_ID;
|
||||
}
|
||||
@ -47,16 +63,6 @@ this.WebappRT = {
|
||||
return appsService.getAppLocalIdByManifestURL(manifestURL);
|
||||
},
|
||||
|
||||
loadConfig: function() {
|
||||
if (this.config) {
|
||||
return;
|
||||
}
|
||||
|
||||
let webappJson = OS.Path.join(Services.dirsvc.get("AppRegD", Ci.nsIFile).path,
|
||||
"webapp.json");
|
||||
this.config = yield AppsUtils.loadJSONAsync(webappJson);
|
||||
},
|
||||
|
||||
isUpdatePending: Task.async(function*() {
|
||||
let webappJson = OS.Path.join(Services.dirsvc.get("AppRegD", Ci.nsIFile).path,
|
||||
"update", "webapp.json");
|
||||
@ -85,12 +91,13 @@ this.WebappRT = {
|
||||
// The update has been applied successfully, the new config file
|
||||
// is the config file that was in the update directory.
|
||||
this.config = config;
|
||||
this._configPromise = Promise.resolve();
|
||||
|
||||
return true;
|
||||
}),
|
||||
|
||||
startUpdateService: function() {
|
||||
let manifestURL = WebappRT.config.app.manifestURL;
|
||||
let manifestURL = this.config.app.manifestURL;
|
||||
// We used to install apps without storing their manifest URL.
|
||||
// Now we can't update them.
|
||||
if (!manifestURL) {
|
||||
|
@ -59,6 +59,7 @@ function becomeWebapp(manifestURL, parameters, onBecome) {
|
||||
installRecord.mm = subj;
|
||||
installRecord.registryDir = Services.dirsvc.get("ProfD", Ci.nsIFile).path;
|
||||
WebappRT.config = installRecord;
|
||||
WebappRT._configPromise = new Promise((resolve) => resolve());
|
||||
|
||||
let win = Services.wm.getMostRecentWindow("webapprt:webapp");
|
||||
if (!win) {
|
||||
|
@ -9,6 +9,7 @@ const Cu = Components.utils;
|
||||
Cu.import("resource://webapprt/modules/WebappRT.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "gAppBrowser",
|
||||
function() document.getElementById("content"));
|
||||
@ -54,7 +55,7 @@ let progressListener = {
|
||||
// of the page being loaded if it's from a different origin than the app
|
||||
// (per security bug 741955, which specifies that other-origin pages loaded
|
||||
// in runtime windows must be identified in chrome).
|
||||
let title = WebappRT.config.app.manifest.name;
|
||||
let title = WebappRT.localeManifest.name;
|
||||
if (!isSameOrigin(location.spec)) {
|
||||
title = location.prePath + " - " + title;
|
||||
}
|
||||
@ -141,10 +142,11 @@ document.addEventListener('mozfullscreenchange', function() {
|
||||
|
||||
// On Mac, we dynamically create the label for the Quit menuitem, using
|
||||
// a string property to inject the name of the webapp into it.
|
||||
function updateMenuItems() {
|
||||
let updateMenuItems = Task.async(function*() {
|
||||
#ifdef XP_MACOSX
|
||||
let installRecord = WebappRT.config.app;
|
||||
let manifest = WebappRT.config.app.manifest;
|
||||
yield WebappRT.configPromise;
|
||||
|
||||
let manifest = WebappRT.localeManifest;
|
||||
let bundle =
|
||||
Services.strings.createBundle("chrome://webapprt/locale/webapp.properties");
|
||||
let quitLabel = bundle.formatStringFromName("quitApplicationCmdMac.label",
|
||||
@ -154,7 +156,7 @@ function updateMenuItems() {
|
||||
document.getElementById("menu_FileQuitItem").setAttribute("label", quitLabel);
|
||||
document.getElementById("menu_mac_hide_app").setAttribute("label", hideLabel);
|
||||
#endif
|
||||
}
|
||||
});
|
||||
|
||||
#ifndef XP_MACOSX
|
||||
let gEditUIVisible = true;
|
||||
|
Loading…
Reference in New Issue
Block a user