Skip to content
This repository has been archived by the owner on Sep 18, 2018. It is now read-only.

Commit

Permalink
Remove nsIFaviconService indiscriminate favicon size handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
chromakode committed Jun 21, 2012
1 parent fc731f1 commit 1a1a157
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 40 deletions.
3 changes: 3 additions & 0 deletions NEWS
@@ -1,3 +1,6 @@
== Version 1.5.1 ==
* Fix favicon handling with alternate icon <link>s.

== Version 1.5 ==
* Update authentication scraping for compatibility with the new reddit layout.
* Prevent the built in reddit tool bar from activating.
Expand Down
2 changes: 1 addition & 1 deletion src/install.rdf
Expand Up @@ -9,7 +9,7 @@
<RDF:Description RDF:about="urn:mozilla:install-manifest"
em:id="socialite@chromakode"
em:name="Socialite"
em:version="1.5"
em:version="1.5.1"
em:type="2"
em:iconURL="chrome://socialite/skin/socialite.png"
em:optionsURL="chrome://socialite/content/socialitePreferences.xul">
Expand Down
2 changes: 1 addition & 1 deletion src/modules/site.jsm
Expand Up @@ -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() {
Expand Down
51 changes: 13 additions & 38 deletions src/modules/utils/faviconWatch.jsm
Expand Up @@ -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) {
Expand All @@ -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);

0 comments on commit 1a1a157

Please sign in to comment.