| Index: chrome/browser/safe_browsing/download_protection_service.cc
|
| diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc
|
| index d8bb7267bf001ff228fb38e29a7352464fedc39d..450d5e9178466dd1b7ca54a88d99e80389f64f62 100644
|
| --- a/chrome/browser/safe_browsing/download_protection_service.cc
|
| +++ b/chrome/browser/safe_browsing/download_protection_service.cc
|
| @@ -73,23 +73,9 @@
|
| using content::BrowserThread;
|
|
|
| namespace {
|
| -
|
| -const int64_t kDownloadRequestTimeoutMs = 7000;
|
| +static const int64_t kDownloadRequestTimeoutMs = 7000;
|
| // We sample 1% of whitelisted downloads to still send out download pings.
|
| -const double kWhitelistDownloadSampleRate = 0.01;
|
| -
|
| -enum WhitelistType {
|
| - NO_WHITELIST_MATCH,
|
| - URL_WHITELIST,
|
| - SIGNATURE_WHITELIST,
|
| - WHITELIST_TYPE_MAX
|
| -};
|
| -
|
| -void RecordCountOfWhitelistedDownload(WhitelistType type) {
|
| - UMA_HISTOGRAM_ENUMERATION("SBClientDownload.CheckWhitelistResult", type,
|
| - WHITELIST_TYPE_MAX);
|
| -}
|
| -
|
| +static const double kWhitelistDownloadSampleRate = 0.01;
|
| } // namespace
|
|
|
| namespace safe_browsing {
|
| @@ -774,7 +760,20 @@
|
| }
|
| #endif // defined(OS_MACOSX)
|
|
|
| - bool ShouldSampleWhitelistedDownload() {
|
| + enum WhitelistType {
|
| + NO_WHITELIST_MATCH,
|
| + URL_WHITELIST,
|
| + SIGNATURE_WHITELIST,
|
| + WHITELIST_TYPE_MAX
|
| + };
|
| +
|
| + static void RecordCountOfWhitelistedDownload(WhitelistType type) {
|
| + UMA_HISTOGRAM_ENUMERATION("SBClientDownload.CheckWhitelistResult",
|
| + type,
|
| + WHITELIST_TYPE_MAX);
|
| + }
|
| +
|
| + virtual bool ShouldSampleWhitelistedDownload() {
|
| // We currently sample 1% whitelisted downloads from users who opted
|
| // in extended reporting and are not in incognito mode.
|
| return service_ && is_extended_reporting_ && !is_incognito_ &&
|
| @@ -1201,7 +1200,6 @@
|
| const GURL& requestor_url,
|
| const base::FilePath& default_file_path,
|
| const std::vector<base::FilePath::StringType>& alternate_extensions,
|
| - Profile* profile,
|
| const CheckDownloadCallback& callback,
|
| DownloadProtectionService* service,
|
| scoped_refptr<SafeBrowsingDatabaseManager> database_manager)
|
| @@ -1214,13 +1212,7 @@
|
| start_time_(base::TimeTicks::Now()),
|
| supported_path_(
|
| GetSupportedFilePath(default_file_path, alternate_extensions)),
|
| - sample_url_whitelist_(false),
|
| - weakptr_factory_(this) {
|
| - DCHECK(profile);
|
| - is_extended_reporting_ = profile->GetPrefs()->GetBoolean(
|
| - prefs::kSafeBrowsingExtendedReportingEnabled);
|
| - is_incognito_ = profile->IsOffTheRecord();
|
| - }
|
| + weakptr_factory_(this) {}
|
|
|
| ~PPAPIDownloadRequest() override {
|
| if (fetcher_ && !callback_.is_null())
|
| @@ -1270,13 +1262,6 @@
|
| }
|
|
|
| private:
|
| - bool ShouldSampleWhitelistedDownload() {
|
| - // We currently sample 1% whitelisted downloads from users who opted
|
| - // in extended reporting and are not in incognito mode.
|
| - return service_ && !is_incognito_ && is_extended_reporting_ &&
|
| - base::RandDouble() < service_->whitelist_sample_rate();
|
| - }
|
| -
|
| // Whitelist checking needs to the done on the IO thread.
|
| static void CheckWhitelistsOnIOThread(
|
| const GURL& requestor_url,
|
| @@ -1297,14 +1282,10 @@
|
| void WhitelistCheckComplete(bool was_on_whitelist) {
|
| DVLOG(2) << __FUNCTION__ << " was_on_whitelist:" << was_on_whitelist;
|
| if (was_on_whitelist) {
|
| - RecordCountOfWhitelistedDownload(URL_WHITELIST);
|
| - if (!ShouldSampleWhitelistedDownload()) {
|
| - Finish(RequestOutcome::WHITELIST_HIT, SAFE);
|
| - return;
|
| - }
|
| - sample_url_whitelist_ = true;
|
| - } else {
|
| - RecordCountOfWhitelistedDownload(NO_WHITELIST_MATCH);
|
| + // TODO(asanka): Should sample whitelisted downloads based on
|
| + // service_->whitelist_sample_rate(). http://crbug.com/610924
|
| + Finish(RequestOutcome::WHITELIST_HIT, SAFE);
|
| + return;
|
| }
|
|
|
| // Not on whitelist, so we are going to check with the SafeBrowsing
|
| @@ -1325,11 +1306,6 @@
|
| request.set_file_basename(supported_path_.BaseName().AsUTF8Unsafe());
|
| request.set_length(0);
|
| request.mutable_digests()->set_md5(std::string());
|
| - request.set_skipped_url_whitelist(sample_url_whitelist_);
|
| - // Download protection does not check certificate whitelist for
|
| - // base::RunLoop()
|
| - // downloads.
|
| - request.set_skipped_certificate_whitelist(false);
|
| for (const auto& alternate_extension : alternate_extensions_) {
|
| if (alternate_extension.empty())
|
| continue;
|
| @@ -1392,13 +1368,12 @@
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| DVLOG(2) << __FUNCTION__ << " response: " << response;
|
| UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| - "SBClientDownload.base::RunLoop()DownloadRequest.RequestOutcome",
|
| + "SBClientDownload.PPAPIDownloadRequest.RequestOutcome",
|
| static_cast<int>(reason));
|
| - UMA_HISTOGRAM_SPARSE_SLOWLY(
|
| - "SBClientDownload.base::RunLoop()DownloadRequest.Result", response);
|
| - UMA_HISTOGRAM_TIMES(
|
| - "SBClientDownload.base::RunLoop()DownloadRequest.RequestDuration",
|
| - start_time_ - base::TimeTicks::Now());
|
| + UMA_HISTOGRAM_SPARSE_SLOWLY("SBClientDownload.PPAPIDownloadRequest.Result",
|
| + response);
|
| + UMA_HISTOGRAM_TIMES("SBClientDownload.PPAPIDownloadRequest.RequestDuration",
|
| + start_time_ - base::TimeTicks::Now());
|
| if (!callback_.is_null())
|
| base::ResetAndReturn(&callback_).Run(response);
|
| fetcher_.reset();
|
| @@ -1483,12 +1458,6 @@
|
| // ping.
|
| const base::FilePath supported_path_;
|
|
|
| - bool sample_url_whitelist_;
|
| -
|
| - bool is_extended_reporting_;
|
| -
|
| - bool is_incognito_;
|
| -
|
| base::WeakPtrFactory<PPAPIDownloadRequest> weakptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(PPAPIDownloadRequest);
|
| @@ -1594,13 +1563,12 @@
|
| const GURL& requestor_url,
|
| const base::FilePath& default_file_path,
|
| const std::vector<base::FilePath::StringType>& alternate_extensions,
|
| - Profile* profile,
|
| const CheckDownloadCallback& callback) {
|
| DVLOG(1) << __FUNCTION__ << " url:" << requestor_url
|
| << " default_file_path:" << default_file_path.value();
|
| std::unique_ptr<PPAPIDownloadRequest> request(new PPAPIDownloadRequest(
|
| - requestor_url, default_file_path, alternate_extensions, profile, callback,
|
| - this, database_manager_));
|
| + requestor_url, default_file_path, alternate_extensions, callback, this,
|
| + database_manager_));
|
| PPAPIDownloadRequest* request_copy = request.get();
|
| auto insertion_result = ppapi_download_requests_.insert(
|
| std::make_pair(request_copy, std::move(request)));
|
|
|