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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_util.h

Issue 1420143002: Revert of Move prefix_set and parts of s_b_util into a new component safe_browsing_db. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 code. 5 // Utilities for the SafeBrowsing code.
6 6
7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
9 9
10 #include <cstring> 10 #include <cstring>
11 #include <set>
11 #include <string> 12 #include <string>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/basictypes.h" 15 #include "base/basictypes.h"
15 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_piece.h" 17 #include "base/strings/string_piece.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "chrome/browser/safe_browsing/chunk_range.h" 19 #include "chrome/browser/safe_browsing/chunk_range.h"
19 #include "components/safe_browsing_db/safe_browsing_db_util.h"
20 20
21 namespace safe_browsing { 21 namespace safe_browsing {
22 class ChunkData; 22 class ChunkData;
23 }; 23 };
24 24
25 class GURL; 25 class GURL;
26 26
27 // A truncated hash's type.
28 typedef uint32 SBPrefix;
29
27 // Container for holding a chunk URL and the list it belongs to. 30 // Container for holding a chunk URL and the list it belongs to.
28 struct ChunkUrl { 31 struct ChunkUrl {
29 std::string url; 32 std::string url;
30 std::string list_name; 33 std::string list_name;
31 }; 34 };
32 35
36 // A full hash.
37 union SBFullHash {
38 char full_hash[32];
39 SBPrefix prefix;
40 };
41
42 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) {
43 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash));
44 }
45
46 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) {
47 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0;
48 }
49
50 // Generate full hash for the given string.
51 SBFullHash SBFullHashForString(const base::StringPiece& str);
52
33 // Data for an individual chunk sent from the server. 53 // Data for an individual chunk sent from the server.
34 class SBChunkData { 54 class SBChunkData {
35 public: 55 public:
36 SBChunkData(); 56 SBChunkData();
37 ~SBChunkData(); 57 ~SBChunkData();
38 58
39 // Create with manufactured data, for testing only. 59 // Create with manufactured data, for testing only.
40 // TODO(shess): Right now the test code calling this is in an anonymous 60 // TODO(shess): Right now the test code calling this is in an anonymous
41 // namespace. Figure out how to shift this into private:. 61 // namespace. Figure out how to shift this into private:.
42 explicit SBChunkData(safe_browsing::ChunkData* chunk_data); 62 explicit SBChunkData(safe_browsing::ChunkData* chunk_data);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 // Container for deleting chunks from the database. 115 // Container for deleting chunks from the database.
96 struct SBChunkDelete { 116 struct SBChunkDelete {
97 SBChunkDelete(); 117 SBChunkDelete();
98 ~SBChunkDelete(); 118 ~SBChunkDelete();
99 119
100 std::string list_name; 120 std::string list_name;
101 bool is_sub_del; 121 bool is_sub_del;
102 std::vector<ChunkRange> chunk_del; 122 std::vector<ChunkRange> chunk_del;
103 }; 123 };
104 124
125 // Different types of threats that SafeBrowsing protects against.
126 enum SBThreatType {
127 // No threat at all.
128 SB_THREAT_TYPE_SAFE,
129
130 // The URL is being used for phishing.
131 SB_THREAT_TYPE_URL_PHISHING,
132
133 // The URL hosts malware.
134 SB_THREAT_TYPE_URL_MALWARE,
135
136 // The URL hosts unwanted programs.
137 SB_THREAT_TYPE_URL_UNWANTED,
138
139 // The download URL is malware.
140 SB_THREAT_TYPE_BINARY_MALWARE_URL,
141
142 // Url detected by the client-side phishing model. Note that unlike the
143 // above values, this does not correspond to a downloaded list.
144 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL,
145
146 // The Chrome extension or app (given by its ID) is malware.
147 SB_THREAT_TYPE_EXTENSION,
148
149 // Url detected by the client-side malware IP list. This IP list is part
150 // of the client side detection model.
151 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL,
152 };
153
105 // Utility functions ----------------------------------------------------------- 154 // Utility functions -----------------------------------------------------------
106 155
107 namespace safe_browsing_util { 156 namespace safe_browsing_util {
108 157
109 // SafeBrowsing list names. 158 // SafeBrowsing list names.
110 extern const char kMalwareList[]; 159 extern const char kMalwareList[];
111 extern const char kPhishingList[]; 160 extern const char kPhishingList[];
112 // Binary Download list name. 161 // Binary Download list name.
113 extern const char kBinUrlList[]; 162 extern const char kBinUrlList[];
114 // SafeBrowsing client-side detection whitelist list name. 163 // SafeBrowsing client-side detection whitelist list name.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Given a URL, returns all the hosts we need to check. They are returned 216 // Given a URL, returns all the hosts we need to check. They are returned
168 // in order of size (i.e. b.c is first, then a.b.c). 217 // in order of size (i.e. b.c is first, then a.b.c).
169 void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts); 218 void GenerateHostsToCheck(const GURL& url, std::vector<std::string>* hosts);
170 219
171 // Given a URL, returns all the paths we need to check. 220 // Given a URL, returns all the paths we need to check.
172 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); 221 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths);
173 222
174 // Given a URL, returns all the patterns we need to check. 223 // Given a URL, returns all the patterns we need to check.
175 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); 224 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls);
176 225
226 GURL GeneratePhishingReportUrl(const std::string& report_page,
227 const std::string& url_to_report,
228 bool is_client_side_detection);
229
177 SBFullHash StringToSBFullHash(const std::string& hash_in); 230 SBFullHash StringToSBFullHash(const std::string& hash_in);
178 std::string SBFullHashToString(const SBFullHash& hash_out); 231 std::string SBFullHashToString(const SBFullHash& hash_out);
179 232
180 } // namespace safe_browsing_util 233 } // namespace safe_browsing_util
181 234
182 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_ 235 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_UTIL_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store_file_unittest.cc ('k') | chrome/browser/safe_browsing/safe_browsing_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698