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/safe_browsing_service.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 prefs_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, | 332 prefs_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CREATED, |
333 content::NotificationService::AllSources()); | 333 content::NotificationService::AllSources()); |
334 prefs_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, | 334 prefs_registrar_.Add(this, chrome::NOTIFICATION_PROFILE_DESTROYED, |
335 content::NotificationService::AllSources()); | 335 content::NotificationService::AllSources()); |
336 | 336 |
337 // Register all the delayed analysis to the incident reporting service. | 337 // Register all the delayed analysis to the incident reporting service. |
338 RegisterAllDelayedAnalysis(); | 338 RegisterAllDelayedAnalysis(); |
339 } | 339 } |
340 | 340 |
341 void SafeBrowsingService::ShutDown() { | 341 void SafeBrowsingService::ShutDown() { |
| 342 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 343 shutdown_callback_list_.Notify(); |
| 344 |
342 // Delete the PrefChangeRegistrars, whose dtors also unregister |this| as an | 345 // Delete the PrefChangeRegistrars, whose dtors also unregister |this| as an |
343 // observer of the preferences. | 346 // observer of the preferences. |
344 prefs_map_.clear(); | 347 prefs_map_.clear(); |
345 | 348 |
346 // Remove Profile creation/destruction observers. | 349 // Remove Profile creation/destruction observers. |
347 prefs_registrar_.RemoveAll(); | 350 prefs_registrar_.RemoveAll(); |
348 | 351 |
349 Stop(true); | 352 Stop(true); |
350 | 353 |
351 services_delegate_->ShutdownServices(); | 354 services_delegate_->ShutdownServices(); |
(...skipping 19 matching lines...) Expand all Loading... |
371 | 374 |
372 #if defined(FULL_SAFE_BROWSING) | 375 #if defined(FULL_SAFE_BROWSING) |
373 return database_manager()->IsDownloadProtectionEnabled() || | 376 return database_manager()->IsDownloadProtectionEnabled() || |
374 (download_protection_service() && | 377 (download_protection_service() && |
375 download_protection_service()->enabled()); | 378 download_protection_service()->enabled()); |
376 #else | 379 #else |
377 return false; | 380 return false; |
378 #endif | 381 #endif |
379 } | 382 } |
380 | 383 |
381 net::URLRequestContextGetter* SafeBrowsingService::url_request_context() { | 384 scoped_refptr<net::URLRequestContextGetter> |
| 385 SafeBrowsingService::url_request_context() { |
382 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 386 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
383 return url_request_context_getter_.get(); | 387 return url_request_context_getter_; |
384 } | 388 } |
385 | 389 |
386 const scoped_refptr<SafeBrowsingUIManager>& | 390 const scoped_refptr<SafeBrowsingUIManager>& |
387 SafeBrowsingService::ui_manager() const { | 391 SafeBrowsingService::ui_manager() const { |
388 return ui_manager_; | 392 return ui_manager_; |
389 } | 393 } |
390 | 394 |
391 const scoped_refptr<SafeBrowsingDatabaseManager>& | 395 const scoped_refptr<SafeBrowsingDatabaseManager>& |
392 SafeBrowsingService::database_manager() const { | 396 SafeBrowsingService::database_manager() const { |
393 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; | 397 return enabled_v4_only_ ? v4_local_database_manager() : database_manager_; |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 676 } |
673 } | 677 } |
674 | 678 |
675 std::unique_ptr<SafeBrowsingService::StateSubscription> | 679 std::unique_ptr<SafeBrowsingService::StateSubscription> |
676 SafeBrowsingService::RegisterStateCallback( | 680 SafeBrowsingService::RegisterStateCallback( |
677 const base::Callback<void(void)>& callback) { | 681 const base::Callback<void(void)>& callback) { |
678 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 682 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
679 return state_callback_list_.Add(callback); | 683 return state_callback_list_.Add(callback); |
680 } | 684 } |
681 | 685 |
| 686 std::unique_ptr<SafeBrowsingService::ShutdownSubscription> |
| 687 SafeBrowsingService::RegisterShutdownCallback( |
| 688 const base::Callback<void(void)>& callback) { |
| 689 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 690 return shutdown_callback_list_.Add(callback); |
| 691 } |
| 692 |
682 void SafeBrowsingService::RefreshState() { | 693 void SafeBrowsingService::RefreshState() { |
683 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 694 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
684 // Check if any profile requires the service to be active. | 695 // Check if any profile requires the service to be active. |
685 bool enable = false; | 696 bool enable = false; |
686 for (const auto& pref : prefs_map_) { | 697 for (const auto& pref : prefs_map_) { |
687 if (pref.first->GetBoolean(prefs::kSafeBrowsingEnabled)) { | 698 if (pref.first->GetBoolean(prefs::kSafeBrowsingEnabled)) { |
688 enable = true; | 699 enable = true; |
689 break; | 700 break; |
690 } | 701 } |
691 } | 702 } |
(...skipping 26 matching lines...) Expand all Loading... |
718 ping_manager()->ReportThreatDetails(report); | 729 ping_manager()->ReportThreatDetails(report); |
719 } | 730 } |
720 | 731 |
721 void SafeBrowsingService::ProcessResourceRequest( | 732 void SafeBrowsingService::ProcessResourceRequest( |
722 const ResourceRequestInfo& request) { | 733 const ResourceRequestInfo& request) { |
723 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 734 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
724 services_delegate_->ProcessResourceRequest(&request); | 735 services_delegate_->ProcessResourceRequest(&request); |
725 } | 736 } |
726 | 737 |
727 } // namespace safe_browsing | 738 } // namespace safe_browsing |
OLD | NEW |