OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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" |
11 #include "base/stl_util-inl.h" | 11 #include "base/stl_util-inl.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/threading/thread_restrictions.h" | 13 #include "base/threading/thread_restrictions.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/metrics/metrics_service.h" | 15 #include "chrome/browser/metrics/metrics_service.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 17 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | |
noelutz
2011/03/28 20:55:16
Is this header necessary?
Brian Ryner
2011/03/29 00:04:41
Whoops, this was left over from a code reorganizat
| |
18 #include "chrome/browser/safe_browsing/malware_details.h" | 19 #include "chrome/browser/safe_browsing/malware_details.h" |
19 #include "chrome/browser/safe_browsing/protocol_manager.h" | 20 #include "chrome/browser/safe_browsing/protocol_manager.h" |
20 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 21 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
21 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
22 #include "chrome/browser/tab_contents/tab_util.h" | 23 #include "chrome/browser/tab_contents/tab_util.h" |
23 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/net/url_request_context_getter.h" | 27 #include "chrome/common/net/url_request_context_getter.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 client, | 237 client, |
237 NewRunnableMethod(this, | 238 NewRunnableMethod(this, |
238 &SafeBrowsingService::CheckDownloadHashOnSBThread, | 239 &SafeBrowsingService::CheckDownloadHashOnSBThread, |
239 check), | 240 check), |
240 download_hashcheck_timeout_ms_); | 241 download_hashcheck_timeout_ms_); |
241 return false; | 242 return false; |
242 } | 243 } |
243 | 244 |
244 bool SafeBrowsingService::MatchCsdWhitelistUrl(const GURL& url) { | 245 bool SafeBrowsingService::MatchCsdWhitelistUrl(const GURL& url) { |
245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
246 DCHECK(enable_csd_whitelist_); | |
247 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) { | 247 if (!enabled_ || !enable_csd_whitelist_ || !MakeDatabaseAvailable()) { |
248 // There is something funky going on here. Just to be safe we return | 248 // There is something funky going on here -- for example, perhaps the user |
249 // true in this case. | 249 // has not restarted since enabling metrics reporting, so we haven't |
250 // enabled the csd whitelist yet. Just to be safe we return true in this | |
251 // case. | |
250 return true; | 252 return true; |
251 } | 253 } |
252 return database_->ContainsCsdWhitelistedUrl(url); | 254 return database_->ContainsCsdWhitelistedUrl(url); |
253 } | 255 } |
254 | 256 |
255 bool SafeBrowsingService::CheckBrowseUrl(const GURL& url, | 257 bool SafeBrowsingService::CheckBrowseUrl(const GURL& url, |
256 Client* client) { | 258 Client* client) { |
257 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 259 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
258 if (!enabled_) | 260 if (!enabled_) |
259 return true; | 261 return true; |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
875 | 877 |
876 CommandLine* cmdline = CommandLine::ForCurrentProcess(); | 878 CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
877 enable_download_protection_ = | 879 enable_download_protection_ = |
878 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); | 880 !cmdline->HasSwitch(switches::kSbDisableDownloadProtection); |
879 | 881 |
880 // We only download the csd-whitelist if client-side phishing detection is | 882 // We only download the csd-whitelist if client-side phishing detection is |
881 // enabled and if the user has opted in with stats collection. Note: we | 883 // enabled and if the user has opted in with stats collection. Note: we |
882 // cannot check whether the metrics_service() object is created because it | 884 // cannot check whether the metrics_service() object is created because it |
883 // may be initialized after this method is called. | 885 // may be initialized after this method is called. |
884 enable_csd_whitelist_ = | 886 enable_csd_whitelist_ = |
885 (cmdline->HasSwitch(switches::kEnableClientSidePhishingDetection) && | 887 (!cmdline->HasSwitch(switches::kDisableClientSidePhishingDetection) && |
886 local_state && local_state->GetBoolean(prefs::kMetricsReportingEnabled)); | 888 local_state && local_state->GetBoolean(prefs::kMetricsReportingEnabled)); |
887 | 889 |
888 BrowserThread::PostTask( | 890 BrowserThread::PostTask( |
889 BrowserThread::IO, FROM_HERE, | 891 BrowserThread::IO, FROM_HERE, |
890 NewRunnableMethod( | 892 NewRunnableMethod( |
891 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, | 893 this, &SafeBrowsingService::OnIOInitialize, client_key, wrapped_key, |
892 request_context_getter)); | 894 request_context_getter)); |
893 } | 895 } |
894 | 896 |
895 void SafeBrowsingService::OnCloseDatabase() { | 897 void SafeBrowsingService::OnCloseDatabase() { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1171 check->is_download = true; | 1173 check->is_download = true; |
1172 check->timeout_task = | 1174 check->timeout_task = |
1173 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); | 1175 NewRunnableMethod(this, &SafeBrowsingService::TimeoutCallback, check); |
1174 checks_.insert(check); | 1176 checks_.insert(check); |
1175 | 1177 |
1176 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1178 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
1177 | 1179 |
1178 MessageLoop::current()->PostDelayedTask( | 1180 MessageLoop::current()->PostDelayedTask( |
1179 FROM_HERE, check->timeout_task, timeout_ms); | 1181 FROM_HERE, check->timeout_task, timeout_ms); |
1180 } | 1182 } |
OLD | NEW |