Make sure the win_chromium_gn_x64_dbg bot is using symbol_level=1
[chromium-blink-merge.git] / chrome / browser / safe_browsing / safe_browsing_api_handler_util.h
blobeee25de7619c9d1fb42be5b0199d19a63004b24d
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
3 // found in the LICENSE file.
4 //
5 // Helper functions for SafeBrowsingApiHandlerImpl. Separated out for tests.
7 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_UTIL_H_
8 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_UTIL_H_
10 #include <string>
12 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
14 namespace safe_browsing {
16 // These match what SafeBrowsingApiHandler.java uses for |resultStatus|
17 enum RemoteCallResultStatus {
18 RESULT_STATUS_INTERNAL_ERROR = -1,
19 RESULT_STATUS_SUCCESS = 0,
20 RESULT_STATUS_TIMEOUT = 1,
23 // Threat types as per the Java code.
24 // This must match those in GMS's SafeBrowsingThreatTypes.java.
25 enum JavaThreatTypes {
26 JAVA_THREAT_TYPE_POTENTIALLY_HARMFUL_APPLICATION = 4,
27 JAVA_THREAT_TYPE_SOCIAL_ENGINEERING = 5,
30 // Do not reorder or delete entries, and make sure changes here are reflected
31 // in SB2RemoteCallResult histogram.
32 enum UmaRemoteCallResult {
33 UMA_STATUS_INTERNAL_ERROR = 0,
34 UMA_STATUS_TIMEOUT = 1,
35 UMA_STATUS_SAFE = 2,
36 UMA_STATUS_UNSAFE = 3,
37 UMA_STATUS_JSON_EMPTY = 4,
38 UMA_STATUS_JSON_FAILED_TO_PARSE = 5,
39 UMA_STATUS_JSON_UNKNOWN_THREAT = 6,
40 UMA_STATUS_MAX_VALUE
43 // This parses the JSON from the GMSCore API and then:
44 // 1) Picks the most severe threat type
45 // 2) Parses remaining key/value pairs into a MalwarePatternType PB
46 // so DisplayBlockingPage() can unmarshal it. We make this string
47 // is binary compatible with the Pver3 API's metadata string even
48 // though it comes from Pver4.
50 // If anything fails to parse, this sets the threat to "safe". The caller
51 // should report the return value via UMA.
52 UmaRemoteCallResult ParseJsonToThreatAndPB(const std::string& metadata_str,
53 SBThreatType* worst_threat,
54 std::string* metadata_pb_str);
55 } // namespace safe_browsing
57 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_API_HANDLER_UTIL_H_