Bug 1142758 - Use the getLocalizedValue language when falling back to manifest values r=ferjm

This commit is contained in:
Fabrice Desré 2015-03-19 10:06:32 -07:00
parent bd32c0e3d0
commit f7f44db9b8
3 changed files with 14 additions and 8 deletions

View File

@ -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]) {

View File

@ -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;

View File

@ -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;
});
},