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 |
283 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 294 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
284 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 295 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
285 observer_list_.AddObserver(observer); | 296 observer_list_.AddObserver(observer); |
286 } | 297 } |
287 | 298 |
288 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 299 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
289 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
290 observer_list_.RemoveObserver(observer); | 301 observer_list_.RemoveObserver(observer); |
291 } | 302 } |
292 | 303 |
293 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | 304 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( |
294 const std::string& serialized_report) { | 305 const std::string& serialized_report) { |
295 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 306 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
296 | 307 |
297 // The service may delete the ping manager (i.e. when user disabling service, | 308 // The service may delete the ping manager (i.e. when user disabling service, |
298 // etc). This happens on the IO thread. | 309 // etc). This happens on the IO thread. |
299 if (!sb_service_ || !sb_service_->ping_manager()) | 310 if (!sb_service_ || !sb_service_->ping_manager()) |
300 return; | 311 return; |
301 | 312 |
302 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); | 313 sb_service_->ping_manager()->ReportInvalidCertificateChain(serialized_report); |
303 } | 314 } |
304 | 315 |
| 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 |
305 // 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 |
306 // when the report is ready. | 332 // when the report is ready. |
307 void SafeBrowsingUIManager::SendSerializedThreatDetails( | 333 void SafeBrowsingUIManager::SendSerializedThreatDetails( |
308 const std::string& serialized) { | 334 const std::string& serialized) { |
309 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 335 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
310 | 336 |
311 // 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, |
312 // etc). This happens on the IO thread. | 338 // etc). This happens on the IO thread. |
313 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) | 339 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) |
314 return; | 340 return; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 } | 390 } |
365 | 391 |
366 WhitelistUrlSet* site_list = | 392 WhitelistUrlSet* site_list = |
367 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); | 393 static_cast<WhitelistUrlSet*>(web_contents->GetUserData(kWhitelistKey)); |
368 if (!site_list) | 394 if (!site_list) |
369 return false; | 395 return false; |
370 return site_list->Contains(maybe_whitelisted_url); | 396 return site_list->Contains(maybe_whitelisted_url); |
371 } | 397 } |
372 | 398 |
373 } // namespace safe_browsing | 399 } // namespace safe_browsing |
OLD | NEW |