 |
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/.
4
5 #ifdef MOZ_SAFE_BROWSING
6 var gSafeBrowsing = {
7
8 setReportPhishingMenu: function() {
9 // A phishing page will have a specific about:blocked content documentURI
10 var uri = gBrowser.currentURI;
11 var isPhishingPage = uri && uri.spec.startsWith("about:blocked?e=phishingBlocked");
12
13 // Show/hide the appropriate menu item.
14 document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
15 .hidden = isPhishingPage;
16 document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
17 .hidden = !isPhishingPage;
18
19 var broadcasterId = isPhishingPage
20 ? "reportPhishingErrorBroadcaster"
21 : "reportPhishingBroadcaster";
22
23 var broadcaster = document.getElementById(broadcasterId);
24 if (!broadcaster)
25 return;
26
27 if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
28 broadcaster.removeAttribute("disabled");
29 else
30 broadcaster.setAttribute("disabled", true);
31 },
32
33 /**
34 * Used to report a phishing page or a false positive
35 * @param name String One of "Phish", "Error", "Malware" or "MalwareError"
36 * @return String the report phishing URL.
37 */
38 getReportURL: function(name) {
39 var reportUrl = SafeBrowsing.getReportURL(name);
40
41 var pageUri = gBrowser.currentURI.clone();
42
43 // Remove the query to avoid including potentially sensitive data
44 if (pageUri instanceof Ci.nsIURL)
45 pageUri.query = '';
46
47 reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec);
48
49 return reportUrl;
50 }
51 }
52 #endif
53