| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 enable_download_protection_(false), | 162 enable_download_protection_(false), |
| 163 enable_csd_whitelist_(false), | 163 enable_csd_whitelist_(false), |
| 164 update_in_progress_(false), | 164 update_in_progress_(false), |
| 165 database_update_in_progress_(false), | 165 database_update_in_progress_(false), |
| 166 closing_database_(false), | 166 closing_database_(false), |
| 167 download_urlcheck_timeout_ms_(kDownloadUrlCheckTimeoutMs), | 167 download_urlcheck_timeout_ms_(kDownloadUrlCheckTimeoutMs), |
| 168 download_hashcheck_timeout_ms_(kDownloadHashCheckTimeoutMs) { | 168 download_hashcheck_timeout_ms_(kDownloadHashCheckTimeoutMs) { |
| 169 #if !defined(OS_CHROMEOS) | 169 #if !defined(OS_CHROMEOS) |
| 170 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 170 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 171 switches::kDisableClientSidePhishingDetection) && | 171 switches::kDisableClientSidePhishingDetection) && |
| 172 CanReportStats()) { | 172 (CommandLine::ForCurrentProcess()->HasSwitch( |
| 173 switches::kEnableSanitizedClientSidePhishingDetection) || |
| 174 CanReportStats())) { |
| 173 csd_service_.reset( | 175 csd_service_.reset( |
| 174 safe_browsing::ClientSideDetectionService::Create( | 176 safe_browsing::ClientSideDetectionService::Create( |
| 175 g_browser_process->system_request_context())); | 177 g_browser_process->system_request_context())); |
| 176 } | 178 } |
| 177 #endif | 179 #endif |
| 178 } | 180 } |
| 179 | 181 |
| 180 SafeBrowsingService::~SafeBrowsingService() { | 182 SafeBrowsingService::~SafeBrowsingService() { |
| 181 // Deletes the PrefChangeRegistrars, whose dtors also unregister |this| as an | 183 // Deletes the PrefChangeRegistrars, whose dtors also unregister |this| as an |
| 182 // observer of the preferences. | 184 // observer of the preferences. |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 // enabled and if the user has opted in with stats collection. Note: we | 894 // enabled and if the user has opted in with stats collection. Note: we |
| 893 // cannot check whether the metrics_service() object is created because it | 895 // cannot check whether the metrics_service() object is created because it |
| 894 // may be initialized after this method is called. | 896 // may be initialized after this method is called. |
| 895 #ifdef OS_CHROMEOS | 897 #ifdef OS_CHROMEOS |
| 896 // Client-side detection is disabled on ChromeOS for now, so don't bother | 898 // Client-side detection is disabled on ChromeOS for now, so don't bother |
| 897 // downloading the whitelist. | 899 // downloading the whitelist. |
| 898 enable_csd_whitelist_ = false; | 900 enable_csd_whitelist_ = false; |
| 899 #else | 901 #else |
| 900 enable_csd_whitelist_ = | 902 enable_csd_whitelist_ = |
| 901 (!cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection) && | 903 (!cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection) && |
| 902 local_state && local_state->GetBoolean(prefs::kMetricsReportingEnabled)); | 904 (cmdline->HasSwitch( |
| 905 switches::kEnableSanitizedClientSidePhishingDetection) || |
| 906 (local_state && |
| 907 local_state->GetBoolean(prefs::kMetricsReportingEnabled)))); |
| 903 #endif | 908 #endif |
| 904 | 909 |
| 905 BrowserThread::PostTask( | 910 BrowserThread::PostTask( |
| 906 BrowserThread::IO, FROM_HERE, | 911 BrowserThread::IO, FROM_HERE, |
| 907 NewRunnableMethod( | 912 NewRunnableMethod( |
| 908 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, | 913 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, |
| 909 request_context_getter)); | 914 request_context_getter)); |
| 910 } | 915 } |
| 911 | 916 |
| 912 void SafeBrowsingService::Stop() { | 917 void SafeBrowsingService::Stop() { |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 } | 1342 } |
| 1338 | 1343 |
| 1339 if (enable) | 1344 if (enable) |
| 1340 Start(); | 1345 Start(); |
| 1341 else | 1346 else |
| 1342 Stop(); | 1347 Stop(); |
| 1343 | 1348 |
| 1344 if (csd_service_.get()) | 1349 if (csd_service_.get()) |
| 1345 csd_service_->SetEnabled(enable); | 1350 csd_service_->SetEnabled(enable); |
| 1346 } | 1351 } |
| OLD | NEW |