Skip to content

Commit

Permalink
Bug 1021751 - Homebanner snippet. r=lucasr
Browse files Browse the repository at this point in the history
  • Loading branch information
liuche committed Aug 22, 2014
1 parent b1637f3 commit 7a148d6
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions js/src/tests/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ user_pref("browser.safebrowsing.enabled", false);
user_pref("browser.safebrowsing.malware.enabled", false);
user_pref("browser.snippets.enabled", false);
user_pref("browser.snippets.syncPromo.enabled", false);
user_pref("browser.snippets.firstrunHomepage.enabled", false);
user_pref("general.useragent.updates.enabled", false);
user_pref("browser.webapps.checkForUpdates", 0);
1 change: 1 addition & 0 deletions layout/tools/reftest/runreftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def createReftestProfile(self, options, manifest, server='localhost',
# And for snippets.
prefs['browser.snippets.enabled'] = False
prefs['browser.snippets.syncPromo.enabled'] = False
prefs['browser.snippets.firstrunHomepage.enabled'] = False
# And for useragent updates.
prefs['general.useragent.updates.enabled'] = False
# And for webapp updates. Yes, it is supposed to be an integer.
Expand Down
1 change: 1 addition & 0 deletions mobile/android/app/mobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ pref("browser.snippets.statsUrl", "https://snippets-stats.mozilla.org/mobile");
// These prefs require a restart to take effect.
pref("browser.snippets.enabled", true);
pref("browser.snippets.syncPromo.enabled", true);
pref("browser.snippets.firstrunHomepage.enabled", true);

// The URL of the APK factory from which we obtain APKs for webapps.
pref("browser.webapps.apkFactoryUrl", "https://controller.apk.firefox.com/application.apk");
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 27 additions & 1 deletion mobile/android/components/Snippets.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,30 @@ function loadSyncPromoBanner() {
);
}

function loadHomePanelsBanner() {
let stringBundle = Services.strings.createBundle("chrome://browser/locale/aboutHome.properties");
let text = stringBundle.GetStringFromName("banner.firstrunHomepage.text");

let id = Home.banner.add({
text: text,
icon: "drawable://homepage_banner_firstrun",
onclick: function() {
// Remove the message, so that it won't show again for the rest of the app lifetime.
Home.banner.remove(id);
// User has interacted with this snippet so don't show it again.
Services.prefs.setBoolPref("browser.snippets.firstrunHomepage.enabled", false);

UITelemetry.addEvent("action.1", "banner", null, "firstrun-homepage");
},
ondismiss: function() {
Home.banner.remove(id);
Services.prefs.setBoolPref("browser.snippets.firstrunHomepage.enabled", false);

UITelemetry.addEvent("cancel.1", "banner", null, "firstrun-homepage");
}
});
}

function Snippets() {}

Snippets.prototype = {
Expand All @@ -386,7 +410,9 @@ Snippets.prototype = {
observe: function(subject, topic, data) {
switch(topic) {
case "browser-delayed-startup-finished":
if (Services.prefs.getBoolPref("browser.snippets.syncPromo.enabled")) {
if (Services.prefs.getBoolPref("browser.snippets.firstrunHomepage.enabled")) {
loadHomePanelsBanner();
} else if (Services.prefs.getBoolPref("browser.snippets.syncPromo.enabled")) {
loadSyncPromoBanner();
}

Expand Down
5 changes: 5 additions & 0 deletions mobile/android/locales/en-US/chrome/aboutHome.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# 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/.

banner.firstrunHomepage.text=Welcome to your Homepage! Get back here every time you open a new tab.
1 change: 1 addition & 0 deletions mobile/android/locales/jar.mn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
locale/@AB_CD@/browser/aboutDownloads.properties (%chrome/aboutDownloads.properties)
locale/@AB_CD@/browser/aboutFeedback.dtd (%chrome/aboutFeedback.dtd)
locale/@AB_CD@/browser/aboutHome.dtd (%chrome/aboutHome.dtd)
locale/@AB_CD@/browser/aboutHome.properties (%chrome/aboutHome.properties)
locale/@AB_CD@/browser/aboutPrivateBrowsing.dtd (%chrome/aboutPrivateBrowsing.dtd)
locale/@AB_CD@/browser/aboutReader.properties (%chrome/aboutReader.properties)
#ifdef MOZ_SERVICES_HEALTHREPORT
Expand Down
1 change: 1 addition & 0 deletions testing/profiles/prefs_general.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ user_pref("browser.webapps.testing", true);
// Disable android snippets
user_pref("browser.snippets.enabled", false);
user_pref("browser.snippets.syncPromo.enabled", false);
user_pref("browser.snippets.firstrunHomepage.enabled", false);

// Disable useragent updates.
user_pref("general.useragent.updates.enabled", false);
Expand Down

0 comments on commit 7a148d6

Please sign in to comment.