Bug 625329 - Pinned tabs are used when setting homepage from current tabs [r=gavin]

This commit is contained in:
Paul O’Shannessy 2011-12-13 11:41:25 -08:00
Родитель b851f68c6d
Коммит ff2551efd4
1 изменённых файлов: 29 добавлений и 36 удалений

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

@ -50,7 +50,7 @@ var gMainPane = {
// set up the "use current page" label-changing listener
this._updateUseCurrentButton();
window.addEventListener("focus", this._updateUseCurrentButton, false);
window.addEventListener("focus", this._updateUseCurrentButton.bind(this), false);
this.updateBrowserStartupLastSession();
this.startupPagePrefChanged();
@ -128,23 +128,13 @@ var gMainPane = {
*/
setHomePageToCurrent: function ()
{
var win;
if (document.documentElement.instantApply) {
// If we're in instant-apply mode, use the most recent browser window
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
win = wm.getMostRecentWindow("navigator:browser");
}
else
win = window.opener;
let homePage = document.getElementById("browser.startup.homepage");
let tabs = this._getTabsForHomePage();
function getTabURI(t) t.linkedBrowser.currentURI.spec;
if (win) {
var homePage = document.getElementById("browser.startup.homepage");
var tabs = win.gBrowser.visibleTabs;
function getTabURI(t) t.linkedBrowser.currentURI.spec;
// FIXME Bug 244192: using dangerous "|" joiner!
// FIXME Bug 244192: using dangerous "|" joiner!
if (tabs.length)
homePage.value = tabs.map(getTabURI).join("|");
}
},
/**
@ -170,10 +160,26 @@ var gMainPane = {
* forms.
*/
_updateUseCurrentButton: function () {
var useCurrent = document.getElementById("useCurrent");
let useCurrent = document.getElementById("useCurrent");
var windowIsPresent;
let tabs = this._getTabsForHomePage();
if (tabs.length > 1)
useCurrent.label = useCurrent.getAttribute("label2");
else
useCurrent.label = useCurrent.getAttribute("label1");
// In this case, the button's disabled state is set by preferences.xml.
if (document.getElementById
("pref.browser.homepage.disable_button.current_page").locked)
return;
useCurrent.disabled = !tabs.length
},
_getTabsForHomePage: function ()
{
var win;
var tabs = [];
if (document.documentElement.instantApply) {
const Cc = Components.classes, Ci = Components.interfaces;
// If we're in instant-apply mode, use the most recent browser window
@ -181,30 +187,17 @@ var gMainPane = {
.getService(Ci.nsIWindowMediator);
win = wm.getMostRecentWindow("navigator:browser");
}
else
else {
win = window.opener;
}
if (win && win.document.documentElement
.getAttribute("windowtype") == "navigator:browser") {
windowIsPresent = true;
var tabbrowser = win.document.getElementById("content");
if (tabbrowser.browsers.length > 1)
useCurrent.label = useCurrent.getAttribute("label2");
else
useCurrent.label = useCurrent.getAttribute("label1");
}
else {
windowIsPresent = false;
useCurrent.label = useCurrent.getAttribute("label1");
// We should only include visible & non-pinned tabs
tabs = win.gBrowser.visibleTabs.slice(win.gBrowser._numPinnedTabs);
}
// In this case, the button's disabled state is set by preferences.xml.
if (document.getElementById
("pref.browser.homepage.disable_button.current_page").locked)
return;
useCurrent.disabled = !windowIsPresent;
return tabs;
},
/**