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";
|
2018-09-24 23:20:07 +03:00
|
|
|
ChromeUtils.import("resource://gre/modules/Localization.jsm");
|
2018-11-06 19:28:45 +03:00
|
|
|
ChromeUtils.import("resource://gre/modules/FxAccountsConfig.jsm");
|
|
|
|
|
2018-09-24 23:20:07 +03:00
|
|
|
const L10N = new Localization([
|
|
|
|
"branding/brand.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
|
|
|
|
2018-11-06 19:28:45 +03:00
|
|
|
const ONBOARDING_MESSAGES = async () => ([
|
2018-05-30 16:48:00 +03:00
|
|
|
{
|
|
|
|
id: "ONBOARDING_1",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 2,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-private-browsing-title"},
|
|
|
|
text: {string_id: "onboarding-private-browsing-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "privatebrowsing",
|
2018-09-24 23:20:07 +03:00
|
|
|
button_label: {string_id: "onboarding-button-label-try-now"},
|
2018-09-14 23:18:00 +03:00
|
|
|
button_action: {type: "OPEN_PRIVATE_BROWSER_WINDOW"},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:00 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_2",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 3,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-screenshots-title"},
|
|
|
|
text: {string_id: "onboarding-screenshots-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "screenshots",
|
2018-09-24 23:20:07 +03:00
|
|
|
button_label: {string_id: "onboarding-button-label-try-now"},
|
2018-08-15 18:26:07 +03:00
|
|
|
button_action: {
|
|
|
|
type: "OPEN_URL",
|
2018-11-15 11:54:00 +03:00
|
|
|
data: {args: "https://screenshots.firefox.com/#tour", where: "tabshifted"},
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:00 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_3",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 1,
|
2018-05-30 16:48:00 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-addons-title"},
|
|
|
|
text: {string_id: "onboarding-addons-text"},
|
2018-05-30 16:48:00 +03:00
|
|
|
icon: "addons",
|
2018-09-24 23:20:07 +03:00
|
|
|
button_label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
button_action: {
|
|
|
|
type: "OPEN_ABOUT_PAGE",
|
2018-10-31 20:51:24 +03:00
|
|
|
data: {args: "addons"},
|
2018-09-24 23:20:07 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
targeting: "attributionData.campaign != 'non-fx-button' && attributionData.source != 'addons.mozilla.org'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-05-30 16:48:37 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "ONBOARDING_4",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
2018-07-25 17:33:31 +03:00
|
|
|
order: 1,
|
2018-05-30 16:48:37 +03:00
|
|
|
content: {
|
2018-09-24 23:20:07 +03:00
|
|
|
title: {string_id: "onboarding-ghostery-title"},
|
|
|
|
text: {string_id: "onboarding-ghostery-text"},
|
2018-05-30 16:48:37 +03:00
|
|
|
icon: "gift",
|
2018-09-24 23:20:07 +03:00
|
|
|
button_label: {string_id: "onboarding-button-label-try-now"},
|
|
|
|
button_action: {
|
|
|
|
type: "OPEN_URL",
|
2018-11-15 11:54:00 +03:00
|
|
|
data: {args: "https://addons.mozilla.org/en-US/firefox/addon/ghostery/", where: "tabshifted"},
|
2018-09-24 23:20:07 +03:00
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-10-05 17:50:46 +03:00
|
|
|
targeting: "providerCohorts.onboarding == 'ghostery'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-11-06 19:28:45 +03:00
|
|
|
{
|
|
|
|
id: "ONBOARDING_5",
|
|
|
|
template: "onboarding",
|
|
|
|
bundled: 3,
|
|
|
|
order: 4,
|
|
|
|
content: {
|
|
|
|
title: {string_id: "onboarding-fxa-title"},
|
|
|
|
text: {string_id: "onboarding-fxa-text"},
|
|
|
|
icon: "sync",
|
|
|
|
button_label: {string_id: "onboarding-button-label-get-started"},
|
|
|
|
button_action: {
|
|
|
|
type: "OPEN_URL",
|
2018-11-15 11:54:00 +03:00
|
|
|
data: {args: await FxAccountsConfig.promiseEmailFirstURI("onboarding"), where: "tabshifted"},
|
2018-11-06 19:28:45 +03:00
|
|
|
},
|
|
|
|
},
|
|
|
|
targeting: "attributionData.campaign == 'non-fx-button' && attributionData.source == 'addons.mozilla.org'",
|
2018-11-15 18:59:55 +03:00
|
|
|
trigger: {id: "showOnboarding"},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: "FXA_1",
|
|
|
|
template: "fxa_overlay",
|
|
|
|
targeting: "attributionData.campaign != 'non-fx-button' && attributionData.source != 'addons.mozilla.org'",
|
2018-11-06 19:28:45 +03:00
|
|
|
trigger: {id: "firstRun"},
|
|
|
|
},
|
2018-10-02 23:01:54 +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([
|
|
|
|
{id: "onboarding-welcome-header"},
|
|
|
|
{id: "onboarding-start-browsing-button-label"},
|
|
|
|
]);
|
|
|
|
return {header: header.value, button_label: button_label.value};
|
|
|
|
},
|
|
|
|
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) {
|
|
|
|
let translatedMessage = msg;
|
2018-11-15 18:59:55 +03:00
|
|
|
// If the message has no content, do not attempt to translate it
|
|
|
|
if (!msg.content) {
|
|
|
|
translatedMessages.push(msg);
|
|
|
|
continue;
|
|
|
|
}
|
2018-09-24 23:20:07 +03:00
|
|
|
const [button_string, title_string, text_string] = await L10N.formatMessages([
|
|
|
|
{id: msg.content.button_label.string_id},
|
|
|
|
{id: msg.content.title.string_id},
|
|
|
|
{id: msg.content.text.string_id},
|
|
|
|
]);
|
|
|
|
translatedMessage.content.button_label = button_string.value;
|
|
|
|
translatedMessage.content.title = title_string.value;
|
|
|
|
translatedMessage.content.text = text_string.value;
|
|
|
|
translatedMessages.push(translatedMessage);
|
|
|
|
}
|
|
|
|
return translatedMessages;
|
2018-09-14 23:18:00 +03:00
|
|
|
},
|
2018-05-30 16:48:00 +03:00
|
|
|
};
|
|
|
|
this.OnboardingMessageProvider = OnboardingMessageProvider;
|
|
|
|
|
|
|
|
const EXPORTED_SYMBOLS = ["OnboardingMessageProvider"];
|