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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // or after the warning dialog for download urls, only for | 107 // or after the warning dialog for download urls, only for |
108 // extended-reporting users. | 108 // extended-reporting users. |
109 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( | 109 void SafeBrowsingUIManager::MaybeReportSafeBrowsingHit( |
110 const HitReport& hit_report) { | 110 const HitReport& hit_report) { |
111 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 111 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
112 | 112 |
113 // Send report if user opted-in extended reporting. | 113 // Send report if user opted-in extended reporting. |
114 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF) { | 114 if (hit_report.extended_reporting_level != SBER_LEVEL_OFF) { |
115 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
116 BrowserThread::IO, FROM_HERE, | 116 BrowserThread::IO, FROM_HERE, |
117 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, | 117 base::BindOnce(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, |
118 this, hit_report)); | 118 this, hit_report)); |
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread( | 122 void SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread( |
123 const HitReport& hit_report) { | 123 const HitReport& hit_report) { |
124 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 124 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
125 | 125 |
126 // The service may delete the ping manager (i.e. when user disabling service, | 126 // The service may delete the ping manager (i.e. when user disabling service, |
127 // etc). This happens on the IO thread. | 127 // etc). This happens on the IO thread. |
128 if (!sb_service_ || !sb_service_->ping_manager()) | 128 if (!sb_service_ || !sb_service_->ping_manager()) |
129 return; | 129 return; |
130 | 130 |
131 DVLOG(1) << "ReportSafeBrowsingHit: " << hit_report.malicious_url << " " | 131 DVLOG(1) << "ReportSafeBrowsingHit: " << hit_report.malicious_url << " " |
132 << hit_report.page_url << " " << hit_report.referrer_url << " " | 132 << hit_report.page_url << " " << hit_report.referrer_url << " " |
133 << hit_report.is_subresource << " " << hit_report.threat_type; | 133 << hit_report.is_subresource << " " << hit_report.threat_type; |
134 sb_service_->ping_manager()->ReportSafeBrowsingHit(hit_report); | 134 sb_service_->ping_manager()->ReportSafeBrowsingHit(hit_report); |
135 } | 135 } |
136 | 136 |
137 void SafeBrowsingUIManager::ReportPermissionAction( | 137 void SafeBrowsingUIManager::ReportPermissionAction( |
138 const PermissionReportInfo& report_info) { | 138 const PermissionReportInfo& report_info) { |
139 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 139 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
140 BrowserThread::PostTask( | 140 BrowserThread::PostTask( |
141 BrowserThread::IO, FROM_HERE, | 141 BrowserThread::IO, FROM_HERE, |
142 base::Bind(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, this, | 142 base::BindOnce(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, |
143 report_info)); | 143 this, report_info)); |
144 } | 144 } |
145 | 145 |
146 // Static. | 146 // Static. |
147 void SafeBrowsingUIManager::CreateWhitelistForTesting( | 147 void SafeBrowsingUIManager::CreateWhitelistForTesting( |
148 content::WebContents* web_contents) { | 148 content::WebContents* web_contents) { |
149 EnsureWhitelistCreated(web_contents); | 149 EnsureWhitelistCreated(web_contents); |
150 } | 150 } |
151 | 151 |
152 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 152 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
153 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 153 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 } | 207 } |
208 | 208 |
209 // Static. | 209 // Static. |
210 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( | 210 GURL SafeBrowsingUIManager::GetMainFrameWhitelistUrlForResourceForTesting( |
211 const security_interstitials::UnsafeResource& resource) { | 211 const security_interstitials::UnsafeResource& resource) { |
212 return GetMainFrameWhitelistUrlForResource(resource); | 212 return GetMainFrameWhitelistUrlForResource(resource); |
213 } | 213 } |
214 | 214 |
215 } // namespace safe_browsing | 215 } // namespace safe_browsing |
OLD | NEW |