Bug 1344319 - Create Activity Stream browser extension. r=rhelmer
MozReview-Commit-ID: EUthIoHKlOm
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/bootstrap.js
@@ -0,0 +1,94 @@
+/* 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/. */
+/* globals Components, XPCOMUtils, Preferences, ActivityStream */
+"use strict";
+
+const {utils: Cu} = Components;
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Preferences.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "ActivityStream",
+ "resource://activity-stream/lib/ActivityStream.jsm");
+
+const ACTIVITY_STREAM_ENABLED_PREF = "browser.newtabpage.activity-stream.enabled";
+const REASON_STARTUP_ON_PREF_CHANGE = "PREF_ON";
+const REASON_SHUTDOWN_ON_PREF_CHANGE = "PREF_OFF";
+
+const ACTIVITY_STREAM_OPTIONS = {newTabURL: "about:newtab"};
+
+let activityStream;
+let startupData;
+
+/**
+ * init - Initializes an instance of ActivityStream. This could be called by
+ * the startup() function exposed by bootstrap.js, or it could be called
+ * when ACTIVITY_STREAM_ENABLED_PREF is changed from false to true.
+ *
+ * @param {string} reason - Reason for initialization. Could be install, upgrade, or PREF_ON
+ */
+function init(reason) {
+ // Don't re-initialize
+ if (activityStream && activityStream.initialized) {
+ return;
+ }
+ const options = Object.assign({}, startupData || {}, ACTIVITY_STREAM_OPTIONS);
+ activityStream = new ActivityStream(options);
+ activityStream.init(reason);
+}
+
+/**
+ * uninit - Uninitializes the activityStream instance, if it exsits.This could be
+ * called by the shutdown() function exposed by bootstrap.js, or it could
+ * be called when ACTIVITY_STREAM_ENABLED_PREF is changed from true to false.
+ *
+ * @param {type} reason Reason for uninitialization. Could be uninstall, upgrade, or PREF_OFF
+ */
+function uninit(reason) {
+ if (activityStream) {
+ activityStream.uninit(reason);
+ activityStream = null;
+ }
+}
+
+/**
+ * onPrefChanged - handler for changes to ACTIVITY_STREAM_ENABLED_PREF
+ *
+ * @param {bool} isEnabled Determines whether Activity Stream is enabled
+ */
+function onPrefChanged(isEnabled) {
+ if (isEnabled) {
+ init(REASON_STARTUP_ON_PREF_CHANGE);
+ } else {
+ uninit(REASON_SHUTDOWN_ON_PREF_CHANGE);
+ }
+}
+
+// The functions below are required by bootstrap.js
+
+this.install = function install(data, reason) {};
+
+this.startup = function startup(data, reason) {
+ // Cache startup data which contains stuff like the version number, etc.
+ // so we can use it when we init
+ startupData = data;
+
+ // Listen for changes to the pref that enables Activity Stream
+ Preferences.observe(ACTIVITY_STREAM_ENABLED_PREF, onPrefChanged);
+
+ // Only initialize if the pref is true
+ if (Preferences.get(ACTIVITY_STREAM_ENABLED_PREF)) {
+ init(reason);
+ }
+};
+
+this.shutdown = function shutdown(data, reason) {
+ // Uninitialize Activity Stream
+ startupData = null;
+ uninit(reason);
+
+ // Stop listening to the pref that enables Activity Stream
+ Preferences.ignore(ACTIVITY_STREAM_ENABLED_PREF, onPrefChanged);
+};
+
+this.uninstall = function uninstall(data, reason) {};
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/data/content/activity-stream.html
@@ -0,0 +1,12 @@
+<!doctype html>
+<html lang="en-us" dir="ltr">
+ <head>
+ <meta charset="utf-8">
+ <title>New Tab</title>
+ </head>
+ <body>
+ <div id="root">
+ <h1>New Tab</h1>
+ </div>
+ </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/install.rdf.in
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+#filter substitution
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>activity-stream@mozilla.org</em:id>
+ <em:type>2</em:type>
+ <em:bootstrap>true</em:bootstrap>
+ <em:unpack>false</em:unpack>
+ <em:version>0.0.0</em:version>
+ <em:name>Activity Stream</em:name>
+ <em:description>A rich visual history feed and a reimagined home page make it easier than ever to find exactly what you're looking for in Firefox.</em:description>
+ <em:multiprocessCompatible>true</em:multiprocessCompatible>
+
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>@MOZ_APP_VERSION@</em:minVersion>
+ <em:maxVersion>@MOZ_APP_MAXVERSION@</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ </Description>
+</RDF>
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/jar.mn
@@ -0,0 +1,8 @@
+# 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/.
+
+[features/activity-stream@mozilla.org] chrome.jar:
+% resource activity-stream %content/
+ content/lib/ (./lib/*)
+ content/data/ (./data/*)
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/lib/ActivityStream.jsm
@@ -0,0 +1,28 @@
+/* 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/. */
+"use strict";
+
+class ActivityStream {
+
+ /**
+ * constructor - Initializes an instance of ActivityStream
+ *
+ * @param {object} options Options for the ActivityStream instance
+ * @param {string} options.id Add-on ID. e.g. "activity-stream@mozilla.org".
+ * @param {string} options.version Version of the add-on. e.g. "0.1.0"
+ * @param {string} options.newTabURL URL of New Tab page on which A.S. is displayed. e.g. "about:newtab"
+ */
+ constructor(options) {
+ this.initialized = false;
+ this.options = options;
+ }
+ init() {
+ this.initialized = true;
+ }
+ uninit() {
+ this.initialized = false;
+ }
+}
+
+this.EXPORTED_SYMBOLS = ["ActivityStream"];
new file mode 100644
--- /dev/null
+++ b/browser/extensions/activity-stream/moz.build
@@ -0,0 +1,18 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
+# 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/.
+
+DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
+DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
+
+FINAL_TARGET_FILES.features['activity-stream@mozilla.org'] += [
+ 'bootstrap.js',
+]
+
+FINAL_TARGET_PP_FILES.features['activity-stream@mozilla.org'] += [
+ 'install.rdf.in'
+]
+
+JAR_MANIFESTS += ['jar.mn']
--- a/browser/extensions/moz.build
+++ b/browser/extensions/moz.build
@@ -25,10 +25,11 @@ if not CONFIG['RELEASE_OR_BETA']:
if CONFIG['MOZ_MORTAR']:
DIRS += [
'mortar',
]
# Nightly-only system add-ons
if CONFIG['NIGHTLY_BUILD']:
DIRS += [
+ 'activity-stream',
'webcompat-reporter',
]
--- a/testing/talos/talos/xtalos/xperf_whitelist.json
+++ b/testing/talos/talos/xtalos/xperf_whitelist.json
@@ -11,16 +11,17 @@
"{firefox}\\browser\\features\\flyweb@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\formautofill@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\loop@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\firefox@getpocket.com.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\presentation@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\webcompat@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\webcompat-reporter@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{firefox}\\browser\\features\\shield-recipe-client@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
+ "{firefox}\\browser\\features\\activity-stream@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000},
"{talos}\\talos\\tests\\tp5n\\tp5n.manifest": {"mincount": 0, "maxcount": 8, "minbytes": 0, "maxbytes": 32786},
"{talos}\\talos\\tests\\tp5n\\tp5n.manifest.develop": {"mincount": 0, "maxcount": 8, "minbytes": 0, "maxbytes": 32786},
"{profile}\\localstore.rdf": {"mincount": 2, "maxcount": 2, "minbytes": 8192, "maxbytes": 8192},
"{firefox}\\dependentlibs.list": {"mincount": 4, "maxcount": 4, "minbytes": 16384, "maxbytes": 16384},
"{profile}\\content-prefs.sqlite": {"mincount": 6, "maxcount": 6, "minbytes": 65768, "maxbytes": 65768},
"{profile}\\extensions.ini": {"mincount": 2, "maxcount": 2, "minbytes": 8192, "maxbytes": 8192},
"{profile}\\extensions\\pageloader@mozilla.org\\chrome.manifest": {"mincount": 2, "maxcount": 2, "minbytes": 600, "maxbytes": 600},
"{profile}\\extensions\\talos-powers@mozilla.org\\chrome.manifest": {"mincount": 2, "maxcount": 2, "minbytes": 600, "maxbytes": 600},