OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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 // Utilities for the SafeBrowsing DB code. | 5 // Utilities for the SafeBrowsing DB code. |
6 | 6 |
7 #ifndef COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 7 #ifndef COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
8 #define COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 8 #define COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // SafeBrowsing download whitelist list name. | 90 // SafeBrowsing download whitelist list name. |
91 extern const char kDownloadWhiteList[]; | 91 extern const char kDownloadWhiteList[]; |
92 // SafeBrowsing extension list name. | 92 // SafeBrowsing extension list name. |
93 extern const char kExtensionBlacklist[]; | 93 extern const char kExtensionBlacklist[]; |
94 // SafeBrowsing csd malware IP blacklist name. | 94 // SafeBrowsing csd malware IP blacklist name. |
95 extern const char kIPBlacklist[]; | 95 extern const char kIPBlacklist[]; |
96 // SafeBrowsing unwanted URL list. | 96 // SafeBrowsing unwanted URL list. |
97 extern const char kUnwantedUrlList[]; | 97 extern const char kUnwantedUrlList[]; |
98 // SafeBrowsing off-domain inclusion whitelist list name. | 98 // SafeBrowsing off-domain inclusion whitelist list name. |
99 extern const char kInclusionWhitelist[]; | 99 extern const char kInclusionWhitelist[]; |
| 100 // SafeBrowsing module whitelist list name. |
| 101 extern const char kModuleWhitelist[]; |
100 // This array must contain all Safe Browsing lists. | 102 // This array must contain all Safe Browsing lists. |
101 extern const char* kAllLists[9]; | 103 extern const char* kAllLists[10]; |
102 | |
103 | 104 |
104 enum ListType { | 105 enum ListType { |
105 INVALID = -1, | 106 INVALID = -1, |
106 MALWARE = 0, | 107 MALWARE = 0, |
107 PHISH = 1, | 108 PHISH = 1, |
108 BINURL = 2, | 109 BINURL = 2, |
109 // Obsolete BINHASH = 3, | 110 // Obsolete BINHASH = 3, |
110 CSDWHITELIST = 4, | 111 CSDWHITELIST = 4, |
111 // SafeBrowsing lists are stored in pairs. Keep ListType 5 | 112 // SafeBrowsing lists are stored in pairs. Keep ListType 5 |
112 // available for a potential second list that we would store in the | 113 // available for a potential second list that we would store in the |
113 // csd-whitelist store file. | 114 // csd-whitelist store file. |
114 DOWNLOADWHITELIST = 6, | 115 DOWNLOADWHITELIST = 6, |
115 // See above comment. Leave 7 available. | 116 // See above comment. Leave 7 available. |
116 EXTENSIONBLACKLIST = 8, | 117 EXTENSIONBLACKLIST = 8, |
117 // See above comment. Leave 9 available. | 118 // See above comment. Leave 9 available. |
118 // Obsolete SIDEEFFECTFREEWHITELIST = 10, | 119 // Obsolete SIDEEFFECTFREEWHITELIST = 10, |
119 // See above comment. Leave 11 available. | 120 // See above comment. Leave 11 available. |
120 IPBLACKLIST = 12, | 121 IPBLACKLIST = 12, |
121 // See above comment. Leave 13 available. | 122 // See above comment. Leave 13 available. |
122 UNWANTEDURL = 14, | 123 UNWANTEDURL = 14, |
123 // See above comment. Leave 15 available. | 124 // See above comment. Leave 15 available. |
124 INCLUSIONWHITELIST = 16, | 125 INCLUSIONWHITELIST = 16, |
125 // See above comment. Leave 17 available. | 126 // See above comment. Leave 17 available. |
| 127 MODULEWHITELIST = 18, |
| 128 // See above comment. Leave 19 available. |
126 }; | 129 }; |
127 | 130 |
128 | |
129 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { | 131 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { |
130 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); | 132 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); |
131 } | 133 } |
132 | 134 |
133 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { | 135 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { |
134 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; | 136 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; |
135 } | 137 } |
136 | 138 |
137 // Generate full hash for the given string. | 139 // Generate full hash for the given string. |
138 SBFullHash SBFullHashForString(const base::StringPiece& str); | 140 SBFullHash SBFullHashForString(const base::StringPiece& str); |
(...skipping 29 matching lines...) Expand all Loading... |
168 | 170 |
169 // Given a URL, returns all the paths we need to check. | 171 // Given a URL, returns all the paths we need to check. |
170 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 172 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
171 | 173 |
172 // Given a URL, returns all the patterns we need to check. | 174 // Given a URL, returns all the patterns we need to check. |
173 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); | 175 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
174 | 176 |
175 } // namespace safe_browsing | 177 } // namespace safe_browsing |
176 | 178 |
177 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 179 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |