Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2706 from mozilla-services/2699-fix-terms-and-pri…
Browse files Browse the repository at this point in the history
…vacy-urls

2699 fix terms and privacy urls
  • Loading branch information
ianb authored Apr 19, 2017
2 parents 70b2a43 + e8c5809 commit e1dccdc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion addon/webextension/background/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ this.communication = (function() {
}


// A singleton/sentinal (with a name):
// A singleton/sentinel (with a name):
exports.NO_BOOTSTRAP = {name: "communication.NO_BOOTSTRAP"};

return exports;
Expand Down
10 changes: 10 additions & 0 deletions addon/webextension/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,5 +272,15 @@ this.main = (function() {
});
});

// Note: this signal is only needed until bug 1357589 is fixed.
communication.register("openTermsPage", () => {
return catcher.watchPromise(browser.tabs.create({url: "https://www.mozilla.org/about/legal/terms/services/"}));
});

// Note: this signal is also only needed until bug 1357589 is fixed.
communication.register("openPrivacyPage", () => {
return catcher.watchPromise(browser.tabs.create({url: "https://www.mozilla.org/privacy/firefox-cloud/"}));
});

return exports;
})();
33 changes: 22 additions & 11 deletions addon/webextension/onboarding/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,29 +84,30 @@ this.slides = (function() {
// termsAndPrivacyNoticeCloudServices is a more complicated substitution:
let termsContainer = doc.querySelector(".onboarding-legal-notice");
termsContainer.innerHTML = "";
let termsSentinal = "__TERMS__";
let privacySentinal = "__PRIVACY__";
let sentinalSplitter = "!!!";
let termsSentinel = "__TERMS__";
let privacySentinel = "__PRIVACY__";
let sentinelSplitter = "!!!";
let linkTexts = {
[termsSentinal]: browser.i18n.getMessage("termsAndPrivacyNoticeTermsLink"),
[privacySentinal]: browser.i18n.getMessage("termsAndPrivacyNoticyPrivacyLink")
[termsSentinel]: browser.i18n.getMessage("termsAndPrivacyNoticeTermsLink"),
[privacySentinel]: browser.i18n.getMessage("termsAndPrivacyNoticyPrivacyLink")
};
let linkUrls = {
[termsSentinal]: "https://www.mozilla.org/about/legal/terms/services/",
[privacySentinal]: "https://www.mozilla.org/privacy/firefox-cloud/"
[termsSentinel]: "https://www.mozilla.org/about/legal/terms/services/",
[privacySentinel]: "https://www.mozilla.org/privacy/firefox-cloud/"
};
let text = browser.i18n.getMessage(
"termsAndPrivacyNoticeCloudServices",
[sentinalSplitter + termsSentinal + sentinalSplitter,
sentinalSplitter + privacySentinal + sentinalSplitter]);
let parts = text.split(sentinalSplitter);
[sentinelSplitter + termsSentinel + sentinelSplitter,
sentinelSplitter + privacySentinel + sentinelSplitter]);
let parts = text.split(sentinelSplitter);
for (let part of parts) {
let el;
if (part === termsSentinal || part === privacySentinal) {
if (part === termsSentinel || part === privacySentinel) {
el = doc.createElement("a");
el.href = linkUrls[part];
el.textContent = linkTexts[part];
el.target = "_blank";
el.id = (part === termsSentinel) ? "terms" : "privacy";
} else {
el = doc.createTextNode(part);
}
Expand Down Expand Up @@ -140,6 +141,16 @@ this.slides = (function() {
shooter.sendEvent("finish-slides", "done");
callbacks.onEnd();
})));
// Note: e10s breaks the terms and privacy anchor tags. Work around this by
// manually opening the correct URLs on click until bug 1357589 is fixed.
doc.querySelector("#terms").addEventListener("click", watchFunction(assertIsTrusted((event) => {
event.preventDefault();
callBackground("openTermsPage");
})));
doc.querySelector("#privacy").addEventListener("click", watchFunction(assertIsTrusted((event) => {
event.preventDefault();
callBackground("openPrivacyPage");
})));
setSlide(1);
}

Expand Down

0 comments on commit e1dccdc

Please sign in to comment.