browser/base/content/browser-safebrowsing.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:8b676e661a76
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
10 // A phishing page will have a specific about:blocked content documentURI
11 var isPhishingPage = content.document.documentURI.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 var uri = getBrowser().currentURI;
28 if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
29 broadcaster.removeAttribute("disabled");
30 else
31 broadcaster.setAttribute("disabled", true);
32 },
33
34 /**
35 * Used to report a phishing page or a false positive
36 * @param name String One of "Phish", "Error", "Malware" or "MalwareError"
37 * @return String the report phishing URL.
38 */
39 getReportURL: function(name) {
40 var reportUrl = SafeBrowsing.getReportURL(name);
41
42 var pageUri = gBrowser.currentURI.clone();
43
44 // Remove the query to avoid including potentially sensitive data
45 if (pageUri instanceof Ci.nsIURL)
46 pageUri.query = '';
47
48 reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec);
49
50 return reportUrl;
51 }
52 }
53 #endif

mercurial