| 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/database_manager.h" | 5 #include "chrome/browser/safe_browsing/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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 enable_download_whitelist_(false), | 206 enable_download_whitelist_(false), |
| 207 enable_extension_blacklist_(false), | 207 enable_extension_blacklist_(false), |
| 208 enable_side_effect_free_whitelist_(false), | 208 enable_side_effect_free_whitelist_(false), |
| 209 enable_ip_blacklist_(false), | 209 enable_ip_blacklist_(false), |
| 210 update_in_progress_(false), | 210 update_in_progress_(false), |
| 211 database_update_in_progress_(false), | 211 database_update_in_progress_(false), |
| 212 closing_database_(false), | 212 closing_database_(false), |
| 213 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { | 213 check_timeout_(base::TimeDelta::FromMilliseconds(kCheckTimeoutMs)) { |
| 214 DCHECK(sb_service_.get() != NULL); | 214 DCHECK(sb_service_.get() != NULL); |
| 215 | 215 |
| 216 // Android only supports a subset of FULL_SAFE_BROWSING. |
| 217 // TODO(shess): This shouldn't be OS-driven <http://crbug.com/394379> |
| 218 #if !defined(OS_ANDROID) |
| 216 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 219 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 217 enable_download_protection_ = | 220 enable_download_protection_ = |
| 218 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 221 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
| 219 | 222 |
| 220 // We only download the csd-whitelist if client-side phishing detection is | 223 // We only download the csd-whitelist if client-side phishing detection is |
| 221 // enabled. | 224 // enabled. |
| 222 enable_csd_whitelist_ = | 225 enable_csd_whitelist_ = |
| 223 !cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection); | 226 !cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection); |
| 224 | 227 |
| 225 // TODO(noelutz): remove this boolean variable since it should always be true | 228 // TODO(noelutz): remove this boolean variable since it should always be true |
| (...skipping 20 matching lines...) Expand all Loading... |
| 246 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX | 249 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX |
| 247 }; | 250 }; |
| 248 | 251 |
| 249 SideEffectFreeWhitelistStatus side_effect_free_whitelist_status = | 252 SideEffectFreeWhitelistStatus side_effect_free_whitelist_status = |
| 250 enable_side_effect_free_whitelist_ ? SIDE_EFFECT_FREE_WHITELIST_ENABLED : | 253 enable_side_effect_free_whitelist_ ? SIDE_EFFECT_FREE_WHITELIST_ENABLED : |
| 251 SIDE_EFFECT_FREE_WHITELIST_DISABLED; | 254 SIDE_EFFECT_FREE_WHITELIST_DISABLED; |
| 252 | 255 |
| 253 UMA_HISTOGRAM_ENUMERATION("SB2.SideEffectFreeWhitelistStatus", | 256 UMA_HISTOGRAM_ENUMERATION("SB2.SideEffectFreeWhitelistStatus", |
| 254 side_effect_free_whitelist_status, | 257 side_effect_free_whitelist_status, |
| 255 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); | 258 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); |
| 259 #endif |
| 256 } | 260 } |
| 257 | 261 |
| 258 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { | 262 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { |
| 259 // We should have already been shut down. If we're still enabled, then the | 263 // We should have already been shut down. If we're still enabled, then the |
| 260 // database isn't going to be closed properly, which could lead to corruption. | 264 // database isn't going to be closed properly, which could lead to corruption. |
| 261 DCHECK(!enabled_); | 265 DCHECK(!enabled_); |
| 262 } | 266 } |
| 263 | 267 |
| 264 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { | 268 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { |
| 265 return url.SchemeIs(url::kFtpScheme) || | 269 return url.SchemeIs(url::kFtpScheme) || |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); | 1060 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); |
| 1057 checks_.insert(check); | 1061 checks_.insert(check); |
| 1058 | 1062 |
| 1059 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1063 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
| 1060 | 1064 |
| 1061 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1065 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
| 1062 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, | 1066 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, |
| 1063 check->timeout_factory_->GetWeakPtr(), check), | 1067 check->timeout_factory_->GetWeakPtr(), check), |
| 1064 check_timeout_); | 1068 check_timeout_); |
| 1065 } | 1069 } |
| OLD | NEW |