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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 SBFullHash StringToSBFullHash(const std::string& hash_in); | 184 SBFullHash StringToSBFullHash(const std::string& hash_in); |
185 std::string SBFullHashToString(const SBFullHash& hash_out); | 185 std::string SBFullHashToString(const SBFullHash& hash_out); |
186 | 186 |
187 | 187 |
188 // Maps a list name to ListType. | 188 // Maps a list name to ListType. |
189 ListType GetListId(const base::StringPiece& name); | 189 ListType GetListId(const base::StringPiece& name); |
190 | 190 |
191 // Maps a ListId to list name. Return false if fails. | 191 // Maps a ListId to list name. Return false if fails. |
192 bool GetListName(ListType list_id, std::string* list); | 192 bool GetListName(ListType list_id, std::string* list); |
193 | 193 |
| 194 // Canonicalizes url as per Google Safe Browsing Specification. |
| 195 // See section 6.1 in |
| 196 // http://code.google.com/p/google-safe-browsing/wiki/Protocolv2Spec. |
| 197 void CanonicalizeUrl(const GURL& url, std::string* canonicalized_hostname, |
| 198 std::string* canonicalized_path, |
| 199 std::string* canonicalized_query); |
| 200 |
| 201 |
194 // Generate the set of full hashes to check for |url|. If | 202 // Generate the set of full hashes to check for |url|. If |
195 // |include_whitelist_hashes| is true we will generate additional path-prefixes | 203 // |include_whitelist_hashes| is true we will generate additional path-prefixes |
196 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the | 204 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the |
197 // whitelist it should also match /foo/bar which is not the case for all the | 205 // whitelist it should also match /foo/bar which is not the case for all the |
198 // other lists. We'll also always add a pattern for the empty path. | 206 // other lists. We'll also always add a pattern for the empty path. |
199 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, | 207 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, |
200 std::vector<SBFullHash>* full_hashes); | 208 std::vector<SBFullHash>* full_hashes); |
| 209 |
| 210 // Given a URL, returns all the hosts we need to check. They are returned |
| 211 // in order of size (i.e. b.c is first, then a.b.c). |
| 212 void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts); |
| 213 |
| 214 // Given a URL, returns all the paths we need to check. |
| 215 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
| 216 |
| 217 // Given a URL, returns all the patterns we need to check. |
| 218 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
| 219 |
201 } // namespace safe_browsing | 220 } // namespace safe_browsing |
202 | 221 |
203 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 222 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |