Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Commit

Permalink
Bug 788275 - Tab preview should respect the private browsing mode whe…
Browse files Browse the repository at this point in the history
…n attempting to load a favicon; r=jdm,jimm
  • Loading branch information
ehsan committed Sep 17, 2012
1 parent becb708 commit 1834e55
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions browser/modules/WindowsPreviewPerTab.jsm
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1834e55

Please sign in to comment.