Bug 598174 - Frontend loads the favicon unconditionally [r=mark.finkle]
authorWesley Johnston <wjohnston@mozilla.com>
Wed, 29 Sep 2010 16:03:00 -0400
changeset 66750 a9a908e8484101dbd0da2718cd542fd14489011a
parent 66749 3dff38d74bb792965c74ea09a8dae0e52d1879da
child 66751 da815c4f387d5d8bfab9529fb0fe05fa311ce1e6
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmark
bugs598174
Bug 598174 - Frontend loads the favicon unconditionally [r=mark.finkle]
mobile/chrome/content/bindings/browser.xml
--- a/mobile/chrome/content/bindings/browser.xml
+++ b/mobile/chrome/content/bindings/browser.xml
@@ -106,21 +106,17 @@
               case "pageshow":
                 self.onPageShow(aMessage);
 
                 if (self.mIconURL == "" && self._documentURI) {
                   // newURI call is throwing for chrome URI
                   try {
                     // Use documentURIObject in the favicon construction so that we
                     // do the right thing with about:-style error pages.  Bug 515188
-                    let iconURI = Services.io.newURI(self.documentURI.prePath + "/favicon.ico", null, null);
-                    if (!iconURI.schemeIs("javascript") && !gFaviconService.isFailedFavicon(iconURI)) {
-                      gFaviconService.setAndLoadFaviconForPage(self.currentURI, iconURI, true);
-                      self.mIconURL = iconURI.spec;
-                    }
+                    self.loadFavicon(self.documentURI.prePath + "/favicon.ico", null);
                   }
                   catch(e) {}
                 }
                 break;
 
               case "pagehide":
                 self.onPageHide(aMessage);
                 break;
@@ -133,21 +129,17 @@
                 let link = aMessage.json;
                 // ignore results from subdocuments
                 if (link.windowId != self.contentWindowId)
                   return;
 
                 let linkType = self._getLinkType(link);
                 switch(linkType) {
                   case "icon":
-                    let iconURI = Services.io.newURI(link.href, link.charset, null);
-                    if (!iconURI.schemeIs("javascript") && !gFaviconService.isFailedFavicon(iconURI)) {
-                      gFaviconService.setAndLoadFaviconForPage(self.currentURI, iconURI, true);
-                      self.mIconURL = iconURI.spec;
-                    }
+                    self.loadFavicon(link.href, link.charset);
                     break;
                   case "search":
                     self._searchEngines.push({ title: link.title, href: link.href });
                     break;
                 }
                 break;
 
               case "MozScrolledAreaChanged":
@@ -158,16 +150,40 @@
                 self.scrollBy(0, 0);
                 self._updateCacheViewport();
                 break;
             }
           }
         })
       ]]></field>
 
+      <method name="loadFavicon">
+        <parameter name="aURL"/>
+        <parameter name="aCharset"/>
+        <body><![CDATA[
+            let iconURI = Services.io.newURI(aURL, aCharset, null);
+            if (this.shouldLoadFavicon(iconURI)) {
+              gFaviconService.setAndLoadFaviconForPage(this.currentURI, iconURI, true);
+              this.mIconURL = iconURI.spec;
+            }
+            else {
+               this.mIconURL = "";
+            }
+        ]]></body>
+      </method>
+
+      <method name="shouldLoadFavicon">
+        <parameter name="aURI"/>
+        <body><![CDATA[
+          let docURI = this.currentURI;
+          return (!gFaviconService.isFailedFavicon(aURI) && docURI && ("schemeIs" in docURI) &&
+                  (docURI.schemeIs("http") || docURI.schemeIs("https") || docURI.schemeIs("about") || docURI.schemeIs("chrome")));
+        ]]></body>
+      </method>
+
       <method name="_getLinkType">
         <parameter name="aLink" />
         <body><![CDATA[
           let type = "";
           if (/\bicon\b/i(aLink.rel)) {
             type = "icon";
           }
           else if (/\bsearch\b/i(aLink.rel) && aLink.type && aLink.title) {