Bug 1231757 - Notification on first activation of Tracking Protection in normal mode. r=past

This commit is contained in:
Paolo Amadini 2016-01-22 13:02:50 +00:00
parent 47adbd3e3f
commit 55edaa4ac4
3 changed files with 28 additions and 14 deletions

View File

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
var TrackingProtection = {
// If the user ignores the doorhanger, we stop showing it after some time.
MAX_INTROS: 0,
PREF_ENABLED_GLOBALLY: "privacy.trackingprotection.enabled",
PREF_ENABLED_IN_PRIVATE_WINDOWS: "privacy.trackingprotection.pbmode.enabled",
@ -106,11 +107,13 @@ var TrackingProtection = {
this.content.setAttribute("state", "blocked-tracking-content");
// Open the tracking protection introduction panel, if applicable.
let introCount = gPrefService.getIntPref("privacy.trackingprotection.introCount");
if (introCount < TrackingProtection.MAX_INTROS) {
gPrefService.setIntPref("privacy.trackingprotection.introCount", ++introCount);
gPrefService.savePrefFile(null);
this.showIntroPanel();
if (this.enabledGlobally) {
let introCount = gPrefService.getIntPref("privacy.trackingprotection.introCount");
if (introCount < TrackingProtection.MAX_INTROS) {
gPrefService.setIntPref("privacy.trackingprotection.introCount", ++introCount);
gPrefService.savePrefFile(null);
this.showIntroPanel();
}
}
this.shieldHistogramAdd(2);
@ -183,6 +186,16 @@ var TrackingProtection = {
BrowserReload();
},
dontShowIntroPanelAgain() {
// This function may be called in private windows, but it does not change
// any preference unless Tracking Protection is enabled globally.
if (this.enabledGlobally) {
gPrefService.setIntPref("privacy.trackingprotection.introCount",
this.MAX_INTROS);
gPrefService.savePrefFile(null);
}
},
showIntroPanel: Task.async(function*() {
let brandBundle = document.getElementById("bundle_brand");
let brandShortName = brandBundle.getString("brandShortName");
@ -190,12 +203,10 @@ var TrackingProtection = {
let openStep2 = () => {
// When the user proceeds in the tour, adjust the counter to indicate that
// the user doesn't need to see the intro anymore.
gPrefService.setIntPref("privacy.trackingprotection.introCount",
this.MAX_INTROS);
gPrefService.savePrefFile(null);
this.dontShowIntroPanelAgain();
let nextURL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
"#step2";
"?step=2&newtab=true";
switchToTabHavingURI(nextURL, true, {
// Ignore the fragment in case the intro is shown on the tour page
// (e.g. if the user manually visited the tour or clicked the link from
@ -220,8 +231,9 @@ var TrackingProtection = {
UITour.initForBrowser(gBrowser.selectedBrowser, window);
UITour.showInfo(window, panelTarget,
gNavigatorBundle.getString("trackingProtection.intro.title"),
gNavigatorBundle.getFormattedString("trackingProtection.intro.description",
gNavigatorBundle.getFormattedString("trackingProtection.intro.description2",
[brandShortName]),
undefined, buttons);
undefined, buttons,
{ closeButtonCallback: () => this.dontShowIntroPanelAgain() });
}),
};

View File

@ -52,7 +52,7 @@ add_task(function* test_trackingPages() {
is(Services.prefs.getIntPref(PREF_INTRO_COUNT), TrackingProtection.MAX_INTROS, "Check intro count increased");
let step2URL = Services.urlFormatter.formatURLPref("privacy.trackingprotection.introURL") +
"#step2";
"?step=2&newtab=true";
let buttons = document.getElementById("UITourTooltipButtons");
info("Click the step text and nothing should happen");

View File

@ -332,8 +332,10 @@ identity.identified.state_and_country=%S, %S
identity.unknown.tooltip=This website does not supply identity information.
trackingProtection.intro.title=How Tracking Protection works
# LOCALIZATION NOTE (trackingProtection.intro.description): %S is brandShortName
trackingProtection.intro.description=When the shield is visible, that means Firefox is actively blocking content that tracks you.
# LOCALIZATION NOTE (trackingProtection.intro.description2):
# %S is brandShortName. This string should match the one from Step 1 of the tour
# when it starts from the button shown when a new private window is opened.
trackingProtection.intro.description2=When you see the shield, %S is blocking some parts of the page that could track your browsing activity.
# LOCALIZATION NOTE (trackingProtection.intro.step1of3): Indicates that the intro panel is step one of three in a tour.
trackingProtection.intro.step1of3=1 of 3
trackingProtection.intro.nextButton.label=Next