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