| 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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 279 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 280 BrowserThread::PostTaskAndReply( | 280 BrowserThread::PostTaskAndReply( |
| 281 BrowserThread::IO, FROM_HERE, | 281 BrowserThread::IO, FROM_HERE, |
| 282 base::Bind( | 282 base::Bind( |
| 283 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, | 283 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, |
| 284 serialized_report), | 284 serialized_report), |
| 285 callback); | 285 callback); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void SafeBrowsingUIManager::ReportPermissionAction( | 288 void SafeBrowsingUIManager::ReportPermissionAction( |
| 289 const GURL& origin, | 289 const PermissionReportInfo& report_info) { |
| 290 content::PermissionType permission, | |
| 291 PermissionAction action, | |
| 292 PermissionSourceUI source_ui, | |
| 293 PermissionRequestGestureType gesture_type, | |
| 294 int num_prior_dismissals, | |
| 295 int num_prior_ignores) { | |
| 296 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 290 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 297 BrowserThread::PostTask( | 291 BrowserThread::PostTask( |
| 298 BrowserThread::IO, FROM_HERE, | 292 BrowserThread::IO, FROM_HERE, |
| 299 base::Bind(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, this, | 293 base::Bind(&SafeBrowsingUIManager::ReportPermissionActionOnIOThread, this, |
| 300 origin, permission, action, source_ui, gesture_type, | 294 report_info)); |
| 301 num_prior_dismissals, num_prior_ignores)); | |
| 302 } | 295 } |
| 303 | 296 |
| 304 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 297 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
| 305 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 298 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 306 observer_list_.AddObserver(observer); | 299 observer_list_.AddObserver(observer); |
| 307 } | 300 } |
| 308 | 301 |
| 309 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 302 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
| 310 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 303 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 311 observer_list_.RemoveObserver(observer); | 304 observer_list_.RemoveObserver(observer); |
| 312 } | 305 } |
| 313 | 306 |
| 314 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | 307 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( |
| 315 const std::string& serialized_report) { | 308 const std::string& serialized_report) { |
| 316 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 309 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 317 | 310 |
| 318 // 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, |
| 319 // etc). This happens on the IO thread. | 312 // etc). This happens on the IO thread. |
| 320 if (!sb_service_ || !sb_service_->ping_manager()) | 313 if (!sb_service_ || !sb_service_->ping_manager()) |
| 321 return; | 314 return; |
| 322 | 315 |
| 323 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); | 316 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); |
| 324 } | 317 } |
| 325 | 318 |
| 326 void SafeBrowsingUIManager::ReportPermissionActionOnIOThread( | 319 void SafeBrowsingUIManager::ReportPermissionActionOnIOThread( |
| 327 const GURL& origin, | 320 const PermissionReportInfo& report_info) { |
| 328 content::PermissionType permission, | |
| 329 PermissionAction action, | |
| 330 PermissionSourceUI source_ui, | |
| 331 PermissionRequestGestureType gesture_type, | |
| 332 int num_prior_dismissals, | |
| 333 int num_prior_ignores) { | |
| 334 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 321 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 335 | 322 |
| 336 // The service may delete the ping manager (i.e. when user disabling service, | 323 // The service may delete the ping manager (i.e. when user disabling service, |
| 337 // etc). This happens on the IO thread. | 324 // etc). This happens on the IO thread. |
| 338 if (!sb_service_ || !sb_service_->ping_manager()) | 325 if (!sb_service_ || !sb_service_->ping_manager()) |
| 339 return; | 326 return; |
| 340 | 327 |
| 341 sb_service_->ping_manager()->ReportPermissionAction( | 328 sb_service_->ping_manager()->ReportPermissionAction(report_info); |
| 342 origin, permission, action, source_ui, gesture_type, num_prior_dismissals, | |
| 343 num_prior_ignores); | |
| 344 } | 329 } |
| 345 | 330 |
| 346 // If the user had opted-in to send ThreatDetails, this gets called | 331 // If the user had opted-in to send ThreatDetails, this gets called |
| 347 // when the report is ready. | 332 // when the report is ready. |
| 348 void SafeBrowsingUIManager::SendSerializedThreatDetails( | 333 void SafeBrowsingUIManager::SendSerializedThreatDetails( |
| 349 const std::string& serialized) { | 334 const std::string& serialized) { |
| 350 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 335 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 351 | 336 |
| 352 // The service may delete the ping manager (i.e. when user disabling service, | 337 // The service may delete the ping manager (i.e. when user disabling service, |
| 353 // etc). This happens on the IO thread. | 338 // etc). This happens on the IO thread. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 } | 387 } |
| 403 | 388 |
| 404 WhitelistUrlSet* site_list = static_cast<WhitelistUrlSet*>( | 389 WhitelistUrlSet* site_list = static_cast<WhitelistUrlSet*>( |
| 405 resource.web_contents_getter.Run()->GetUserData(kWhitelistKey)); | 390 resource.web_contents_getter.Run()->GetUserData(kWhitelistKey)); |
| 406 if (!site_list) | 391 if (!site_list) |
| 407 return false; | 392 return false; |
| 408 return site_list->Contains(maybe_whitelisted_url); | 393 return site_list->Contains(maybe_whitelisted_url); |
| 409 } | 394 } |
| 410 | 395 |
| 411 } // namespace safe_browsing | 396 } // namespace safe_browsing |
| OLD | NEW |