Bug 1077740 - Handle multiple homepages when resetting to about:home. r=gavin

This commit is contained in:
Dão Gottwald 2014-10-24 12:56:08 +02:00
Родитель a11790a844
Коммит 37c62d21f8
1 изменённых файлов: 19 добавлений и 5 удалений

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

@ -1623,11 +1623,25 @@ BrowserGlue.prototype = {
// Reset homepage pref for users who have it set to start.mozilla.org
// or google.com/firefox.
const HOMEPAGE_PREF = "browser.startup.homepage";
let uri = Services.prefs.getComplexValue(HOMEPAGE_PREF,
Ci.nsIPrefLocalizedString).data;
if (uri && (uri.startsWith("http://start.mozilla.org") ||
/^https?:\/\/(www\.)?google\.[a-z.]+\/firefox/i.test(uri))) {
Services.prefs.clearUserPref(HOMEPAGE_PREF);
if (Services.prefs.prefHasUserValue(HOMEPAGE_PREF)) {
const DEFAULT =
Services.prefs.getDefaultBranch(HOMEPAGE_PREF)
.getComplexValue("", Ci.nsIPrefLocalizedString).data;
let value =
Services.prefs.getComplexValue(HOMEPAGE_PREF, Ci.nsISupportsString);
let updated =
value.data.replace(/https?:\/\/start\.mozilla\.org[^|]*/i, DEFAULT)
.replace(/https?:\/\/(www\.)?google\.[a-z.]+\/firefox[^|]*/i,
DEFAULT);
if (updated != value.data) {
if (updated == DEFAULT) {
Services.prefs.clearUserPref(HOMEPAGE_PREF);
} else {
value.data = updated;
Services.prefs.setComplexValue(HOMEPAGE_PREF,
Ci.nsISupportsString, value);
}
}
}
}