Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: components/safe_browsing_db/util.h

Issue 2650973005: Componentize ping_manager (Closed)
Patch Set: rebase Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/safe_browsing_db/DEPS ('k') | components/safe_browsing_db/util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 namespace ProtocolManagerHelper {
185
186 // returns chrome version.
187 std::string Version();
188
189 // Composes a URL using |prefix|, |method| (e.g.: gethash, download, report).
190 // |client_name| and |version|. When not empty, |additional_query| is
191 // appended to the URL with an additional "&" in the front.
192 std::string ComposeUrl(const std::string& prefix,
193 const std::string& method,
194 const std::string& client_name,
195 const std::string& version,
196 const std::string& additional_query);
197
198 // Similar to above function, and appends "&ext=1" at the end of URL if
199 // |is_extended_reporting| is true, otherwise, appends "&ext=0".
200 std::string ComposeUrl(const std::string& prefix,
201 const std::string& method,
202 const std::string& client_name,
203 const std::string& version,
204 const std::string& additional_query,
205 ExtendedReportingLevel reporting_level);
206
207 } // namespace ProtocolManagerHelper
208
169 } // namespace safe_browsing 209 } // namespace safe_browsing
170 210
171 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ 211 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/DEPS ('k') | components/safe_browsing_db/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698