2012-05-21 04:12:37 -07:00
|
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-07-27 23:25:11 -07:00
|
|
|
#ifdef MOZ_SAFE_BROWSING
|
|
|
|
var gSafeBrowsing = {
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
setReportPhishingMenu: function() {
|
2012-07-27 23:25:11 -07:00
|
|
|
|
2008-08-19 21:11:39 -07:00
|
|
|
// A phishing page will have a specific about:blocked content documentURI
|
2012-09-23 12:09:29 -07:00
|
|
|
var isPhishingPage = content.document.documentURI.startsWith("about:blocked?e=phishingBlocked");
|
2012-07-27 23:25:11 -07:00
|
|
|
|
2008-08-19 21:11:39 -07:00
|
|
|
// Show/hide the appropriate menu item.
|
|
|
|
document.getElementById("menu_HelpPopup_reportPhishingtoolmenu")
|
|
|
|
.hidden = isPhishingPage;
|
|
|
|
document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu")
|
|
|
|
.hidden = !isPhishingPage;
|
|
|
|
|
|
|
|
var broadcasterId = isPhishingPage
|
|
|
|
? "reportPhishingErrorBroadcaster"
|
|
|
|
: "reportPhishingBroadcaster";
|
|
|
|
|
|
|
|
var broadcaster = document.getElementById(broadcasterId);
|
|
|
|
if (!broadcaster)
|
|
|
|
return;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var uri = getBrowser().currentURI;
|
2008-02-25 22:48:55 -08:00
|
|
|
if (uri && (uri.schemeIs("http") || uri.schemeIs("https")))
|
|
|
|
broadcaster.removeAttribute("disabled");
|
|
|
|
else
|
2008-08-19 21:11:39 -07:00
|
|
|
broadcaster.setAttribute("disabled", true);
|
2007-03-22 10:30:00 -07:00
|
|
|
},
|
2008-02-25 22:48:55 -08:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* Used to report a phishing page or a false positive
|
2008-10-27 12:36:46 -07:00
|
|
|
* @param name String One of "Phish", "Error", "Malware" or "MalwareError"
|
2007-03-22 10:30:00 -07:00
|
|
|
* @return String the report phishing URL.
|
|
|
|
*/
|
|
|
|
getReportURL: function(name) {
|
2012-07-27 23:25:11 -07:00
|
|
|
var reportUrl = SafeBrowsing.getReportURL(name);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-05-06 18:34:01 -07:00
|
|
|
var pageUri = gBrowser.currentURI.clone();
|
|
|
|
|
|
|
|
// Remove the query to avoid including potentially sensitive data
|
|
|
|
if (pageUri instanceof Ci.nsIURL)
|
|
|
|
pageUri.query = '';
|
|
|
|
|
|
|
|
reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return reportUrl;
|
|
|
|
}
|
|
|
|
}
|
2012-07-27 23:25:11 -07:00
|
|
|
#endif
|