k***@gmail.com
2008-06-29 23:06:49 UTC
Let's say that my XUL app has <browser> element. How can I get now an
URL pointing to favicon of google.com? google.com was loaded some time
ago and should be present in cache (as well as its favicon).
The following example doesn't work
/******************************************************/
const mlFIS = Components.classes["@mozilla.org/browser/favicon-
service;1"]
.getService(Components.interfaces.nsIFaviconService);
const mlIOService = Components.classes["@mozilla.org/network/io-
service;1"]
.getService(Components.interfaces.nsIIOService2);
var mURI;
mURI = mlIOService.newURI("http://google.com", null, null);
try
{
mURI = mlFIS.getFaviconForPage(mURI);
}
catch(e)
{
alert(e);
mURI = {};
mURI.spec = "<no>";
}
alert(mURI.spec);
/******************************************************/
It raises exception
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIFaviconService.getFaviconForPage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)
URL pointing to favicon of google.com? google.com was loaded some time
ago and should be present in cache (as well as its favicon).
The following example doesn't work
/******************************************************/
const mlFIS = Components.classes["@mozilla.org/browser/favicon-
service;1"]
.getService(Components.interfaces.nsIFaviconService);
const mlIOService = Components.classes["@mozilla.org/network/io-
service;1"]
.getService(Components.interfaces.nsIIOService2);
var mURI;
mURI = mlIOService.newURI("http://google.com", null, null);
try
{
mURI = mlFIS.getFaviconForPage(mURI);
}
catch(e)
{
alert(e);
mURI = {};
mURI.spec = "<no>";
}
alert(mURI.spec);
/******************************************************/
It raises exception
[Exception... "Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIFaviconService.getFaviconForPage]"
nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)