Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove nsIFaviconService indiscriminate favicon size handling.

Occasionally, it looks like nsIFaviconService grabs the 256x256 icon link
instead of the 16x16. This causes UI issues when displayed in the
Socialite bar.
  • Loading branch information...
commit f17f01de78490a1320219c4389a4a36f29e197be 1 parent fc731f1
Max Goodman authored
Showing with 14 additions and 39 deletions.
  1. +1 −1  src/modules/site.jsm
  2. +13 −38 src/modules/utils/faviconWatch.jsm
View
2  src/modules/site.jsm
@@ -33,7 +33,7 @@ SocialiteSite.prototype = {
getIconURI: function() {
// We'll assume that favicon.ico exists for now.
- return this.siteURL+"/favicon.ico";
+ return this.siteURI.prePath+"/favicon.ico";
},
onLoad: function() {
View
51 src/modules/utils/faviconWatch.jsm
@@ -12,32 +12,30 @@ var historyService = Components.classes["@mozilla.org/browser/nav-history-servic
var EXPORTED_SYMBOLS = ["setFavicon", "getFaviconURL", "addFaviconWatch", "useFaviconAsAttribute"];
var watchables = {};
+var favicons = {}
-function setFavicon(siteURL, faviconURL, skipLoad) {
- let siteURI = IOService.newURI(siteURL, null, null);
- let faviconURI = IOService.newURI(faviconURL, null, null);
-
- if (!skipLoad) {
- faviconService.setAndLoadFaviconForPage(siteURI, faviconURI, false);
+function setFavicon(siteURL, faviconURL) {
+ favicons[siteURL] = faviconURL;
+
+ let watchable = watchables[siteURL];
+ if (watchable) {
+ watchable.send(faviconURL);
}
- return faviconService.getFaviconImageForPage(siteURI).spec;
+
+ return faviconURL;
}
function getFaviconURL(siteURL) {
- let siteURI = IOService.newURI(siteURL, null, null);
- return faviconService.getFaviconImageForPage(siteURI).spec;
+ return favicons[siteURL]
}
function addFaviconWatch(siteURL, changedCallback) {
- let siteURI = IOService.newURI(siteURL, null, null);
- let siteURISpec = siteURI.spec;
-
// Add the watch
- if (!watchables[siteURISpec]) {
- watchables[siteURISpec] = new Watchable();
+ if (!watchables[siteURL]) {
+ watchables[siteURL] = new Watchable();
}
- return watchables[siteURISpec].watch(changedCallback);
+ return watchables[siteURL].watch(changedCallback);
}
function useFaviconWatch(siteURL, changedCallback) {
@@ -57,26 +55,3 @@ function useFaviconAsProperty(element, propertyName, siteURL) {
element[propertyName] = faviconURL;
});
}
-
-historyObserver = {
- onPageChanged: function(URI, what, value) {
- if (what == Components.interfaces.nsINavHistoryObserver.ATTRIBUTE_FAVICON) {
- // Notify all watchables that the favicon has changed, passing the new URI
- let watchable = watchables[URI.spec];
- if (watchable) {
- watchable.send(value);
- }
- }
- },
-
- onBeginUpdateBatch: function() {},
- onEndUpdateBatch: function() {},
- onVisit: function() {},
- onTitleChanged: function() {},
- onDeleteURI: function() {},
- onClearHistory: function() {},
- onPageExpired: function() {},
-}
-
-// This module persists for the lifetime of the app, so don't worry about removing the observer.
-historyService.addObserver(historyObserver, false);
Please sign in to comment.
Something went wrong with that request. Please try again.