Chromium Code Reviews| 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/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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 const base::Closure& callback) { | 274 const base::Closure& callback) { |
| 275 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 275 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 276 BrowserThread::PostTaskAndReply( | 276 BrowserThread::PostTaskAndReply( |
| 277 BrowserThread::IO, FROM_HERE, | 277 BrowserThread::IO, FROM_HERE, |
| 278 base::Bind( | 278 base::Bind( |
| 279 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, | 279 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, |
| 280 serialized_report), | 280 serialized_report), |
| 281 callback); | 281 callback); |
| 282 } | 282 } |
| 283 | 283 |
| 284 void SafeBrowsingUIManager::ReportPermissionAction( | |
| 285 const GURL& origin, | |
| 286 content::PermissionType permission, | |
| 287 PermissionAction action) { | |
| 288 DCHECK_CURRENTLY_ON(BrowserThread::UI); | |
|
Nathan Parker
2016/06/16 21:08:41
nit: I'm not clear on why this _has_ to be on the
stefanocs
2016/06/17 00:42:08
I'm also not clear about this but the other two re
| |
| 289 BrowserThread::PostTask( | |
| 290 BrowserThread::IO, FROM_HERE, | |
| 291 base::Bind(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, this, | |
| 292 origin, permission, action)); | |
| 293 } | |
| 294 | |
| 284 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 295 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
| 285 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 296 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 286 observer_list_.AddObserver(observer); | 297 observer_list_.AddObserver(observer); |
| 287 } | 298 } |
| 288 | 299 |
| 289 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 300 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
| 290 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 301 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 291 observer_list_.RemoveObserver(observer); | 302 observer_list_.RemoveObserver(observer); |
| 292 } | 303 } |
| 293 | 304 |
| 294 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | 305 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( |
| 295 const std::string& serialized_report) { | 306 const std::string& serialized_report) { |
| 296 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 307 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 297 | 308 |
| 298 // The service may delete the ping manager (i.e. when user disabling service, | 309 // The service may delete the ping manager (i.e. when user disabling service, |
| 299 // etc). This happens on the IO thread. | 310 // etc). This happens on the IO thread. |
| 300 if (!sb_service_ || !sb_service_->ping_manager()) | 311 if (!sb_service_ || !sb_service_->ping_manager()) |
| 301 return; | 312 return; |
| 302 | 313 |
| 303 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); | 314 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); |
| 304 } | 315 } |
| 305 | 316 |
| 317 void SafeBrowsingUIManager::ReportPermissionActionOnIOThread( | |
| 318 const GURL& origin, | |
| 319 content::PermissionType permission, | |
| 320 PermissionAction action) { | |
| 321 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
| 322 | |
| 323 // The service may delete the ping manager (i.e. when user disabling service, | |
| 324 // etc). This happens on the IO thread. | |
| 325 if (!sb_service_ || !sb_service_->ping_manager()) | |
| 326 return; | |
| 327 | |
| 328 sb_service_->ping_manager()->ReportPermissionAction(origin, permission, | |
| 329 action); | |
| 330 } | |
| 331 | |
| 306 // If the user had opted-in to send ThreatDetails, this gets called | 332 // If the user had opted-in to send ThreatDetails, this gets called |
| 307 // when the report is ready. | 333 // when the report is ready. |
| 308 void SafeBrowsingUIManager::SendSerializedThreatDetails( | 334 void SafeBrowsingUIManager::SendSerializedThreatDetails( |
| 309 const std::string& serialized) { | 335 const std::string& serialized) { |
| 310 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 336 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 311 | 337 |
| 312 // The service may delete the ping manager (i.e. when user disabling service, | 338 // The service may delete the ping manager (i.e. when user disabling service, |
| 313 // etc). This happens on the IO thread. | 339 // etc). This happens on the IO thread. |
| 314 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) | 340 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) |
| 315 return; | 341 return; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 391 } |
| 366 | 392 |
| 367 WhitelistUrlSet* site_list = | 393 WhitelistUrlSet* site_list = |
| 368 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); | 394 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); |
| 369 if (!site_list) | 395 if (!site_list) |
| 370 return false; | 396 return false; |
| 371 return site_list->Contains(maybe_whitelisted_url); | 397 return site_list->Contains(maybe_whitelisted_url); |
| 372 } | 398 } |
| 373 | 399 |
| 374 } // namespace safe_browsing | 400 } // namespace safe_browsing |
| OLD | NEW |