| OLD | NEW |
| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 | 106 // static |
| 107 bool SafeBrowsingUIManager::ShouldSendHitReport(const HitReport& hit_report, | 107 bool SafeBrowsingUIManager::ShouldSendHitReport( |
| 108 WebContents* web_contents) { | 108 const HitReport& hit_report, |
| 109 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF && | 109 const WebContents* web_contents) { |
| 110 !web_contents->GetBrowserContext()->IsOffTheRecord()) { | 110 return hit_report.extended_reporting_level != SBER_LEVEL_OFF && |
| 111 return true; | 111 !web_contents->GetBrowserContext()->IsOffTheRecord(); |
| 112 } | |
| 113 return false; | |
| 114 } | 112 } |
| 115 | 113 |
| 116 // A safebrowsing hit is sent after a blocking page for malware/phishing | 114 // A SafeBrowsing hit is sent after a blocking page for malware/phishing |
| 117 // or after the warning dialog for download urls, only for | 115 // or after the warning dialog for download urls, only for |
| 118 // extended-reporting users. | 116 // extended-reporting users. |
| 119 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( | 117 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( |
| 120 const HitReport& hit_report, | 118 const HitReport& hit_report, |
| 121 WebContents* web_contents) { | 119 const WebContents* web_contents) { |
| 122 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 120 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 123 | 121 |
| 124 // Send report if user opted-in to extended reporting and is not in | 122 // Send report if user opted-in to extended reporting and is not in |
| 125 // incognito mode. | 123 // incognito mode. |
| 126 if (ShouldSendHitReport(hit_report, web_contents)) { | 124 if (ShouldSendHitReport(hit_report, web_contents)) { |
| 127 BrowserThread::PostTask( | 125 BrowserThread::PostTask( |
| 128 BrowserThread::IO, FROM_HERE, | 126 BrowserThread::IO, FROM_HERE, |
| 129 base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, | 127 base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, |
| 130 this, hit_report)); | 128 this, hit_report)); |
| 131 } | 129 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 216 } |
| 219 } | 217 } |
| 220 | 218 |
| 221 // Static. | 219 // Static. |
| 222 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( | 220 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( |
| 223 const security_interstitials::UnsafeResource& resource) { | 221 const security_interstitials::UnsafeResource& resource) { |
| 224 return GetMainFrameWhitelistUrlForResource(resource); | 222 return GetMainFrameWhitelistUrlForResource(resource); |
| 225 } | 223 } |
| 226 | 224 |
| 227 } // namespace safe_browsing | 225 } // namespace safe_browsing |
| OLD | NEW |