1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/base/content/browser-safebrowsing.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +#ifdef MOZ_SAFE_BROWSING 1.9 +var gSafeBrowsing = { 1.10 + 1.11 + setReportPhishingMenu: function() { 1.12 + 1.13 + // A phishing page will have a specific about:blocked content documentURI 1.14 + var isPhishingPage = content.document.documentURI.startsWith("about:blocked?e=phishingBlocked"); 1.15 + 1.16 + // Show/hide the appropriate menu item. 1.17 + document.getElementById("menu_HelpPopup_reportPhishingtoolmenu") 1.18 + .hidden = isPhishingPage; 1.19 + document.getElementById("menu_HelpPopup_reportPhishingErrortoolmenu") 1.20 + .hidden = !isPhishingPage; 1.21 + 1.22 + var broadcasterId = isPhishingPage 1.23 + ? "reportPhishingErrorBroadcaster" 1.24 + : "reportPhishingBroadcaster"; 1.25 + 1.26 + var broadcaster = document.getElementById(broadcasterId); 1.27 + if (!broadcaster) 1.28 + return; 1.29 + 1.30 + var uri = getBrowser().currentURI; 1.31 + if (uri && (uri.schemeIs("http") || uri.schemeIs("https"))) 1.32 + broadcaster.removeAttribute("disabled"); 1.33 + else 1.34 + broadcaster.setAttribute("disabled", true); 1.35 + }, 1.36 + 1.37 + /** 1.38 + * Used to report a phishing page or a false positive 1.39 + * @param name String One of "Phish", "Error", "Malware" or "MalwareError" 1.40 + * @return String the report phishing URL. 1.41 + */ 1.42 + getReportURL: function(name) { 1.43 + var reportUrl = SafeBrowsing.getReportURL(name); 1.44 + 1.45 + var pageUri = gBrowser.currentURI.clone(); 1.46 + 1.47 + // Remove the query to avoid including potentially sensitive data 1.48 + if (pageUri instanceof Ci.nsIURL) 1.49 + pageUri.query = ''; 1.50 + 1.51 + reportUrl += "&url=" + encodeURIComponent(pageUri.asciiSpec); 1.52 + 1.53 + return reportUrl; 1.54 + } 1.55 +} 1.56 +#endif