michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: #ifdef MOZ_SAFE_BROWSING michael@0: var gSafeBrowsing = { michael@0: michael@0: setReportPhishingMenu: function() { michael@0: michael@0: // A phishing page will have a specific about:blocked content documentURI michael@0: var isPhishingPage = content.document.documentURI.startsWith("about:blocked?e=phishingBlocked"); michael@0: michael@0: // Show/hide the appropriate menu item. michael@0: document.getElementById("menu_HelpPopup_reportPhishingtoolmenu") michael@0: .hidden = isPhishingPage; michael@0: document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu") michael@0: .hidden = !isPhishingPage; michael@0: michael@0: var broadcasterId = isPhishingPage michael@0: ? "reportPhishingErrorBroadcaster" michael@0: : "reportPhishingBroadcaster"; michael@0: michael@0: var broadcaster = document.getElementById(broadcasterId); michael@0: if (!broadcaster) michael@0: return; michael@0: michael@0: var uri = getBrowser().currentURI; michael@0: if (uri && (uri.schemeIs("http") || uri.schemeIs("https"))) michael@0: broadcaster.removeAttribute("disabled"); michael@0: else michael@0: broadcaster.setAttribute("disabled", true); michael@0: }, michael@0: michael@0: /** michael@0: * Used to report a phishing page or a false positive michael@0: * @param name String One of "Phish", "Error", "Malware" or "MalwareError" michael@0: * @return String the report phishing URL. michael@0: */ michael@0: getReportURL: function(name) { michael@0: var reportUrl = SafeBrowsing.getReportURL(name); michael@0: michael@0: var pageUri = gBrowser.currentURI.clone(); michael@0: michael@0: // Remove the query to avoid including potentially sensitive data michael@0: if (pageUri instanceof Ci.nsIURL) michael@0: pageUri.query = ''; michael@0: michael@0: reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec); michael@0: michael@0: return reportUrl; michael@0: } michael@0: } michael@0: #endif