| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 // This file should not be build on Android but is currently getting built. | 5 // This file should not be build on Android but is currently getting built. |
| 6 // TODO(vakh): Fix that: http://crbug.com/621647 | 6 // TODO(vakh): Fix that: http://crbug.com/621647 |
| 7 | 7 |
| 8 #include "components/safe_browsing_db/v4_local_database_manager.h" | 8 #include "components/safe_browsing_db/v4_local_database_manager.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/metrics/histogram_macros.h" | 16 #include "base/metrics/histogram_macros.h" |
| 17 #include "components/safe_browsing_db/v4_feature_list.h" | 17 #include "components/safe_browsing_db/v4_feature_list.h" |
| 18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 18 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "crypto/sha2.h" |
| 20 | 21 |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 using base::TimeTicks; | 23 using base::TimeTicks; |
| 23 | 24 |
| 24 namespace safe_browsing { | 25 namespace safe_browsing { |
| 25 | 26 |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 const ThreatSeverity kLeastSeverity = | 29 const ThreatSeverity kLeastSeverity = |
| 29 std::numeric_limits<ThreatSeverity>::max(); | 30 std::numeric_limits<ThreatSeverity>::max(); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 | 306 |
| 306 bool V4LocalDatabaseManager::MatchModuleWhitelistString( | 307 bool V4LocalDatabaseManager::MatchModuleWhitelistString( |
| 307 const std::string& str) { | 308 const std::string& str) { |
| 308 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 309 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 309 | 310 |
| 310 if (!enabled_ || !v4_database_) { | 311 if (!enabled_ || !v4_database_) { |
| 311 // To make sure we are conservative we return true. | 312 // To make sure we are conservative we return true. |
| 312 return true; | 313 return true; |
| 313 } | 314 } |
| 314 | 315 |
| 316 // str is the module's filename. Convert to hash. |
| 317 FullHash hash = crypto::SHA256HashString(str); |
| 315 return HandleHashSynchronously( | 318 return HandleHashSynchronously( |
| 316 str, StoresToCheck({GetChromeFilenameClientIncidentId()})); | 319 hash, StoresToCheck({GetChromeFilenameClientIncidentId()})); |
| 317 } | 320 } |
| 318 | 321 |
| 319 ThreatSource V4LocalDatabaseManager::GetThreatSource() const { | 322 ThreatSource V4LocalDatabaseManager::GetThreatSource() const { |
| 320 return ThreatSource::LOCAL_PVER4; | 323 return ThreatSource::LOCAL_PVER4; |
| 321 } | 324 } |
| 322 | 325 |
| 323 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 326 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 324 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 327 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 325 return false; | 328 return false; |
| 326 } | 329 } |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 } | 680 } |
| 678 | 681 |
| 679 void V4LocalDatabaseManager::UpdateRequestCompleted( | 682 void V4LocalDatabaseManager::UpdateRequestCompleted( |
| 680 std::unique_ptr<ParsedServerResponse> parsed_server_response) { | 683 std::unique_ptr<ParsedServerResponse> parsed_server_response) { |
| 681 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 684 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 682 v4_database_->ApplyUpdate(std::move(parsed_server_response), | 685 v4_database_->ApplyUpdate(std::move(parsed_server_response), |
| 683 db_updated_callback_); | 686 db_updated_callback_); |
| 684 } | 687 } |
| 685 | 688 |
| 686 } // namespace safe_browsing | 689 } // namespace safe_browsing |
| OLD | NEW |