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");
|
|
|
|
const L10N = new Localization([
|
|
|
|
"branding/brand.ftl",
|
|
|
|
"browser/newtab/onboarding.ftl",
|
|
|
|
]);
|
2018-05-30 16:48:00 +03:00
|
|
|
|
2018-10-02 23:01:54 +03:00
|
|
|
const ONBOARDING_MESSAGES = () => ([
|
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-09-14 23:18:00 +03:00
|
|
|
trigger: {id: "firstRun"},
|
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-09-14 23:18:00 +03:00
|
|
|
data: {url: "https://screenshots.firefox.com/#tour"},
|
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-09-14 23:18:00 +03:00
|
|
|
trigger: {id: "firstRun"},
|
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",
|
|
|
|
data: {page: "addons"},
|
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-06-23 00:10:08 +03:00
|
|
|
targeting: "isInExperimentCohort == 1",
|
2018-09-14 23:18:00 +03:00
|
|
|
trigger: {id: "firstRun"},
|
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",
|
|
|
|
data: {url: "https://addons.mozilla.org/en-US/firefox/addon/ghostery/"},
|
|
|
|
},
|
2018-05-31 23:23:07 +03:00
|
|
|
},
|
2018-06-23 00:10:08 +03:00
|
|
|
targeting: "isInExperimentCohort == 2",
|
2018-09-14 23:18:00 +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-10-02 23:01:54 +03:00
|
|
|
const messages = await this.translateMessages(ONBOARDING_MESSAGES());
|
2018-09-24 23:20:07 +03:00
|
|
|
return messages;
|
|
|
|
},
|
|
|
|
async translateMessages(messages) {
|
|
|
|
let translatedMessages = [];
|
|
|
|
for (const msg of messages) {
|
|
|
|
let translatedMessage = msg;
|
|
|
|
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"];
|