mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 511091: Support custom icons for disabled extensions. r=robstrong
This commit is contained in:
parent
56a5e72cf0
commit
273084e6ef
@ -7752,17 +7752,15 @@ ExtensionsDataSource.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets an URL to a theme's image file
|
||||
* Gets an URL to an item's image file
|
||||
* @param item
|
||||
* The RDF Resource representing the item
|
||||
* @param fileName
|
||||
* The file to locate a URL for
|
||||
* @param fallbackURL
|
||||
* If the location fails, supply this URL instead
|
||||
* @returns An RDF Resource to the URL discovered, or the fallback
|
||||
* if the discovery failed.
|
||||
*/
|
||||
_getThemeImageURL: function EMDS__getThemeImageURL(item, fileName, fallbackURL) {
|
||||
_getImageURL: function EMDS__getImageURL(item, fileName) {
|
||||
var id = stripPrefix(item.Value, PREFIX_ITEM_URI);
|
||||
var installLocation = this._em.getInstallLocation(id);
|
||||
if (!installLocation)
|
||||
@ -7771,7 +7769,7 @@ ExtensionsDataSource.prototype = {
|
||||
if (file.exists())
|
||||
return gRDF.GetResource(getURLSpecFromFile(file));
|
||||
|
||||
return fallbackURL ? gRDF.GetResource(fallbackURL) : null;
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -7780,29 +7778,34 @@ ExtensionsDataSource.prototype = {
|
||||
_rdfGet_iconURL: function EMDS__rdfGet_iconURL(item, property) {
|
||||
var id = stripPrefix(item.Value, PREFIX_ITEM_URI);
|
||||
var type = this.getItemProperty(id, "type");
|
||||
if (type & Ci.nsIUpdateItem.TYPE_THEME)
|
||||
return this._getThemeImageURL(item, "icon.png", URI_GENERIC_ICON_THEME);
|
||||
|
||||
if (inSafeMode())
|
||||
return gRDF.GetResource(URI_GENERIC_ICON_XPINSTALL);
|
||||
// Try to pick an icon from the item's install folder
|
||||
iconURL = this._getImageURL(item, "icon.png");
|
||||
if (iconURL)
|
||||
return iconURL;
|
||||
|
||||
var hasIconURL = this._inner.hasArcOut(item, property);
|
||||
// If the addon doesn't have an IconURL property or it is disabled use the
|
||||
// generic icon URL instead.
|
||||
if (!hasIconURL || this.getItemProperty(id, "isDisabled") == "true")
|
||||
return gRDF.GetResource(URI_GENERIC_ICON_XPINSTALL);
|
||||
var iconURL = stringData(this._inner.GetTarget(item, property, true));
|
||||
try {
|
||||
var uri = newURI(iconURL);
|
||||
var scheme = uri.scheme;
|
||||
// Only allow chrome URIs or when installing http(s) URIs.
|
||||
if (scheme == "chrome" || (scheme == "http" || scheme == "https") &&
|
||||
this._inner.hasArcOut(item, EM_R("downloadURL")))
|
||||
return null;
|
||||
if (type == Ci.nsIUpdateItem.TYPE_THEME)
|
||||
return gRDF.GetResource(URI_GENERIC_ICON_THEME);
|
||||
|
||||
// Only look for an iconURL if the item is not disabled and safe mode isn't
|
||||
// active
|
||||
if (!inSafeMode() && this.getItemProperty(id, "isDisabled") != "true") {
|
||||
var iconURL = stringData(this._inner.GetTarget(item, property, true));
|
||||
if (iconURL) {
|
||||
try {
|
||||
var uri = newURI(iconURL);
|
||||
var scheme = uri.scheme;
|
||||
// Only allow chrome URIs normally. When an item is being installed
|
||||
// allow http(s) URIs.
|
||||
if (scheme == "chrome" || (scheme == "http" || scheme == "https") &&
|
||||
this._inner.hasArcOut(item, EM_R("downloadURL")))
|
||||
return null;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
// Use a generic icon URL for addons that have an invalid iconURL.
|
||||
|
||||
return gRDF.GetResource(URI_GENERIC_ICON_XPINSTALL);
|
||||
},
|
||||
|
||||
@ -7811,8 +7814,8 @@ ExtensionsDataSource.prototype = {
|
||||
*/
|
||||
_rdfGet_previewImage: function EMDS__rdfGet_previewImage(item, property) {
|
||||
var type = this.getItemProperty(stripPrefix(item.Value, PREFIX_ITEM_URI), "type");
|
||||
if (type != -1 && type & Ci.nsIUpdateItem.TYPE_THEME)
|
||||
return this._getThemeImageURL(item, "preview.png", null);
|
||||
if (type == Ci.nsIUpdateItem.TYPE_THEME)
|
||||
return this._getImageURL(item, "preview.png");
|
||||
return null;
|
||||
},
|
||||
|
||||
|
BIN
toolkit/mozapps/extensions/test/addons/test_bug511091/icon.png
Normal file
BIN
toolkit/mozapps/extensions/test/addons/test_bug511091/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>bug511091@tests.mozilla.org</em:id>
|
||||
<em:version>1.0</em:version>
|
||||
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>xpcshell@tests.mozilla.org</em:id>
|
||||
<em:minVersion>1</em:minVersion>
|
||||
<em:maxVersion>1</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Icon test</em:name>
|
||||
<em:iconURL>chrome://foo/content/bar</em:iconURL>
|
||||
|
||||
</Description>
|
||||
</RDF>
|
75
toolkit/mozapps/extensions/test/unit/test_bug511091.js
Normal file
75
toolkit/mozapps/extensions/test/unit/test_bug511091.js
Normal file
@ -0,0 +1,75 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Dave Townsend <dtownsend@oxymoronical.com>.
|
||||
*
|
||||
* Portions created by the Initial Developer are Copyright (C) 2009
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
const ID = "bug511091@tests.mozilla.org";
|
||||
const ADDON = "test_bug511091";
|
||||
|
||||
function run_test()
|
||||
{
|
||||
// Setup for test
|
||||
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
|
||||
|
||||
// Install test add-on
|
||||
startupEM();
|
||||
gEM.installItemFromFile(do_get_addon(ADDON), NS_INSTALL_LOCATION_APPPROFILE);
|
||||
var addon = gEM.getItemForID(ID);
|
||||
do_check_neq(addon, null);
|
||||
do_check_eq(getManifestProperty(ID, "iconURL"), "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png");
|
||||
restartEM();
|
||||
|
||||
var location = gEM.getInstallLocation(ID);
|
||||
var file = location.getItemFile(ID, "icon.png");
|
||||
var ioservice = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
|
||||
var addon = gEM.getItemForID(ID);
|
||||
do_check_neq(addon, null);
|
||||
var uri = ioservice.newURI(getManifestProperty(ID, "iconURL"), null, null);
|
||||
uri.QueryInterface(Components.interfaces.nsIFileURL);
|
||||
do_check_true(uri.file.equals(file));
|
||||
gEM.disableItem(ID);
|
||||
restartEM();
|
||||
|
||||
addon = gEM.getItemForID(ID);
|
||||
do_check_neq(addon, null);
|
||||
uri = ioservice.newURI(getManifestProperty(ID, "iconURL"), null, null);
|
||||
uri.QueryInterface(Components.interfaces.nsIFileURL);
|
||||
do_check_true(uri.file.equals(file));
|
||||
|
||||
shutdownEM();
|
||||
}
|
Loading…
Reference in New Issue
Block a user