2018-05-30 16:48:00 +03:00
|
|
|
/* 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";
|
2019-07-03 07:27:55 +03:00
|
|
|
/* globals Localization */
|
2019-07-05 18:05:02 +03:00
|
|
|
const { AttributionCode } = ChromeUtils.import(
|
|
|
|
"resource:///modules/AttributionCode.jsm"
|
|
|
|
);
|
|
|
|
const { AddonRepository } = ChromeUtils.import(
|
|
|
|
"resource://gre/modules/addons/AddonRepository.jsm"
|
|
|
|
);
|
|
|
|
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
|
2018-11-28 23:31:48 +03:00
|
|
|
|
2018-09-24 23:20:07 +03:00
|
|
|
const L10N = new Localization([
|
|
|
|
"branding/brand.ftl",
|
2019-05-08 21:08:54 +03:00
|
|
|
"browser/branding/brandings.ftl",
|
2018-11-06 19:28:45 +03:00
|
|
|
"browser/branding/sync-brand.ftl",
|
2018-09-24 23:20:07 +03:00
|
|
|
"browser/newtab/onboarding.ftl",
|
|
|
|
]);
|
2018-05-30 16:48:00 +03:00
|
|
|
|
2019-07-08 19:53:16 +03:00
|
|
|
const ONBOARDING_MESSAGES = () => [
|
2019-04-27 00:18:28 +03:00
|
|
|
{
|
2019-05-01 22:42:24 +03:00
|
|
|
id: "TRAILHEAD_1",
|
2019-04-27 00:18:28 +03:00
|
|
|
template: "trailhead",
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadInterrupt == 'join'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "firstRun" },
|
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
2019-05-07 22:21:11 +03:00
|
|
|
utm_term: "trailhead-join",
|
2019-05-01 22:42:24 +03:00
|
|
|
content: {
|
|
|
|
className: "joinCohort",
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-welcome-body" },
|
|
|
|
benefits: ["products", "knowledge", "privacy"].map(id => ({
|
|
|
|
id,
|
|
|
|
title: { string_id: `onboarding-benefit-${id}-title` },
|
|
|
|
text: { string_id: `onboarding-benefit-${id}-text` },
|
|
|
|
})),
|
2019-05-01 22:42:24 +03:00
|
|
|
learn: {
|
2019-07-05 18:05:02 +03:00
|
|
|
text: { string_id: "onboarding-welcome-learn-more" },
|
2019-05-01 22:42:24 +03:00
|
|
|
url: "https://www.mozilla.org/firefox/accounts/",
|
|
|
|
},
|
|
|
|
form: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-join-form-header" },
|
|
|
|
text: { string_id: "onboarding-join-form-body" },
|
|
|
|
email: { string_id: "onboarding-join-form-email" },
|
|
|
|
button: { string_id: "onboarding-join-form-continue" },
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
2019-07-05 18:05:02 +03:00
|
|
|
skipButton: { string_id: "onboarding-start-browsing-button-label" },
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_2",
|
|
|
|
template: "trailhead",
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadInterrupt == 'sync'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "firstRun" },
|
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
2019-05-07 22:21:11 +03:00
|
|
|
utm_term: "trailhead-sync",
|
2019-05-01 22:42:24 +03:00
|
|
|
content: {
|
|
|
|
className: "syncCohort",
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-sync-welcome-header" },
|
|
|
|
subtitle: { string_id: "onboarding-sync-welcome-content" },
|
2019-05-01 22:42:24 +03:00
|
|
|
benefits: [],
|
|
|
|
learn: {
|
2019-07-05 18:05:02 +03:00
|
|
|
text: { string_id: "onboarding-sync-welcome-learn-more-link" },
|
2019-05-01 22:42:24 +03:00
|
|
|
url: "https://www.mozilla.org/firefox/accounts/",
|
|
|
|
},
|
|
|
|
form: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-sync-form-header" },
|
|
|
|
text: { string_id: "onboarding-sync-form-sub-header" },
|
|
|
|
email: { string_id: "onboarding-sync-form-input" },
|
|
|
|
button: { string_id: "onboarding-sync-form-continue-button" },
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
2019-07-05 18:05:02 +03:00
|
|
|
skipButton: { string_id: "onboarding-sync-form-skip-login-button" },
|
2019-05-01 22:42:24 +03:00
|
|
|
},
|
2019-04-27 00:18:28 +03:00
|
|
|
},
|
2019-05-02 00:07:50 +03:00
|
|
|
{
|
|
|
|
id: "TRAILHEAD_3",
|
|
|
|
template: "trailhead",
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadInterrupt == 'cards'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "firstRun" },
|
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
2019-05-07 22:21:11 +03:00
|
|
|
utm_term: "trailhead-cards",
|
2019-05-02 00:07:50 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_4",
|
|
|
|
template: "trailhead",
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadInterrupt == 'nofirstrun'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "firstRun" },
|
2019-05-02 00:07:50 +03:00
|
|
|
},
|
2019-07-25 19:43:43 +03:00
|
|
|
{
|
|
|
|
id: "EXTENDED_TRIPLETS_1",
|
|
|
|
template: "extended_triplets",
|
|
|
|
targeting:
|
|
|
|
"trailheadTriplet && ((currentDate|date - profileAgeCreated) / 86400000) < 7",
|
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
|
|
|
frequency: { lifetime: 20 },
|
|
|
|
utm_term: "trailhead-cards",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_1",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 2,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-tracking-protection-title2" },
|
|
|
|
text: { string_id: "onboarding-tracking-protection-text2" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "tracking",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-tracking-protection-button2" },
|
|
|
|
action:
|
|
|
|
Services.locale.appLocaleAsLangTag.substr(0, 2) === "en"
|
|
|
|
? {
|
|
|
|
type: "OPEN_URL",
|
|
|
|
data: {
|
|
|
|
args: "https://mzl.la/ETPdefault",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
: {
|
|
|
|
type: "OPEN_PREFERENCES_PAGE",
|
|
|
|
data: { category: "privacy-trackingprotection" },
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'privacy'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_2",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 2,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-data-sync-title" },
|
|
|
|
text: { string_id: "onboarding-data-sync-text2" },
|
2019-05-02 00:30:30 +03:00
|
|
|
icon: "devices",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-data-sync-button2" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-05-07 22:21:11 +03:00
|
|
|
addFlowParams: true,
|
2019-07-05 18:05:02 +03:00
|
|
|
data: {
|
|
|
|
args:
|
|
|
|
"https://accounts.firefox.com/?service=sync&action=email&context=fx_desktop_v3&entrypoint=activity-stream-firstrun&style=trailhead",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'supercharge'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_3",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 3,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-firefox-monitor-title" },
|
|
|
|
text: { string_id: "onboarding-firefox-monitor-text" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "ffmonitor",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-firefox-monitor-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: { args: "https://monitor.firefox.com/", where: "tabshifted" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet in ['payoff', 'supercharge']",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_4",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 1,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-browse-privately-title" },
|
|
|
|
text: { string_id: "onboarding-browse-privately-text" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "private",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-browse-privately-button" },
|
|
|
|
action: { type: "OPEN_PRIVATE_BROWSER_WINDOW" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'privacy'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_5",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 5,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-firefox-send-title" },
|
|
|
|
text: { string_id: "onboarding-firefox-send-text2" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "ffsend",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-firefox-send-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: { args: "https://send.firefox.com/", where: "tabshifted" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'payoff'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_6",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 1,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-mobile-phone-title" },
|
|
|
|
text: { string_id: "onboarding-mobile-phone-text" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "mobile",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-mobile-phone-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: {
|
|
|
|
args: "https://www.mozilla.org/firefox/mobile/",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet in ['supercharge', 'multidevice']",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "TRAILHEAD_CARD_7",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 3,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-send-tabs-title" },
|
|
|
|
text: { string_id: "onboarding-send-tabs-text" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "sendtab",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-send-tabs-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: {
|
|
|
|
args:
|
|
|
|
"https://support.mozilla.org/kb/send-tab-firefox-desktop-other-devices",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'multidevice'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
2019-05-08 01:08:16 +03:00
|
|
|
id: "TRAILHEAD_CARD_8",
|
2019-04-30 22:11:11 +03:00
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 2,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-pocket-anywhere-title" },
|
|
|
|
text: { string_id: "onboarding-pocket-anywhere-text2" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "pocket",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-pocket-anywhere-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: {
|
|
|
|
args: "https://getpocket.com/firefox_learnmore",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'multidevice'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
2019-05-08 01:08:16 +03:00
|
|
|
id: "TRAILHEAD_CARD_9",
|
2019-04-30 22:11:11 +03:00
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 3,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-lockwise-passwords-title" },
|
|
|
|
text: { string_id: "onboarding-lockwise-passwords-text2" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "lockwise",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-lockwise-passwords-button2" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: { args: "https://lockwise.firefox.com/", where: "tabshifted" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'privacy'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
{
|
2019-05-08 01:08:16 +03:00
|
|
|
id: "TRAILHEAD_CARD_10",
|
2019-04-30 22:11:11 +03:00
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2019-05-04 00:23:36 +03:00
|
|
|
order: 4,
|
2019-04-30 22:11:11 +03:00
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
title: { string_id: "onboarding-facebook-container-title" },
|
|
|
|
text: { string_id: "onboarding-facebook-container-text2" },
|
2019-04-30 22:41:19 +03:00
|
|
|
icon: "fbcont",
|
2019-04-30 22:11:11 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "onboarding-facebook-container-button" },
|
2019-04-30 22:11:11 +03:00
|
|
|
action: {
|
|
|
|
type: "OPEN_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: {
|
|
|
|
args:
|
|
|
|
"https://addons.mozilla.org/firefox/addon/facebook-container/",
|
|
|
|
where: "tabshifted",
|
|
|
|
},
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2019-05-04 00:23:36 +03:00
|
|
|
targeting: "trailheadTriplet == 'payoff'",
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "showOnboarding" },
|
2019-04-30 22:11:11 +03:00
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
{
|
|
|
|
id: "FXA_1",
|
|
|
|
template: "fxa_overlay",
|
2019-07-08 19:53:16 +03:00
|
|
|
content: {},
|
2019-07-05 18:05:02 +03:00
|
|
|
trigger: { id: "firstRun" },
|
2019-07-08 19:53:16 +03:00
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
},
|
2018-11-28 23:31:48 +03:00
|
|
|
{
|
|
|
|
id: "RETURN_TO_AMO_1",
|
|
|
|
template: "return_to_amo_overlay",
|
|
|
|
content: {
|
2019-07-05 18:05:02 +03:00
|
|
|
header: { string_id: "onboarding-welcome-header" },
|
|
|
|
title: { string_id: "return-to-amo-sub-header" },
|
2019-01-03 15:59:23 +03:00
|
|
|
addon_icon: null,
|
2018-11-28 23:31:48 +03:00
|
|
|
icon: "gift-extension",
|
2019-07-05 18:05:02 +03:00
|
|
|
text: {
|
|
|
|
string_id: "return-to-amo-addon-header",
|
|
|
|
args: { "addon-name": null },
|
|
|
|
},
|
2018-11-28 23:31:48 +03:00
|
|
|
primary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "return-to-amo-extension-button" },
|
2018-11-28 23:31:48 +03:00
|
|
|
action: {
|
|
|
|
type: "INSTALL_ADDON_FROM_URL",
|
2019-07-05 18:05:02 +03:00
|
|
|
data: { url: null, telemetrySource: "rtamo" },
|
2018-11-28 23:31:48 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
secondary_button: {
|
2019-07-05 18:05:02 +03:00
|
|
|
label: { string_id: "return-to-amo-get-started-button" },
|
2018-11-28 23:31:48 +03:00
|
|
|
},
|
|
|
|
},
|
2019-07-08 19:53:16 +03:00
|
|
|
includeBundle: {
|
|
|
|
length: 3,
|
|
|
|
template: "onboarding",
|
|
|
|
trigger: { id: "showOnboarding" },
|
|
|
|
},
|
2019-07-05 18:05:02 +03:00
|
|
|
targeting:
|
|
|
|
"attributionData.campaign == 'non-fx-button' && attributionData.source == 'addons.mozilla.org'",
|
|
|
|
trigger: { id: "firstRun" },
|
2018-11-28 23:31:48 +03:00
|
|
|
},
|
2019-08-02 16:43:11 +03:00
|
|
|
{
|
|
|
|
id: "FXA_ACCOUNTS_BADGE",
|
|
|
|
template: "toolbar_badge",
|
|
|
|
content: {
|
|
|
|
delay: 10000, // delay for 10 seconds
|
|
|
|
target: "fxa-toolbar-menu-button",
|
|
|
|
},
|
|
|
|
// Never accessed the FxA panel && doesn't use Firefox sync & has FxA enabled
|
|
|
|
targeting: `isFxABadgeEnabled && !hasAccessedFxAPanel && !usesFirefoxSync && isFxAEnabled == true`,
|
|
|
|
trigger: { id: "toolbarBadgeUpdate" },
|
|
|
|
},
|
2019-07-05 18:05:02 +03:00
|
|
|
];
|
2018-05-30 16:48:00 +03:00
|
|
|
|
|
|
|
const OnboardingMessageProvider = {
|
2018-09-24 23:20:07 +03:00
|
|
|
async getExtraAttributes() {
|
|
|
|
const [header, button_label] = await L10N.formatMessages([
|
2019-07-05 18:05:02 +03:00
|
|
|
{ id: "onboarding-welcome-header" },
|
|
|
|
{ id: "onboarding-start-browsing-button-label" },
|
2018-09-24 23:20:07 +03:00
|
|
|
]);
|
2019-07-05 18:05:02 +03:00
|
|
|
return { header: header.value, button_label: button_label.value };
|
2018-09-24 23:20:07 +03:00
|
|
|
},
|
|
|
|
async getMessages() {
|
2018-11-06 19:28:45 +03:00
|
|
|
const messages = await this.translateMessages(await ONBOARDING_MESSAGES());
|
2018-09-24 23:20:07 +03:00
|
|
|
return messages;
|
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
async getUntranslatedMessages() {
|
2018-10-31 20:51:24 +03:00
|
|
|
// This is helpful for jsonSchema testing - since we are localizing in the provider
|
2018-11-06 19:28:45 +03:00
|
|
|
const messages = await ONBOARDING_MESSAGES();
|
|
|
|
return messages;
|
2018-10-31 20:51:24 +03:00
|
|
|
},
|
2018-09-24 23:20:07 +03:00
|
|
|
async translateMessages(messages) {
|
|
|
|
let translatedMessages = [];
|
|
|
|
for (const msg of messages) {
|
2019-07-05 18:05:02 +03:00
|
|
|
let translatedMessage = { ...msg };
|
2018-11-28 23:31:48 +03:00
|
|
|
|
2018-11-15 18:59:55 +03:00
|
|
|
// If the message has no content, do not attempt to translate it
|
2018-11-28 23:31:48 +03:00
|
|
|
if (!translatedMessage.content) {
|
|
|
|
translatedMessages.push(translatedMessage);
|
2018-11-15 18:59:55 +03:00
|
|
|
continue;
|
|
|
|
}
|
2018-11-28 23:31:48 +03:00
|
|
|
|
2019-01-03 15:59:23 +03:00
|
|
|
// We need some addon info if we are showing return to amo overlay, so fetch
|
|
|
|
// that, and update the message accordingly
|
|
|
|
if (msg.template === "return_to_amo_overlay") {
|
|
|
|
try {
|
2019-07-05 18:05:02 +03:00
|
|
|
const { name, iconURL, url } = await this.getAddonInfo();
|
2019-01-03 15:59:23 +03:00
|
|
|
// If we do not have all the data from the AMO api to indicate to the user
|
|
|
|
// what they are installing we don't want to show the message
|
|
|
|
if (!name || !iconURL || !url) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
msg.content.text.args["addon-name"] = name;
|
|
|
|
msg.content.addon_icon = iconURL;
|
|
|
|
msg.content.primary_button.action.data.url = url;
|
|
|
|
} catch (e) {
|
|
|
|
continue;
|
|
|
|
}
|
2019-05-09 13:24:42 +03:00
|
|
|
|
|
|
|
// We know we want to show this message, so translate message strings
|
2019-07-05 18:05:02 +03:00
|
|
|
const [
|
|
|
|
primary_button_string,
|
|
|
|
title_string,
|
|
|
|
text_string,
|
|
|
|
] = await L10N.formatMessages([
|
|
|
|
{ id: msg.content.primary_button.label.string_id },
|
|
|
|
{ id: msg.content.title.string_id },
|
|
|
|
{ id: msg.content.text.string_id, args: msg.content.text.args },
|
2019-05-09 13:24:42 +03:00
|
|
|
]);
|
2019-07-05 18:05:02 +03:00
|
|
|
translatedMessage.content.primary_button.label =
|
|
|
|
primary_button_string.value;
|
2019-05-09 13:24:42 +03:00
|
|
|
translatedMessage.content.title = title_string.value;
|
|
|
|
translatedMessage.content.text = text_string.value;
|
2019-01-03 15:59:23 +03:00
|
|
|
}
|
|
|
|
|
2018-11-28 23:31:48 +03:00
|
|
|
// Translate any secondary buttons separately
|
|
|
|
if (msg.content.secondary_button) {
|
2019-07-05 18:05:02 +03:00
|
|
|
const [secondary_button_string] = await L10N.formatMessages([
|
|
|
|
{ id: msg.content.secondary_button.label.string_id },
|
|
|
|
]);
|
|
|
|
translatedMessage.content.secondary_button.label =
|
|
|
|
secondary_button_string.value;
|
2018-11-28 23:31:48 +03:00
|
|
|
}
|
|
|
|
if (msg.content.header) {
|
2019-07-05 18:05:02 +03:00
|
|
|
const [header_string] = await L10N.formatMessages([
|
|
|
|
{ id: msg.content.header.string_id },
|
|
|
|
]);
|
2018-11-28 23:31:48 +03:00
|
|
|
translatedMessage.content.header = header_string.value;
|
|
|
|
}
|
2018-09-24 23:20:07 +03:00
|
|
|
translatedMessages.push(translatedMessage);
|
|
|
|
}
|
|
|
|
return translatedMessages;
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2019-07-04 00:21:40 +03:00
|
|
|
async getAddonInfo() {
|
|
|
|
try {
|
2019-07-05 18:05:02 +03:00
|
|
|
let { content, source } = await AttributionCode.getAttrDataAsync();
|
2019-07-04 00:21:40 +03:00
|
|
|
if (!content || source !== "addons.mozilla.org") {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// Attribution data can be double encoded
|
|
|
|
while (content.includes("%")) {
|
|
|
|
try {
|
|
|
|
const result = decodeURIComponent(content);
|
|
|
|
if (result === content) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
content = result;
|
|
|
|
} catch (e) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const [addon] = await AddonRepository.getAddonsByIDs([content]);
|
|
|
|
if (addon.sourceURI.scheme !== "https") {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
name: addon.name,
|
|
|
|
url: addon.sourceURI.spec,
|
|
|
|
iconURL: addon.icons["64"] || addon.icons["32"],
|
|
|
|
};
|
|
|
|
} catch (e) {
|
2019-07-05 18:05:02 +03:00
|
|
|
Cu.reportError(
|
|
|
|
"Failed to get the latest add-on version for Return to AMO"
|
|
|
|
);
|
2019-07-04 00:21:40 +03:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
},
|
2018-05-30 16:48:00 +03:00
|
|
|
};
|
|
|
|
this.OnboardingMessageProvider = OnboardingMessageProvider;
|
|
|
|
|
|
|
|
const EXPORTED_SYMBOLS = ["OnboardingMessageProvider"];
|