OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Utilities for the SafeBrowsing DB code. |
| 6 |
| 7 #ifndef COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_DB_UTIL_H_ |
| 8 #define COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_DB_UTIL_H_ |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/strings/string_piece.h" |
| 12 |
| 13 // A truncated hash's type. |
| 14 typedef uint32 SBPrefix; |
| 15 |
| 16 // A full hash. |
| 17 union SBFullHash { |
| 18 char full_hash[32]; |
| 19 SBPrefix prefix; |
| 20 }; |
| 21 |
| 22 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { |
| 23 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); |
| 24 } |
| 25 |
| 26 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { |
| 27 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; |
| 28 } |
| 29 |
| 30 // Generate full hash for the given string. |
| 31 SBFullHash SBFullHashForString(const base::StringPiece& str); |
| 32 |
| 33 // Different types of threats that SafeBrowsing protects against. |
| 34 enum SBThreatType { |
| 35 // No threat at all. |
| 36 SB_THREAT_TYPE_SAFE, |
| 37 |
| 38 // The URL is being used for phishing. |
| 39 SB_THREAT_TYPE_URL_PHISHING, |
| 40 |
| 41 // The URL hosts malware. |
| 42 SB_THREAT_TYPE_URL_MALWARE, |
| 43 |
| 44 // The URL hosts unwanted programs. |
| 45 SB_THREAT_TYPE_URL_UNWANTED, |
| 46 |
| 47 // The download URL is malware. |
| 48 SB_THREAT_TYPE_BINARY_MALWARE_URL, |
| 49 |
| 50 // Url detected by the client-side phishing model. Note that unlike the |
| 51 // above values, this does not correspond to a downloaded list. |
| 52 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, |
| 53 |
| 54 // The Chrome extension or app (given by its ID) is malware. |
| 55 SB_THREAT_TYPE_EXTENSION, |
| 56 |
| 57 // Url detected by the client-side malware IP list. This IP list is part |
| 58 // of the client side detection model. |
| 59 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, |
| 60 }; |
| 61 |
| 62 #endif // COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |