Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / safe_browsing / incident_reporting / tracked_preference_incident.cc
blob4996961aaaaa085a2c9d1655816e8bf73311359b
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.
5 #include "chrome/browser/safe_browsing/incident_reporting/tracked_preference_incident.h"
7 #include "base/logging.h"
8 #include "chrome/browser/safe_browsing/incident_reporting/incident_handler_util.h"
9 #include "chrome/common/safe_browsing/csd.pb.h"
11 namespace safe_browsing {
13 TrackedPreferenceIncident::TrackedPreferenceIncident(
14 scoped_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
15 tracked_preference_incident,
16 bool is_personal)
17 : is_personal_(is_personal) {
18 DCHECK(tracked_preference_incident);
19 DCHECK(tracked_preference_incident->has_path());
20 payload()->set_allocated_tracked_preference(
21 tracked_preference_incident.release());
24 TrackedPreferenceIncident::~TrackedPreferenceIncident() {
27 IncidentType TrackedPreferenceIncident::GetType() const {
28 return IncidentType::TRACKED_PREFERENCE;
31 // Returns the preference path.
32 std::string TrackedPreferenceIncident::GetKey() const {
33 return payload()->tracked_preference().path();
36 // Returns a digest computed over the payload.
37 uint32_t TrackedPreferenceIncident::ComputeDigest() const {
38 // Tracked preference incidents are sufficiently canonical (and have no
39 // default values), so it's safe to serialize the incident as given.
40 return HashMessage(payload()->tracked_preference());
43 // Filter out personal preferences.
44 scoped_ptr<ClientIncidentReport_IncidentData>
45 TrackedPreferenceIncident::TakePayload() {
46 scoped_ptr<ClientIncidentReport_IncidentData> payload(
47 Incident::TakePayload());
49 if (is_personal_) {
50 ClientIncidentReport_IncidentData_TrackedPreferenceIncident* incident =
51 payload->mutable_tracked_preference();
52 incident->clear_atomic_value();
53 incident->clear_split_key();
56 return payload.Pass();
59 } // namespace safe_browsing