Bug 801151 - Make sure that favicon loads from tabs which are loading right near the end of a private browsing session do not into the non-private session; r=jdm

--HG--
extra : rebase_source : 50c8cc5fd90c907bb8fa00b2851c5f544f355505
This commit is contained in:
Ehsan Akhgari 2012-10-12 19:36:46 -04:00
parent 4ef6a7114a
commit 3eff91e626
2 changed files with 25 additions and 2 deletions

View File

@ -101,12 +101,19 @@ PrivateBrowsingService.prototype = {
.usePrivateBrowsing = aFlag;
},
_onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() {
_adjustPBFlagOnExistingWindows: function PBS__adjustPBFlagOnExistingWindows() {
var windowsEnum = Services.wm.getEnumerator(null);
while (windowsEnum.hasMoreElements()) {
var window = windowsEnum.getNext();
this._setPerWindowPBFlag(window, this._inPrivateBrowsing);
}
},
_onBeforePrivateBrowsingModeChange: function PBS__onBeforePrivateBrowsingModeChange() {
// If we're about to enter PB mode, adjust the flags now
if (this._inPrivateBrowsing) {
this._adjustPBFlagOnExistingWindows();
}
// nothing needs to be done here if we're enabling at startup
if (!this._autoStarted) {
@ -180,6 +187,11 @@ PrivateBrowsingService.prototype = {
}
else
this._saveSession = false;
// If we're about to leave PB mode, adjust the flags now
if (!this._inPrivateBrowsing) {
this._adjustPBFlagOnExistingWindows();
}
},
_onAfterPrivateBrowsingModeChange: function PBS__onAfterPrivateBrowsingModeChange() {

View File

@ -515,7 +515,18 @@ AsyncFetchAndSetIconForPage::AsyncFetchAndSetIconForPage(
if (pbService) {
bool inPrivateBrowsing = false;
if (NS_SUCCEEDED(pbService->GetPrivateBrowsingEnabled(&inPrivateBrowsing))) {
MOZ_ASSERT(inPrivateBrowsing == mFaviconLoadPrivate);
// In one specific case that we know of, it is possible for these flags
// to not match (bug 801151). We mostly care about the cases where the
// global private browsing mode is on, but the favicon load is not marked
// as private, as those cases will cause privacy leaks. But because
// fixing bug 801151 properly is going to mean tons of really dirty and
// fragile work which might cause other types of problems, we fatally
// assert the condition which would be a privacy leak, and non-fatally
// assert the other side of the condition which would designate a bug,
// but not a privacy sensitive one.
MOZ_ASSERT_IF(inPrivateBrowsing && !mFaviconLoadPrivate, false);
NS_ASSERTION(inPrivateBrowsing == mFaviconLoadPrivate,
"The favicon load flag and the global PB flag do not match");
}
}
#endif