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

Side by Side Diff: chrome/browser/safe_browsing/ui_manager.cc

Issue 2505153002: Add support for scout to 'ext' param when creating SafeBrowsing ping URLs. (Closed)
Patch Set: Go back to IsExtendedReportingEnabled where level doesn't matter 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 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/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/leak_tracker.h" 10 #include "base/debug/leak_tracker.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 // with page_url. 302 // with page_url.
303 if (!resource.is_subresource && 303 if (!resource.is_subresource &&
304 !resource.original_url.is_empty() && 304 !resource.original_url.is_empty() &&
305 resource.original_url != resource.url) { 305 resource.original_url != resource.url) {
306 hit_report.referrer_url = hit_report.page_url; 306 hit_report.referrer_url = hit_report.page_url;
307 hit_report.page_url = resource.original_url; 307 hit_report.page_url = resource.original_url;
308 } 308 }
309 309
310 Profile* profile = 310 Profile* profile =
311 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 311 Profile::FromBrowserContext(web_contents->GetBrowserContext());
312 hit_report.is_extended_reporting = 312 hit_report.extended_reporting_level =
313 profile && IsExtendedReportingEnabled(*profile->GetPrefs()); 313 profile ? GetExtendedReportingLevel(*profile->GetPrefs())
314 : SBER_LEVEL_OFF;
314 hit_report.is_metrics_reporting_active = 315 hit_report.is_metrics_reporting_active =
315 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); 316 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled();
316 317
317 MaybeReportSafeBrowsingHit(hit_report); 318 MaybeReportSafeBrowsingHit(hit_report);
318 } 319 }
319 320
320 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { 321 if (resource.threat_type != SB_THREAT_TYPE_SAFE) {
321 for (Observer& observer : observer_list_) 322 for (Observer& observer : observer_list_)
322 observer.OnSafeBrowsingHit(resource); 323 observer.OnSafeBrowsingHit(resource);
323 } 324 }
324 AddToWhitelistUrlSet(GetMainFrameWhitelistUrlForResource(resource), 325 AddToWhitelistUrlSet(GetMainFrameWhitelistUrlForResource(resource),
325 resource.web_contents_getter.Run(), 326 resource.web_contents_getter.Run(),
326 true /* A decision is now pending */, 327 true /* A decision is now pending */,
327 resource.threat_type); 328 resource.threat_type);
328 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource); 329 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
329 } 330 }
330 331
331 // A safebrowsing hit is sent after a blocking page for malware/phishing 332 // A safebrowsing hit is sent after a blocking page for malware/phishing
332 // or after the warning dialog for download urls, only for 333 // or after the warning dialog for download urls, only for
333 // UMA || extended_reporting users. 334 // UMA || extended_reporting users.
334 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( 335 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit(
335 const HitReport& hit_report) { 336 const HitReport& hit_report) {
336 DCHECK_CURRENTLY_ON(BrowserThread::UI); 337 DCHECK_CURRENTLY_ON(BrowserThread::UI);
337 338
338 // Send report if user opted-in extended reporting. 339 // Send report if user opted-in extended reporting.
339 if (hit_report.is_extended_reporting) { 340 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF) {
340 BrowserThread::PostTask( 341 BrowserThread::PostTask(
341 BrowserThread::IO, FROM_HERE, 342 BrowserThread::IO, FROM_HERE,
342 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, 343 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread,
343 this, hit_report)); 344 this, hit_report));
344 } 345 }
345 } 346 }
346 347
347 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread( 348 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread(
348 const HitReport& hit_report) { 349 const HitReport& hit_report) {
349 DCHECK_CURRENTLY_ON(BrowserThread::IO); 350 DCHECK_CURRENTLY_ON(BrowserThread::IO);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 543 }
543 } 544 }
544 545
545 // Static. 546 // Static.
546 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( 547 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting(
547 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource) { 548 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource) {
548 return GetMainFrameWhitelistUrlForResource(resource); 549 return GetMainFrameWhitelistUrlForResource(resource);
549 } 550 }
550 551
551 } // namespace safe_browsing 552 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc ('k') | components/safe_browsing_db/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698