From 1a1a157715e9eb17577a6c9b89364f455290b2e4 Mon Sep 17 00:00:00 2001 From: Max Goodman Date: Thu, 21 Jun 2012 15:19:06 -0700 Subject: [PATCH] Remove nsIFaviconService indiscriminate favicon size handling. --- NEWS | 3 ++ src/install.rdf | 2 +- src/modules/site.jsm | 2 +- src/modules/utils/faviconWatch.jsm | 51 ++++++++---------------------- 4 files changed, 18 insertions(+), 40 deletions(-) diff --git a/NEWS b/NEWS index 5654ee0..d91aeaf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +== Version 1.5.1 == +* Fix favicon handling with alternate icon s. + == Version 1.5 == * Update authentication scraping for compatibility with the new reddit layout. * Prevent the built in reddit tool bar from activating. diff --git a/src/install.rdf b/src/install.rdf index fef8afa..b27639c 100644 --- a/src/install.rdf +++ b/src/install.rdf @@ -9,7 +9,7 @@ diff --git a/src/modules/site.jsm b/src/modules/site.jsm index bca1fd8..d97e3a1 100644 --- a/src/modules/site.jsm +++ b/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() { diff --git a/src/modules/utils/faviconWatch.jsm b/src/modules/utils/faviconWatch.jsm index d254338..65cfda9 100644 --- a/src/modules/utils/faviconWatch.jsm +++ b/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); \ No newline at end of file