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/local_database_manager.h" | 5 #include "chrome/browser/safe_browsing/local_database_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const scoped_refptr<SafeBrowsingService>& service) | 261 const scoped_refptr<SafeBrowsingService>& service) |
262 : sb_service_(service), | 262 : sb_service_(service), |
263 database_(NULL), | 263 database_(NULL), |
264 enabled_(false), | 264 enabled_(false), |
265 enable_download_protection_(false), | 265 enable_download_protection_(false), |
266 enable_csd_whitelist_(false), | 266 enable_csd_whitelist_(false), |
267 enable_download_whitelist_(false), | 267 enable_download_whitelist_(false), |
268 enable_extension_blacklist_(false), | 268 enable_extension_blacklist_(false), |
269 enable_ip_blacklist_(false), | 269 enable_ip_blacklist_(false), |
270 enable_unwanted_software_blacklist_(true), | 270 enable_unwanted_software_blacklist_(true), |
| 271 enable_module_whitelist_(true), |
271 update_in_progress_(false), | 272 update_in_progress_(false), |
272 database_update_in_progress_(false), | 273 database_update_in_progress_(false), |
273 closing_database_(false), | 274 closing_database_(false), |
274 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { | 275 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { |
275 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 276 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
276 DCHECK(sb_service_.get() != NULL); | 277 DCHECK(sb_service_.get() != NULL); |
277 | 278 |
278 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 279 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
279 enable_download_protection_ = | 280 enable_download_protection_ = |
280 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 281 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); | 774 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); |
774 | 775 |
775 if (database_) | 776 if (database_) |
776 return database_; | 777 return database_; |
777 | 778 |
778 const base::TimeTicks before = base::TimeTicks::Now(); | 779 const base::TimeTicks before = base::TimeTicks::Now(); |
779 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create( | 780 SafeBrowsingDatabase* database = SafeBrowsingDatabase::Create( |
780 safe_browsing_task_runner_, enable_download_protection_, | 781 safe_browsing_task_runner_, enable_download_protection_, |
781 enable_csd_whitelist_, enable_download_whitelist_, | 782 enable_csd_whitelist_, enable_download_whitelist_, |
782 enable_extension_blacklist_, enable_ip_blacklist_, | 783 enable_extension_blacklist_, enable_ip_blacklist_, |
783 enable_unwanted_software_blacklist_); | 784 enable_unwanted_software_blacklist_, enable_module_whitelist_); |
784 | 785 |
785 database->Init(SafeBrowsingService::GetBaseFilename()); | 786 database->Init(SafeBrowsingService::GetBaseFilename()); |
786 { | 787 { |
787 // Acquiring the lock here guarantees correct ordering between the writes to | 788 // Acquiring the lock here guarantees correct ordering between the writes to |
788 // the new database object above, and the setting of |database_| below. | 789 // the new database object above, and the setting of |database_| below. |
789 base::AutoLock lock(database_lock_); | 790 base::AutoLock lock(database_lock_); |
790 database_ = database; | 791 database_ = database; |
791 } | 792 } |
792 | 793 |
793 BrowserThread::PostTask( | 794 BrowserThread::PostTask( |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, | 1194 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, |
1194 check->weak_ptr_factory_->GetWeakPtr(), check), | 1195 check->weak_ptr_factory_->GetWeakPtr(), check), |
1195 check_timeout_); | 1196 check_timeout_); |
1196 } | 1197 } |
1197 | 1198 |
1198 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { | 1199 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { |
1199 return enable_download_protection_; | 1200 return enable_download_protection_; |
1200 } | 1201 } |
1201 | 1202 |
1202 } // namespace safe_browsing | 1203 } // namespace safe_browsing |
OLD | NEW |