Commit b09b521b authored by Bettina's avatar Bettina Committed by Commit Bot

SafeBrowsingEnabled pref needs to be on for Enhanced Protection

SafeBrowsingEnabled pref is turned on when Enhanced
or standard protection is turned on. It is always
turned off if no safe browsing is selected. Devices
can be out of sync or not on the most updated versions.
This means that enhanced protection may not be offered
on these devices. To make sure that all safe browsing
is kept consistent, SafeBrowsingEnhanced needs to
also check SafeBrowsingEnabled. If the user has
no safe browsing on a device and syncs user pref,
all devices should not have safe browsing on unless
they select a different safe browsing afterwards
on any device.

Bug: 1068777
Change-Id: I9a13c8347c30c965d8e0da4e704856ba9b054c30
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2148433
Commit-Queue: Bettina Dea <bdea@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#759008}
parent 47fca515
......@@ -146,12 +146,14 @@ SafeBrowsingState GetSafeBrowsingState(const PrefService& prefs) {
}
bool IsSafeBrowsingEnabled(const PrefService& prefs) {
return prefs.GetBoolean(prefs::kSafeBrowsingEnabled) ||
IsEnhancedProtectionEnabled(prefs);
return prefs.GetBoolean(prefs::kSafeBrowsingEnabled);
}
bool IsEnhancedProtectionEnabled(const PrefService& prefs) {
// SafeBrowsingEnabled is checked too due to devices being out
// of sync or not on a version that includes SafeBrowsingEnhanced pref.
return prefs.GetBoolean(prefs::kSafeBrowsingEnhanced) &&
IsSafeBrowsingEnabled(prefs) &&
base::FeatureList::IsEnabled(kEnhancedProtection);
}
......@@ -251,6 +253,9 @@ void SetExtendedReportingPref(PrefService* prefs, bool value) {
}
void SetEnhancedProtectionPref(PrefService* prefs, bool value) {
// SafeBrowsingEnabled pref needs to be turned on in order for enhanced
// protection pref to be turned on. This method is only used for tests.
prefs->SetBoolean(prefs::kSafeBrowsingEnabled, value);
prefs->SetBoolean(prefs::kSafeBrowsingEnhanced, value);
}
......
......@@ -135,6 +135,13 @@ TEST_F(SafeBrowsingPrefsTest, EnhancedProtection) {
safe_browsing::kEnhancedProtection);
EXPECT_TRUE(IsEnhancedProtectionEnabled(prefs_));
}
{
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(
safe_browsing::kEnhancedProtection);
prefs_.SetBoolean(prefs::kSafeBrowsingEnabled, false);
EXPECT_FALSE(IsEnhancedProtectionEnabled(prefs_));
}
}
TEST_F(SafeBrowsingPrefsTest, IsExtendedReportingPolicyManaged) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment