Bug 799001 - Part 2: Hook up the per-window version of the gPrivateBrowsingUI object; r=dao

This commit is contained in:
Ehsan Akhgari 2012-10-07 23:30:32 -04:00
Родитель 00975f6415
Коммит 4f7ec5f784
1 изменённых файлов: 64 добавлений и 0 удалений

Просмотреть файл

@ -1563,7 +1563,9 @@ var gBrowserInit = {
PlacesStarButton.uninit();
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
gPrivateBrowsingUI.uninit();
#endif
TabsOnTop.uninit();
@ -1711,7 +1713,9 @@ var gBrowserInit = {
BrowserOffline.uninit();
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
gPrivateBrowsingUI.uninit();
#endif
},
#endif
@ -7052,6 +7056,64 @@ function getTabModalPromptBox(aWindow) {
function getBrowser() gBrowser;
function getNavToolbox() gNavToolbox;
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
# We define a new gPrivateBrowsingUI object, as the per-window PB implementation
# is completely different to the global PB one. Specifically, the per-window
# PB implementation does not expose many APIs on the gPrivateBrowsingUI object,
# and only uses it as a way to initialize and uninitialize private browsing
# windows. While we could use #ifdefs all around the global PB mode code to
# make it work in both modes, the amount of duplicated code is small and the
# code is much more readable this way.
let gPrivateBrowsingUI = {
_inited: false,
_initCallbacks: [],
init: function PBUI_init() {
// Do nothing for normal windows
if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
return;
}
// Disable the Clear Recent History... menu item when in PB mode
// temporary fix until bug 463607 is fixed
document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
// Adjust the window's title
if (window.location.href == getBrowserURL()) {
let docElement = document.documentElement;
docElement.setAttribute("title",
docElement.getAttribute("title_privatebrowsing"));
docElement.setAttribute("titlemodifier",
docElement.getAttribute("titlemodifier_privatebrowsing"));
docElement.setAttribute("privatebrowsingmode", "temporary");
gBrowser.updateTitlebar();
}
this._inited = true;
this._initCallbacks.forEach(function (callback) callback.apply());
this._initCallbacks = [];
},
get autoStarted() {
return false; // auto-started PB not supported for now
},
get initialized() {
return this._inited;
},
addInitializationCallback: function PBUI_addInitializationCallback(aCallback) {
if (this._inited)
return;
this._initCallbacks.push(aCallback);
}
};
#else
let gPrivateBrowsingUI = {
_privateBrowsingService: null,
_searchBarValue: null,
@ -7305,6 +7367,8 @@ let gPrivateBrowsingUI = {
}
};
#endif
/**
* Switch to a tab that has a given URI, and focusses its browser window.