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