Chromium Code Reviews| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 35 #include "components/safe_browsing_db/util.h" | 35 #include "components/safe_browsing_db/util.h" |
| 36 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/browser/notification_service.h" | 37 #include "content/public/browser/notification_service.h" |
| 38 #include "url/url_constants.h" | 38 #include "url/url_constants.h" |
| 39 | 39 |
| 40 using content::BrowserThread; | 40 using content::BrowserThread; |
| 41 | 41 |
| 42 namespace { | 42 namespace { |
| 43 | 43 |
| 44 using safe_browsing::SBThreatType; | |
| 45 using safe_browsing::SBFullHashResult; | |
| 46 using safe_browsing::SafeBrowsingProtocolManager; | |
| 47 | |
| 44 // Timeout for match checks, e.g. download URLs, hashes. | 48 // Timeout for match checks, e.g. download URLs, hashes. |
| 45 const int kCheckTimeoutMs = 10000; | 49 const int kCheckTimeoutMs = 10000; |
| 46 | 50 |
| 47 // Records disposition information about the check. |hit| should be | 51 // Records disposition information about the check. |hit| should be |
| 48 // |true| if there were any prefix hits in |full_hashes|. | 52 // |true| if there were any prefix hits in |full_hashes|. |
| 49 void RecordGetHashCheckStatus( | 53 void RecordGetHashCheckStatus( |
| 50 bool hit, | 54 bool hit, |
| 51 safe_browsing::ListType check_type, | 55 safe_browsing::ListType check_type, |
| 52 const std::vector<SBFullHashResult>& full_hashes) { | 56 const std::vector<SBFullHashResult>& full_hashes) { |
| 53 SafeBrowsingProtocolManager::ResultType result; | 57 SafeBrowsingProtocolManager::ResultType result; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 66 const SBThreatType threat_type, | 70 const SBThreatType threat_type, |
| 67 const std::vector<SBThreatType>& expected_threats) { | 71 const std::vector<SBThreatType>& expected_threats) { |
| 68 return expected_threats.end() != std::find(expected_threats.begin(), | 72 return expected_threats.end() != std::find(expected_threats.begin(), |
| 69 expected_threats.end(), | 73 expected_threats.end(), |
| 70 threat_type); | 74 threat_type); |
| 71 } | 75 } |
| 72 | 76 |
| 73 // Return the severest list id from the results in |full_hashes| which matches | 77 // Return the severest list id from the results in |full_hashes| which matches |
| 74 // |hash|, or INVALID if none match. | 78 // |hash|, or INVALID if none match. |
| 75 safe_browsing::ListType GetHashSeverestThreatListType( | 79 safe_browsing::ListType GetHashSeverestThreatListType( |
| 76 const SBFullHash& hash, | 80 const safe_browsing::SBFullHash& hash, |
| 77 const std::vector<SBFullHashResult>& full_hashes, | 81 const std::vector<SBFullHashResult>& full_hashes, |
| 78 size_t* index) { | 82 size_t* index) { |
| 79 safe_browsing::ListType pending_threat = safe_browsing::INVALID; | 83 safe_browsing::ListType pending_threat = safe_browsing::INVALID; |
| 80 for (size_t i = 0; i < full_hashes.size(); ++i) { | 84 for (size_t i = 0; i < full_hashes.size(); ++i) { |
| 81 if (safe_browsing::SBFullHashEqual(hash, full_hashes[i].hash)) { | 85 if (SBFullHashEqual(hash, full_hashes[i].hash)) { |
| 82 const safe_browsing::ListType threat = | 86 const safe_browsing::ListType threat = |
| 83 static_cast<safe_browsing::ListType>(full_hashes[i].list_id); | 87 static_cast<safe_browsing::ListType>(full_hashes[i].list_id); |
| 84 switch (threat) { | 88 switch (threat) { |
| 85 case safe_browsing::INVALID: | 89 case safe_browsing::INVALID: |
| 86 // |full_hashes| should never contain INVALID as a |list_id|. | 90 // |full_hashes| should never contain INVALID as a |list_id|. |
| 87 NOTREACHED(); | 91 NOTREACHED(); |
| 88 break; | 92 break; |
| 89 case safe_browsing::MALWARE: // Falls through. | 93 case safe_browsing::MALWARE: // Falls through. |
| 90 case safe_browsing::PHISH: // Falls through. | 94 case safe_browsing::PHISH: // Falls through. |
| 91 case safe_browsing::BINURL: // Falls through. | 95 case safe_browsing::BINURL: // Falls through. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 143 case safe_browsing::UNWANTEDURL: | 147 case safe_browsing::UNWANTEDURL: |
| 144 // UNWANTEDURL is considered less severe than other threats, keep | 148 // UNWANTEDURL is considered less severe than other threats, keep |
| 145 // looking. | 149 // looking. |
| 146 pending_threat = threat; | 150 pending_threat = threat; |
| 147 break; | 151 break; |
| 148 } | 152 } |
| 149 } | 153 } |
| 150 return pending_threat; | 154 return pending_threat; |
| 151 } | 155 } |
| 152 | 156 |
| 153 SBThreatType GetThreatTypeFromListType(safe_browsing::ListType list_type) { | 157 safe_browsing::SBThreatType GetThreatTypeFromListType( |
| 158 safe_browsing::ListType list_type) { | |
| 154 switch (list_type) { | 159 switch (list_type) { |
| 155 case safe_browsing::PHISH: | 160 case safe_browsing::PHISH: |
| 156 return SB_THREAT_TYPE_URL_PHISHING; | 161 return safe_browsing::SB_THREAT_TYPE_URL_PHISHING; |
| 157 case safe_browsing::MALWARE: | 162 case safe_browsing::MALWARE: |
| 158 return SB_THREAT_TYPE_URL_MALWARE; | 163 return safe_browsing::SB_THREAT_TYPE_URL_MALWARE; |
| 159 case safe_browsing::UNWANTEDURL: | 164 case safe_browsing::UNWANTEDURL: |
| 160 return SB_THREAT_TYPE_URL_UNWANTED; | 165 return safe_browsing::SB_THREAT_TYPE_URL_UNWANTED; |
| 161 case safe_browsing::BINURL: | 166 case safe_browsing::BINURL: |
| 162 return SB_THREAT_TYPE_BINARY_MALWARE_URL; | 167 return safe_browsing::SB_THREAT_TYPE_BINARY_MALWARE_URL; |
| 163 case safe_browsing::EXTENSIONBLACKLIST: | 168 case safe_browsing::EXTENSIONBLACKLIST: |
| 164 return SB_THREAT_TYPE_EXTENSION; | 169 return safe_browsing::SB_THREAT_TYPE_EXTENSION; |
| 165 default: | 170 default: |
| 166 DVLOG(1) << "Unknown safe browsing list id " << list_type; | 171 DVLOG(1) << "Unknown safe browsing list id " << list_type; |
| 167 return SB_THREAT_TYPE_SAFE; | 172 return safe_browsing::SB_THREAT_TYPE_SAFE; |
| 168 } | 173 } |
| 169 } | 174 } |
| 170 | 175 |
| 171 } // namespace | 176 } // namespace |
| 172 | 177 |
| 178 namespace safe_browsing { | |
|
Nathan Parker
2015/11/07 01:15:13
If you put this up top, and the anonymous namespac
vakh (old account. dont use)
2015/11/07 01:22:57
You mean like this:
namespace safe_browsing {
nam
Nathan Parker
2015/11/10 23:53:34
Really? Hrm, then I've lead you astray. Carry on.
mattm
2015/11/11 01:10:16
It definitely should work. I noticed prefix_set.cc
vakh (old account. dont use)
2015/11/11 18:59:53
You're right. I have fixed prefix_set.cc and it wo
| |
| 179 | |
| 173 // static | 180 // static |
| 174 SBThreatType LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType( | 181 SBThreatType LocalSafeBrowsingDatabaseManager::GetHashSeverestThreatType( |
| 175 const SBFullHash& hash, | 182 const SBFullHash& hash, |
| 176 const std::vector<SBFullHashResult>& full_hashes) { | 183 const std::vector<SBFullHashResult>& full_hashes) { |
| 177 return GetThreatTypeFromListType( | 184 return GetThreatTypeFromListType( |
| 178 GetHashSeverestThreatListType(hash, full_hashes, NULL)); | 185 GetHashSeverestThreatListType(hash, full_hashes, NULL)); |
| 179 } | 186 } |
| 180 | 187 |
| 181 // static | 188 // static |
| 182 SBThreatType LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType( | 189 SBThreatType LocalSafeBrowsingDatabaseManager::GetUrlSeverestThreatType( |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 212 void LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck:: | 219 void LocalSafeBrowsingDatabaseManager::SafeBrowsingCheck:: |
| 213 OnSafeBrowsingResult() { | 220 OnSafeBrowsingResult() { |
| 214 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 221 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 215 | 222 |
| 216 DCHECK(client); | 223 DCHECK(client); |
| 217 DCHECK_EQ(urls.size(), url_results.size()); | 224 DCHECK_EQ(urls.size(), url_results.size()); |
| 218 DCHECK_EQ(full_hashes.size(), full_hash_results.size()); | 225 DCHECK_EQ(full_hashes.size(), full_hash_results.size()); |
| 219 if (!urls.empty()) { | 226 if (!urls.empty()) { |
| 220 DCHECK(full_hashes.empty()); | 227 DCHECK(full_hashes.empty()); |
| 221 switch (check_type) { | 228 switch (check_type) { |
| 222 case safe_browsing::MALWARE: | 229 case MALWARE: |
| 223 case safe_browsing::PHISH: | 230 case PHISH: |
| 224 case safe_browsing::UNWANTEDURL: | 231 case UNWANTEDURL: |
| 225 DCHECK_EQ(1u, urls.size()); | 232 DCHECK_EQ(1u, urls.size()); |
| 226 client->OnCheckBrowseUrlResult(urls[0], url_results[0], | 233 client->OnCheckBrowseUrlResult(urls[0], url_results[0], |
| 227 url_metadata[0]); | 234 url_metadata[0]); |
| 228 break; | 235 break; |
| 229 case safe_browsing::BINURL: | 236 case BINURL: |
| 230 DCHECK_EQ(urls.size(), url_results.size()); | 237 DCHECK_EQ(urls.size(), url_results.size()); |
| 231 client->OnCheckDownloadUrlResult( | 238 client->OnCheckDownloadUrlResult( |
| 232 urls, *std::max_element(url_results.begin(), url_results.end())); | 239 urls, *std::max_element(url_results.begin(), url_results.end())); |
| 233 break; | 240 break; |
| 234 default: | 241 default: |
| 235 NOTREACHED(); | 242 NOTREACHED(); |
| 236 } | 243 } |
| 237 } else if (!full_hashes.empty()) { | 244 } else if (!full_hashes.empty()) { |
| 238 switch (check_type) { | 245 switch (check_type) { |
| 239 case safe_browsing::EXTENSIONBLACKLIST: { | 246 case EXTENSIONBLACKLIST: { |
| 240 std::set<std::string> unsafe_extension_ids; | 247 std::set<std::string> unsafe_extension_ids; |
| 241 for (size_t i = 0; i < full_hashes.size(); ++i) { | 248 for (size_t i = 0; i < full_hashes.size(); ++i) { |
| 242 std::string extension_id = | 249 std::string extension_id = |
| 243 safe_browsing::SBFullHashToString(full_hashes[i]); | 250 SBFullHashToString(full_hashes[i]); |
| 244 if (full_hash_results[i] == SB_THREAT_TYPE_EXTENSION) | 251 if (full_hash_results[i] == SB_THREAT_TYPE_EXTENSION) |
| 245 unsafe_extension_ids.insert(extension_id); | 252 unsafe_extension_ids.insert(extension_id); |
| 246 } | 253 } |
| 247 client->OnCheckExtensionsResult(unsafe_extension_ids); | 254 client->OnCheckExtensionsResult(unsafe_extension_ids); |
| 248 break; | 255 break; |
| 249 } | 256 } |
| 250 default: | 257 default: |
| 251 NOTREACHED(); | 258 NOTREACHED(); |
| 252 } | 259 } |
| 253 } else { | 260 } else { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 339 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 333 if (!enabled_ || !enable_download_protection_) | 340 if (!enabled_ || !enable_download_protection_) |
| 334 return true; | 341 return true; |
| 335 | 342 |
| 336 // We need to check the database for url prefix, and later may fetch the url | 343 // We need to check the database for url prefix, and later may fetch the url |
| 337 // from the safebrowsing backends. These need to be asynchronous. | 344 // from the safebrowsing backends. These need to be asynchronous. |
| 338 SafeBrowsingCheck* check = | 345 SafeBrowsingCheck* check = |
| 339 new SafeBrowsingCheck(url_chain, | 346 new SafeBrowsingCheck(url_chain, |
| 340 std::vector<SBFullHash>(), | 347 std::vector<SBFullHash>(), |
| 341 client, | 348 client, |
| 342 safe_browsing::BINURL, | 349 BINURL, |
| 343 std::vector<SBThreatType>(1, | 350 std::vector<SBThreatType>(1, |
| 344 SB_THREAT_TYPE_BINARY_MALWARE_URL)); | 351 SB_THREAT_TYPE_BINARY_MALWARE_URL)); |
| 345 std::vector<SBPrefix> prefixes; | 352 std::vector<SBPrefix> prefixes; |
| 346 SafeBrowsingDatabase::GetDownloadUrlPrefixes(url_chain, &prefixes); | 353 SafeBrowsingDatabase::GetDownloadUrlPrefixes(url_chain, &prefixes); |
| 347 StartSafeBrowsingCheck( | 354 StartSafeBrowsingCheck( |
| 348 check, | 355 check, |
| 349 base::Bind(&LocalSafeBrowsingDatabaseManager::CheckDownloadUrlOnSBThread, | 356 base::Bind(&LocalSafeBrowsingDatabaseManager::CheckDownloadUrlOnSBThread, |
| 350 this, prefixes)); | 357 this, prefixes)); |
| 351 return false; | 358 return false; |
| 352 } | 359 } |
| 353 | 360 |
| 354 bool LocalSafeBrowsingDatabaseManager::CheckExtensionIDs( | 361 bool LocalSafeBrowsingDatabaseManager::CheckExtensionIDs( |
| 355 const std::set<std::string>& extension_ids, | 362 const std::set<std::string>& extension_ids, |
| 356 Client* client) { | 363 Client* client) { |
| 357 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 364 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 358 | 365 |
| 359 if (!enabled_ || !enable_extension_blacklist_) | 366 if (!enabled_ || !enable_extension_blacklist_) |
| 360 return true; | 367 return true; |
| 361 | 368 |
| 362 std::vector<SBFullHash> extension_id_hashes; | 369 std::vector<SBFullHash> extension_id_hashes; |
| 363 std::transform(extension_ids.begin(), extension_ids.end(), | 370 std::transform(extension_ids.begin(), extension_ids.end(), |
| 364 std::back_inserter(extension_id_hashes), | 371 std::back_inserter(extension_id_hashes), |
| 365 safe_browsing::StringToSBFullHash); | 372 StringToSBFullHash); |
| 366 std::vector<SBPrefix> prefixes; | 373 std::vector<SBPrefix> prefixes; |
| 367 for (const SBFullHash& hash : extension_id_hashes) | 374 for (const SBFullHash& hash : extension_id_hashes) |
| 368 prefixes.push_back(hash.prefix); | 375 prefixes.push_back(hash.prefix); |
| 369 | 376 |
| 370 SafeBrowsingCheck* check = new SafeBrowsingCheck( | 377 SafeBrowsingCheck* check = new SafeBrowsingCheck( |
| 371 std::vector<GURL>(), | 378 std::vector<GURL>(), |
| 372 extension_id_hashes, | 379 extension_id_hashes, |
| 373 client, | 380 client, |
| 374 safe_browsing::EXTENSIONBLACKLIST, | 381 EXTENSIONBLACKLIST, |
| 375 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION)); | 382 std::vector<SBThreatType>(1, SB_THREAT_TYPE_EXTENSION)); |
| 376 StartSafeBrowsingCheck( | 383 StartSafeBrowsingCheck( |
| 377 check, | 384 check, |
| 378 base::Bind(&LocalSafeBrowsingDatabaseManager::CheckExtensionIDsOnSBThread, | 385 base::Bind(&LocalSafeBrowsingDatabaseManager::CheckExtensionIDsOnSBThread, |
| 379 this, prefixes)); | 386 this, prefixes)); |
| 380 return false; | 387 return false; |
| 381 } | 388 } |
| 382 | 389 |
| 383 bool LocalSafeBrowsingDatabaseManager::MatchMalwareIP( | 390 bool LocalSafeBrowsingDatabaseManager::MatchMalwareIP( |
| 384 const std::string& ip_address) { | 391 const std::string& ip_address) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 452 if (!CanCheckUrl(url)) | 459 if (!CanCheckUrl(url)) |
| 453 return true; | 460 return true; |
| 454 | 461 |
| 455 std::vector<SBThreatType> expected_threats; | 462 std::vector<SBThreatType> expected_threats; |
| 456 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); | 463 expected_threats.push_back(SB_THREAT_TYPE_URL_MALWARE); |
| 457 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); | 464 expected_threats.push_back(SB_THREAT_TYPE_URL_PHISHING); |
| 458 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED); | 465 expected_threats.push_back(SB_THREAT_TYPE_URL_UNWANTED); |
| 459 | 466 |
| 460 const base::TimeTicks start = base::TimeTicks::Now(); | 467 const base::TimeTicks start = base::TimeTicks::Now(); |
| 461 if (!MakeDatabaseAvailable()) { | 468 if (!MakeDatabaseAvailable()) { |
| 462 QueuedCheck queued_check(safe_browsing::MALWARE, // or PHISH | 469 QueuedCheck queued_check(MALWARE, // or PHISH |
| 463 client, | 470 client, |
| 464 url, | 471 url, |
| 465 expected_threats, | 472 expected_threats, |
| 466 start); | 473 start); |
| 467 queued_checks_.push_back(queued_check); | 474 queued_checks_.push_back(queued_check); |
| 468 return false; | 475 return false; |
| 469 } | 476 } |
| 470 | 477 |
| 471 // Cache hits should, in general, be the same for both (ignoring potential | 478 // Cache hits should, in general, be the same for both (ignoring potential |
| 472 // cache evictions in the second call for entries that were just about to be | 479 // cache evictions in the second call for entries that were just about to be |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 503 | 510 |
| 504 // Needs to be asynchronous, since we could be in the constructor of a | 511 // Needs to be asynchronous, since we could be in the constructor of a |
| 505 // ResourceDispatcherHost event handler which can't pause there. | 512 // ResourceDispatcherHost event handler which can't pause there. |
| 506 // This check will ping the Safe Browsing servers and get all lists which it | 513 // This check will ping the Safe Browsing servers and get all lists which it |
| 507 // matches. These lists will then be filtered against the |expected_threats| | 514 // matches. These lists will then be filtered against the |expected_threats| |
| 508 // and the result callback for MALWARE (which is the same as for PHISH and | 515 // and the result callback for MALWARE (which is the same as for PHISH and |
| 509 // UNWANTEDURL) will eventually be invoked with the final decision. | 516 // UNWANTEDURL) will eventually be invoked with the final decision. |
| 510 SafeBrowsingCheck* check = new SafeBrowsingCheck(std::vector<GURL>(1, url), | 517 SafeBrowsingCheck* check = new SafeBrowsingCheck(std::vector<GURL>(1, url), |
| 511 std::vector<SBFullHash>(), | 518 std::vector<SBFullHash>(), |
| 512 client, | 519 client, |
| 513 safe_browsing::MALWARE, | 520 MALWARE, |
| 514 expected_threats); | 521 expected_threats); |
| 515 check->need_get_hash = cache_hits.empty(); | 522 check->need_get_hash = cache_hits.empty(); |
| 516 check->prefix_hits.swap(prefix_hits); | 523 check->prefix_hits.swap(prefix_hits); |
| 517 check->cache_hits.swap(cache_hits); | 524 check->cache_hits.swap(cache_hits); |
| 518 checks_.insert(check); | 525 checks_.insert(check); |
| 519 | 526 |
| 520 BrowserThread::PostTask( | 527 BrowserThread::PostTask( |
| 521 BrowserThread::IO, FROM_HERE, | 528 BrowserThread::IO, FROM_HERE, |
| 522 base::Bind(&LocalSafeBrowsingDatabaseManager::OnCheckDone, this, check)); | 529 base::Bind(&LocalSafeBrowsingDatabaseManager::OnCheckDone, this, check)); |
| 523 | 530 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 665 void LocalSafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( | 672 void LocalSafeBrowsingDatabaseManager::NotifyDatabaseUpdateFinished( |
| 666 bool update_succeeded) { | 673 bool update_succeeded) { |
| 667 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 674 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 668 content::NotificationService::current()->Notify( | 675 content::NotificationService::current()->Notify( |
| 669 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 676 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
| 670 content::Source<SafeBrowsingDatabaseManager>(this), | 677 content::Source<SafeBrowsingDatabaseManager>(this), |
| 671 content::Details<bool>(&update_succeeded)); | 678 content::Details<bool>(&update_succeeded)); |
| 672 } | 679 } |
| 673 | 680 |
| 674 LocalSafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( | 681 LocalSafeBrowsingDatabaseManager::QueuedCheck::QueuedCheck( |
| 675 const safe_browsing::ListType check_type, | 682 const ListType check_type, |
| 676 Client* client, | 683 Client* client, |
| 677 const GURL& url, | 684 const GURL& url, |
| 678 const std::vector<SBThreatType>& expected_threats, | 685 const std::vector<SBThreatType>& expected_threats, |
| 679 const base::TimeTicks& start) | 686 const base::TimeTicks& start) |
| 680 : check_type(check_type), | 687 : check_type(check_type), |
| 681 client(client), | 688 client(client), |
| 682 url(url), | 689 url(url), |
| 683 expected_threats(expected_threats), | 690 expected_threats(expected_threats), |
| 684 start(start) { | 691 start(start) { |
| 685 } | 692 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 865 return is_extended_reporting; | 872 return is_extended_reporting; |
| 866 } | 873 } |
| 867 | 874 |
| 868 void LocalSafeBrowsingDatabaseManager::RequestFullHash( | 875 void LocalSafeBrowsingDatabaseManager::RequestFullHash( |
| 869 SafeBrowsingCheck* check) { | 876 SafeBrowsingCheck* check) { |
| 870 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 877 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 871 | 878 |
| 872 if (!enabled_) | 879 if (!enabled_) |
| 873 return; | 880 return; |
| 874 | 881 |
| 875 bool is_download = check->check_type == safe_browsing::BINURL; | 882 bool is_download = check->check_type == BINURL; |
| 876 sb_service_->protocol_manager()->GetFullHash( | 883 sb_service_->protocol_manager()->GetFullHash( |
| 877 check->prefix_hits, | 884 check->prefix_hits, |
| 878 base::Bind(&LocalSafeBrowsingDatabaseManager::HandleGetHashResults, | 885 base::Bind(&LocalSafeBrowsingDatabaseManager::HandleGetHashResults, |
| 879 base::Unretained(this), check), | 886 base::Unretained(this), check), |
| 880 is_download, check->is_extended_reporting); | 887 is_download, check->is_extended_reporting); |
| 881 } | 888 } |
| 882 | 889 |
| 883 void LocalSafeBrowsingDatabaseManager::GetAllChunksFromDatabase( | 890 void LocalSafeBrowsingDatabaseManager::GetAllChunksFromDatabase( |
| 884 GetChunksCallback callback) { | 891 GetChunksCallback callback) { |
| 885 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); | 892 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 void LocalSafeBrowsingDatabaseManager::OnResetDatabase() { | 1025 void LocalSafeBrowsingDatabaseManager::OnResetDatabase() { |
| 1019 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); | 1026 DCHECK(safe_browsing_task_runner_->RunsTasksOnCurrentThread()); |
| 1020 | 1027 |
| 1021 GetDatabase()->ResetDatabase(); | 1028 GetDatabase()->ResetDatabase(); |
| 1022 } | 1029 } |
| 1023 | 1030 |
| 1024 void LocalSafeBrowsingDatabaseManager::OnHandleGetHashResults( | 1031 void LocalSafeBrowsingDatabaseManager::OnHandleGetHashResults( |
| 1025 SafeBrowsingCheck* check, | 1032 SafeBrowsingCheck* check, |
| 1026 const std::vector<SBFullHashResult>& full_hashes) { | 1033 const std::vector<SBFullHashResult>& full_hashes) { |
| 1027 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1034 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1028 safe_browsing::ListType check_type = check->check_type; | 1035 ListType check_type = check->check_type; |
| 1029 SBPrefix prefix = check->prefix_hits[0]; | 1036 SBPrefix prefix = check->prefix_hits[0]; |
| 1030 GetHashRequests::iterator it = gethash_requests_.find(prefix); | 1037 GetHashRequests::iterator it = gethash_requests_.find(prefix); |
| 1031 if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) { | 1038 if (check->prefix_hits.size() > 1 || it == gethash_requests_.end()) { |
| 1032 const bool hit = HandleOneCheck(check, full_hashes); | 1039 const bool hit = HandleOneCheck(check, full_hashes); |
| 1033 RecordGetHashCheckStatus(hit, check_type, full_hashes); | 1040 RecordGetHashCheckStatus(hit, check_type, full_hashes); |
| 1034 return; | 1041 return; |
| 1035 } | 1042 } |
| 1036 | 1043 |
| 1037 // Call back all interested parties, noting if any has a hit. | 1044 // Call back all interested parties, noting if any has a hit. |
| 1038 GetHashRequestors& requestors = it->second; | 1045 GetHashRequestors& requestors = it->second; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1182 check->weak_ptr_factory_->GetWeakPtr(), check)); | 1189 check->weak_ptr_factory_->GetWeakPtr(), check)); |
| 1183 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1190 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 1184 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, | 1191 FROM_HERE, base::Bind(&LocalSafeBrowsingDatabaseManager::TimeoutCallback, |
| 1185 check->weak_ptr_factory_->GetWeakPtr(), check), | 1192 check->weak_ptr_factory_->GetWeakPtr(), check), |
| 1186 check_timeout_); | 1193 check_timeout_); |
| 1187 } | 1194 } |
| 1188 | 1195 |
| 1189 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { | 1196 bool LocalSafeBrowsingDatabaseManager::download_protection_enabled() const { |
| 1190 return enable_download_protection_; | 1197 return enable_download_protection_; |
| 1191 } | 1198 } |
| 1199 | |
| 1200 } // namespace safe_browsing | |
| OLD | NEW |