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