From c14cfa5f8a62b4628bd7d97c60e74065916c8ae3 Mon Sep 17 00:00:00 2001 From: "rflint%ryanflint.com" Date: Wed, 10 Oct 2007 05:03:52 +0000 Subject: [PATCH] Bug 399265 - Use the favicon service's hash table instead of cache to store failed favicons. r/a=mconnor git-svn-id: svn://10.0.0.236/trunk@237512 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/browser/base/content/browser.js | 34 ++++------ mozilla/browser/base/content/browser.xul | 3 +- mozilla/browser/base/content/tabbrowser.xml | 73 +++++++-------------- 3 files changed, 36 insertions(+), 74 deletions(-) diff --git a/mozilla/browser/base/content/browser.js b/mozilla/browser/base/content/browser.js index c55275dc655..d5f8f3e6de2 100644 --- a/mozilla/browser/base/content/browser.js +++ b/mozilla/browser/base/content/browser.js @@ -2663,18 +2663,14 @@ const DOMLinkHandler = { if (!gPrefService.getBoolPref("browser.chrome.site_icons")) break; - try { - var contentPolicy = Cc["@mozilla.org/layout/content-policy;1"]. - getService(Ci.nsIContentPolicy); - } catch(e) { - break; // Refuse to load if we can't do a security check. - } - var targetDoc = link.ownerDocument; var ios = Cc["@mozilla.org/network/io-service;1"]. getService(Ci.nsIIOService); var uri = ios.newURI(link.href, targetDoc.characterSet, null); + if (gBrowser.isFailedIcon(uri)) + break; + // Verify that the load of this icon is legal. // error pages can load their favicon, to be on the safe side, // only allow chrome:// favicons @@ -2691,6 +2687,13 @@ const DOMLinkHandler = { } } + try { + var contentPolicy = Cc["@mozilla.org/layout/content-policy;1"]. + getService(Ci.nsIContentPolicy); + } catch(e) { + break; // Refuse to load if we can't do a security check. + } + // Security says okay, now ask content policy if (contentPolicy.shouldLoad(Ci.nsIContentPolicy.TYPE_IMAGE, uri, targetDoc.documentURIObject, @@ -3301,22 +3304,9 @@ nsBrowserStatusHandler.prototype = onLinkIconAvailable : function(aBrowser) { - if (gProxyFavIcon && - gBrowser.mCurrentBrowser == aBrowser && + if (gProxyFavIcon && gBrowser.mCurrentBrowser == aBrowser && gBrowser.userTypedValue === null) - { - // update the favicon in the URL bar - PageProxySetIcon(aBrowser.mIconURL); - } - - // Save this favicon in the favicon service - if (aBrowser.mIconURL) { - var faviconService = Components.classes["@mozilla.org/browser/favicon-service;1"] - .getService(Components.interfaces.nsIFaviconService); - var uri = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService).newURI(aBrowser.mIconURL, null, null); - faviconService.setAndLoadFaviconForPage(aBrowser.currentURI, uri, false); - } + PageProxySetIcon(aBrowser.mIconURL); // update the favicon in the URL bar }, onProgressChange : function (aWebProgress, aRequest, diff --git a/mozilla/browser/base/content/browser.xul b/mozilla/browser/base/content/browser.xul index b33bf7adb48..c50e80ab16c 100644 --- a/mozilla/browser/base/content/browser.xul +++ b/mozilla/browser/base/content/browser.xul @@ -241,8 +241,7 @@ ondraggesture="PageProxyDragGesture(event);" onload="this.parentNode.selectedIndex = 1; event.stopPropagation();" - onerror="gBrowser.addToMissedIconCache(this.src); - this.removeAttribute('src'); + onerror="this.removeAttribute('src'); this.parentNode.selectedIndex = 0;" tooltiptext="&proxyIcon.tooltip;"/> diff --git a/mozilla/browser/base/content/tabbrowser.xml b/mozilla/browser/base/content/tabbrowser.xml index 932a30c9a86..1e3bd36b8d3 100644 --- a/mozilla/browser/base/content/tabbrowser.xml +++ b/mozilla/browser/base/content/tabbrowser.xml @@ -119,8 +119,7 @@ node = node.parentNode; node.removeCurrentTab();"> @@ -144,6 +143,10 @@ Components.classes["@mozilla.org/docshell/urifixup;1"] .getService(Components.interfaces.nsIURIFixup); + + Components.classes["@mozilla.org/browser/favicon-service;1"] + .getService(Components.interfaces.nsIFaviconService); + document.getAnonymousElementByAttribute(this, "anonid", "tabbox"); @@ -189,9 +192,6 @@ false - - null - null @@ -493,6 +493,16 @@ var browser = this.getBrowserForTab(aTab); browser.mIconURL = aURI; + if (aURI) { + if (!(aURI instanceof Components.interfaces.nsIURI)) { + var ios = Components.classes["@mozilla.org/network/io-service;1"] + .getService(Components.interfaces.nsIIOService); + aURI = ios.newURI(aURI, null, null); + } + this.mFaviconService.setAndLoadFaviconForPage(browser.currentURI, + aURI, false); + } + this.updateIcon(aTab); for (var i = 0; i < this.mProgressListeners.length; i++) { @@ -552,61 +562,24 @@ } else if (this.shouldLoadFavIcon(browser.currentURI)) { var url = browser.currentURI.prePath + "/favicon.ico"; - if (!this.isIconKnownMissing(url)) + if (!this.isFailedIcon(url)) this.setIcon(aTab, url); } ]]> - + - - - - - - - - - - - - - - @@ -1132,7 +1105,7 @@ t.width = 0; t.setAttribute("flex", "100"); t.setAttribute("validate", "never"); - t.setAttribute("onerror", "this.parentNode.parentNode.parentNode.parentNode.addToMissedIconCache(this.getAttribute('image')); this.removeAttribute('image');"); + t.setAttribute("onerror", "this.removeAttribute('image');"); t.className = "tabbrowser-tab"; this.mTabContainer.appendChild(t);