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> |
11 | 11 |
12 #include <cstring> | 12 #include <cstring> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
19 #include "components/safe_browsing_db/safe_browsing_prefs.h" | |
19 #include "components/safe_browsing_db/v4_protocol_manager_util.h" | 20 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
20 | 21 |
21 class GURL; | 22 class GURL; |
22 | 23 |
23 namespace safe_browsing { | 24 namespace safe_browsing { |
24 | 25 |
25 // Metadata that indicates what kind of URL match this is. | 26 // Metadata that indicates what kind of URL match this is. |
26 enum class ThreatPatternType { | 27 enum class ThreatPatternType { |
27 NONE = 0, // Pattern type didn't appear in the metadata | 28 NONE = 0, // Pattern type didn't appear in the metadata |
28 MALWARE_LANDING = 1, // The match is a malware landing page | 29 MALWARE_LANDING = 1, // The match is a malware landing page |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 // Maps a ListId to list name. Return false if fails. | 160 // Maps a ListId to list name. Return false if fails. |
160 bool GetListName(ListType list_id, std::string* list); | 161 bool GetListName(ListType list_id, std::string* list); |
161 | 162 |
162 // Generate the set of full hashes to check for |url|. If | 163 // Generate the set of full hashes to check for |url|. If |
163 // |include_whitelist_hashes| is true we will generate additional path-prefixes | 164 // |include_whitelist_hashes| is true we will generate additional path-prefixes |
164 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the | 165 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the |
165 // whitelist it should also match /foo/bar which is not the case for all the | 166 // whitelist it should also match /foo/bar which is not the case for all the |
166 // other lists. We'll also always add a pattern for the empty path. | 167 // other lists. We'll also always add a pattern for the empty path. |
167 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, | 168 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, |
168 std::vector<SBFullHash>* full_hashes); | 169 std::vector<SBFullHash>* full_hashes); |
170 | |
171 struct SafeBrowsingProtocolConfig { | |
172 SafeBrowsingProtocolConfig(); | |
173 SafeBrowsingProtocolConfig(const SafeBrowsingProtocolConfig& other); | |
174 ~SafeBrowsingProtocolConfig(); | |
175 std::string client_name; | |
176 std::string url_prefix; | |
177 std::string backup_connect_error_url_prefix; | |
178 std::string backup_http_error_url_prefix; | |
179 std::string backup_network_error_url_prefix; | |
180 std::string version; | |
181 bool disable_auto_update; | |
182 }; | |
183 | |
184 // returns chrome version. | |
185 std::string Version(); | |
vakh (use Gerrit instead)
2017/02/14 02:33:31
The function name is very generic. I think it woul
Jialiu Lin
2017/02/14 18:44:07
Sounds good. Namespace added.
| |
186 | |
187 // Composes a URL using |prefix|, |method| (e.g.: gethash, download, report). | |
188 // |client_name| and |version|. When not empty, |additional_query| is | |
189 // appended to the URL with an additional "&" in the front. | |
190 std::string ComposeUrl(const std::string& prefix, | |
191 const std::string& method, | |
192 const std::string& client_name, | |
193 const std::string& version, | |
194 const std::string& additional_query); | |
195 | |
196 // Similar to above function, and appends "&ext=1" at the end of URL if | |
197 // |is_extended_reporting| is true, otherwise, appends "&ext=0". | |
198 std::string ComposeUrl(const std::string& prefix, | |
199 const std::string& method, | |
200 const std::string& client_name, | |
201 const std::string& version, | |
202 const std::string& additional_query, | |
203 ExtendedReportingLevel reporting_level); | |
204 | |
169 } // namespace safe_browsing | 205 } // namespace safe_browsing |
170 | 206 |
171 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 207 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |