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 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/safe_browsing/safe_browsing_database.h" | 27 #include "chrome/browser/safe_browsing/safe_browsing_database.h" |
28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 28 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
29 #include "chrome/browser/safe_browsing/ui_manager.h" | 29 #include "chrome/browser/safe_browsing/ui_manager.h" |
30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
33 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
34 #include "components/startup_metric_utils/startup_metric_utils.h" | 34 #include "components/startup_metric_utils/startup_metric_utils.h" |
35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
36 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 37 #include "net/base/url_constants.h" |
37 | 38 |
38 using content::BrowserThread; | 39 using content::BrowserThread; |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // Timeout for match checks, e.g. download URLs, hashes. | 43 // Timeout for match checks, e.g. download URLs, hashes. |
43 const int kCheckTimeoutMs = 10000; | 44 const int kCheckTimeoutMs = 10000; |
44 | 45 |
45 // Records disposition information about the check. |hit| should be | 46 // Records disposition information about the check. |hit| should be |
46 // |true| if there were any prefix hits in |full_hashes|. | 47 // |true| if there were any prefix hits in |full_hashes|. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); | 215 SIDE_EFFECT_FREE_WHITELIST_STATUS_MAX); |
215 } | 216 } |
216 | 217 |
217 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { | 218 SafeBrowsingDatabaseManager::~SafeBrowsingDatabaseManager() { |
218 // We should have already been shut down. If we're still enabled, then the | 219 // We should have already been shut down. If we're still enabled, then the |
219 // database isn't going to be closed properly, which could lead to corruption. | 220 // database isn't going to be closed properly, which could lead to corruption. |
220 DCHECK(!enabled_); | 221 DCHECK(!enabled_); |
221 } | 222 } |
222 | 223 |
223 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { | 224 bool SafeBrowsingDatabaseManager::CanCheckUrl(const GURL& url) const { |
224 return url.SchemeIs(content::kFtpScheme) || | 225 return url.SchemeIs(content::kFtpScheme) || url.SchemeIs(net::kHttpScheme) || |
225 url.SchemeIs(content::kHttpScheme) || | 226 url.SchemeIs(net::kHttpsScheme); |
226 url.SchemeIs(content::kHttpsScheme); | |
227 } | 227 } |
228 | 228 |
229 bool SafeBrowsingDatabaseManager::CheckDownloadUrl( | 229 bool SafeBrowsingDatabaseManager::CheckDownloadUrl( |
230 const std::vector<GURL>& url_chain, | 230 const std::vector<GURL>& url_chain, |
231 Client* client) { | 231 Client* client) { |
232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 232 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
233 if (!enabled_ || !enable_download_protection_) | 233 if (!enabled_ || !enable_download_protection_) |
234 return true; | 234 return true; |
235 | 235 |
236 // We need to check the database for url prefix, and later may fetch the url | 236 // We need to check the database for url prefix, and later may fetch the url |
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); | 1015 new base::WeakPtrFactory<SafeBrowsingDatabaseManager>(this)); |
1016 checks_.insert(check); | 1016 checks_.insert(check); |
1017 | 1017 |
1018 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); | 1018 safe_browsing_thread_->message_loop()->PostTask(FROM_HERE, task); |
1019 | 1019 |
1020 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1020 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, |
1021 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, | 1021 base::Bind(&SafeBrowsingDatabaseManager::TimeoutCallback, |
1022 check->timeout_factory_->GetWeakPtr(), check), | 1022 check->timeout_factory_->GetWeakPtr(), check), |
1023 check_timeout_); | 1023 check_timeout_); |
1024 } | 1024 } |
OLD | NEW |