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 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 | 13 |
14 namespace safe_browsing { | 14 namespace safe_browsing { |
15 | 15 |
16 class ClientIncidentReport_IncidentData; | 16 class ClientIncidentReport_IncidentData; |
17 | 17 |
18 // An incident's type. Values from this enum are used for histograms (hence the | 18 // An incident's type. Values from this enum are used for histograms (hence the |
19 // making underlying type the same as histogram samples.). Do not re-use | 19 // making underlying type the same as histogram samples.). Do not re-use |
20 // existing values. | 20 // existing values. |
21 enum class IncidentType : int32_t { | 21 enum class IncidentType : int32_t { |
22 // Start with 1 rather than zero; otherwise there won't be enough buckets for | 22 // Start with 1 rather than zero; otherwise there won't be enough buckets for |
23 // the histogram. | 23 // the histogram. |
24 TRACKED_PREFERENCE = 1, | 24 TRACKED_PREFERENCE = 1, |
25 BINARY_INTEGRITY = 2, | 25 BINARY_INTEGRITY = 2, |
26 BLACKLIST_LOAD = 3, | 26 BLACKLIST_LOAD = 3, |
27 OMNIBOX_INTERACTION = 4, | 27 OMNIBOX_INTERACTION = 4, |
28 VARIATIONS_SEED_SIGNATURE = 5, | 28 VARIATIONS_SEED_SIGNATURE = 5, |
29 RESOURCE_REQUEST = 6, | 29 RESOURCE_REQUEST = 6, |
| 30 SUSPICIOUS_MODULE = 7, |
30 // Values for new incident types go here. | 31 // Values for new incident types go here. |
31 NUM_TYPES = 7 | 32 NUM_TYPES = 8 |
| 33 }; |
| 34 |
| 35 // The level of consent required by the incident to be associated with a |
| 36 // profile. |
| 37 enum class MinimumProfileConsent { |
| 38 SAFE_BROWSING_ENABLED = 0, |
| 39 SAFE_BROWSING_EXTENDED_REPORTING_ENABLED = 1, |
32 }; | 40 }; |
33 | 41 |
34 // An abstract incident. Subclasses provide type-specific functionality to | 42 // An abstract incident. Subclasses provide type-specific functionality to |
35 // enable logging and pruning by the incident reporting service. | 43 // enable logging and pruning by the incident reporting service. |
36 class Incident { | 44 class Incident { |
37 public: | 45 public: |
38 virtual ~Incident(); | 46 virtual ~Incident(); |
39 | 47 |
40 // Returns the type of the incident. | 48 // Returns the type of the incident. |
41 virtual IncidentType GetType() const = 0; | 49 virtual IncidentType GetType() const = 0; |
42 | 50 |
43 // Returns a key that identifies a particular instance among the type's | 51 // Returns a key that identifies a particular instance among the type's |
44 // possibilities. | 52 // possibilities. |
45 virtual std::string GetKey() const = 0; | 53 virtual std::string GetKey() const = 0; |
46 | 54 |
47 // Returns a computed fingerprint of the payload. Incidents of the same | 55 // Returns a computed fingerprint of the payload. Incidents of the same |
48 // incident must result in the same digest. | 56 // incident must result in the same digest. |
49 virtual uint32_t ComputeDigest() const = 0; | 57 virtual uint32_t ComputeDigest() const = 0; |
50 | 58 |
51 // Returns the incident's payload. | 59 // Returns the incident's payload. |
52 virtual scoped_ptr<ClientIncidentReport_IncidentData> TakePayload(); | 60 virtual scoped_ptr<ClientIncidentReport_IncidentData> TakePayload(); |
53 | 61 |
| 62 // Returns the minimum level of consent required for reporting of the |
| 63 // incident. |
| 64 virtual MinimumProfileConsent GetMinimumProfileConsent() const; |
| 65 |
54 protected: | 66 protected: |
55 // Constructs the payload with an empty protobuf, setting its incident time to | 67 // Constructs the payload with an empty protobuf, setting its incident time to |
56 // the current time. | 68 // the current time. |
57 Incident(); | 69 Incident(); |
58 | 70 |
59 // Accessors for the payload. These must not be called after the payload has | 71 // Accessors for the payload. These must not be called after the payload has |
60 // been taken. | 72 // been taken. |
61 ClientIncidentReport_IncidentData* payload(); | 73 ClientIncidentReport_IncidentData* payload(); |
62 const ClientIncidentReport_IncidentData* payload() const; | 74 const ClientIncidentReport_IncidentData* payload() const; |
63 | 75 |
64 private: | 76 private: |
65 scoped_ptr<ClientIncidentReport_IncidentData> payload_; | 77 scoped_ptr<ClientIncidentReport_IncidentData> payload_; |
66 | 78 |
67 DISALLOW_COPY_AND_ASSIGN(Incident); | 79 DISALLOW_COPY_AND_ASSIGN(Incident); |
68 }; | 80 }; |
69 | 81 |
70 } // namespace safe_browsing | 82 } // namespace safe_browsing |
71 | 83 |
72 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ | 84 #endif // CHROME_BROWSER_SAFE_BROWSING_INCIDENT_REPORTING_INCIDENT_H_ |
OLD | NEW |