1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 // This file is loaded into the browser window scope.
6 /* eslint-env mozilla/browser-window */
9 setReportPhishingMenu() {
10 // In order to detect whether or not we're at the phishing warning
11 // page, we have to check the documentURI instead of the currentURI.
12 // This is because when the DocShell loads an error page, the
13 // currentURI stays at the original target, while the documentURI
14 // will point to the internal error page we loaded instead.
15 var docURI = gBrowser.selectedBrowser.documentURI;
17 docURI && docURI.spec.startsWith("about:blocked?e=deceptiveBlocked");
19 // Show/hide the appropriate menu item.
20 const reportMenu = document.getElementById(
21 "menu_HelpPopup_reportPhishingtoolmenu"
23 reportMenu.hidden = isPhishingPage;
24 const reportErrorMenu = document.getElementById(
25 "menu_HelpPopup_reportPhishingErrortoolmenu"
27 reportErrorMenu.hidden = !isPhishingPage;
29 // Now look at the currentURI to learn which page we were trying
31 const uri = gBrowser.currentURI;
32 const isReportablePage =
33 uri && (uri.schemeIs("http") || uri.schemeIs("https"));
35 const disabledByPolicy = !Services.policies.isAllowed("feedbackCommands");
37 if (disabledByPolicy || isPhishingPage || !isReportablePage) {
38 reportMenu.setAttribute("disabled", "true");
40 reportMenu.removeAttribute("disabled");
43 if (disabledByPolicy || !isPhishingPage || !isReportablePage) {
44 reportErrorMenu.setAttribute("disabled", "true");
46 reportErrorMenu.removeAttribute("disabled");
51 * Used to report a phishing page or a false positive
54 * String One of "PhishMistake", "MalwareMistake", or "Phish"
56 * Information about the reasons for blocking the resource.
57 * In the case false positive, it may contain SafeBrowsing
58 * matching list and provider of the list
59 * @return String the report phishing URL.
61 getReportURL(name, info) {
62 let reportInfo = info;
64 let pageUri = gBrowser.currentURI;
66 // Remove the query to avoid including potentially sensitive data
67 if (pageUri instanceof Ci.nsIURL) {
68 pageUri = pageUri.mutate().setQuery("").finalize();
71 reportInfo = { uri: pageUri.asciiSpec };
73 return SafeBrowsing.getReportURL(name, reportInfo);