| 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 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/browser/safe_browsing/ui_manager.h" | 31 #include "chrome/browser/safe_browsing/ui_manager.h" |
| 32 #include "chrome/common/chrome_constants.h" | 32 #include "chrome/common/chrome_constants.h" |
| 33 #include "chrome/common/chrome_paths.h" | 33 #include "chrome/common/chrome_paths.h" |
| 34 #include "chrome/common/chrome_switches.h" | 34 #include "chrome/common/chrome_switches.h" |
| 35 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 36 #include "chrome/common/safe_browsing/file_type_policies.h" | 36 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 37 #include "chrome/common/url_constants.h" | 37 #include "chrome/common/url_constants.h" |
| 38 #include "components/prefs/pref_change_registrar.h" | 38 #include "components/prefs/pref_change_registrar.h" |
| 39 #include "components/prefs/pref_service.h" | 39 #include "components/prefs/pref_service.h" |
| 40 #include "components/safe_browsing_db/database_manager.h" | 40 #include "components/safe_browsing_db/database_manager.h" |
| 41 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 41 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 42 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
| 42 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h
" | 43 #include "components/user_prefs/tracked/tracked_preference_validation_delegate.h
" |
| 43 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
| 44 #include "content/public/browser/cookie_store_factory.h" | 45 #include "content/public/browser/cookie_store_factory.h" |
| 45 #include "content/public/browser/notification_service.h" | 46 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/resource_request_info.h" | 47 #include "content/public/browser/resource_request_info.h" |
| 47 #include "google_apis/google_api_keys.h" | 48 #include "google_apis/google_api_keys.h" |
| 48 #include "net/cookies/cookie_store.h" | 49 #include "net/cookies/cookie_store.h" |
| 49 #include "net/extras/sqlite/cookie_crypto_delegate.h" | 50 #include "net/extras/sqlite/cookie_crypto_delegate.h" |
| 50 #include "net/extras/sqlite/sqlite_channel_id_store.h" | 51 #include "net/extras/sqlite/sqlite_channel_id_store.h" |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 622 | 623 |
| 623 void SafeBrowsingService::AddPrefService(PrefService* pref_service) { | 624 void SafeBrowsingService::AddPrefService(PrefService* pref_service) { |
| 624 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end()); | 625 DCHECK(prefs_map_.find(pref_service) == prefs_map_.end()); |
| 625 PrefChangeRegistrar* registrar = new PrefChangeRegistrar(); | 626 PrefChangeRegistrar* registrar = new PrefChangeRegistrar(); |
| 626 registrar->Init(pref_service); | 627 registrar->Init(pref_service); |
| 627 registrar->Add(prefs::kSafeBrowsingEnabled, | 628 registrar->Add(prefs::kSafeBrowsingEnabled, |
| 628 base::Bind(&SafeBrowsingService::RefreshState, | 629 base::Bind(&SafeBrowsingService::RefreshState, |
| 629 base::Unretained(this))); | 630 base::Unretained(this))); |
| 630 // ClientSideDetectionService will need to be refresh the models | 631 // ClientSideDetectionService will need to be refresh the models |
| 631 // renderers have if extended-reporting changes. | 632 // renderers have if extended-reporting changes. |
| 632 registrar->Add(prefs::kSafeBrowsingExtendedReportingEnabled, | 633 registrar->Add( |
| 633 base::Bind(&SafeBrowsingService::RefreshState, | 634 GetExtendedReportingPrefName(), |
| 634 base::Unretained(this))); | 635 base::Bind(&SafeBrowsingService::RefreshState, base::Unretained(this))); |
| 635 prefs_map_[pref_service] = registrar; | 636 prefs_map_[pref_service] = registrar; |
| 636 RefreshState(); | 637 RefreshState(); |
| 637 | 638 |
| 638 // Record the current pref state. | 639 // Record the current pref state. |
| 639 UMA_HISTOGRAM_BOOLEAN("SafeBrowsing.Pref.General", | 640 UMA_HISTOGRAM_BOOLEAN("SafeBrowsing.Pref.General", |
| 640 pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); | 641 pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); |
| 641 UMA_HISTOGRAM_BOOLEAN( | 642 // Extended Reporting metrics are handled together elsewhere. |
| 642 "SafeBrowsing.Pref.Extended", | 643 RecordExtendedReportingMetrics(*pref_service); |
| 643 pref_service->GetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled)); | |
| 644 } | 644 } |
| 645 | 645 |
| 646 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) { | 646 void SafeBrowsingService::RemovePrefService(PrefService* pref_service) { |
| 647 if (prefs_map_.find(pref_service) != prefs_map_.end()) { | 647 if (prefs_map_.find(pref_service) != prefs_map_.end()) { |
| 648 delete prefs_map_[pref_service]; | 648 delete prefs_map_[pref_service]; |
| 649 prefs_map_.erase(pref_service); | 649 prefs_map_.erase(pref_service); |
| 650 RefreshState(); | 650 RefreshState(); |
| 651 } else { | 651 } else { |
| 652 NOTREACHED(); | 652 NOTREACHED(); |
| 653 } | 653 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 ping_manager()->ReportThreatDetails(report); | 700 ping_manager()->ReportThreatDetails(report); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void SafeBrowsingService::ProcessResourceRequest( | 703 void SafeBrowsingService::ProcessResourceRequest( |
| 704 const ResourceRequestInfo& request) { | 704 const ResourceRequestInfo& request) { |
| 705 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 705 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 706 services_delegate_->ProcessResourceRequest(&request); | 706 services_delegate_->ProcessResourceRequest(&request); |
| 707 } | 707 } |
| 708 | 708 |
| 709 } // namespace safe_browsing | 709 } // namespace safe_browsing |
| OLD | NEW |