Bug 721211: consolidate home page retrieval code, make it support non-localized prefs, r?dolske
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -234,17 +234,17 @@ pref("browser.shell.checkDefaultBrowser"
pref("browser.shell.shortcutFavicons",true);
pref("browser.shell.mostRecentDateSetAsDefault", "");
pref("browser.shell.skipDefaultBrowserCheck", true);
pref("browser.shell.defaultBrowserCheckCount", 0);
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last visited page, 3 = resume previous browser session
// The behavior of option 3 is detailed at: http://wiki.mozilla.org/Session_Restore
pref("browser.startup.page", 1);
-pref("browser.startup.homepage", "chrome://branding/locale/browserconfig.properties");
+pref("browser.startup.homepage", "about:home");
pref("browser.slowStartup.notificationDisabled", false);
pref("browser.slowStartup.timeThreshold", 40000);
pref("browser.slowStartup.maxSamples", 5);
// This url, if changed, MUST continue to point to an https url. Pulling arbitrary content to inject into
// this page over http opens us up to a man-in-the-middle attack that we'd rather not face. If you are a downstream
// repackager of this code using an alternate snippet url, please keep your users safe
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -5181,33 +5181,20 @@ var gHomeButton = {
homePage = homePage.replace(/\|/g,', ');
if (homePage.toLowerCase() == "about:home")
homeButton.setAttribute("tooltiptext", homeButton.getAttribute("aboutHomeOverrideTooltip"));
else
homeButton.setAttribute("tooltiptext", homePage);
}
},
- getHomePage: function ()
- {
- var url;
- try {
- url = gPrefService.getComplexValue(this.prefDomain,
- Components.interfaces.nsIPrefLocalizedString).data;
- } catch (e) {
- }
-
- // use this if we can't find the pref
- if (!url) {
- var configBundle = Services.strings
- .createBundle("chrome://branding/locale/browserconfig.properties");
- url = configBundle.GetStringFromName(this.prefDomain);
- }
-
- return url;
+ getHomePage: function () {
+ if (!this.HomePage)
+ Cu.import("resource:///modules/HomePage.jsm", this);
+ return this.HomePage.get();
},
};
const nodeToTooltipMap = {
"bookmarks-menu-button": "bookmarksMenuButton.tooltip",
"new-window-button": "newWindowButton.tooltip",
"new-tab-button": "newTabButton.tooltip",
"tabs-newtab-button": "newTabButton.tooltip",
deleted file mode 100644
--- a/browser/branding/aurora/locales/browserconfig.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/.
-
-# Do NOT localize or otherwise change these values
-browser.startup.homepage=about:home
--- a/browser/branding/aurora/locales/jar.mn
+++ b/browser/branding/aurora/locales/jar.mn
@@ -4,9 +4,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@AB_CD@.jar:
% locale branding @AB_CD@ %locale/branding/
# Aurora branding only exists in en-US
locale/branding/brand.dtd (en-US/brand.dtd)
locale/branding/brand.properties (en-US/brand.properties)
- locale/branding/browserconfig.properties
deleted file mode 100644
--- a/browser/branding/nightly/locales/browserconfig.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/.
-
-# Do NOT localize or otherwise change these values
-browser.startup.homepage=about:home
--- a/browser/branding/nightly/locales/jar.mn
+++ b/browser/branding/nightly/locales/jar.mn
@@ -4,9 +4,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@AB_CD@.jar:
% locale branding @AB_CD@ %locale/branding/
# Nightly branding only exists in en-US
locale/branding/brand.dtd (en-US/brand.dtd)
locale/branding/brand.properties (en-US/brand.properties)
- locale/branding/browserconfig.properties
deleted file mode 100644
--- a/browser/branding/official/locales/browserconfig.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/.
-
-# Do NOT localize or otherwise change these values
-browser.startup.homepage=about:home
--- a/browser/branding/official/locales/jar.mn
+++ b/browser/branding/official/locales/jar.mn
@@ -3,9 +3,8 @@
# 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/.
@AB_CD@.jar:
% locale branding @AB_CD@ %locale/branding/
locale/branding/brand.dtd (%brand.dtd)
locale/branding/brand.properties (%brand.properties)
- locale/branding/browserconfig.properties
deleted file mode 100644
--- a/browser/branding/unofficial/locales/browserconfig.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-# 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/.
-
-# Do NOT localize or otherwise change these values
-browser.startup.homepage=about:home
--- a/browser/branding/unofficial/locales/jar.mn
+++ b/browser/branding/unofficial/locales/jar.mn
@@ -4,9 +4,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@AB_CD@.jar:
% locale branding @AB_CD@ %locale/branding/
# Unofficial branding only exists in en-US
locale/branding/brand.dtd (en-US/brand.dtd)
locale/branding/brand.properties (en-US/brand.properties)
- locale/branding/browserconfig.properties
--- a/browser/components/nsBrowserContentHandler.js
+++ b/browser/components/nsBrowserContentHandler.js
@@ -582,24 +582,19 @@ nsBrowserContentHandler.prototype = {
// Only show the startPage if we're not restoring an update session.
if (overridePage && startPage && !willRestoreSession)
return overridePage + "|" + startPage;
return overridePage || startPage || "about:blank";
},
get startPage() {
- var uri = Services.prefs.getComplexValue("browser.startup.homepage",
- nsIPrefLocalizedString).data;
- if (!uri) {
- Services.prefs.clearUserPref("browser.startup.homepage");
- uri = Services.prefs.getComplexValue("browser.startup.homepage",
- nsIPrefLocalizedString).data;
- }
- return uri;
+ if (!this.HomePage)
+ Components.utils.import("resource:///modules/HomePage.jsm", this);
+ return this.HomePage.get();
},
mFeatures : null,
getFeatures : function bch_features(cmdLine) {
if (this.mFeatures === null) {
this.mFeatures = "";
new file mode 100644
--- /dev/null
+++ b/browser/modules/HomePage.jsm
@@ -0,0 +1,37 @@
+/* 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/. */
+
+let EXPORTED_SYMBOLS = ["HomePage"];
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+const prefName = "browser.startup.homepage";
+
+let HomePage = {
+ get: function HomePage_get() {
+ var homePage;
+ try {
+ homePage = Services.prefs.getComplexValue(prefName,
+ Ci.nsIPrefLocalizedString).data;
+ } catch (ex) {}
+
+ if (!homePage)
+ homePage = Services.prefs.getComplexValue(prefName,
+ Ci.nsISupportsString).data;
+
+ // Apparently at some point users ended up with blank home pages somehow.
+ // If that happens, reset the pref and read it again.
+ if (!homePage) {
+ Services.prefs.clearUserPref(prefName);
+ homePage = Services.prefs.getComplexValue(prefName,
+ Ci.nsISupportsString).data;
+ }
+
+ return homePage;
+ }
+}
--- a/browser/modules/moz.build
+++ b/browser/modules/moz.build
@@ -24,16 +24,17 @@ EXTRA_JS_MODULES += [
'ContentWebRTC.jsm',
'CustomizationTabPreloader.jsm',
'DirectoryLinksProvider.jsm',
'E10SUtils.jsm',
'Feeds.jsm',
'FormSubmitObserver.jsm',
'FormValidationHandler.jsm',
'HiddenFrame.jsm',
+ 'HomePage.jsm',
'NetworkPrioritizer.jsm',
'offlineAppCache.jsm',
'PanelFrame.jsm',
'PluginContent.jsm',
'ProcessHangMonitor.jsm',
'ReaderParent.jsm',
'RecentWindow.jsm',
'RemotePrompt.jsm',
--- a/toolkit/mozapps/installer/upload-files.mk
+++ b/toolkit/mozapps/installer/upload-files.mk
@@ -298,17 +298,16 @@ DIST_FILES += \
res \
lib \
extensions \
application.ini \
package-name.txt \
ua-update.json \
platform.ini \
greprefs.js \
- browserconfig.properties \
blocklist.xml \
chrome.manifest \
update.locale \
removed-files \
distribution \
$(NULL)
NON_DIST_FILES = \