Bug 1152597 - Icons are shown for some apps. r=marco

This commit is contained in:
Nick Desaulniers 2015-05-19 11:43:39 -07:00
parent 34ded8d2ca
commit f485fbbc3c
6 changed files with 24 additions and 7 deletions

View File

@ -891,18 +891,17 @@ ManifestHelper.prototype = {
return {};
},
get biggestIconURL() {
biggestIconURL: function(predicate) {
let icons = this._localeProp("icons");
if (!icons) {
return null;
}
let iconSizes = Object.keys(icons);
let iconSizes = Object.keys(icons).sort((a, b) => a - b)
.filter(predicate || (() => true));
if (iconSizes.length == 0) {
return null;
}
iconSizes.sort((a, b) => a - b);
let biggestIconSize = iconSizes.pop();
let biggestIcon = icons[biggestIconSize];
let biggestIconURL = this._baseURI.resolve(biggestIcon);

View File

@ -114,7 +114,7 @@ function addApplication(aApp) {
container.setAttribute("title", manifest.name);
let img = document.createElement("img");
img.src = manifest.biggestIconURL || DEFAULT_ICON;
img.src = manifest.biggestIconURL() || DEFAULT_ICON;
img.onerror = function() {
// If the image failed to load, and it was not our default icon, attempt to
// use our default as a fallback.

View File

@ -103,8 +103,14 @@ CommonNativeApp.prototype = {
let manifest = new ManifestHelper(aManifest, aApp.origin, aApp.manifestURL);
let origin = Services.io.newURI(aApp.origin, null, null);
this.iconURI = Services.io.newURI(manifest.biggestIconURL || DEFAULT_ICON_URL,
null, null);
#ifdef XP_WIN
let biggestIconURL = manifest.biggestIconURL(v => v <= 256);
#else
let biggestIconURL = manifest.biggestIconURL();
#endif
this.iconURI = Services.io.newURI(biggestIconURL || DEFAULT_ICON_URL, null,
null);
if (manifest.developer) {
if (manifest.developer.name) {

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -57,6 +57,8 @@ let iconTests = [
{"32": generateDataURI(getFile(getTestFilePath("data/icon.png"))) },
// URI to a file that isn't an image
{"32": "/chrome/toolkit/webapps/tests/data/app/index.html"},
// Large icon that won't be used on Windows (bug #1152597)
{"512": "/chrome/toolkit/webapps/tests/data/512.png"},
];
// This is an array of the icon sizes associated with the elements of
@ -79,6 +81,7 @@ if (LINUX) {
[2787, 0],
[2787, 0],
[4009, 0],
[2195, 0],
];
} else if (WIN) {
iconSizes = [
@ -87,6 +90,8 @@ if (LINUX) {
[4286, 0],
[4286, 0],
[16958, 0],
// Windows ICO doesn't support 512x512 icons. The default should be chosen.
[16958, 0],
];
} else if (MAC) {
iconSizes = [
@ -95,6 +100,7 @@ if (LINUX) {
[27000, 2000],
[27000, 2000],
[14000, 2000],
[1000, 2000],
];
}

View File

@ -65,6 +65,8 @@ let iconTests = [
{"32": generateDataURI(testIconFile) },
// URI to a file that isn't an image
{"32": "/index.html"},
// Large icon that won't be used on Windows (bug #1152597)
{"512": "http://example.com/chrome/toolkit/webapps/tests/data/512.png"},
];
// This is an array of the icon sizes associated with the elements of
@ -87,6 +89,7 @@ if (LINUX) {
[2787, 0],
[2787, 0],
[4009, 0],
[2195, 0],
];
} else if (WIN) {
iconSizes = [
@ -95,6 +98,8 @@ if (LINUX) {
[4286, 0],
[4286, 0],
[16958, 0],
// Windows ICO doesn't support 512x512 icons. The default should be chosen.
[16958, 0],
];
} else if (MAC) {
iconSizes = [
@ -103,6 +108,7 @@ if (LINUX) {
[27000, 2000],
[27000, 2000],
[14000, 2000],
[1000, 2000],
];
}