Prevent mistaken overwriting of browser.newtab.url when using the browser preferences dialog
parent
6be95e865d
commit
3cdad969b3
|
@ -22,7 +22,11 @@ var gNewtabUrl = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice");
|
if (this.newtabUrlChoiceIsSet) {
|
||||||
|
newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice");
|
||||||
|
} else {
|
||||||
|
newtabUrlChoice = this.getNewtabChoice();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (browserHomepageUrl || browserHomepageUrl == "") {
|
if (browserHomepageUrl || browserHomepageUrl == "") {
|
||||||
if (Services.prefs.getBoolPref("browser.preferences.instantApply")) {
|
if (Services.prefs.getBoolPref("browser.preferences.instantApply")) {
|
||||||
|
@ -64,5 +68,35 @@ var gNewtabUrl = {
|
||||||
}
|
}
|
||||||
Services.prefs.setCharPref("browser.newtab.url",newtabUrlPref);
|
Services.prefs.setCharPref("browser.newtab.url",newtabUrlPref);
|
||||||
} catch(e) { console.error(e); }
|
} catch(e) { console.error(e); }
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines the value of browser.newtab.choice based
|
||||||
|
* on the value of browser.newtab.url
|
||||||
|
*
|
||||||
|
* @returns the value of browser.newtab.choice
|
||||||
|
*/
|
||||||
|
getNewtabChoice: function() {
|
||||||
|
let newtabUrlPref = Services.prefs.getCharPref("browser.newtab.url");
|
||||||
|
let browserHomepageUrl = Services.prefs.getComplexValue("browser.startup.homepage",
|
||||||
|
Components.interfaces.nsIPrefLocalizedString).data;
|
||||||
|
let newtabUrlSanitizedPref = browserHomepageUrl.split("|")[0];
|
||||||
|
let defaultStartupHomepage = Services.prefs.getDefaultBranch("browser.")
|
||||||
|
.getComplexValue("startup.homepage",
|
||||||
|
Components.interfaces.nsIPrefLocalizedString).data;
|
||||||
|
switch (newtabUrlPref) {
|
||||||
|
case "about:logopage":
|
||||||
|
return 1;
|
||||||
|
case defaultStartupHomepage:
|
||||||
|
return 2;
|
||||||
|
case newtabUrlSanitizedPref:
|
||||||
|
return 3;
|
||||||
|
case "about:newtab":
|
||||||
|
return 4;
|
||||||
|
default: // Custom URL entered.
|
||||||
|
// We need this to consider instantApply.
|
||||||
|
this.newtabPageCustom = newtabUrlPref;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -78,34 +78,13 @@ var gTabsPane = {
|
||||||
/**
|
/**
|
||||||
* Determines the value of the New Tab display drop-down based
|
* Determines the value of the New Tab display drop-down based
|
||||||
* on the value of browser.newtab.url.
|
* on the value of browser.newtab.url.
|
||||||
*
|
|
||||||
* @returns the appropriate value of browser.newtab.choice
|
|
||||||
*/
|
*/
|
||||||
readNewtabUrl: function() {
|
readNewtabUrl: function() {
|
||||||
let newtabUrlPref = document.getElementById("browser.newtab.url");
|
|
||||||
let newtabUrlSanitizedPref = document.getElementById("browser.newtab.myhome");
|
|
||||||
let newtabUrlChoice = document.getElementById("browser.newtab.choice");
|
let newtabUrlChoice = document.getElementById("browser.newtab.choice");
|
||||||
let defaultStartupHomepage = Services.prefs.getDefaultBranch("browser.")
|
newtabUrlChoice.value = gNewtabUrl.getNewtabChoice();
|
||||||
.getComplexValue("startup.homepage",
|
if (newtabUrlChoice.value == 0) {
|
||||||
Components.interfaces.nsIPrefLocalizedString).data;
|
document.getElementById("newtabPageCustom").hidden = false;
|
||||||
switch (newtabUrlPref.value) {
|
|
||||||
case "about:logopage":
|
|
||||||
newtabUrlChoice.value = 1;
|
|
||||||
break;
|
|
||||||
case defaultStartupHomepage:
|
|
||||||
newtabUrlChoice.value = 2;
|
|
||||||
break;
|
|
||||||
case newtabUrlSanitizedPref.value:
|
|
||||||
newtabUrlChoice.value = 3;
|
|
||||||
break;
|
|
||||||
case "about:newtab":
|
|
||||||
newtabUrlChoice.value = 4;
|
|
||||||
break;
|
|
||||||
default: // Custom URL entered.
|
|
||||||
document.getElementById("newtabPageCustom").hidden = false;
|
|
||||||
newtabUrlChoice.value = 0;
|
|
||||||
// We need this to consider instantApply.
|
|
||||||
this.newtabPageCustom = newtabUrlPref.value;
|
|
||||||
}
|
}
|
||||||
|
gNewtabUrl.newtabUrlChoiceIsSet = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue