| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/metrics/histogram_macros.h" | 6 #include "base/metrics/histogram_macros.h" |
| 7 #include "components/prefs/pref_service.h" | 7 #include "components/prefs/pref_service.h" |
| 8 #include "components/safe_browsing_db/safe_browsing_prefs.h" | 8 #include "components/safe_browsing_db/safe_browsing_prefs.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 int scout_resource) { | 45 int scout_resource) { |
| 46 return IsScout(GetExtendedReportingPrefName(prefs)) | 46 return IsScout(GetExtendedReportingPrefName(prefs)) |
| 47 ? scout_resource | 47 ? scout_resource |
| 48 : extended_reporting_resource; | 48 : extended_reporting_resource; |
| 49 } | 49 } |
| 50 | 50 |
| 51 bool ExtendedReportingPrefExists(const PrefService& prefs) { | 51 bool ExtendedReportingPrefExists(const PrefService& prefs) { |
| 52 return prefs.HasPrefPath(GetExtendedReportingPrefName(prefs)); | 52 return prefs.HasPrefPath(GetExtendedReportingPrefName(prefs)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 ExtendedReportingLevel GetExtendedReportingLevel(const PrefService& prefs) { |
| 56 if (!IsExtendedReportingEnabled(prefs)) { |
| 57 return SBER_LEVEL_OFF; |
| 58 } else { |
| 59 return IsScout(GetExtendedReportingPrefName(prefs)) ? SBER_LEVEL_SCOUT |
| 60 : SBER_LEVEL_LEGACY; |
| 61 } |
| 62 } |
| 63 |
| 55 const char* GetExtendedReportingPrefName(const PrefService& prefs) { | 64 const char* GetExtendedReportingPrefName(const PrefService& prefs) { |
| 56 // The Scout pref is active if either of the experiment features are on, and | 65 // The Scout pref is active if either of the experiment features are on, and |
| 57 // ScoutGroupSelected is on as well. | 66 // ScoutGroupSelected is on as well. |
| 58 if ((base::FeatureList::IsEnabled(kCanShowScoutOptIn) || | 67 if ((base::FeatureList::IsEnabled(kCanShowScoutOptIn) || |
| 59 base::FeatureList::IsEnabled(kOnlyShowScoutOptIn)) && | 68 base::FeatureList::IsEnabled(kOnlyShowScoutOptIn)) && |
| 60 prefs.GetBoolean(prefs::kSafeBrowsingScoutGroupSelected)) { | 69 prefs.GetBoolean(prefs::kSafeBrowsingScoutGroupSelected)) { |
| 61 return prefs::kSafeBrowsingScoutReportingEnabled; | 70 return prefs::kSafeBrowsingScoutReportingEnabled; |
| 62 } | 71 } |
| 63 | 72 |
| 64 // ..otherwise, either no experiment is on (ie: the Control group) or | 73 // ..otherwise, either no experiment is on (ie: the Control group) or |
| (...skipping 30 matching lines...) Expand all Loading... |
| 95 | 104 |
| 96 void UpdatePrefsBeforeSecurityInterstitial(PrefService* prefs) { | 105 void UpdatePrefsBeforeSecurityInterstitial(PrefService* prefs) { |
| 97 // Move the user into the Scout Group if the CanShowScoutOptIn experiment is | 106 // Move the user into the Scout Group if the CanShowScoutOptIn experiment is |
| 98 // enabled. | 107 // enabled. |
| 99 if (base::FeatureList::IsEnabled(kCanShowScoutOptIn)) { | 108 if (base::FeatureList::IsEnabled(kCanShowScoutOptIn)) { |
| 100 prefs->SetBoolean(prefs::kSafeBrowsingScoutGroupSelected, true); | 109 prefs->SetBoolean(prefs::kSafeBrowsingScoutGroupSelected, true); |
| 101 } | 110 } |
| 102 } | 111 } |
| 103 | 112 |
| 104 } // namespace safe_browsing | 113 } // namespace safe_browsing |
| OLD | NEW |