OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "chrome/browser/safe_browsing/incident_reporting/preference_validation_
delegate.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/preference_validation_
delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 PreferenceValidationDelegate::PreferenceValidationDelegate( | 53 PreferenceValidationDelegate::PreferenceValidationDelegate( |
54 Profile* profile, | 54 Profile* profile, |
55 std::unique_ptr<IncidentReceiver> incident_receiver) | 55 std::unique_ptr<IncidentReceiver> incident_receiver) |
56 : profile_(profile), incident_receiver_(std::move(incident_receiver)) {} | 56 : profile_(profile), incident_receiver_(std::move(incident_receiver)) {} |
57 | 57 |
58 PreferenceValidationDelegate::~PreferenceValidationDelegate() { | 58 PreferenceValidationDelegate::~PreferenceValidationDelegate() { |
59 } | 59 } |
60 | 60 |
61 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( | 61 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( |
62 const std::string& pref_path, | 62 const std::string& pref_path, |
63 const base::Value* value, | 63 std::unique_ptr<base::Value> value, |
64 PrefHashStoreTransaction::ValueState value_state, | 64 PrefHashStoreTransaction::ValueState value_state, |
65 PrefHashStoreTransaction::ValueState external_validation_value_state, | 65 PrefHashStoreTransaction::ValueState external_validation_value_state, |
66 bool is_personal) { | 66 bool is_personal) { |
67 TPIncident_ValueState proto_value_state = | 67 TPIncident_ValueState proto_value_state = |
68 MapValueState(value_state, external_validation_value_state); | 68 MapValueState(value_state, external_validation_value_state); |
69 if (proto_value_state != TPIncident::UNKNOWN) { | 69 if (proto_value_state != TPIncident::UNKNOWN) { |
70 std::unique_ptr<TPIncident> incident( | 70 std::unique_ptr<TPIncident> incident( |
71 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); | 71 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); |
72 incident->set_path(pref_path); | 72 incident->set_path(pref_path); |
73 if (!value || | 73 if (!value || |
74 (!value->GetAsString(incident->mutable_atomic_value()) && | 74 (!value->GetAsString(incident->mutable_atomic_value()) && |
75 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) { | 75 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) { |
76 incident->clear_atomic_value(); | 76 incident->clear_atomic_value(); |
77 } | 77 } |
78 incident->set_value_state(proto_value_state); | 78 incident->set_value_state(proto_value_state); |
79 incident_receiver_->AddIncidentForProfile( | 79 incident_receiver_->AddIncidentForProfile( |
80 profile_, base::MakeUnique<TrackedPreferenceIncident>( | 80 profile_, base::MakeUnique<TrackedPreferenceIncident>( |
81 std::move(incident), is_personal)); | 81 std::move(incident), is_personal)); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 void PreferenceValidationDelegate::OnSplitPreferenceValidation( | 85 void PreferenceValidationDelegate::OnSplitPreferenceValidation( |
86 const std::string& pref_path, | 86 const std::string& pref_path, |
87 const base::DictionaryValue* /* dict_value */, | |
88 const std::vector<std::string>& invalid_keys, | 87 const std::vector<std::string>& invalid_keys, |
89 const std::vector<std::string>& external_validation_invalid_keys, | 88 const std::vector<std::string>& external_validation_invalid_keys, |
90 PrefHashStoreTransaction::ValueState value_state, | 89 PrefHashStoreTransaction::ValueState value_state, |
91 PrefHashStoreTransaction::ValueState external_validation_value_state, | 90 PrefHashStoreTransaction::ValueState external_validation_value_state, |
92 bool is_personal) { | 91 bool is_personal) { |
93 TPIncident_ValueState proto_value_state = | 92 TPIncident_ValueState proto_value_state = |
94 MapValueState(value_state, external_validation_value_state); | 93 MapValueState(value_state, external_validation_value_state); |
95 if (proto_value_state != TPIncident::UNKNOWN) { | 94 if (proto_value_state != TPIncident::UNKNOWN) { |
96 std::unique_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident> | 95 std::unique_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident> |
97 incident( | 96 incident( |
(...skipping 13 matching lines...) Expand all Loading... |
111 } | 110 } |
112 } | 111 } |
113 incident->set_value_state(proto_value_state); | 112 incident->set_value_state(proto_value_state); |
114 incident_receiver_->AddIncidentForProfile( | 113 incident_receiver_->AddIncidentForProfile( |
115 profile_, base::MakeUnique<TrackedPreferenceIncident>( | 114 profile_, base::MakeUnique<TrackedPreferenceIncident>( |
116 std::move(incident), is_personal)); | 115 std::move(incident), is_personal)); |
117 } | 116 } |
118 } | 117 } |
119 | 118 |
120 } // namespace safe_browsing | 119 } // namespace safe_browsing |
OLD | NEW |