| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 const 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 |
| 69 if (proto_value_state != TPIncident::UNKNOWN) { | 70 if (proto_value_state != TPIncident::UNKNOWN) { |
| 70 std::unique_ptr<TPIncident> incident( | 71 std::unique_ptr<TPIncident> incident( |
| 71 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); | 72 new ClientIncidentReport_IncidentData_TrackedPreferenceIncident()); |
| 72 incident->set_path(pref_path); | 73 incident->set_path(pref_path); |
| 73 if (!value || | 74 if (!value || |
| 74 (!value->GetAsString(incident->mutable_atomic_value()) && | 75 (!value->GetAsString(incident->mutable_atomic_value()) && |
| 75 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) { | 76 !base::JSONWriter::Write(*value, incident->mutable_atomic_value()))) { |
| 76 incident->clear_atomic_value(); | 77 incident->clear_atomic_value(); |
| 77 } | 78 } |
| 78 incident->set_value_state(proto_value_state); | 79 incident->set_value_state(proto_value_state); |
| 80 |
| 81 NOTREACHED() << "Incident shouldn't be triggered from try bot. DO NOT SUBMIT
." << pref_path; |
| 82 |
| 79 incident_receiver_->AddIncidentForProfile( | 83 incident_receiver_->AddIncidentForProfile( |
| 80 profile_, base::MakeUnique<TrackedPreferenceIncident>( | 84 profile_, base::MakeUnique<TrackedPreferenceIncident>( |
| 81 std::move(incident), is_personal)); | 85 std::move(incident), is_personal)); |
| 82 } | 86 } |
| 83 } | 87 } |
| 84 | 88 |
| 85 void PreferenceValidationDelegate::OnSplitPreferenceValidation( | 89 void PreferenceValidationDelegate::OnSplitPreferenceValidation( |
| 86 const std::string& pref_path, | 90 const std::string& pref_path, |
| 87 const base::DictionaryValue* /* dict_value */, | 91 const base::DictionaryValue* /* dict_value */, |
| 88 const std::vector<std::string>& invalid_keys, | 92 const std::vector<std::string>& invalid_keys, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 103 external_validation_invalid_keys.begin()); | 107 external_validation_invalid_keys.begin()); |
| 104 scan != external_validation_invalid_keys.end(); ++scan) { | 108 scan != external_validation_invalid_keys.end(); ++scan) { |
| 105 incident->add_split_key(*scan); | 109 incident->add_split_key(*scan); |
| 106 } | 110 } |
| 107 } else { | 111 } else { |
| 108 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); | 112 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); |
| 109 scan != invalid_keys.end(); ++scan) { | 113 scan != invalid_keys.end(); ++scan) { |
| 110 incident->add_split_key(*scan); | 114 incident->add_split_key(*scan); |
| 111 } | 115 } |
| 112 } | 116 } |
| 117 |
| 118 NOTREACHED() << "Incident shouldn't be triggered from try bot. DO NOT SUBMIT
." << pref_path; |
| 119 |
| 113 incident->set_value_state(proto_value_state); | 120 incident->set_value_state(proto_value_state); |
| 114 incident_receiver_->AddIncidentForProfile( | 121 incident_receiver_->AddIncidentForProfile( |
| 115 profile_, base::MakeUnique<TrackedPreferenceIncident>( | 122 profile_, base::MakeUnique<TrackedPreferenceIncident>( |
| 116 std::move(incident), is_personal)); | 123 std::move(incident), is_personal)); |
| 117 } | 124 } |
| 118 } | 125 } |
| 119 | 126 |
| 120 } // namespace safe_browsing | 127 } // namespace safe_browsing |
| OLD | NEW |