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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/safe_browsing/ui_manager.h" 5 #include "chrome/browser/safe_browsing/ui_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 } 85 }
86 86
87 Profile* profile = 87 Profile* profile =
88 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 88 Profile::FromBrowserContext(web_contents->GetBrowserContext());
89 hit_report.extended_reporting_level = 89 hit_report.extended_reporting_level =
90 profile ? GetExtendedReportingLevel(*profile->GetPrefs()) 90 profile ? GetExtendedReportingLevel(*profile->GetPrefs())
91 : SBER_LEVEL_OFF; 91 : SBER_LEVEL_OFF;
92 hit_report.is_metrics_reporting_active = 92 hit_report.is_metrics_reporting_active =
93 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); 93 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
94 94
95 MaybeReportSafeBrowsingHit(hit_report); 95 MaybeReportSafeBrowsingHit(hit_report, web_contents);
96 96
97 for (Observer& observer : observer_list_) 97 for (Observer& observer : observer_list_)
98 observer.OnSafeBrowsingHit(resource); 98 observer.OnSafeBrowsingHit(resource);
99 } 99 }
100 100
101 void SafeBrowsingUIManager::ShowBlockingPageForResource( 101 void SafeBrowsingUIManager::ShowBlockingPageForResource(
102 const UnsafeResource& resource) { 102 const UnsafeResource& resource) {
103 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); 103 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
104 } 104 }
105 105
106 // Static
vakh (use Gerrit instead) 2017/05/19 22:41:13 nit: static
mortonm 2017/05/22 17:03:59 Done.
107 bool SafeBrowsingUIManager::ShouldSendHitReport(const HitReport& hit_report,
108 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.
109 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF &&
110 !web_contents->GetBrowserContext()->IsOffTheRecord()) {
111 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.
112 }
113 return false;
114 }
115
106 // A safebrowsing hit is sent after a blocking page for malware/phishing 116 // A safebrowsing hit is sent after a blocking page for malware/phishing
107 // or after the warning dialog for download urls, only for 117 // or after the warning dialog for download urls, only for
108 // extended-reporting users. 118 // extended-reporting users.
109 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( 119 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit(
110 const HitReport& hit_report) { 120 const HitReport& hit_report,
121 WebContents* web_contents) {
111 DCHECK_CURRENTLY_ON(BrowserThread::UI); 122 DCHECK_CURRENTLY_ON(BrowserThread::UI);
112 123
113 // Send report if user opted-in extended reporting. 124 // Send report if user opted-in to extended reporting and is not in
114 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF) { 125 // incognito mode.
126 if (ShouldSendHitReport(hit_report, web_contents)) {
115 BrowserThread::PostTask( 127 BrowserThread::PostTask(
116 BrowserThread::IO, FROM_HERE, 128 BrowserThread::IO, FROM_HERE,
117 base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, 129 base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread,
118 this, hit_report)); 130 this, hit_report));
119 } 131 }
120 } 132 }
121 133
122 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread( 134 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread(
123 const HitReport& hit_report) { 135 const HitReport& hit_report) {
124 DCHECK_CURRENTLY_ON(BrowserThread::IO); 136 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 } 218 }
207 } 219 }
208 220
209 // Static. 221 // Static.
210 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( 222 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting(
211 const security_interstitials::UnsafeResource& resource) { 223 const security_interstitials::UnsafeResource& resource) {
212 return GetMainFrameWhitelistUrlForResource(resource); 224 return GetMainFrameWhitelistUrlForResource(resource);
213 } 225 }
214 226
215 } // namespace safe_browsing 227 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698