mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-29 18:47:31 +09:00
Update 'browser.newtab.url' when it's used for new tabs and 'browser.startup.homepage' changes
This commit is contained in:
parent
0c59e08e58
commit
84ae67b1bc
6 changed files with 74 additions and 55 deletions
|
|
@ -24,6 +24,7 @@ browser.jar:
|
||||||
content/browser/preferences/languages.js
|
content/browser/preferences/languages.js
|
||||||
* content/browser/preferences/main.xul
|
* content/browser/preferences/main.xul
|
||||||
content/browser/preferences/main.js
|
content/browser/preferences/main.js
|
||||||
|
content/browser/preferences/newtaburl.js
|
||||||
content/browser/preferences/permissions.xul
|
content/browser/preferences/permissions.xul
|
||||||
* content/browser/preferences/permissions.js
|
* content/browser/preferences/permissions.js
|
||||||
* content/browser/preferences/preferences.xul
|
* content/browser/preferences/preferences.xul
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@
|
||||||
type="autocomplete" autocompletesearch="history"
|
type="autocomplete" autocompletesearch="history"
|
||||||
onsyncfrompreference="return gMainPane.syncFromHomePref();"
|
onsyncfrompreference="return gMainPane.syncFromHomePref();"
|
||||||
onsynctopreference="return gMainPane.syncToHomePref(this.value);"
|
onsynctopreference="return gMainPane.syncToHomePref(this.value);"
|
||||||
|
oninput="gNewtabUrl.writeNewtabUrl(null, this.value);"
|
||||||
placeholder="&abouthome.pageTitle;"
|
placeholder="&abouthome.pageTitle;"
|
||||||
preference="browser.startup.homepage"/>
|
preference="browser.startup.homepage"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
@ -103,15 +104,15 @@
|
||||||
<button label="" accesskey="&useCurrentPage.accesskey;"
|
<button label="" accesskey="&useCurrentPage.accesskey;"
|
||||||
label1="&useCurrentPage.label;"
|
label1="&useCurrentPage.label;"
|
||||||
label2="&useMultiple.label;"
|
label2="&useMultiple.label;"
|
||||||
oncommand="gMainPane.setHomePageToCurrent();"
|
oncommand="gMainPane.setHomePageToCurrent(); gNewtabUrl.writeNewtabUrl();"
|
||||||
id="useCurrent"
|
id="useCurrent"
|
||||||
preference="pref.browser.homepage.disable_button.current_page"/>
|
preference="pref.browser.homepage.disable_button.current_page"/>
|
||||||
<button label="&chooseBookmark.label;" accesskey="&chooseBookmark.accesskey;"
|
<button label="&chooseBookmark.label;" accesskey="&chooseBookmark.accesskey;"
|
||||||
oncommand="gMainPane.setHomePageToBookmark();"
|
oncommand="gMainPane.setHomePageToBookmark(); gNewtabUrl.writeNewtabUrl();"
|
||||||
id="useBookmark"
|
id="useBookmark"
|
||||||
preference="pref.browser.homepage.disable_button.bookmark_page"/>
|
preference="pref.browser.homepage.disable_button.bookmark_page"/>
|
||||||
<button label="&restoreDefault.label;" accesskey="&restoreDefault.accesskey;"
|
<button label="&restoreDefault.label;" accesskey="&restoreDefault.accesskey;"
|
||||||
oncommand="gMainPane.restoreDefaultHomePage();"
|
oncommand="gMainPane.restoreDefaultHomePage(); gNewtabUrl.writeNewtabUrl();"
|
||||||
id="restoreDefaultHomePage"
|
id="restoreDefaultHomePage"
|
||||||
preference="pref.browser.homepage.disable_button.restore_default"/>
|
preference="pref.browser.homepage.disable_button.restore_default"/>
|
||||||
</hbox>
|
</hbox>
|
||||||
|
|
|
||||||
66
application/palemoon/components/preferences/newtaburl.js
Normal file
66
application/palemoon/components/preferences/newtaburl.js
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
var gNewtabUrl = {
|
||||||
|
/**
|
||||||
|
* Writes browser.newtab.url with the appropriate value.
|
||||||
|
* If the choice is "my home page", get and sanitize
|
||||||
|
* the browser home page URL to make it suitable for newtab use.
|
||||||
|
*
|
||||||
|
* Called from prefwindow ondialogaccept in preferences.xul,
|
||||||
|
* newtabPage oncommand in tabs.xul, browserHomePage oninput,
|
||||||
|
* useCurrent, useBookmark and restoreDefaultHomePage oncommand
|
||||||
|
* in main.xul to consider instantApply.
|
||||||
|
*/
|
||||||
|
writeNewtabUrl: function(newtabUrlChoice, browserHomepageUrl) {
|
||||||
|
try {
|
||||||
|
if (newtabUrlChoice) {
|
||||||
|
if (Services.prefs.getBoolPref("browser.preferences.instantApply")) {
|
||||||
|
newtabUrlChoice = parseInt(newtabUrlChoice);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice");
|
||||||
|
}
|
||||||
|
if (browserHomepageUrl || browserHomepageUrl == "") {
|
||||||
|
if (Services.prefs.getBoolPref("browser.preferences.instantApply")) {
|
||||||
|
if (browserHomepageUrl == "") {
|
||||||
|
browserHomepageUrl = "about:home";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
browserHomepageUrl = Services.prefs.getComplexValue("browser.startup.homepage",
|
||||||
|
Components.interfaces.nsIPrefLocalizedString).data;
|
||||||
|
}
|
||||||
|
let newtabUrlPref = Services.prefs.getCharPref("browser.newtab.url");
|
||||||
|
switch (newtabUrlChoice) {
|
||||||
|
case 1:
|
||||||
|
newtabUrlPref = "about:logopage";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
newtabUrlPref = "http://start.palemoon.org/";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
// If url is a pipe-delimited set of pages, just take the first one.
|
||||||
|
let newtabUrlSanitizedPref=browserHomepageUrl.split("|")[0];
|
||||||
|
// XXX: do we need extra sanitation here, e.g. for invalid URLs?
|
||||||
|
Services.prefs.setCharPref("browser.newtab.myhome", newtabUrlSanitizedPref);
|
||||||
|
newtabUrlPref = newtabUrlSanitizedPref;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
newtabUrlPref = "about:newtab";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// In case of any other value it's a custom URL, consider instantApply.
|
||||||
|
if (this.newtabPageCustom) {
|
||||||
|
newtabUrlPref = this.newtabPageCustom;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Services.prefs.setCharPref("browser.newtab.url",newtabUrlPref);
|
||||||
|
} catch(e) { console.error(e); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -56,10 +56,10 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
onunload="if (typeof gSecurityPane != 'undefined') gSecurityPane.syncAddonSecurityLevel();"
|
onunload="if (typeof gSecurityPane != 'undefined') gSecurityPane.syncAddonSecurityLevel();"
|
||||||
ondialogaccept="if (typeof gTabsPane != 'undefined') gTabsPane.writeNewtabUrl();
|
ondialogaccept="gNewtabUrl.writeNewtabUrl();">
|
||||||
return true;">
|
|
||||||
|
|
||||||
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
|
||||||
|
<script type="application/javascript" src="chrome://browser/content/preferences/newtaburl.js"/>
|
||||||
|
|
||||||
<stringbundle id="bundleBrand" src="chrome://branding/locale/brand.properties"/>
|
<stringbundle id="bundleBrand" src="chrome://branding/locale/brand.properties"/>
|
||||||
<stringbundle id="bundlePreferences"
|
<stringbundle id="bundlePreferences"
|
||||||
|
|
|
||||||
|
|
@ -104,54 +104,5 @@ var gTabsPane = {
|
||||||
// We need this to consider instantApply.
|
// We need this to consider instantApply.
|
||||||
this.newtabPageCustom = newtabUrlPref.value;
|
this.newtabPageCustom = newtabUrlPref.value;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes browser.newtab.url with the appropriate value.
|
|
||||||
* if the choice is "my home page", get and sanitize the browser home page
|
|
||||||
* URL to make it suitable for newtab use.
|
|
||||||
*
|
|
||||||
* Called from prefwindow's ondialogaccept handler and
|
|
||||||
* from browser.newtab.choice's oncommand to consider instantApply.
|
|
||||||
*/
|
|
||||||
writeNewtabUrl: function(newtabUrlChoice) {
|
|
||||||
try {
|
|
||||||
if (newtabUrlChoice) {
|
|
||||||
if (Services.prefs.getBoolPref("browser.preferences.instantApply")) {
|
|
||||||
newtabUrlChoice = parseInt(newtabUrlChoice);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
newtabUrlChoice = Services.prefs.getIntPref("browser.newtab.choice");
|
|
||||||
}
|
|
||||||
let browserHomepageUrl = Services.prefs.getComplexValue("browser.startup.homepage",
|
|
||||||
Components.interfaces.nsIPrefLocalizedString).data;
|
|
||||||
let newtabUrlPref = Services.prefs.getCharPref("browser.newtab.url");
|
|
||||||
switch (newtabUrlChoice) {
|
|
||||||
case 1:
|
|
||||||
newtabUrlPref = "about:logopage";
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
newtabUrlPref = "http://start.palemoon.org/";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// If url is a pipe-delimited set of pages, just take the first one.
|
|
||||||
let newtabUrlSanitizedPref=browserHomepageUrl.split("|")[0];
|
|
||||||
// XXX: do we need extra sanitation here, e.g. for invalid URLs?
|
|
||||||
Services.prefs.setCharPref("browser.newtab.myhome", newtabUrlSanitizedPref);
|
|
||||||
newtabUrlPref = newtabUrlSanitizedPref;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
newtabUrlPref = "about:newtab";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// In case of any other value it's a custom URL, consider instantApply.
|
|
||||||
if (this.newtabPageCustom) {
|
|
||||||
newtabUrlPref = this.newtabPageCustom;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Services.prefs.setCharPref("browser.newtab.url",newtabUrlPref);
|
|
||||||
} catch(e) { console.error(e); }
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@
|
||||||
<menulist
|
<menulist
|
||||||
id="newtabPage"
|
id="newtabPage"
|
||||||
preference="browser.newtab.choice"
|
preference="browser.newtab.choice"
|
||||||
oncommand="gTabsPane.writeNewtabUrl(event.target.value);">
|
oncommand="gNewtabUrl.writeNewtabUrl(event.target.value);">
|
||||||
<menupopup>
|
<menupopup>
|
||||||
<menuitem label="&newtabPage.custom.label;" value="0" id="newtabPageCustom" hidden="true" />
|
<menuitem label="&newtabPage.custom.label;" value="0" id="newtabPageCustom" hidden="true" />
|
||||||
<menuitem label="&newtabPage.blank.label;" value="1" />
|
<menuitem label="&newtabPage.blank.label;" value="1" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue