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