Index: chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc |
diff --git a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc |
index 236aae45af138738b2594857ca3b508eb49e7d7c..9282dff4cf1b2a0ff8c58bcef1080db2eb357a9c 100644 |
--- a/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc |
+++ b/chrome/browser/safe_browsing/incident_reporting/incident_reporting_service.cc |
@@ -132,6 +132,38 @@ void MarkIncidentsAsReported(const std::vector<PersistentIncidentState>& states, |
} |
} |
+// Removes a profile's prune state for legacy incident types. |
+void CleanLegacyPruneState(Profile* profile) { |
+ static const IncidentType kLegacyTypes[] = { |
+ IncidentType::OMNIBOX_INTERACTION, // TODO(grt): remove in M44. |
robertshield
2015/01/27 14:12:02
Reference bug with milestone?
grt (UTC plus 2)
2015/01/27 18:33:06
Done.
|
+ }; |
+ |
+ // Figure out if there are any values to remove before committing to making |
+ // any changes since notifications are sent for pref dict modifications. |
robertshield
2015/01/27 14:12:02
is this a performance concern or a functional one?
grt (UTC plus 2)
2015/01/27 18:33:06
Done.
|
+ const base::Value* value = |
+ profile->GetPrefs()->GetUserPrefValue(prefs::kSafeBrowsingIncidentsSent); |
+ const base::DictionaryValue* incidents_sent = NULL; |
+ if (!value || !value->GetAsDictionary(&incidents_sent)) |
+ return; |
+ std::vector<std::string> types_to_remove; |
+ for (size_t i = 0; i < arraysize(kLegacyTypes); ++i) { |
+ const std::string incident_type( |
+ base::IntToString(static_cast<int32_t>(kLegacyTypes[i]))); |
+ const base::DictionaryValue* type_dict = NULL; |
+ if (incidents_sent->GetDictionaryWithoutPathExpansion(incident_type, |
+ &type_dict)) { |
+ types_to_remove.push_back(incident_type); |
+ } |
+ } |
+ if (types_to_remove.empty()) |
+ return; |
+ |
+ DictionaryPrefUpdate pref_update(profile->GetPrefs(), |
+ prefs::kSafeBrowsingIncidentsSent); |
+ for (const auto& incident_type : types_to_remove) |
+ pref_update.Get()->RemoveWithoutPathExpansion(incident_type, NULL); |
+} |
+ |
// Runs |callback| on the thread to which |thread_runner| belongs. The callback |
// is run immediately if this function is called on |thread_runner|'s thread. |
void AddIncidentOnOriginThread( |
@@ -378,6 +410,8 @@ void IncidentReportingService::OnProfileAdded(Profile* profile) { |
BeginReportProcessing(); |
} |
+ CleanLegacyPruneState(profile); |
+ |
// TODO(grt): register for pref change notifications to start delayed analysis |
// and/or report processing if sb is currently disabled but subsequently |
// enabled. |