Bug 1392324 - Add pref to enable Activity Stream on about:home.
MozReview-Commit-ID: 8aRn6vWWpF0
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -1275,16 +1275,18 @@ pref("browser.newtabpage.directory.sourc
// activates Activity Stream
#ifdef NIGHTLY_BUILD
pref("browser.newtabpage.activity-stream.enabled", true);
#else
pref("browser.newtabpage.activity-stream.enabled", false);
#endif
+pref("browser.newtabpage.activity-stream.aboutHome.enabled", false);
+
// Enable the DOM fullscreen API.
pref("full-screen-api.enabled", true);
// Startup Crash Tracking
// number of startup crashes that can occur before starting into safe mode automatically
// (this pref has no effect if more than 6 hours have passed since the last crash)
pref("toolkit.startup.max_resumed_crashes", 3);
--- a/browser/components/about/AboutRedirector.cpp
+++ b/browser/components/about/AboutRedirector.cpp
@@ -18,16 +18,17 @@
namespace mozilla {
namespace browser {
NS_IMPL_ISUPPORTS(AboutRedirector, nsIAboutModule)
bool AboutRedirector::sUseOldPreferences = false;
bool AboutRedirector::sActivityStreamEnabled = false;
+bool AboutRedirector::sActivityStreamAboutHomeEnabled = false;
struct RedirEntry {
const char* id;
const char* url;
uint32_t flags;
};
/*
@@ -115,16 +116,29 @@ GetAboutModuleName(nsIURI *aURI)
f = path.FindChar('?');
if (f >= 0)
path.SetLength(f);
ToLowerCase(path);
return path;
}
+void
+AboutRedirector::LoadActivityStreamPrefs()
+{
+ static bool sASEnabledCacheInited = false;
+ if (!sASEnabledCacheInited) {
+ Preferences::AddBoolVarCache(&AboutRedirector::sActivityStreamEnabled,
+ "browser.newtabpage.activity-stream.enabled");
+ Preferences::AddBoolVarCache(&AboutRedirector::sActivityStreamAboutHomeEnabled,
+ "browser.newtabpage.activity-stream.aboutHome.enabled");
+ sASEnabledCacheInited = true;
+ }
+}
+
NS_IMETHODIMP
AboutRedirector::NewChannel(nsIURI* aURI,
nsILoadInfo* aLoadInfo,
nsIChannel** result)
{
NS_ENSURE_ARG_POINTER(aURI);
NS_ENSURE_ARG_POINTER(aLoadInfo);
@@ -137,22 +151,24 @@ AboutRedirector::NewChannel(nsIURI* aURI
NS_ENSURE_SUCCESS(rv, rv);
static bool sPrefCacheInited = false;
if (!sPrefCacheInited) {
Preferences::AddBoolVarCache(&sUseOldPreferences,
"browser.preferences.useOldOrganization");
sPrefCacheInited = true;
}
+ LoadActivityStreamPrefs();
for (auto & redir : kRedirMap) {
if (!strcmp(path.get(), redir.id)) {
nsAutoCString url;
- if (path.EqualsLiteral("newtab")) {
+ if (path.EqualsLiteral("newtab") ||
+ (path.EqualsLiteral("home") && sActivityStreamEnabled && sActivityStreamAboutHomeEnabled)) {
// let the aboutNewTabService decide where to redirect
nsCOMPtr<nsIAboutNewTabService> aboutNewTabService =
do_GetService("@mozilla.org/browser/aboutnewtab-service;1", &rv);
NS_ENSURE_SUCCESS(rv, rv);
rv = aboutNewTabService->GetDefaultURL(url);
NS_ENSURE_SUCCESS(rv, rv);
} else if (path.EqualsLiteral("preferences") && !sUseOldPreferences) {
url.AssignASCII("chrome://browser/content/preferences/in-content-new/preferences.xul");
@@ -196,30 +212,25 @@ AboutRedirector::NewChannel(nsIURI* aURI
NS_IMETHODIMP
AboutRedirector::GetURIFlags(nsIURI *aURI, uint32_t *result)
{
NS_ENSURE_ARG_POINTER(aURI);
nsAutoCString name = GetAboutModuleName(aURI);
- static bool sASEnabledCacheInited = false;
- if (!sASEnabledCacheInited) {
- Preferences::AddBoolVarCache(&sActivityStreamEnabled,
- "browser.newtabpage.activity-stream.enabled");
- sASEnabledCacheInited = true;
- }
+ LoadActivityStreamPrefs();
for (auto & redir : kRedirMap) {
if (name.Equals(redir.id)) {
// Once ActivityStream is fully rolled out and we've removed Tiles,
// this special case can go away and the flag can just become part
// of the normal about:newtab entry in kRedirMap.
- if (name.EqualsLiteral("newtab")) {
+ if (name.EqualsLiteral("newtab") || (name.EqualsLiteral("home") && sActivityStreamAboutHomeEnabled)) {
if (sActivityStreamEnabled) {
*result = redir.flags |
nsIAboutModule::URI_MUST_LOAD_IN_CHILD |
nsIAboutModule::ENABLE_INDEXED_DB |
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT;
return NS_OK;
}
}
--- a/browser/components/about/AboutRedirector.h
+++ b/browser/components/about/AboutRedirector.h
@@ -23,14 +23,17 @@ public:
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
protected:
virtual ~AboutRedirector() {}
private:
static bool sUseOldPreferences;
static bool sActivityStreamEnabled;
+ static bool sActivityStreamAboutHomeEnabled;
+
+ static void LoadActivityStreamPrefs();
};
} // namespace browser
} // namespace mozilla
#endif // AboutRedirector_h__
--- a/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm
+++ b/browser/extensions/activity-stream/lib/ActivityStreamMessageChannel.jsm
@@ -6,16 +6,17 @@
const {utils: Cu} = Components;
Cu.import("resource:///modules/AboutNewTab.jsm");
Cu.import("resource://gre/modules/RemotePageManager.jsm");
const {actionCreators: ac, actionTypes: at, actionUtils: au} = Cu.import("resource://activity-stream/common/Actions.jsm", {});
const ABOUT_NEW_TAB_URL = "about:newtab";
+const ABOUT_HOME_URL = "about:home";
const DEFAULT_OPTIONS = {
dispatch(action) {
throw new Error(`\nMessageChannel: Received action ${action.type}, but no dispatcher was defined.\n`);
},
pageURL: ABOUT_NEW_TAB_URL,
outgoingMessageName: "ActivityStream:MainToContent",
incomingMessageName: "ActivityStream:ContentToMain"
@@ -123,17 +124,17 @@ this.ActivityStreamMessageChannel = clas
/**
* createChannel - Create RemotePages channel to establishing message passing
* between the main process and child pages
*/
createChannel() {
// Receive AboutNewTab's Remote Pages instance, if it exists, on override
const channel = this.pageURL === ABOUT_NEW_TAB_URL && AboutNewTab.override(true);
- this.channel = channel || new RemotePages(this.pageURL);
+ this.channel = channel || new RemotePages([ABOUT_HOME_URL, ABOUT_NEW_TAB_URL]);
this.channel.addMessageListener("RemotePage:Init", this.onNewTabInit);
this.channel.addMessageListener("RemotePage:Load", this.onNewTabLoad);
this.channel.addMessageListener("RemotePage:Unload", this.onNewTabUnload);
this.channel.addMessageListener(this.incomingMessageName, this.onMessage);
// Some pages might have already loaded, so we won't get the usual message
for (const {loaded, portID} of this.channel.messagePorts) {
if (loaded) {
--- a/browser/modules/AboutNewTab.jsm
+++ b/browser/modules/AboutNewTab.jsm
@@ -25,17 +25,17 @@ var AboutNewTab = {
pageListener: null,
isOverridden: false,
init(pageListener) {
if (this.isOverridden) {
return;
}
- this.pageListener = pageListener || new RemotePages("about:newtab");
+ this.pageListener = pageListener || new RemotePages(["about:home", "about:newtab"]);
this.pageListener.addMessageListener("NewTab:Customize", this.customize);
this.pageListener.addMessageListener("NewTab:MaybeShowMigrateMessage",
this.maybeShowMigrateMessage);
},
maybeShowMigrateMessage({ target }) {
AutoMigrate.shouldShowMigratePrompt(target.browser).then((prompt) => {
if (prompt) {