| Index: components/safe_browsing_db/safe_browsing_prefs.cc
|
| diff --git a/components/safe_browsing_db/safe_browsing_prefs.cc b/components/safe_browsing_db/safe_browsing_prefs.cc
|
| index 66c1dbb6e477866287b7ecf8bbc8d27b4d5ad2af..1e5ff213c55f9916ac9703c8cbe2fc6d18a9a9fa 100644
|
| --- a/components/safe_browsing_db/safe_browsing_prefs.cc
|
| +++ b/components/safe_browsing_db/safe_browsing_prefs.cc
|
| @@ -57,6 +57,25 @@ enum ActiveExtendedReportingPref {
|
| MAX_SBER_PREF
|
| };
|
|
|
| +// A histogram for tracking a nullable boolean, which can be false, true or
|
| +// null. These values are written to logs. New enum values can be added, but
|
| +// existing enums must never be renumbered or deleted and reused.
|
| +enum NullableBoolean {
|
| + NULLABLE_BOOLEAN_FALSE = 0,
|
| + NULLABLE_BOOLEAN_TRUE = 1,
|
| + NULLABLE_BOOLEAN_NULL = 2,
|
| + MAX_NULLABLE_BOOLEAN
|
| +};
|
| +
|
| +NullableBoolean GetPrefValueOrNull(const PrefService& prefs,
|
| + const std::string& pref_name) {
|
| + if (!prefs.HasPrefPath(pref_name)) {
|
| + return NULLABLE_BOOLEAN_NULL;
|
| + }
|
| + return prefs.GetBoolean(pref_name) ? NULLABLE_BOOLEAN_TRUE
|
| + : NULLABLE_BOOLEAN_FALSE;
|
| +}
|
| +
|
| // Update the correct UMA metric based on which pref was changed and which UI
|
| // the change was made on.
|
| void RecordExtendedReportingPrefChanged(
|
| @@ -279,23 +298,27 @@ void RecordExtendedReportingMetrics(const PrefService& prefs) {
|
| // These metrics track the Scout transition.
|
| if (prefs.GetBoolean(prefs::kSafeBrowsingScoutGroupSelected)) {
|
| // Users in the Scout group: currently seeing the Scout opt-in.
|
| - UMA_HISTOGRAM_BOOLEAN(
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| "SafeBrowsing.Pref.Scout.ScoutGroup.SBER1Pref",
|
| - prefs.GetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled));
|
| - UMA_HISTOGRAM_BOOLEAN(
|
| + GetPrefValueOrNull(prefs, prefs::kSafeBrowsingExtendedReportingEnabled),
|
| + MAX_NULLABLE_BOOLEAN);
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| "SafeBrowsing.Pref.Scout.ScoutGroup.SBER2Pref",
|
| - prefs.GetBoolean(prefs::kSafeBrowsingScoutReportingEnabled));
|
| + GetPrefValueOrNull(prefs, prefs::kSafeBrowsingScoutReportingEnabled),
|
| + MAX_NULLABLE_BOOLEAN);
|
| } else {
|
| // Users not in the Scout group: currently seeing the SBER opt-in.
|
| - UMA_HISTOGRAM_BOOLEAN(
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| "SafeBrowsing.Pref.Scout.NoScoutGroup.SBER1Pref",
|
| - prefs.GetBoolean(prefs::kSafeBrowsingExtendedReportingEnabled));
|
| + GetPrefValueOrNull(prefs, prefs::kSafeBrowsingExtendedReportingEnabled),
|
| + MAX_NULLABLE_BOOLEAN);
|
| // The following metric is a corner case. User was previously in the
|
| // Scout group and was able to opt-in to the Scout pref, but was since
|
| // removed from the Scout group (eg: by rolling back a Scout experiment).
|
| - UMA_HISTOGRAM_BOOLEAN(
|
| + UMA_HISTOGRAM_ENUMERATION(
|
| "SafeBrowsing.Pref.Scout.NoScoutGroup.SBER2Pref",
|
| - prefs.GetBoolean(prefs::kSafeBrowsingScoutReportingEnabled));
|
| + GetPrefValueOrNull(prefs, prefs::kSafeBrowsingScoutReportingEnabled),
|
| + MAX_NULLABLE_BOOLEAN);
|
| }
|
| }
|
|
|
|
|