Bug 1038465: Pass suggested filename to application reputation query (r=paolo)
authorMonica Chew <mmc@mozilla.com>
Tue, 15 Jul 2014 13:46:52 -0700
changeset 216218 69b8e7c58dc6445cb3eb60c04ff836ee99a0b977
parent 216217 a33939fdd6efa44980510041ab02257c05f68d1a
child 216219 e8d086d9a01ada25aafe3de8882fa2dea75b86d5
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1038465
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1038465: Pass suggested filename to application reputation query (r=paolo)
testing/profiles/prefs_general.js
toolkit/components/downloads/ApplicationReputation.cpp
toolkit/components/jsdownloads/src/DownloadIntegration.jsm
--- a/testing/profiles/prefs_general.js
+++ b/testing/profiles/prefs_general.js
@@ -77,16 +77,17 @@ user_pref("geo.wifi.logging.enabled", tr
 
 user_pref("camino.warn_when_closing", false); // Camino-only, harmless to others
 
 // Make url-classifier updates so rare that they won't affect tests
 user_pref("urlclassifier.updateinterval", 172800);
 // Point the url-classifier to the local testing server for fast failures
 user_pref("browser.safebrowsing.gethashURL", "http://%(server)s/safebrowsing-dummy/gethash");
 user_pref("browser.safebrowsing.updateURL", "http://%(server)s/safebrowsing-dummy/update");
+user_pref("browser.safebrowsing.appRepURL", "http://%(server)s/safebrowsing-dummy/update");
 // Point update checks to the local testing server for fast failures
 user_pref("extensions.update.url", "http://%(server)s/extensions-dummy/updateURL");
 user_pref("extensions.update.background.url", "http://%(server)s/extensions-dummy/updateBackgroundURL");
 user_pref("extensions.blocklist.url", "http://%(server)s/extensions-dummy/blocklistURL");
 user_pref("extensions.hotfix.url", "http://%(server)s/extensions-dummy/hotfixURL");
 // Turn off extension updates so they don't bother tests
 user_pref("extensions.update.enabled", false);
 // Make sure opening about:addons won't hit the network
--- a/toolkit/components/downloads/ApplicationReputation.cpp
+++ b/toolkit/components/downloads/ApplicationReputation.cpp
@@ -356,18 +356,21 @@ PendingLookup::~PendingLookup()
 }
 
 bool
 PendingLookup::IsBinaryFile()
 {
   nsString fileName;
   nsresult rv = mQuery->GetSuggestedFileName(fileName);
   if (NS_FAILED(rv)) {
+    LOG(("No suggested filename [this = %p]", this));
     return false;
   }
+  LOG(("Suggested filename: %s [this = %p]",
+       NS_ConvertUTF16toUTF8(fileName).get(), this));
   return
     // Executable extensions for MS Windows, from
     // https://code.google.com/p/chromium/codesearch#chromium/src/chrome/common/safe_browsing/download_protection_util.cc&l=14
     StringEndsWith(fileName, NS_LITERAL_STRING(".apk")) ||
     StringEndsWith(fileName, NS_LITERAL_STRING(".bas")) ||
     StringEndsWith(fileName, NS_LITERAL_STRING(".bat")) ||
     StringEndsWith(fileName, NS_LITERAL_STRING(".cab")) ||
     StringEndsWith(fileName, NS_LITERAL_STRING(".cmd")) ||
--- a/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
+++ b/toolkit/components/jsdownloads/src/DownloadIntegration.jsm
@@ -512,21 +512,23 @@ this.DownloadIntegration = {
     if (!hash || !sigInfo) {
       return Promise.resolve(false);
     }
     let deferred = Promise.defer();
     let aReferrer = null;
     if (aDownload.source.referrer) {
       aReferrer: NetUtil.newURI(aDownload.source.referrer);
     }
+    let aSuggestedFileName = OS.Path.basename(aDownload.target.path);
     gApplicationReputationService.queryReputation({
       sourceURI: NetUtil.newURI(aDownload.source.url),
       referrerURI: aReferrer,
       fileSize: aDownload.currentBytes,
       sha256Hash: hash,
+      suggestedFileName: aSuggestedFileName,
       signatureInfo: sigInfo,
       redirects: channelRedirects },
       function onComplete(aShouldBlock, aRv) {
         deferred.resolve(aShouldBlock);
       });
     return deferred.promise;
   },