b=174265 (also 252288, 253161): favicon handling merge from aviary branch

This commit is contained in:
vladimir@pobox.com 2007-08-21 21:59:33 -07:00
parent 124b58877d
commit d6e58683ba

View File

@ -477,7 +477,7 @@
p.onSecurityChange(webProgress, null, securityUI.state); p.onSecurityChange(webProgress, null, securityUI.state);
var listener = this.mTabListeners[this.mPanelContainer.selectedIndex]; var listener = this.mTabListeners[this.mPanelContainer.selectedIndex];
if (listener.mIcon) if (listener.mIcon)
p.onLinkIconAvailable(listener.mIcon); p.onLinkIconAvailable(newBrowser, listener.mIcon);
} }
} }
this.mCurrentBrowser.userTypedClear = userTypedClear; this.mCurrentBrowser.userTypedClear = userTypedClear;
@ -579,10 +579,11 @@
if (!href) if (!href)
return; return;
const nsIContentPolicy = Components.interfaces.nsIContentPolicy;
try { try {
var contentPolicy = var contentPolicy =
Components.classes['@mozilla.org/layout/content-policy;1'] Components.classes['@mozilla.org/layout/content-policy;1']
.getService(Components.interfaces.nsIContentPolicy); .getService(nsIContentPolicy);
} catch(e) { } catch(e) {
return; // Refuse to load if we can't do a security check. return; // Refuse to load if we can't do a security check.
} }
@ -615,40 +616,42 @@
return; return;
} }
var notifyListeners = true;
var i;
// Security says okay, now ask content policy // Security says okay, now ask content policy
if (tabBrowser.mTabbedMode) { if (contentPolicy.shouldLoad(nsIContentPolicy.TYPE_IMAGE,
// We need to update a tab. uri, origURI, event.target,
for (i = 0; i < this.childNodes.length; i++) { safeGetProperty(event.target, "type"),
if (this.childNodes[i].contentDocument == event.target.ownerDocument) { null) != nsIContentPolicy.ACCEPT)
if (contentPolicy.shouldLoad(Components.interfaces.nsIContentPolicy.TYPE_IMAGE,
uri, origURI, event.target,
safeGetProperty(event.target, "type"),
null) != Components.interfaces.nsIContentPolicy.ACCEPT)
return;
var listener = tabBrowser.mTabListeners[i];
listener.mIcon = href;
break;
}
}
notifyListeners = (this.childNodes[i] == tabBrowser.mCurrentBrowser);
}
else if ((this.contentDocument != safeGetProperty(event.originalTarget, "ownerDocument")) ||
(contentPolicy.shouldLoad(Components.interfaces.nsIContentPolicy.TYPE_IMAGE,
uri, origURI, event.target,
safeGetProperty(event.target, "type"),
null) != Components.interfaces.nsIContentPolicy.ACCEPT))
return; return;
if (notifyListeners && tabBrowser.mProgressListeners) { // var browserIndex = tabBrowser.getBrowserIndexForDocument(targetDoc);
var browserIndex = -1;
if (tabBrowser.mTabbedMode) {
for (var i = 0; i < tabBrowser.mPanelContainer.childNodes.length; i++) {
if (tabBrowser.mPanelContainer.childNodes[i].contentDocument == targetDoc) {
browserIndex = i;
break;
}
}
} else {
if (tabBrowser.mCurrentBrowser.contentDocument == targetDoc)
browserIndex = 0;
}
// no browser? no favicon.
if (browserIndex == -1)
return;
var listener = tabBrowser.mTabListeners[browserIndex];
// there's no tab listener for non-tabbed mode browser 0
if (listener)
listener.mIcon = href;
if (tabBrowser.mProgressListeners) {
var targetBrowser = tabBrowser.mTabbedMode ? tabBrowser.mPanelContainer.childNodes[i] : tabBrowser.mCurrentBrowser;
for (i = 0; i < tabBrowser.mProgressListeners.length; i++) { for (i = 0; i < tabBrowser.mProgressListeners.length; i++) {
var p = tabBrowser.mProgressListeners[i]; var p = tabBrowser.mProgressListeners[i];
if (p) if (p)
p.onLinkIconAvailable(href); p.onLinkIconAvailable(targetBrowser, href);
} }
} }
]]> ]]>