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

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

Issue 2886043002: Refrain from sending hit report when user is in incognito mode (Closed)
Patch Set: fixed comment typo Created 3 years, 7 months 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/ui_manager.cc
diff --git a/chrome/browser/safe_browsing/ui_manager.cc b/chrome/browser/safe_browsing/ui_manager.cc
index 6cde6d902f461593fe2df6835c86316d9c058b11..4c64c11ebb66378bb5a0289c3f5df387e000f01a 100644
--- a/chrome/browser/safe_browsing/ui_manager.cc
+++ b/chrome/browser/safe_browsing/ui_manager.cc
@@ -92,7 +92,7 @@ void SafeBrowsingUIManager::CreateAndSendHitReport(
hit_report.is_metrics_reporting_active =
ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
- MaybeReportSafeBrowsingHit(hit_report);
+ MaybeReportSafeBrowsingHit(hit_report, web_contents);
for (Observer& observer : observer_list_)
observer.OnSafeBrowsingHit(resource);
@@ -103,15 +103,27 @@ void SafeBrowsingUIManager::ShowBlockingPageForResource(
SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
}
+// Static
vakh (use Gerrit instead) 2017/05/19 22:41:13 nit: static
mortonm 2017/05/22 17:03:59 Done.
+bool SafeBrowsingUIManager::ShouldSendHitReport(const HitReport& hit_report,
+ WebContents* web_contents) {
vakh (use Gerrit instead) 2017/05/19 22:41:13 could web_contents also be const?
mortonm 2017/05/22 17:03:59 Done.
+ if (hit_report.extended_reporting_level != SBER_LEVEL_OFF &&
+ !web_contents->GetBrowserContext()->IsOffTheRecord()) {
+ return true;
vakh (use Gerrit instead) 2017/05/19 22:41:13 simpler re-write: return hit_report.extended_repor
mortonm 2017/05/19 22:52:42 Sounds good. I'm gonna put all these changes in a
mortonm 2017/05/22 17:03:59 Done.
+ }
+ return false;
+}
+
// A safebrowsing hit is sent after a blocking page for malware/phishing
// or after the warning dialog for download urls, only for
// extended-reporting users.
void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit(
- const HitReport& hit_report) {
+ const HitReport& hit_report,
+ WebContents* web_contents) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
- // Send report if user opted-in extended reporting.
- if (hit_report.extended_reporting_level != SBER_LEVEL_OFF) {
+ // Send report if user opted-in to extended reporting and is not in
+ // incognito mode.
+ if (ShouldSendHitReport(hit_report, web_contents)) {
BrowserThread::PostTask(
BrowserThread::IO, FROM_HERE,
base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread,

Powered by Google App Engine
This is Rietveld 408576698