From 1c219c30733522adab31d91abf56d3730b650981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabrice=20Desr=C3=A9?= Date: Thu, 19 Mar 2015 10:06:32 -0700 Subject: [PATCH] Bug 1142758 - Use the getLocalizedValue language when falling back to manifest values r=ferjm --- dom/apps/AppsUtils.jsm | 15 ++++++++++----- dom/apps/Langpacks.jsm | 2 +- dom/apps/Webapps.jsm | 5 +++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/dom/apps/AppsUtils.jsm b/dom/apps/AppsUtils.jsm index b2983167691e..8374b1396ec9 100644 --- a/dom/apps/AppsUtils.jsm +++ b/dom/apps/AppsUtils.jsm @@ -785,7 +785,7 @@ this.AppsUtils = { /** * Helper object to access manifest information with locale support */ -this.ManifestHelper = function(aManifest, aOrigin, aManifestURL) { +this.ManifestHelper = function(aManifest, aOrigin, aManifestURL, aLang) { // If the app is packaged, we resolve uris against the origin. // If it's not, against the manifest url. @@ -801,10 +801,15 @@ this.ManifestHelper = function(aManifest, aOrigin, aManifestURL) { this._manifestURL = Services.io.newURI(aManifestURL, null, null); this._manifest = aManifest; - let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"] - .getService(Ci.nsIXULChromeRegistry) - .QueryInterface(Ci.nsIToolkitChromeRegistry); - let locale = chrome.getSelectedLocale("global").toLowerCase(); + + let locale = aLang; + if (!locale) { + let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"] + .getService(Ci.nsIXULChromeRegistry) + .QueryInterface(Ci.nsIToolkitChromeRegistry); + locale = chrome.getSelectedLocale("global").toLowerCase(); + } + this._localeRoot = this._manifest; if (this._manifest.locales && this._manifest.locales[locale]) { diff --git a/dom/apps/Langpacks.jsm b/dom/apps/Langpacks.jsm index b2e1769163cf..c3dfd4aa5679 100644 --- a/dom/apps/Langpacks.jsm +++ b/dom/apps/Langpacks.jsm @@ -245,7 +245,7 @@ this.Langpacks = { // We need to get the app with the manifest since the version is only // available in the manifest. - this._appFromManifestURL(aData.manifestURL, aData.entryPoint) + this._appFromManifestURL(aData.manifestURL, aData.entryPoint, aData.lang) .then(aApp => { let manifest = aApp.manifest; diff --git a/dom/apps/Webapps.jsm b/dom/apps/Webapps.jsm index 6eefe9532689..5258311d607d 100755 --- a/dom/apps/Webapps.jsm +++ b/dom/apps/Webapps.jsm @@ -4674,7 +4674,7 @@ this.DOMApplicationRegistry = { }, // Returns a promise that resolves to the app object with the manifest. - getFullAppByManifestURL: function(aManifestURL, aEntryPoint) { + getFullAppByManifestURL: function(aManifestURL, aEntryPoint, aLang) { let app = this.getAppByManifestURL(aManifestURL); if (!app) { return Promise.reject("NoSuchApp"); @@ -4692,7 +4692,8 @@ this.DOMApplicationRegistry = { manifest.version = aManifest.version; } - app.manifest = new ManifestHelper(manifest, app.origin, app.manifestURL); + app.manifest = + new ManifestHelper(manifest, app.origin, app.manifestURL, aLang); return app; }); },