Bug 1409348 - Prefer the per-provider report{Malware,Phish}MistakeURL in about:blocked. r?francois draft
authorHector Zhao <bzhao@mozilla.com>
Tue, 17 Oct 2017 19:42:31 +0800
changeset 681466 cdba75147cf45a7fe234c8405a1dc57f81b49ec8
parent 681384 ca068118abc506b1a1753b754fa8521fd4f3c57f
child 736162 785552109550cbf9fb69dda74a0364a58b0f0d01
push id84846
push userbmo:bzhao@mozilla.com
push dateTue, 17 Oct 2017 11:44:59 +0000
reviewersfrancois
bugs1409348
milestone58.0a1
Bug 1409348 - Prefer the per-provider report{Malware,Phish}MistakeURL in about:blocked. r?francois MozReview-Commit-ID: 6Wmzf4SvXnE
browser/base/content/content.js
--- a/browser/base/content/content.js
+++ b/browser/base/content/content.js
@@ -22,16 +22,17 @@ XPCOMUtils.defineLazyModuleGetters(this,
   LoginManagerContent: "resource://gre/modules/LoginManagerContent.jsm",
   LoginFormFactory: "resource://gre/modules/LoginManagerContent.jsm",
   InsecurePasswordUtils: "resource://gre/modules/InsecurePasswordUtils.jsm",
   PluginContent: "resource:///modules/PluginContent.jsm",
   PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
   FormSubmitObserver: "resource:///modules/FormSubmitObserver.jsm",
   PageMetadata: "resource://gre/modules/PageMetadata.jsm",
   PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
+  SafeBrowsing: "resource://gre/modules/SafeBrowsing.jsm",
   Utils: "resource://gre/modules/sessionstore/Utils.jsm",
   WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.jsm",
   Feeds: "resource:///modules/Feeds.jsm",
   ContextMenu: "resource:///modules/ContextMenu.jsm",
 });
 
 // TabChildGlobal
 var global = this;
@@ -151,24 +152,18 @@ var AboutBlockedSiteListener = {
     if (!this.isBlockedSite) {
       return;
     }
 
     if (aEvent.type != "AboutBlockedLoaded") {
       return;
     }
 
-    let provider = "";
-    if (docShell.failedChannel) {
-      let classifiedChannel = docShell.failedChannel.
-                              QueryInterface(Ci.nsIClassifiedChannel);
-      if (classifiedChannel) {
-        provider = classifiedChannel.matchedProvider;
-      }
-    }
+    let blockedInfo = getSiteBlockedErrorDetails(docShell);
+    let provider = blockedInfo.provider || "";
 
     let doc = content.document;
 
     /**
     * Set error description link in error details.
     * For example, the "reported as a deceptive site" link for
     * blocked phishing pages.
     */
@@ -177,27 +172,29 @@ var AboutBlockedSiteListener = {
     if (desc) {
       doc.getElementById("error_desc_link").setAttribute("href", desc + aEvent.detail.url);
     }
 
     // Set other links in error details.
     switch (aEvent.detail.err) {
       case "malware":
         doc.getElementById("report_detection").setAttribute("href",
-          "https://www.stopbadware.org/firefox");
+          (SafeBrowsing.getReportURL("MalwareMistake", blockedInfo) ||
+           "https://www.stopbadware.org/firefox"));
         doc.getElementById("learn_more_link").setAttribute("href",
           "https://www.stopbadware.org/firefox");
         break;
       case "unwanted":
         doc.getElementById("learn_more_link").setAttribute("href",
           "https://www.google.com/about/unwanted-software-policy.html");
         break;
       case "phishing":
         doc.getElementById("report_detection").setAttribute("href",
-          "https://safebrowsing.google.com/safebrowsing/report_error/?tpl=mozilla");
+          (SafeBrowsing.getReportURL("PhishMistake", blockedInfo) ||
+           "https://safebrowsing.google.com/safebrowsing/report_error/?tpl=mozilla"));
         doc.getElementById("learn_more_link").setAttribute("href",
           "https://www.antiphishing.org//");
         break;
     }
 
     // Set the firefox support url.
     doc.getElementById("firefox_support").setAttribute("href",
       "https://support.mozilla.org/kb/how-does-phishing-and-malware-protection-work");