Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3214)

Unified Diff: chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc

Issue 2384213002: Send a TrackedPreference incident when registry pref validation fails. (Closed)
Patch Set: Improve split preference handling and address comments on #3 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc
diff --git a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc
index 512e894c7722e6baacccacdedfae54b519b9b11d..45fb5ef399c9f272d4b5828fe72f112bed11aca0 100644
--- a/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc
+++ b/chrome/browser/safe_browsing/incident_reporting/preference_validation_delegate.cc
@@ -24,10 +24,11 @@ typedef ClientIncidentReport_IncidentData_TrackedPreferenceIncident TPIncident;
typedef ClientIncidentReport_IncidentData_TrackedPreferenceIncident_ValueState
TPIncident_ValueState;
-// Maps a PrefHashStoreTransaction::ValueState to a
-// TrackedPreferenceIncident::ValueState.
+// Maps a primary PrefHashStoreTransaction::ValueState and an external
+// validation state to a TrackedPreferenceIncident::ValueState.
TPIncident_ValueState MapValueState(
- PrefHashStoreTransaction::ValueState value_state) {
+ PrefHashStoreTransaction::ValueState value_state,
+ PrefHashStoreTransaction::ValueState external_validation_value_state) {
switch (value_state) {
case PrefHashStoreTransaction::CLEARED:
return TPIncident::CLEARED;
@@ -36,7 +37,14 @@ TPIncident_ValueState MapValueState(
case PrefHashStoreTransaction::UNTRUSTED_UNKNOWN_VALUE:
return TPIncident::UNTRUSTED_UNKNOWN_VALUE;
default:
- return TPIncident::UNKNOWN;
+ switch (external_validation_value_state) {
+ case PrefHashStoreTransaction::CLEARED:
+ return TPIncident::BYPASS_CLEARED;
+ case PrefHashStoreTransaction::CHANGED:
+ return TPIncident::BYPASS_CHANGED;
+ default:
+ return TPIncident::UNKNOWN;
+ }
}
}
@@ -54,8 +62,10 @@ void PreferenceValidationDelegate::OnAtomicPreferenceValidation(
const std::string& pref_path,
const base::Value* value,
PrefHashStoreTransaction::ValueState value_state,
+ PrefHashStoreTransaction::ValueState external_validation_value_state,
bool is_personal) {
- TPIncident_ValueState proto_value_state = MapValueState(value_state);
+ TPIncident_ValueState proto_value_state =
+ MapValueState(value_state, external_validation_value_state);
if (proto_value_state != TPIncident::UNKNOWN) {
std::unique_ptr<TPIncident> incident(
new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
@@ -76,18 +86,29 @@ void PreferenceValidationDelegate::OnSplitPreferenceValidation(
const std::string& pref_path,
const base::DictionaryValue* /* dict_value */,
const std::vector<std::string>& invalid_keys,
+ const std::vector<std::string>& external_validation_invalid_keys,
PrefHashStoreTransaction::ValueState value_state,
+ PrefHashStoreTransaction::ValueState external_validation_value_state,
bool is_personal) {
- TPIncident_ValueState proto_value_state = MapValueState(value_state);
+ TPIncident_ValueState proto_value_state =
+ MapValueState(value_state, external_validation_value_state);
if (proto_value_state != TPIncident::UNKNOWN) {
std::unique_ptr<ClientIncidentReport_IncidentData_TrackedPreferenceIncident>
incident(
new ClientIncidentReport_IncidentData_TrackedPreferenceIncident());
incident->set_path(pref_path);
- for (std::vector<std::string>::const_iterator scan(invalid_keys.begin());
- scan != invalid_keys.end();
- ++scan) {
- incident->add_split_key(*scan);
+ if (proto_value_state == TPIncident::BYPASS_CLEARED ||
+ proto_value_state == TPIncident::BYPASS_CHANGED) {
+ for (std::vector<std::string>::const_iterator scan(
+ external_validation_invalid_keys.begin());
+ scan != external_validation_invalid_keys.end(); ++scan) {
+ incident->add_split_key(*scan);
+ }
+ } else {
+ for (std::vector<std::string>::const_iterator scan(invalid_keys.begin());
+ scan != invalid_keys.end(); ++scan) {
+ incident->add_split_key(*scan);
+ }
}
incident->set_value_state(proto_value_state);
incident_receiver_->AddIncidentForProfile(

Powered by Google App Engine
This is Rietveld 408576698