зеркало из https://github.com/mozilla/pjs.git
Bug 605935 - Use private-browsing-transition-complete instead of sessionstore-browser-state-restored r=ehsan a=dietrich
This commit is contained in:
Родитель
c6f197c772
Коммит
d71dd7c2ed
|
@ -100,11 +100,9 @@ let UI = {
|
|||
|
||||
// Variable: _privateBrowsing
|
||||
// Keeps track of info related to private browsing, including:
|
||||
// transitionStage - what step we're on in entering/exiting PB
|
||||
// transitionMode - whether we're entering or exiting PB
|
||||
// wasInTabView - whether TabView was visible before we went into PB
|
||||
_privateBrowsing: {
|
||||
transitionStage: 0,
|
||||
transitionMode: "",
|
||||
wasInTabView: false
|
||||
},
|
||||
|
@ -525,20 +523,6 @@ let UI = {
|
|||
let hasGroupItemsData = GroupItems.load();
|
||||
if (!hasGroupItemsData)
|
||||
self.reset(false);
|
||||
|
||||
// if we're transitioning into/out of private browsing, update appropriately
|
||||
if (self._privateBrowsing.transitionStage == 1)
|
||||
self._privateBrowsing.transitionStage = 2;
|
||||
else if (self._privateBrowsing.transitionStage == 3) {
|
||||
if (self._privateBrowsing.transitionMode == "exit" &&
|
||||
self._privateBrowsing.wasInTabView)
|
||||
self.showTabView(false);
|
||||
|
||||
self._privateBrowsing.transitionStage = 0;
|
||||
self._privateBrowsing.transitionMode = "";
|
||||
TabItems.resumeReconnecting();
|
||||
GroupItems.resumeUpdatingTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(srObserver, "sessionstore-browser-state-restored", false);
|
||||
|
@ -548,20 +532,15 @@ let UI = {
|
|||
});
|
||||
|
||||
// Private Browsing:
|
||||
// We keep track of the transition to/from PB with the transitionStage
|
||||
// and transitionMode properties of _privateBrowsing. The stage is 0 if
|
||||
// not transitioning, 1 if just started ("change-granted"), 2 after the
|
||||
// first sessionrestore, 3 after the "private-browsing" notification, and
|
||||
// then back to 0 after the second sessionrestore. The mode is "" if not
|
||||
// transitioning, otherwise it's "enter" or "exit" as appropriate. When
|
||||
// transitioning to PB, we exit Panorama if necessary (making note of the
|
||||
// When transitioning to PB, we exit Panorama if necessary (making note of the
|
||||
// fact that we were there so we can return after PB) and make sure we
|
||||
// don't reenter Panorama due to all of the session restore tab
|
||||
// manipulation (which otherwise we might). When transitioning away from
|
||||
// PB, we reenter Panorama if we had been there directly before PB.
|
||||
function pbObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic == "private-browsing") {
|
||||
self._privateBrowsing.transitionStage = 3;
|
||||
// We could probably do this in private-browsing-change-granted, but
|
||||
// this seems like a nicer spot, right in the middle of the process.
|
||||
if (aData == "enter") {
|
||||
// If we are in Tab View, exit.
|
||||
self._privateBrowsing.wasInTabView = self.isTabViewVisible();
|
||||
|
@ -570,20 +549,30 @@ let UI = {
|
|||
}
|
||||
} else if (aTopic == "private-browsing-change-granted") {
|
||||
if (aData == "enter" || aData == "exit") {
|
||||
self._privateBrowsing.transitionStage = 1;
|
||||
self._privateBrowsing.transitionMode = aData;
|
||||
GroupItems.pauseUpdatingTabBar();
|
||||
TabItems.pauseReconnecting();
|
||||
}
|
||||
} else if (aTopic == "private-browsing-transition-complete") {
|
||||
// We use .transitionMode here, as aData is empty.
|
||||
if (self._privateBrowsing.transitionMode == "exit" &&
|
||||
self._privateBrowsing.wasInTabView)
|
||||
self.showTabView(false);
|
||||
|
||||
self._privateBrowsing.transitionMode = "";
|
||||
TabItems.resumeReconnecting();
|
||||
GroupItems.resumeUpdatingTabBar();
|
||||
}
|
||||
}
|
||||
|
||||
Services.obs.addObserver(pbObserver, "private-browsing", false);
|
||||
Services.obs.addObserver(pbObserver, "private-browsing-change-granted", false);
|
||||
Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false);
|
||||
|
||||
this._cleanupFunctions.push(function() {
|
||||
Services.obs.removeObserver(pbObserver, "private-browsing");
|
||||
Services.obs.removeObserver(pbObserver, "private-browsing-change-granted");
|
||||
Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete");
|
||||
});
|
||||
|
||||
// TabOpen
|
||||
|
@ -612,7 +601,7 @@ let UI = {
|
|||
} else {
|
||||
// If we're currently in the process of entering private browsing,
|
||||
// we don't want to go to the Tab View UI.
|
||||
if (self._privateBrowsing.transitionStage > 0)
|
||||
if (self._privateBrowsing.transitionMode)
|
||||
return;
|
||||
|
||||
// if not closing the last tab
|
||||
|
|
Загрузка…
Ссылка в новой задаче