blob: 4996961aaaaa085a2c9d1655816e8bf73311359b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_incident.h"
#include "base/logging.h"
#include "chrome/browser/safe_browsing/incident_reporting/incident_handler_util.h"
#include "chrome/common/safe_browsing/csd.pb.h"
namespace safe_browsing {
TrackedPreferenceIncident::TrackedPreferenceIncident(
scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
tracked_preference_incident,
bool is_personal)
: is_personal_(is_personal) {
DCHECK(tracked_preference_incident);
DCHECK(tracked_preference_incident->has_path());
payload()->set_allocated_tracked_preference(
tracked_preference_incident.release());
}
TrackedPreferenceIncident::~TrackedPreferenceIncident() {
}
IncidentType TrackedPreferenceIncident::GetType() const {
return IncidentType::TRACKED_PREFERENCE;
}
// Returns the preference path.
std::string TrackedPreferenceIncident::GetKey() const {
return payload()->tracked_preference().path();
}
// Returns a digest computed over the payload.
uint32_t TrackedPreferenceIncident::ComputeDigest() const {
// Tracked preference incidents are sufficiently canonical (and have no
// default values), so it's safe to serialize the incident as given.
return HashMessage(payload()->tracked_preference());
}
// Filter out personal preferences.
scoped_ptr<ClientIncidentReport_IncidentData>
TrackedPreferenceIncident::TakePayload() {
scoped_ptr<ClientIncidentReport_IncidentData> payload(
Incident::TakePayload());
if (is_personal_) {
ClientIncidentReport_IncidentData_TrackedPreferenceIncident* incident =
payload->mutable_tracked_preference();
incident->clear_atomic_value();
incident->clear_split_key();
}
return payload.Pass();
}
} // namespace safe_browsing
|