OLD | NEW |
---|---|
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 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
7 | 7 |
8 // A class that implements Chrome's interface with the SafeBrowsing protocol. | 8 // A class that implements Chrome's interface with the SafeBrowsing protocol. |
9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for | 9 // See https://developers.google.com/safe-browsing/developers_guide_v2 for |
10 // protocol details. | 10 // protocol details. |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 196 |
197 private: | 197 private: |
198 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); | 198 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestBackOffTimes); |
199 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings); | 199 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestChunkStrings); |
200 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl); | 200 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestGetHashUrl); |
201 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | 201 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, |
202 TestGetV4HashUrl); | 202 TestGetV4HashUrl); |
203 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | 203 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, |
204 TestGetV4HashRequest); | 204 TestGetV4HashRequest); |
205 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | 205 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, |
206 TestParseV4HashResponse); | |
207 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | |
208 TestParseV4HashResponseWrongThreatEntryType); | |
209 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | |
210 TestParseV4HashResponseSocialEngineeringThreatType); | |
211 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | |
212 TestParseV4HashResponseNonPermissionMetadata); | |
213 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, | |
206 TestGetHashBackOffTimes); | 214 TestGetHashBackOffTimes); |
207 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestNextChunkUrl); | 215 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestNextChunkUrl); |
208 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestUpdateUrl); | 216 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingProtocolManagerTest, TestUpdateUrl); |
209 friend class SafeBrowsingServerTest; | 217 friend class SafeBrowsingServerTest; |
210 friend class SBProtocolManagerFactoryImpl; | 218 friend class SBProtocolManagerFactoryImpl; |
211 | 219 |
212 // Internal API for fetching information from the SafeBrowsing servers. The | 220 // Internal API for fetching information from the SafeBrowsing servers. The |
213 // GetHash requests are higher priority since they can block user requests | 221 // GetHash requests are higher priority since they can block user requests |
214 // so are handled separately. | 222 // so are handled separately. |
215 enum SafeBrowsingRequestType { | 223 enum SafeBrowsingRequestType { |
(...skipping 20 matching lines...) Expand all Loading... | |
236 | 244 |
237 // Generates GetHash request URL for retrieving full hashes. | 245 // Generates GetHash request URL for retrieving full hashes. |
238 GURL GetHashUrl(bool is_extended_reporting) const; | 246 GURL GetHashUrl(bool is_extended_reporting) const; |
239 // Generates URL for reporting safe browsing hits for UMA users. | 247 // Generates URL for reporting safe browsing hits for UMA users. |
240 | 248 |
241 // Generates GetHashWithApis Pver4 request URL for retrieving full hashes. | 249 // Generates GetHashWithApis Pver4 request URL for retrieving full hashes. |
242 // |request_base64| is the serialized FindFullHashesRequest protocol buffer | 250 // |request_base64| is the serialized FindFullHashesRequest protocol buffer |
243 // encoded in base 64. | 251 // encoded in base 64. |
244 GURL GetV4HashUrl(const std::string& request_base64) const; | 252 GURL GetV4HashUrl(const std::string& request_base64) const; |
245 | 253 |
246 // Fills a FindFullHashesRequest protocol buffer for an API_ABUSE request. | 254 // Fills a FindFullHashesRequest protocol buffer for a V4 request. |
247 // Returns the serialized and base 64 encoded request as a string. | 255 // Returns the serialized and base 64 encoded request as a string. |
248 std::string GetV4HashRequest(const std::vector<SBPrefix>& prefixes, | 256 std::string GetV4HashRequest(const std::vector<SBPrefix>& prefixes, |
249 ThreatType threat_type); | 257 ThreatType threat_type); |
250 | 258 |
259 // Parses a FindFullHashesResponse protocol buffer and fills the results in | |
260 // |full_hashes| and |cache_lifetime|. |data_base64| is the base 64 encoded | |
awoz
2015/12/30 18:23:13
Can you explain what |cache_lifetime| is? It's unc
kcarattini
2016/01/04 00:52:01
Done.
| |
261 // string of a serialized FindFullHashes procol buffer. Returns true if | |
awoz
2015/12/30 18:23:13
s/procol/protocol
kcarattini
2016/01/04 00:52:01
Done.
| |
262 // parsing is successfull, false otherwise. | |
awoz
2015/12/30 18:23:13
s/successfull/successful
kcarattini
2016/01/04 00:52:01
Done.
| |
263 bool ParseV4HashResponse(const std::string& data_base64, | |
264 std::vector<SBFullHashResult>* full_hashes, | |
265 base::TimeDelta* cache_lifetime); | |
266 | |
251 // Composes a ChunkUrl based on input string. | 267 // Composes a ChunkUrl based on input string. |
252 GURL NextChunkUrl(const std::string& input) const; | 268 GURL NextChunkUrl(const std::string& input) const; |
253 | 269 |
254 // Returns the time for the next update request. If |back_off| is true, | 270 // Returns the time for the next update request. If |back_off| is true, |
255 // the time returned will increment an error count and return the appriate | 271 // the time returned will increment an error count and return the appriate |
256 // next time (see ScheduleNextUpdate below). | 272 // next time (see ScheduleNextUpdate below). |
257 base::TimeDelta GetNextUpdateInterval(bool back_off); | 273 base::TimeDelta GetNextUpdateInterval(bool back_off); |
258 | 274 |
259 // Worker function for calculating GetHash and Update backoff times (in | 275 // Worker function for calculating GetHash and Update backoff times (in |
260 // seconds). |multiplier| is doubled for each consecutive error between the | 276 // seconds). |multiplier| is doubled for each consecutive error between the |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 AddChunksCallback callback) = 0; | 483 AddChunksCallback callback) = 0; |
468 | 484 |
469 // Delete chunks from the database. | 485 // Delete chunks from the database. |
470 virtual void DeleteChunks( | 486 virtual void DeleteChunks( |
471 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) = 0; | 487 scoped_ptr<std::vector<SBChunkDelete> > chunk_deletes) = 0; |
472 }; | 488 }; |
473 | 489 |
474 } // namespace safe_browsing | 490 } // namespace safe_browsing |
475 | 491 |
476 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ | 492 #endif // CHROME_BROWSER_SAFE_BROWSING_PROTOCOL_MANAGER_H_ |
OLD | NEW |