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