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