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/preference_validation_delegate.h" | 5 #include "chrome/browser/safe_browsing/preference_validation_delegate.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 : add_incident_(add_incident) { | 46 : add_incident_(add_incident) { |
47 } | 47 } |
48 | 48 |
49 PreferenceValidationDelegate::~PreferenceValidationDelegate() { | 49 PreferenceValidationDelegate::~PreferenceValidationDelegate() { |
50 } | 50 } |
51 | 51 |
52 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( | 52 void PreferenceValidationDelegate::OnAtomicPreferenceValidation( |
53 const std::string& pref_path, | 53 const std::string& pref_path, |
54 const base::Value* value, | 54 const base::Value* value, |
55 PrefHashStoreTransaction::ValueState value_state, | 55 PrefHashStoreTransaction::ValueState value_state, |
56 TrackedPreferenceHelper::ResetAction reset_action) { | 56 TrackedPreferenceHelper::ResetAction /* reset_action */) { |
57 TPIncident_ValueState proto_value_state = MapValueState(value_state); | 57 TPIncident_ValueState proto_value_state = MapValueState(value_state); |
58 if (proto_value_state != TPIncident::UNKNOWN) { | 58 if (proto_value_state != TPIncident::UNKNOWN) { |
59 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | 59 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( |
60 new ClientIncidentReport_IncidentData()); | 60 new ClientIncidentReport_IncidentData()); |
61 TPIncident* incident = incident_data->mutable_tracked_preference(); | 61 TPIncident* incident = incident_data->mutable_tracked_preference(); |
62 incident->set_path(pref_path); | 62 incident->set_path(pref_path); |
63 if (!value->GetAsString(incident->mutable_atomic_value()) && | 63 if (!value || |
64 !base::JSONWriter::Write(value, incident->mutable_atomic_value())) { | 64 (!value->GetAsString(incident->mutable_atomic_value()) && |
65 !base::JSONWriter::Write(value, incident->mutable_atomic_value()))) { | |
65 incident->clear_atomic_value(); | 66 incident->clear_atomic_value(); |
66 } | 67 } |
67 incident->set_value_state(proto_value_state); | 68 incident->set_value_state(proto_value_state); |
68 add_incident_.Run(incident_data.Pass()); | 69 add_incident_.Run(incident_data.Pass()); |
69 } | 70 } |
70 } | 71 } |
71 | 72 |
72 void PreferenceValidationDelegate::OnSplitPreferenceValidation( | 73 void PreferenceValidationDelegate::OnSplitPreferenceValidation( |
73 const std::string& pref_path, | 74 const std::string& pref_path, |
74 const base::DictionaryValue* dict_value, | 75 const base::DictionaryValue* dict_value, |
gab
2014/06/16 15:45:03
This parameter is also unused, comment it out.
| |
75 const std::vector<std::string>& invalid_keys, | 76 const std::vector<std::string>& invalid_keys, |
76 PrefHashStoreTransaction::ValueState value_state, | 77 PrefHashStoreTransaction::ValueState value_state, |
77 TrackedPreferenceHelper::ResetAction reset_action) { | 78 TrackedPreferenceHelper::ResetAction /* reset_action */) { |
78 TPIncident_ValueState proto_value_state = MapValueState(value_state); | 79 TPIncident_ValueState proto_value_state = MapValueState(value_state); |
79 if (proto_value_state != TPIncident::UNKNOWN) { | 80 if (proto_value_state != TPIncident::UNKNOWN) { |
80 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( | 81 scoped_ptr<ClientIncidentReport_IncidentData> incident_data( |
81 new ClientIncidentReport_IncidentData()); | 82 new ClientIncidentReport_IncidentData()); |
82 TPIncident* incident = incident_data->mutable_tracked_preference(); | 83 TPIncident* incident = incident_data->mutable_tracked_preference(); |
83 incident->set_path(pref_path); | 84 incident->set_path(pref_path); |
84 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); | 85 for (std::vector<std::string>::const_iterator scan(invalid_keys.begin()); |
85 scan != invalid_keys.end(); | 86 scan != invalid_keys.end(); |
86 ++scan) { | 87 ++scan) { |
87 incident->add_split_key(*scan); | 88 incident->add_split_key(*scan); |
88 } | 89 } |
89 incident->set_value_state(proto_value_state); | 90 incident->set_value_state(proto_value_state); |
90 add_incident_.Run(incident_data.Pass()); | 91 add_incident_.Run(incident_data.Pass()); |
91 } | 92 } |
92 } | 93 } |
93 | 94 |
94 } // namespace safe_browsing | 95 } // namespace safe_browsing |
OLD | NEW |