OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 // Helper functions for SafeBrowsingApiHandlerImpl. Separated out for tests. | 5 // Helper functions for SafeBrowsingApiHandlerImpl. Separated out for tests. |
6 | 6 |
7 #ifndef COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ | 7 #ifndef COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ |
8 #define COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ | 8 #define COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 25 matching lines...) Expand all Loading... |
36 UMA_STATUS_UNSAFE = 3, | 36 UMA_STATUS_UNSAFE = 3, |
37 UMA_STATUS_JSON_EMPTY = 4, | 37 UMA_STATUS_JSON_EMPTY = 4, |
38 UMA_STATUS_JSON_FAILED_TO_PARSE = 5, | 38 UMA_STATUS_JSON_FAILED_TO_PARSE = 5, |
39 UMA_STATUS_JSON_UNKNOWN_THREAT = 6, | 39 UMA_STATUS_JSON_UNKNOWN_THREAT = 6, |
40 UMA_STATUS_UNSUPPORTED = 7, | 40 UMA_STATUS_UNSUPPORTED = 7, |
41 UMA_STATUS_MAX_VALUE | 41 UMA_STATUS_MAX_VALUE |
42 }; | 42 }; |
43 | 43 |
44 // This parses the JSON from the GMSCore API and then: | 44 // This parses the JSON from the GMSCore API and then: |
45 // 1) Picks the most severe threat type | 45 // 1) Picks the most severe threat type |
46 // 2) Parses remaining key/value pairs into a MalwarePatternType PB | 46 // 2) Parses that threat's key/value pairs into the metadata struct. |
47 // so DisplayBlockingPage() can unmarshal it. We make this string | |
48 // is binary compatible with the Pver3 API's metadata string even | |
49 // though it comes from Pver4. | |
50 // | 47 // |
51 // If anything fails to parse, this sets the threat to "safe". The caller | 48 // If anything fails to parse, this sets the threat to "safe". The caller |
52 // should report the return value via UMA. | 49 // should report the return value via UMA. |
| 50 UmaRemoteCallResult ParseJsonFromGMSCore(const std::string& metadata_str, |
| 51 SBThreatType* worst_threat, |
| 52 ThreatMetadata* metadata); |
| 53 |
| 54 // DEPRECATED. Will be removed. |
53 UmaRemoteCallResult ParseJsonToThreatAndPB(const std::string& metadata_str, | 55 UmaRemoteCallResult ParseJsonToThreatAndPB(const std::string& metadata_str, |
54 SBThreatType* worst_threat, | 56 SBThreatType* worst_threat, |
55 std::string* metadata_pb_str); | 57 std::string* metadata_pb_str); |
56 } // namespace safe_browsing | 58 } // namespace safe_browsing |
57 | 59 |
58 #endif // COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ | 60 #endif // COMPONENTS_SAFE_BROWSING_DB_SAFE_BROWSING_API_HANDLER_UTIL_H_ |
OLD | NEW |