Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4499)

Unified Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 2505153002: Add support for scout to 'ext' param when creating SafeBrowsing ping URLs. (Closed)
Patch Set: Add missing dep Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6908dd8c2b5d52d2469b535a35abfe2e8d8ef8f7..e457767749f5b09f21c048901a6a36dcd853299b 100644
--- a/chrome/browser/safe_browsing/download_protection_service.cc
+++ b/chrome/browser/safe_browsing/download_protection_service.cc
@@ -177,8 +177,9 @@ class DownloadSBClient
total_type_(total_type),
dangerous_type_(dangerous_type) {
Profile* profile = Profile::FromBrowserContext(item.GetBrowserContext());
- is_extended_reporting_ =
- profile && IsExtendedReportingEnabled(*profile->GetPrefs());
+ extended_reporting_level_ =
+ profile ? GetExtendedReportingLevel(*profile->GetPrefs())
+ : SBER_LEVEL_OFF;
}
virtual void StartCheck() = 0;
@@ -226,7 +227,7 @@ class DownloadSBClient
hit_report.threat_source = safe_browsing::ThreatSource::LOCAL_PVER3;
// TODO(nparker) Populate hit_report.population_id once Pver4 is used here.
hit_report.post_data = post_data;
- hit_report.is_extended_reporting = is_extended_reporting_;
+ hit_report.extended_reporting_level = extended_reporting_level_;
hit_report.is_metrics_reporting_active =
ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
@@ -249,7 +250,7 @@ class DownloadSBClient
private:
const SBStatsType total_type_;
const SBStatsType dangerous_type_;
- bool is_extended_reporting_;
+ ExtendedReportingLevel extended_reporting_level_;
DISALLOW_COPY_AND_ASSIGN(DownloadSBClient);
};
@@ -327,7 +328,7 @@ class DownloadProtectionService::CheckClientDownloadRequest
start_time_(base::TimeTicks::Now()),
skipped_url_whitelist_(false),
skipped_certificate_whitelist_(false),
- is_extended_reporting_(false),
+ extended_reporting_level_(SBER_LEVEL_OFF),
is_incognito_(false),
weakptr_factory_(this) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -340,7 +341,8 @@ class DownloadProtectionService::CheckClientDownloadRequest
// we'll send a "light ping" with private info removed, and we won't
// use the verdict.
const FileTypePolicies* policies = FileTypePolicies::GetInstance();
- return service_ && is_extended_reporting_ && !is_incognito_ &&
+ return service_ && extended_reporting_level_ != SBER_LEVEL_OFF &&
+ !is_incognito_ &&
base::RandDouble() < policies->SampledPingProbability() &&
policies->PingSettingForFile(filename) ==
DownloadFileType::SAMPLED_PING;
@@ -353,8 +355,9 @@ class DownloadProtectionService::CheckClientDownloadRequest
if (item_->GetBrowserContext()) {
Profile* profile =
Profile::FromBrowserContext(item_->GetBrowserContext());
- is_extended_reporting_ =
- profile && IsExtendedReportingEnabled(*profile->GetPrefs());
+ extended_reporting_level_ =
+ profile ? GetExtendedReportingLevel(*profile->GetPrefs())
+ : SBER_LEVEL_OFF;
is_incognito_ = item_->GetBrowserContext()->IsOffTheRecord();
}
@@ -800,8 +803,9 @@ class DownloadProtectionService::CheckClientDownloadRequest
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_ &&
- base::RandDouble() < service_->whitelist_sample_rate();
+ return service_ && extended_reporting_level_ != SBER_LEVEL_OFF &&
+ !is_incognito_ &&
+ base::RandDouble() < service_->whitelist_sample_rate();
}
void CheckWhitelists() {
@@ -944,9 +948,9 @@ class DownloadProtectionService::CheckClientDownloadRequest
return;
ClientDownloadRequest request;
- auto population = is_extended_reporting_
- ? ChromeUserPopulation::EXTENDED_REPORTING
- : ChromeUserPopulation::SAFE_BROWSING;
+ auto population = extended_reporting_level_ != SBER_LEVEL_OFF
Jialiu Lin 2016/11/17 18:47:23 You might want to add ChromeUserPopulation::SCOUT_
lpz 2016/11/17 19:46:05 Agreed, back to a bool. I think adding another pop
+ ? ChromeUserPopulation::EXTENDED_REPORTING
+ : ChromeUserPopulation::SAFE_BROWSING;
request.mutable_population()->set_user_population(population);
request.set_url(SanitizeUrl(item_->GetUrlChain().back()));
@@ -1181,7 +1185,7 @@ class DownloadProtectionService::CheckClientDownloadRequest
base::TimeTicks request_start_time_;
bool skipped_url_whitelist_;
bool skipped_certificate_whitelist_;
- bool is_extended_reporting_;
+ ExtendedReportingLevel extended_reporting_level_;
bool is_incognito_;
base::WeakPtrFactory<CheckClientDownloadRequest> weakptr_factory_;
@@ -1237,7 +1241,7 @@ class DownloadProtectionService::PPAPIDownloadRequest
GetSupportedFilePath(default_file_path, alternate_extensions)),
weakptr_factory_(this) {
DCHECK(profile);
- is_extended_reporting_ = IsExtendedReportingEnabled(*profile->GetPrefs());
+ extended_reporting_level_ = GetExtendedReportingLevel(*profile->GetPrefs());
}
~PPAPIDownloadRequest() override {
@@ -1325,9 +1329,9 @@ class DownloadProtectionService::PPAPIDownloadRequest
DCHECK_CURRENTLY_ON(BrowserThread::UI);
ClientDownloadRequest request;
- auto population = is_extended_reporting_
- ? ChromeUserPopulation::EXTENDED_REPORTING
- : ChromeUserPopulation::SAFE_BROWSING;
+ auto population = extended_reporting_level_ != SBER_LEVEL_OFF
Jialiu Lin 2016/11/17 18:47:23 Similar to above.
lpz 2016/11/17 19:46:05 Done.
+ ? ChromeUserPopulation::EXTENDED_REPORTING
+ : ChromeUserPopulation::SAFE_BROWSING;
request.mutable_population()->set_user_population(population);
request.set_download_type(ClientDownloadRequest::PPAPI_SAVE_REQUEST);
ClientDownloadRequest::Resource* resource = request.add_resources();
@@ -1494,7 +1498,7 @@ class DownloadProtectionService::PPAPIDownloadRequest
// ping.
const base::FilePath supported_path_;
- bool is_extended_reporting_;
+ ExtendedReportingLevel extended_reporting_level_;
base::WeakPtrFactory<PPAPIDownloadRequest> weakptr_factory_;
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/local_database_manager.h » ('j') | chrome/browser/safe_browsing/protocol_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698