Bug 1236231 - Make sure the Tracking Protection tour doorhanger is not shown when the tour starts from about:privatebrowsing. r=past draft
authorPaolo Amadini <paolo.mozmail@amadzone.org>
Mon, 11 Jan 2016 14:40:31 +0000
changeset 320486 5f3b4f9fc0055b3694ab555dc435d72ce34ff673
parent 320485 912e184396a1057fcd4dd96e8bda434a1c315ff4
child 512747 ba43bd1eaf5468ba256ad768c1647cfbe739b32b
push id9208
push userpaolo.mozmail@amadzone.org
push dateMon, 11 Jan 2016 14:41:56 +0000
reviewerspast
bugs1236231
milestone46.0a1
Bug 1236231 - Make sure the Tracking Protection tour doorhanger is not shown when the tour starts from about:privatebrowsing. r=past
browser/base/content/browser.js
browser/base/content/tab-content.js
browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -7898,16 +7898,21 @@ var AboutPrivateBrowsingListener = {
         OpenBrowserWindow({private: true});
     });
     window.messageManager.addMessageListener(
       "AboutPrivateBrowsing:ToggleTrackingProtection",
       msg => {
         const PREF = "privacy.trackingprotection.pbmode.enabled";
         Services.prefs.setBoolPref(PREF, !Services.prefs.getBoolPref(PREF));
     });
+    window.messageManager.addMessageListener(
+      "AboutPrivateBrowsing:DontShowIntroPanelAgain",
+      msg => {
+        TrackingProtection.dontShowIntroPanelAgain();
+    });
   }
 };
 
 function TabModalPromptBox(browser) {
   this._weakBrowserRef = Cu.getWeakReference(browser);
 }
 
 TabModalPromptBox.prototype = {
--- a/browser/base/content/tab-content.js
+++ b/browser/base/content/tab-content.js
@@ -224,16 +224,18 @@ var AboutHomeListener = {
 AboutHomeListener.init(this);
 
 var AboutPrivateBrowsingListener = {
   init(chromeGlobal) {
     chromeGlobal.addEventListener("AboutPrivateBrowsingOpenWindow", this,
                                   false, true);
     chromeGlobal.addEventListener("AboutPrivateBrowsingToggleTrackingProtection", this,
                                   false, true);
+    chromeGlobal.addEventListener("AboutPrivateBrowsingDontShowIntroPanelAgain", this,
+                                  false, true);
   },
 
   get isAboutPrivateBrowsing() {
     return content.document.documentURI.toLowerCase() == "about:privatebrowsing";
   },
 
   handleEvent(aEvent) {
     if (!this.isAboutPrivateBrowsing) {
@@ -241,16 +243,19 @@ var AboutPrivateBrowsingListener = {
     }
     switch (aEvent.type) {
       case "AboutPrivateBrowsingOpenWindow":
         sendAsyncMessage("AboutPrivateBrowsing:OpenPrivateWindow");
         break;
       case "AboutPrivateBrowsingToggleTrackingProtection":
         sendAsyncMessage("AboutPrivateBrowsing:ToggleTrackingProtection");
         break;
+      case "AboutPrivateBrowsingDontShowIntroPanelAgain":
+        sendAsyncMessage("AboutPrivateBrowsing:DontShowIntroPanelAgain");
+        break;
     }
   },
 };
 AboutPrivateBrowsingListener.init(this);
 
 var AboutReaderListener = {
 
   _articlePromise: null,
--- a/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
+++ b/browser/components/privatebrowsing/content/aboutPrivateBrowsing.js
@@ -52,16 +52,18 @@ document.addEventListener("DOMContentLoa
 
   document.title = stringBundle.GetStringFromName("title");
   document.getElementById("favicon")
           .setAttribute("href", FAVICON_PRIVACY);
   document.getElementById("enableTrackingProtection")
           .addEventListener("click", toggleTrackingProtection);
   document.getElementById("disableTrackingProtection")
           .addEventListener("click", toggleTrackingProtection);
+  document.getElementById("startTour")
+          .addEventListener("click", dontShowIntroPanelAgain);
 
   let formatURLPref = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
                         .getService(Ci.nsIURLFormatter).formatURLPref;
   document.getElementById("startTour").setAttribute("href",
                      formatURLPref("privacy.trackingprotection.introURL"));
   document.getElementById("learnMore").setAttribute("href",
                      formatURLPref("app.support.baseURL") + "private-browsing");
 
@@ -76,8 +78,15 @@ function openPrivateWindow() {
 }
 
 function toggleTrackingProtection() {
   // Ask chrome to enable tracking protection
   document.dispatchEvent(
     new CustomEvent("AboutPrivateBrowsingToggleTrackingProtection",
                     {bubbles:true}));
 }
+
+function dontShowIntroPanelAgain() {
+  // Ask chrome to disable the doorhanger
+  document.dispatchEvent(
+    new CustomEvent("AboutPrivateBrowsingDontShowIntroPanelAgain",
+                    {bubbles:true}));
+}