Bug 788275 - Tab preview should respect the private browsing mode when attempting to load a favicon; r=jdm,jimm

This commit is contained in:
Ehsan Akhgari 2012-09-17 14:47:49 -04:00
parent c1b493440d
commit 6b1ba157cc

View File

@ -72,8 +72,14 @@ XPCOMUtils.defineLazyServiceGetter(this, "faviconSvc",
"nsIFaviconService");
// nsIURI -> imgIContainer
function _imageFromURI(uri, callback) {
function _imageFromURI(uri, privateMode, callback) {
let channel = ioSvc.newChannelFromURI(uri);
try {
channel.QueryInterface(Ci.nsIPrivateBrowsingChannel);
channel.setPrivate(privateMode);
} catch (e) {
// Ignore channels which do not support nsIPrivateBrowsingChannel
}
NetUtil.asyncFetch(channel, function(inputStream, resultCode) {
if (!Components.isSuccessCode(resultCode))
return;
@ -92,11 +98,11 @@ function _imageFromURI(uri, callback) {
}
// string? -> imgIContainer
function getFaviconAsImage(iconurl, callback) {
function getFaviconAsImage(iconurl, privateMode, callback) {
if (iconurl)
_imageFromURI(NetUtil.newURI(iconurl), callback);
_imageFromURI(NetUtil.newURI(iconurl), privateMode, callback);
else
_imageFromURI(faviconSvc.defaultFavicon, callback);
_imageFromURI(faviconSvc.defaultFavicon, privateMode, callback);
}
// Snaps the given rectangle to be pixel-aligned at the given scale
@ -436,7 +442,7 @@ TabWindow.prototype = {
preview.visible = AeroPeek.enabled;
preview.active = this.tabbrowser.selectedTab == tab;
// Grab the default favicon
getFaviconAsImage(null, function (img) {
getFaviconAsImage(null, this.win.gPrivateBrowsingUI.privateWindow, function (img) {
// It is possible that we've already gotten the real favicon, so make sure
// we have not set one before setting this default one.
if (!preview.icon)
@ -535,7 +541,7 @@ TabWindow.prototype = {
//// Browser progress listener
onLinkIconAvailable: function (aBrowser, aIconURL) {
let self = this;
getFaviconAsImage(aIconURL, function (img) {
getFaviconAsImage(aIconURL, this.win.gPrivateBrowsingUI.privateWindow, function (img) {
let index = self.tabbrowser.browsers.indexOf(aBrowser);
// Only add it if we've found the index. The tab could have closed!
if (index != -1)